From b0b8e5f54c3d3f408fcd08d07416749cc5bd76b2 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 3 May 2012 16:28:28 +0200 Subject: [PATCH] Move metrics computation close to drawing for drawStrRed/Black --- src/mathed/InsetMathBox.cpp | 2 +- src/mathed/InsetMathExFunc.cpp | 2 +- src/mathed/InsetMathUnknown.cpp | 2 +- src/mathed/MathMacroArgument.cpp | 2 +- src/mathed/MathSupport.cpp | 6 ++++++ src/mathed/MathSupport.h | 2 ++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index 7a59d973cd..60983bca80 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -218,7 +218,7 @@ void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const Dimension wdim; static docstring bracket = from_ascii("["); - mathed_string_dim(mi.base.font, bracket, wdim); + metricsStrRedBlack(mi, wdim, bracket); int w = wdim.wid; Dimension dim0; diff --git a/src/mathed/InsetMathExFunc.cpp b/src/mathed/InsetMathExFunc.cpp index 25c8dcbaf9..35e2f62bcb 100644 --- a/src/mathed/InsetMathExFunc.cpp +++ b/src/mathed/InsetMathExFunc.cpp @@ -44,7 +44,7 @@ Inset * InsetMathExFunc::clone() const void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const { - mathed_string_dim(mi.base.font, name_, dim); + metricsStrRedBlack(mi, dim, name_); } diff --git a/src/mathed/InsetMathUnknown.cpp b/src/mathed/InsetMathUnknown.cpp index 03c41462f0..29dae2b971 100644 --- a/src/mathed/InsetMathUnknown.cpp +++ b/src/mathed/InsetMathUnknown.cpp @@ -47,7 +47,7 @@ void InsetMathUnknown::normalize(NormalStream & os) const void InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const { - mathed_string_dim(mi.base.font, name_, dim); + metricsStrRedBlack(mi, dim, name_); docstring::const_reverse_iterator rit = name_.rbegin(); kerning_ = mathed_char_kerning(mi.base.font, *rit); } diff --git a/src/mathed/MathMacroArgument.cpp b/src/mathed/MathMacroArgument.cpp index 68f4f98452..2e6b0e2275 100644 --- a/src/mathed/MathMacroArgument.cpp +++ b/src/mathed/MathMacroArgument.cpp @@ -62,7 +62,7 @@ void MathMacroArgument::write(WriteStream & os) const void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const { - mathed_string_dim(mi.base.font, str_, dim); + metricsStrRedBlack(mi, dim, str_); } diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp index 1d7358abb0..77b982b84b 100644 --- a/src/mathed/MathSupport.cpp +++ b/src/mathed/MathSupport.cpp @@ -488,6 +488,12 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h, } +void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & str) +{ + mathed_string_dim(mi.base.font, str, dim); +} + + void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str) { FontInfo f = pi.base.font; diff --git a/src/mathed/MathSupport.h b/src/mathed/MathSupport.h index 04bcffb931..2e0ccff38c 100644 --- a/src/mathed/MathSupport.h +++ b/src/mathed/MathSupport.h @@ -40,6 +40,8 @@ void mathed_string_dim(FontInfo const & font, int mathed_string_width(FontInfo const &, docstring const & s); +void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & s); + void drawStrRed(PainterInfo & pi, int x, int y, docstring const & s); void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & s); -- 2.39.2