From 438aaf2ec989d9cdcefe6e59bdc324c8398782bb Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 9 Feb 2009 20:22:48 +0000 Subject: [PATCH] Add a new member to FontInfo denoting the color to be used when painting. * rowpainter.cpp: now the color for painting selected text and changed text is set via FontInfo::setColor. However, this color should remain a ColorCode as this color is used in e.g. the GuiCharacter dialog and for LateX output. Therefore I use now the FontInfo::setPaintColor function. * FontInfo.cpp/h: new members paint_color_ and setPaintColor(). The function realColor is updated to return the paintColor when it is set. See: http://thread.gmane.org/gmane.editors.lyx.devel/114189 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28422 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/FontInfo.cpp | 4 +++- src/FontInfo.h | 13 ++++++++++--- src/rowpainter.cpp | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp index c5b1c85a9b..00a9da165d 100644 --- a/src/FontInfo.cpp +++ b/src/FontInfo.cpp @@ -278,8 +278,10 @@ bool FontInfo::resolved() const } -ColorCode FontInfo::realColor() const +Color FontInfo::realColor() const { + if (paint_color_ != Color_none) + return paint_color_; if (color_ == Color_none) return Color_foreground; return color_; diff --git a/src/FontInfo.h b/src/FontInfo.h index 24951445ba..8e05cee007 100644 --- a/src/FontInfo.h +++ b/src/FontInfo.h @@ -19,6 +19,7 @@ #include "tex2lyx/Font.h" #else +#include "Color.h" #include "ColorCode.h" #include "FontEnums.h" @@ -43,7 +44,7 @@ public: FontState noun, FontState number ): family_(family), series_(series), shape_(shape), size_(size), - color_(color), background_(background), emph_(emph), + color_(color), background_(background), paint_color_(), emph_(emph), underbar_(underbar), noun_(noun), number_(number) {} @@ -88,8 +89,11 @@ public: /// Is a given font fully resolved? bool resolved() const; - /// - ColorCode realColor() const; + /// The real color of the font. This can be the color that is + /// set for painting, the color of the font or a default color. + Color realColor() const; + /// Sets the color which is used during painting + void setPaintColor(Color c) { paint_color_ = c; } /// Converts logical attributes to concrete shape attribute /// Try hard to inline this as it shows up with 4.6 % in the profiler. @@ -122,6 +126,9 @@ public: private: friend bool operator==(FontInfo const & lhs, FontInfo const & rhs); + /// The color used for painting + Color paint_color_; + /// FontFamily family_; /// diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index c5d0bd1291..4de10afe2d 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -304,9 +304,9 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, FontInfo copy = font; if (change_running.changed()) - copy.setColor(change_running.color()); + copy.setPaintColor(change_running.color()); else if (selection) - copy.setColor(Color_selectiontext); + copy.setPaintColor(Color_selectiontext); x_ += pi_.pain.text(int(x_), yo_, s, copy); }