]> git.lyx.org Git - features.git/commitdiff
Improve drawing of macro template frame
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 12 Jul 2020 13:37:58 +0000 (15:37 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 12 Jul 2020 13:39:37 +0000 (15:39 +0200)
Use Inset::xxxOffset as offsets and draw the frame in the middle of
the empty space.

Fixes bug #9657.

src/mathed/InsetMathMacroTemplate.cpp

index 62561b62fe99c00f458abf7439432112fc29cf56..6c109696a753bc90877bd59c89ced44aa430a680 100644 (file)
@@ -574,9 +574,9 @@ void InsetMathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const
        if (macro)
                macro->unlock();
 
-       dim.wid += 6;
-       dim.des += 2;
-       dim.asc += 2;
+       dim.wid += leftOffset(mi.base.bv) + rightOffset(mi.base.bv);;
+       dim.des += bottomOffset(mi.base.bv);
+       dim.asc += topOffset(mi.base.bv);
 }
 
 
@@ -590,17 +590,19 @@ void InsetMathMacroTemplate::draw(PainterInfo & pi, int x, int y) const
        Dimension const dim = dimension(*pi.base.bv);
 
        // draw outer frame
-       int const a = y - dim.asc + 1;
-       int const w = dim.wid - 2;
-       int const h = dim.height() - 2;
-       pi.pain.rectangle(x + 1, a, w, h, Color_mathframe);
+       int const hoffset = leftOffset(pi.base.bv) + rightOffset(pi.base.bv);
+       int const voffset = topOffset(pi.base.bv) + bottomOffset(pi.base.bv);
+       int const a = y - dim.asc + topOffset(pi.base.bv) / 2;
+       int const w = dim.wid - (hoffset - hoffset / 2);
+       int const h = dim.height() - (voffset - voffset / 2);
+       pi.pain.rectangle(x + leftOffset(pi.base.bv) / 2, a, w, h, Color_mathframe);
 
        // just to be sure: set some dummy values for coord cache
        for (idx_type i = 0; i < nargs(); ++i)
                cell(i).setXY(*pi.base.bv, x, y);
 
        // draw contents
-       look_.draw(pi, x + 3, y);
+       look_.draw(pi, x + leftOffset(pi.base.bv), y);
 }