]> git.lyx.org Git - features.git/commitdiff
Remove background_color_ in Insets: it takes a lot of unnecessary memory,
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 12 Jun 2007 13:45:49 +0000 (13:45 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 12 Jun 2007 13:45:49 +0000 (13:45 +0000)
especially in math where each equation has many insets.

* src/Insets.cpp: remove background_color_ member
(setBackgroundColor): remove
(backgroundColor): make virtual

* insets/InsetBranch.cpp:
* insets/InsetNote.cpp: move color setting code from setButtonLabel to
backgroundColor.

* insets/InsetBox.cpp (setButtonLabel): remove call to setBackgroundColor.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18750 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetBox.cpp
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h

index 09be84e480dc524cd37f9e0077acae8568c427ec..8664c5f8d9b410aed637c6b828da879b393d0802 100644 (file)
@@ -117,7 +117,7 @@ static TranslatorMap const build_translator()
 
 /// pretty arbitrary dimensions
 Inset::Inset()
-       : dim_(10, 10, 10), background_color_(Color::background)
+       : dim_(10, 10, 10)
 {}
 
 
@@ -351,15 +351,9 @@ void Inset::dump() const
 }
 
 
-void Inset::setBackgroundColor(Color_color color)
-{
-       background_color_ = color;
-}
-
-
 Color_color Inset::backgroundColor() const
 {
-       return Color::color(background_color_);
+       return Color::background;
 }
 
 
index ca824c8ee46bdf9a42c78e4325583d0aa95c0727..57c3a27cd474a46e9fede8c9ce277d23515b2cee 100644 (file)
@@ -470,9 +470,7 @@ public:
        ///
        int scroll() const { return 0; }
        ///
-       void setBackgroundColor(Color_color);
-       ///
-       Color_color backgroundColor() const;
+       virtual Color_color backgroundColor() const;
        ///
        enum CollapseStatus {
                Collapsed,
@@ -504,10 +502,6 @@ protected:
        mutable Dimension dim_;
 private:
        virtual std::auto_ptr<Inset> doClone() const = 0;
-       /** We store the Color::color value as an int to get Color.h out
-        *  of the header file.
-        */
-       int background_color_;
 };
 
 
index 1ca10c186b0abe106c3ae52bad61cc4a52a90f35..934ec0b4eb8f27a8ce8741cbac3e98aefb03cfb5 100644 (file)
@@ -164,7 +164,6 @@ void InsetBox::setButtonLabel()
        setLabel(label);
 
        font.setColor(Color::foreground);
-       setBackgroundColor(Color::background);
        setLabelFont(font);
 }
 
index 407f7d848e1f96617fa07d32ad1296021ac89366..67ef02f193f4511d8662bf814d9182591d1b3690 100644 (file)
@@ -98,22 +98,33 @@ void InsetBranch::setButtonLabel()
        font.decSize();
 
        docstring s = _("Branch: ") + params_.branch;
-       font.setColor(Color::foreground);
        if (!params_.branch.empty()) {
                // FIXME UNICODE
                Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
                if (c == Color::none) {
-                       c = Color::error;
                        s = _("Undef: ") + s;
                }
-               setBackgroundColor(c);
-       } else
-               setBackgroundColor(Color::background);
+       }
+       font.setColor(Color::foreground);
        setLabel(isOpen() ? s : getNewLabel(s) );
        setLabelFont(font);
 }
 
 
+Color_color InsetBranch::backgroundColor() const
+{
+       if (!params_.branch.empty()) {
+               // FIXME UNICODE
+               Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
+               if (c == Color::none) {
+                       c = Color::error;
+               }
+               return c;
+       } else
+               return Inset::backgroundColor();
+}
+
+
 bool InsetBranch::showInsetDialog(BufferView * bv) const
 {
        InsetBranchMailer(const_cast<InsetBranch &>(*this)).showDialog(bv);
index 72d30a263ff199fd3c614a7d1da606e7ab39d278..5df7b15d3280e209ea6db6b93a524d1fd2c264fa 100644 (file)
@@ -53,6 +53,8 @@ public:
        ///
        void setButtonLabel();
        ///
+       virtual Color_color backgroundColor() const;
+       ///
        bool showInsetDialog(BufferView *) const;
        ///
        int latex(Buffer const &, odocstream &,
index 1a0cadc5feb81cd378243db50320e8613d8e3c0f..511d95a1112d0d055472ab3ee2e792f4317ff63c 100644 (file)
@@ -186,32 +186,53 @@ void InsetNote::setButtonLabel()
        font.decSize();
        font.decSize();
 
+       Color_color c;
        switch (params_.type) {
        case InsetNoteParams::Note:
-               font.setColor(Color::note);
-               setBackgroundColor(Color::notebg);
+               c = Color::note;
                break;
        case InsetNoteParams::Comment:
-               font.setColor(Color::comment);
-               setBackgroundColor(Color::commentbg);
+               c = Color::comment;
                break;
        case InsetNoteParams::Greyedout:
-               font.setColor(Color::greyedout);
-               setBackgroundColor(Color::greyedoutbg);
+               c = Color::greyedout;
                break;
        case InsetNoteParams::Framed:
-               font.setColor(Color::greyedout);
-               setBackgroundColor(Color::greyedoutbg);
+               c = Color::greyedout;
                break;
        case InsetNoteParams::Shaded:
-               font.setColor(Color::greyedout);
-               setBackgroundColor(Color::shadedbg);
+               c = Color::greyedout;
                break;
        }
+       font.setColor(c);
        setLabelFont(font);
 }
 
 
+Color_color InsetNote::backgroundColor() const
+{
+       Color_color c;
+       switch (params_.type) {
+       case InsetNoteParams::Note:
+               c = Color::notebg;
+               break;
+       case InsetNoteParams::Comment:
+               c = Color::commentbg;
+               break;
+       case InsetNoteParams::Greyedout:
+               c = Color::greyedoutbg;
+               break;
+       case InsetNoteParams::Framed:
+               c = Color::greyedoutbg;
+               break;
+       case InsetNoteParams::Shaded:
+               c = Color::shadedbg;
+               break;
+       }
+       return c;
+}
+
+
 bool InsetNote::showInsetDialog(BufferView * bv) const
 {
        InsetNoteMailer(const_cast<InsetNote &>(*this)).showDialog(bv);
index 97cd5d4256a78f941c266b385302a7d38f2125b8..a17889aba4d173e8ac93e5b0f965a81bfe516f96 100644 (file)
@@ -61,6 +61,8 @@ public:
        void read(Buffer const & buf, Lexer & lex);
        ///
        void setButtonLabel();
+       ///
+       virtual Color_color backgroundColor() const;
        /// show the note dialog
        bool showInsetDialog(BufferView * bv) const;
        ///