From 47e6b74e745d54ca992bc9ad20a8a4d0247273ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Fri, 11 Jul 2008 08:46:05 +0000 Subject: [PATCH] * src/insets/InsetSpace.cpp: - proper visualization for negative hspaces, in analogy to negative vspaces. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25557 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetSpace.cpp | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 468adee65b..47082cfe2f 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -173,6 +173,11 @@ void InsetSpace::edit(Cursor & cur, bool, EntryDirection) } +namespace { +int const arrow_size = 8; +} + + void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const { if (isStretchableSpace()) { @@ -206,9 +211,14 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = int(0.5 * fm.width(char_type('M'))); break; case InsetSpaceParams::CUSTOM: - case InsetSpaceParams::CUSTOM_PROTECTED: - dim.wid = max(4, abs(params_.length.inBP())); + case InsetSpaceParams::CUSTOM_PROTECTED: { + int width = params_.length.inBP(); + int minwidth = 4; + if (params_.length.inBP() < 0) + minwidth = 3 * arrow_size; + dim.wid = max(minwidth, abs(params_.length.inBP())); break; + } case InsetSpaceParams::HFILL: case InsetSpaceParams::HFILL_PROTECTED: case InsetSpaceParams::DOTFILL: @@ -229,7 +239,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const { Dimension const dim = dimension(*pi.base.bv); - if (isStretchableSpace()) { + if (isStretchableSpace() || params_.length.inBP() < 0) { int const asc = theFontMetrics(pi.base.font).ascent('M'); int const desc = theFontMetrics(pi.base.font).descent('M'); // Pixel height divisible by 2 for prettier fill graphics: @@ -298,6 +308,18 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special); pi.pain.line(xmr, y2 , x3, y2, Color_special); pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special); + } else if (params_.kind == InsetSpaceParams::CUSTOM) { + pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special); + pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special); + pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special); + pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special); + pi.pain.line(x2, y2 , x3, y2, Color_special); + } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) { + pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex); + pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex); + pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex); + pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex); + pi.pain.line(x2, y2 , x3, y2, Color_latex); } return; } @@ -324,13 +346,8 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const params_.kind == InsetSpaceParams::NEGTHIN || params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) pi.pain.lines(xp, yp, 4, Color_latex); - else { - if (params_.length.inBP() < 0) { - // use another color for negative spaces - pi.pain.lines(xp, yp, 4, Color_red); - } else - pi.pain.lines(xp, yp, 4, Color_special); - } + else + pi.pain.lines(xp, yp, 4, Color_special); } -- 2.39.2