Re: [LyX/master] mathedSymbolDim only needs a MathBase

2016-11-22 Thread Jean-Marc Lasgouttes

Le 22/11/2016 à 00:09, Guillaume Munch a écrit :

Le 21/11/2016 à 17:35, Jean-Marc Lasgouttes a écrit :


Somewhere on my todo list I wanted to make MetricsInfo inherit from
MetricsBase, in order to avoid this stupid mi.base thing. Do you see a
reason not to do it?



Well, do you see a reason to do it? What is wrong with composition in
this case?


Having to add .base. is just noise, it does not bring us any interesting 
information IMO. But I am open to being convinced otherwise.


JMarc


Re: [LyX/master] mathedSymbolDim only needs a MathBase

2016-11-21 Thread Guillaume Munch

Le 21/11/2016 à 17:35, Jean-Marc Lasgouttes a écrit :


Somewhere on my todo list I wanted to make MetricsInfo inherit from
MetricsBase, in order to avoid this stupid mi.base thing. Do you see a
reason not to do it?



Well, do you see a reason to do it? What is wrong with composition in
this case?




Re: [LyX/master] mathedSymbolDim only needs a MathBase

2016-11-21 Thread Jean-Marc Lasgouttes

Le 21/11/2016 à 01:17, Guillaume Munch a écrit :

commit eacac8bea2a7dc56a994eb28e517b0fa8c17937f
Author: Guillaume Munch 
Date:   Sun Nov 20 22:34:03 2016 +0100

mathedSymbolDim only needs a MathBase


Somewhere on my todo list I wanted to make MetricsInfo inherit from 
MetricsBase, in order to avoid this stupid mi.base thing. Do you see a 
reason not to do it?


JMarc


---
 src/mathed/InsetMathChar.cpp   |2 +-
 src/mathed/InsetMathSymbol.cpp |2 +-
 src/mathed/MathSupport.cpp |8 
 src/mathed/MathSupport.h   |3 ++-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index a2b9b76..1fef220 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -109,7 +109,7 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & 
dim) const
if (mathfont && subst_) {
// If the char has a substitute, draw the replacement symbol
// instead, but only in math mode.
-   mathedSymbolDim(mi, dim, subst_);
+   mathedSymbolDim(mi.base, dim, subst_);
kerning_ = mathed_char_kerning(mi.base.font, 
*subst_->draw.rbegin());
return;
} else if (!slanted(char_) && mi.base.fontname == "mathnormal") {
diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp
index 885aa60..92d2573 100644
--- a/src/mathed/InsetMathSymbol.cpp
+++ b/src/mathed/InsetMathSymbol.cpp
@@ -61,7 +61,7 @@ docstring InsetMathSymbol::name() const
 void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
 {
// set dim
-   mathedSymbolDim(mi, dim, sym_);
+   mathedSymbolDim(mi.base, dim, sym_);
// set kerning_
kerning_ = mathed_char_kerning(mi.base.font, *sym_->draw.rbegin());
// correct height for broken cmex and wasy font
diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index 3d70840..16fbbcd 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -660,7 +660,7 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int 
w, int h,
 }


-void mathedSymbolDim(MetricsInfo & mi, Dimension & dim, latexkeys const * sym)
+void mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym)
 {
LASSERT((bool)sym, return);
//lyxerr << "metrics: symbol: '" << sym->name
@@ -670,10 +670,10 @@ void mathedSymbolDim(MetricsInfo & mi, Dimension & dim, 
latexkeys const * sym)

bool const italic_upcase_greek = sym->inset == "cmr" &&
sym->extra == "mathalpha" &&
-   mi.base.fontname == "mathit";
+   mb.fontname == "mathit";
std::string const font = italic_upcase_greek ? "cmm" : sym->inset;
-   Changer dummy = mi.base.changeFontSet(font);
-   mathed_string_dim(mi.base.font, sym->draw, dim);
+   Changer dummy = mb.changeFontSet(font);
+   mathed_string_dim(mb.font, sym->draw, dim);
 }


diff --git a/src/mathed/MathSupport.h b/src/mathed/MathSupport.h
index 003631b..b7e3c7c 100644
--- a/src/mathed/MathSupport.h
+++ b/src/mathed/MathSupport.h
@@ -18,6 +18,7 @@

 namespace lyx {

+class MetricsBase;
 class MetricsInfo;
 class PainterInfo;
 class FontInfo;
@@ -49,7 +50,7 @@ void mathed_string_dim(FontInfo const & font,

 int mathed_string_width(FontInfo const &, docstring const & s);

-void mathedSymbolDim(MetricsInfo & mi, Dimension & dim, latexkeys const * sym);
+void mathedSymbolDim(MetricsBase & mb, Dimension & dim, latexkeys const * sym);

 void mathedSymbolDraw(PainterInfo & pi, int x, int y, latexkeys const * sym);