[LyX/master] Make math decorations scalable with zoom level

Enrico Forestieri forenr at lyx.org
Mon Feb 1 01:52:01 UTC 2021


commit 9f3920447e6752c4ddbe8c74c903c142fa45e589
Author: Enrico Forestieri <forenr at lyx.org>
Date:   Mon Feb 1 02:53:00 2021 +0100

    Make math decorations scalable with zoom level
    
    Fixes #11491
---
 src/mathed/InsetMathDecoration.cpp |   17 +++++++++-----
 src/mathed/MathSupport.cpp         |   43 ++++++++++++++++++++----------------
 2 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp
index c7d6386..adf5656 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -13,6 +13,7 @@
 
 #include "InsetMathDecoration.h"
 
+#include "BufferView.h"
 #include "MathData.h"
 #include "MathParser.h"
 #include "MathSupport.h"
@@ -119,15 +120,19 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
 
 	cell(0).metrics(mi, dim);
 
-	dh_  = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
-	dw_  = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
+	int const l1 = mi.base.bv->zoomedPixels(1);
+	int const l2 = 2 * l1;
+	int const l3 = 3 * l1;
+
+	dh_  = l2; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
+	dw_  = l3; //mathed_char_width(LM_TC_VAR, mi, 'x');
 
 	if (upper()) {
-		dy_ = -dim.asc - dh_;
-		dim.asc += dh_ + 1;
+		dy_ = -dim.asc - dh_ - l1;
+		dim.asc += dh_ + l1;
 	} else {
-		dy_ = dim.des + 1;
-		dim.des += dh_ + 2;
+		dy_ = dim.des + l1;
+		dim.des += dh_ + l2;
 	}
 }
 
diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index a7f66a7..4ebd8c5 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -298,31 +298,31 @@ double const dot[] = {
 //	1, 0.5, 0.2, 0.5, 0.2,
 //	1, 0.4, 0.4, 0.6, 0.4,
 //	1, 0.5, 0.5, 0.5, 0.5,
-	5, 0.4, 0.4, 0.6, 0.4,
+	5, 0.4, 0.6, 0.6, 0.6,
 	0
 };
 
 
 double const ddot[] = {
-	5, 0.0, 0.4, 0.3, 0.4,
-	5, 0.6, 0.4, 1.0, 0.4,
+	5, 0.1, 0.6, 0.3, 0.6,
+	5, 0.6, 0.6, 0.8, 0.6,
 	0
 };
 
 
 double const dddot[] = {
-	1, 0.1,  0.5, 0.2,  0.5,
-	1, 0.45, 0.5, 0.55, 0.5,
-	1, 0.8,  0.5, 0.9,  0.5,
+	5, -0.2, 0.6, 0.0, 0.6,
+	5,  0.3, 0.6, 0.5, 0.6,
+	5,  0.8, 0.6, 1.0, 0.6,
 	0
 };
 
 
 double const ddddot[] = {
-	1, 0.1,  0.5, 0.2,  0.5,
-	1, 0.45, 0.5, 0.55, 0.5,
-	1, 0.8,  0.5, 0.9,  0.5,
-	1, 1.15, 0.5, 1.25, 0.5,
+	5, -0.4, 0.6, -0.2, 0.6,
+	5,  0.1, 0.6,  0.3, 0.6,
+	5,  0.6, 0.6,  0.8, 0.6,
+	5,  1.1, 0.6,  1.3, 0.6,
 	0
 };
 
@@ -344,8 +344,10 @@ double const dline3[] = {
 
 
 double const ring[] = {
-	2, 5,
-	0.5, 0.8,  0.8, 0.5,  0.5, 0.2,  0.2, 0.5,  0.5, 0.8,
+	2, 9,
+	0.5, 0.8,  0.7, 0.7,  0.8, 0.4,
+	0.7, 0.1,  0.5, 0.0,  0.3, 0.1,
+	0.2, 0.4,  0.3, 0.7,  0.5, 0.8,
 	0
 };
 
@@ -364,8 +366,8 @@ double const  Vert[] = {
 
 
 double const tilde[] = {
-	2, 4,
-	0.00, 0.8,  0.25, 0.2,  0.75, 0.8,  1.00, 0.2,
+	2, 6,
+	0.0, 0.8,  0.15, 0.2,  0.35, 0.2,  0.65, 0.8,  0.85, 0.8,  1.0, 0.2,
 	0
 };
 
@@ -594,9 +596,11 @@ int mathed_string_width(FontInfo const & font, docstring const & s)
 void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
 	docstring const & name)
 {
+	int const lw = pi.base.solidLineThickness();
+
 	if (name == ".") {
 		pi.pain.line(x + w/2, y, x + w/2, y + h,
-			  Color_cursor, Painter::line_onoffdash);
+			  Color_cursor, Painter::line_onoffdash, lw);
 		return;
 	}
 
@@ -638,16 +642,16 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
 			pi.pain.line(
 				int(x + xx + 0.5), int(y + yy + 0.5),
 				int(x + x2 + 0.5), int(y + y2 + 0.5),
-				pi.base.font.color());
+				pi.base.font.color(), Painter::line_solid, lw);
 			if (code == 5) {  // thicker, but rounded
 				pi.pain.line(
 					int(x + xx + 0.5+1), int(y + yy + 0.5-1),
 					int(x + x2 + 0.5-1), int(y + y2 + 0.5-1),
-				pi.base.font.color());
+				pi.base.font.color(), Painter::line_solid, lw);
 				pi.pain.line(
 					int(x + xx + 0.5+1), int(y + yy + 0.5+1),
 					int(x + x2 + 0.5-1), int(y + y2 + 0.5+1),
-				pi.base.font.color());
+				pi.base.font.color(), Painter::line_solid, lw);
 			}
 		} else {
 			int xp[32];
@@ -665,7 +669,8 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
 				yp[j] = int(y + yy + 0.5);
 				//  lyxerr << "P[" << j ' ' << xx << ' ' << yy << ' ' << x << ' ' << y << ']';
 			}
-			pi.pain.lines(xp, yp, n2, pi.base.font.color());
+			pi.pain.lines(xp, yp, n2, pi.base.font.color(),
+				Painter::fill_none, Painter::line_solid, lw);
 		}
 	}
 }


More information about the lyx-cvs mailing list