commit 613ace5b774f3fbd79911a94c6cd3489197d8d14
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Wed Jul 16 22:50:40 2025 +0200
Clean-up MetricsInfo and friends
Move members initialization to declaration, move some code where it belongs.
No change intended.
---
src/MetricsInfo.cpp | 110 ++++++++++++++++++++++++----------------------------
src/MetricsInfo.h | 31 ++++++++-------
2 files changed, 67 insertions(+), 74 deletions(-)
diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp
index 095d591c95..90e74e9733 100644
--- a/src/MetricsInfo.cpp
+++ b/src/MetricsInfo.cpp
@@ -34,10 +34,8 @@ namespace lyx {
//
/////////////////////////////////////////////////////////////////////////
-MetricsBase::MetricsBase(BufferView * b, FontInfo f, int w)
- : bv(b), font(std::move(f)), fontname("mathnormal"),
- textwidth(w), macro_nesting(0),
- solid_line_thickness_(1), solid_line_offset_(1),
dotted_line_thickness_(1)
+MetricsBase::MetricsBase(BufferView * b, FontInfo const & f, int w)
+ : bv(b), font(f), textwidth(w)
{
if (lyxrc.currentZoom >= 200) {
// derive the line thickness from zoom factor
@@ -138,6 +136,52 @@ int MetricsBase::inPixels(Length const & len) const
}
+Changer MetricsBase::changeScript()
+{
+ switch (font.style()) {
+ case DISPLAY_STYLE:
+ case TEXT_STYLE:
+ return font.changeStyle(SCRIPT_STYLE);
+ case SCRIPT_STYLE:
+ case SCRIPTSCRIPT_STYLE:
+ return font.changeStyle(SCRIPTSCRIPT_STYLE);
+ case INHERIT_STYLE:
+ case IGNORE_STYLE:
+ return noChange();
+ }
+ //remove Warning
+ return noChange();
+}
+
+
+Changer MetricsBase::changeFrac()
+{
+ switch (font.style()) {
+ case DISPLAY_STYLE:
+ return font.changeStyle(TEXT_STYLE);
+ case TEXT_STYLE:
+ return font.changeStyle(SCRIPT_STYLE);
+ case SCRIPT_STYLE:
+ case SCRIPTSCRIPT_STYLE:
+ return font.changeStyle(SCRIPTSCRIPT_STYLE);
+ case INHERIT_STYLE:
+ case IGNORE_STYLE:
+ return noChange();
+ }
+ //remove Warning
+ return noChange();
+}
+
+
+Changer MetricsBase::changeArray(bool small)
+{
+ if (small)
+ return font.changeStyle(SCRIPT_STYLE);
+ return (font.style() == DISPLAY_STYLE) ? font.changeStyle(TEXT_STYLE)
+ : noChange();
+}
+
+
/////////////////////////////////////////////////////////////////////////
//
// MetricsInfo
@@ -146,8 +190,7 @@ int MetricsBase::inPixels(Length const & len) const
MetricsInfo::MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
MacroContext const & mc, bool vm, bool tight)
- : base(bv, font, textwidth), macrocontext(mc), vmode(vm),
tight_insets(tight),
- extrawidth(0)
+ : base(bv, font, textwidth), macrocontext(mc), vmode(vm),
tight_insets(tight)
{}
@@ -158,13 +201,8 @@ MetricsInfo::MetricsInfo(BufferView * bv, FontInfo font,
int textwidth,
/////////////////////////////////////////////////////////////////////////
PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter)
- : pain(painter), ltr_pos(false), change(),
- selected(false), selected_left(false), selected_right(false),
- do_spellcheck(true), full_repaint(true),
background_color(Color_background),
- leftx(0), rightx(0)
-{
- base.bv = bv;
-}
+ : base(bv), pain(painter)
+{}
void PainterInfo::draw(int x, int y, char_type c)
@@ -226,50 +264,4 @@ Color PainterInfo::textColor(Color const & color) const
}
-Changer MetricsBase::changeScript()
-{
- switch (font.style()) {
- case DISPLAY_STYLE:
- case TEXT_STYLE:
- return font.changeStyle(SCRIPT_STYLE);
- case SCRIPT_STYLE:
- case SCRIPTSCRIPT_STYLE:
- return font.changeStyle(SCRIPTSCRIPT_STYLE);
- case INHERIT_STYLE:
- case IGNORE_STYLE:
- return noChange();
- }
- //remove Warning
- return noChange();
-}
-
-
-Changer MetricsBase::changeFrac()
-{
- switch (font.style()) {
- case DISPLAY_STYLE:
- return font.changeStyle(TEXT_STYLE);
- case TEXT_STYLE:
- return font.changeStyle(SCRIPT_STYLE);
- case SCRIPT_STYLE:
- case SCRIPTSCRIPT_STYLE:
- return font.changeStyle(SCRIPTSCRIPT_STYLE);
- case INHERIT_STYLE:
- case IGNORE_STYLE:
- return noChange();
- }
- //remove Warning
- return noChange();
-}
-
-
-Changer MetricsBase::changeArray(bool small)
-{
- if (small)
- return font.changeStyle(SCRIPT_STYLE);
- return (font.style() == DISPLAY_STYLE) ? font.changeStyle(TEXT_STYLE)
- : noChange();
-}
-
-
} // namespace lyx
diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h
index 889e508efd..cd9096e993 100644
--- a/src/MetricsInfo.h
+++ b/src/MetricsInfo.h
@@ -40,7 +40,7 @@ class MacroContext;
class MetricsBase {
public:
///
- MetricsBase(BufferView * bv = 0, FontInfo font = FontInfo(),
+ MetricsBase(BufferView * bv = 0, FontInfo const & font = FontInfo(),
int textwidth = 0);
/// the current view
@@ -50,11 +50,11 @@ public:
/// font of the containing inset
FontInfo outer_font;
/// name of current font - mathed specific
- std::string fontname;
+ std::string fontname = "mathnormal";
/// This is the width available in pixels
int textwidth;
/// count wether the current mathdata is nested in macro(s)
- int macro_nesting;
+ int macro_nesting = 0;
/// Temporarily change a full font.
Changer changeFontSet(std::string const & name);
@@ -83,12 +83,11 @@ public:
int inPixels(Length const & len) const;
private:
- int solid_line_thickness_;
- int solid_line_offset_;
- int dotted_line_thickness_;
+ int solid_line_thickness_ = 1;
+ int solid_line_offset_ = 1;
+ int dotted_line_thickness_ = 1;
};
-
//
// This contains a MetricsBase and information that's only relevant during
// the first phase of the two-phase draw
@@ -111,7 +110,7 @@ public:
/// if true, do not expand insets to max width artificially
bool tight_insets;
/// Extra width required by an inset, in addition to its dimension
- int extrawidth;
+ int extrawidth = 0;
};
@@ -147,22 +146,24 @@ public:
///
frontend::Painter & pain;
/// Whether the text at this point is right-to-left (for insets)
- bool ltr_pos;
+ bool ltr_pos = false;
/// The change the parent is part of (change tracking)
Change change;
/// Whether the parent is selected as a whole
- bool selected;
+ bool selected = false;
/// Whether the left/right margins are selected
- bool selected_left, selected_right;
+ bool selected_left = false;
+ bool selected_right = false;
/// Whether the spell checker is enabled for the parent
- bool do_spellcheck;
+ bool do_spellcheck = true;
/// True when it can be assumed that the screen has been cleared
- bool full_repaint;
+ bool full_repaint = true;
/// Current background color
- ColorCode background_color;
+ ColorCode background_color = Color_background;
/// The left and right position of current line (inside margins).
/// Useful for drawing display math numbering
- int leftx, rightx;
+ int leftx = 0;
+ int rightx = 0;
};
class TextMetricsInfo {};
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs