]> git.lyx.org Git - features.git/commitdiff
Mouse hover property should be dependent on the specific bufferview. If there are...
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 30 Apr 2010 14:47:46 +0000 (14:47 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 30 Apr 2010 14:47:46 +0000 (14:47 +0000)
This is also in preparation of a decent fix for bug #3900.

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

src/BufferView.cpp
src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetCommand.cpp
src/insets/InsetCommand.h
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathNest.h

index 3aa1854d1fd9cdde12a3f9cefbca6fc1a5e73e7e..0a4e11bcb1c85ee91f38800ae5e52f0b79c97b07 100644 (file)
@@ -1902,13 +1902,13 @@ void BufferView::updateHoveredInset() const
        bool need_redraw = false;
        if (d->last_inset_)
                // Remove the hint on the last hovered inset (if any).
-               need_redraw |= d->last_inset_->setMouseHover(false);
+               need_redraw |= d->last_inset_->setMouseHover(this, false);
        
        // const_cast because of setMouseHover().
        Inset * inset = const_cast<Inset *>(covering_inset);
        if (inset)
                // Highlight the newly hovered inset (if any).
-               need_redraw |= inset->setMouseHover(true);
+               need_redraw |= inset->setMouseHover(this, true);
 
        d->last_inset_ = inset;
        
index 25ce4816c83ea95c6519394920f7d2f8cdfeace4..3fae5bdb18298e42f027c3cf5bb5323e3663fe9b 100644 (file)
@@ -495,7 +495,7 @@ void Inset::metricsMarkers2(Dimension & dim, int framesize) const
 
 void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
 {
-       ColorCode pen_color = mouseHovered() || editing(pi.base.bv)?
+       ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
                Color_mathframe : Color_mathcorners;
 
        Dimension const dim = dimension(*pi.base.bv);
@@ -512,7 +512,7 @@ void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
 
 void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
 {
-       ColorCode pen_color = mouseHovered() || editing(pi.base.bv)?
+       ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
                Color_mathframe : Color_mathcorners;
 
        drawMarkers(pi, x, y);
index 22604a73de1e2e783b50d8ae30b60ad837707df1..ab12fa8ba749067f48c3c69da20c0154fd756422 100644 (file)
@@ -284,15 +284,15 @@ public:
        /// \c cur is the new cursor, some slice points to this. Use the update flags to cause a redraw.
        virtual bool notifyCursorEnters(Cursor & /*cur*/)
                { return false; }
-       /// is called when the mouse enter or leave this inset
-       /// return true if this inset needs repaint
-       virtual bool setMouseHover(bool) { return false; }
+       /// is called when the mouse enters or leaves this inset
+       /// return true if this inset needs repaint
+       virtual bool setMouseHover(BufferView const * bv, bool) { return false; }
        /// return true if this inset is hovered (under mouse)
        /// This is by now only used by mathed to draw corners 
        /// (Inset::drawMarkers() and Inset::drawMarkers2()).
        /// Other insets do not have to redefine this function to 
        /// return the correct status of mouseHovered.
-       virtual bool mouseHovered() const { return false; }
+       virtual bool mouseHovered(BufferView const * bv) const { return false; }
 
        /// request "external features"
        virtual void validate(LaTeXFeatures &) const {}
index f6d94c26be7879e091b96ef1079593f1d664f303..e84d2432d9827ba18b531f3de8f0191896c16aa6 100644 (file)
@@ -42,8 +42,7 @@ using namespace std;
 namespace lyx {
 
 InsetCollapsable::InsetCollapsable(Buffer * buf, InsetText::UsePlain ltype)
-       : InsetText(buf, ltype), status_(Open),
-         openinlined_(false), mouse_hover_(false)
+       : InsetText(buf, ltype), status_(Open), openinlined_(false)
 {
        setAutoBreakRows(true);
        setDrawFrame(true);
@@ -59,7 +58,7 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
          openinlined_(rhs.openinlined_),
          auto_open_(rhs.auto_open_),
          // the sole purpose of this copy constructor
-         mouse_hover_(false)
+         mouse_hover_()
 {
 }
 
@@ -230,9 +229,9 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
 }
 
 
-bool InsetCollapsable::setMouseHover(bool mouse_hover)
+bool InsetCollapsable::setMouseHover(BufferView const * bv, bool mouse_hover)
 {
-       mouse_hover_ = mouse_hover;
+       mouse_hover_[bv] = mouse_hover;
        return true;
 }
 
@@ -261,7 +260,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
                FontInfo labelfont = getLayout().labelfont();
                labelfont.setColor(labelColor());
                pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
-                       mouse_hover_);
+                       mouse_hover_[&bv]);
        } else {
                button_dim.x1 = 0;
                button_dim.y1 = 0;
@@ -586,7 +585,7 @@ void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status)
        setButtonLabel();
        if (status_ == Collapsed) {
                cur.leaveInset(*this);
-               mouse_hover_ = false;
+               mouse_hover_.clear();
        }
 }
 
index 221795dd3b8ee336c4121d953c079b52f25f9460..d93ddae12a760e5d55b4766a079c5ece2bf6c64a 100644 (file)
@@ -125,7 +125,7 @@ public:
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
-       bool setMouseHover(bool mouse_hover);
+       bool setMouseHover(BufferView const * bv, bool mouse_hover);
        ///
        ColorCode backgroundColor(PainterInfo const &) const
                { return getLayout().bgcolor(); }
@@ -163,7 +163,7 @@ private:
        /// dependent on the bufferview, compare with MathMacro::editing_.
        mutable std::map<BufferView const *, bool> auto_open_;
        /// changes color when mouse enters/leaves this inset
-       bool mouse_hover_;
+       mutable std::map<BufferView const *, bool> mouse_hover_;
 };
 
 } // namespace lyx
index 4408433fb98b07e86d12d47d707a459f1d2f3134..d99ccd6c8df8189332c7886b183afcf081969db7 100644 (file)
@@ -73,16 +73,16 @@ void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
 }
 
 
-bool InsetCommand::setMouseHover(bool mouse_hover)
+bool InsetCommand::setMouseHover(BufferView const * bv, bool mouse_hover)
 {
-       mouse_hover_ = mouse_hover;
+       mouse_hover_[bv] = mouse_hover;
        return true;
 }
 
 
 void InsetCommand::draw(PainterInfo & pi, int x, int y) const
 {
-       button_.setRenderState(mouse_hover_);
+       button_.setRenderState(mouse_hover_[pi.base.bv]);
        button_.draw(pi, x, y);
 }
 
index d1f4af0d0f3344bec806ecb64ae907e6f48adbff..57c9c0443a4d0c77cc8ad04d6ac08b0291ad8795 100644 (file)
@@ -99,7 +99,7 @@ private:
        ///
        RenderButton & button() const { return button_; }
        ///
-       bool setMouseHover(bool mouse_hover);
+       bool setMouseHover(BufferView const * bv, bool mouse_hover);
        /// Return parameter information for command cmdName.
        /// Not implemented here. Must be implemented in derived class.
        static ParamInfo const & findInfo(std::string const & cmdName);
@@ -120,7 +120,7 @@ private:
        ///
        std::string mailer_name_;
        /// changes color when mouse enters/leaves this inset
-       bool mouse_hover_;
+       mutable std::map<BufferView const *, bool> mouse_hover_;
        ///
        mutable RenderButton button_;
 };
index 151690f6542246ab1878a1dc02ba6ccc00cfd907..4fae4f5ba5d55928152750e93969a5045e8becf0 100644 (file)
@@ -80,15 +80,14 @@ using cap::selClearOrDel;
 
 
 InsetMathNest::InsetMathNest(Buffer * buf, idx_type nargs)
-       : InsetMath(buf), cells_(nargs), lock_(false), mouse_hover_(false)
+       : InsetMath(buf), cells_(nargs), lock_(false)
 {
        setBuffer(*buf);
 }
 
 
 InsetMathNest::InsetMathNest(InsetMathNest const & inset)
-       : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_),
-         mouse_hover_(false)
+       : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_)
 {}
 
 
@@ -96,7 +95,7 @@ InsetMathNest & InsetMathNest::operator=(InsetMathNest const & inset)
 {
        cells_ = inset.cells_;
        lock_ = inset.lock_;
-       mouse_hover_ = false;
+       mouse_hover_.clear();
        InsetMath::operator=(inset);
        return *this;
 }
@@ -395,9 +394,9 @@ int InsetMathNest::latex(odocstream & os, OutputParams const & runparams) const
 }
 
 
-bool InsetMathNest::setMouseHover(bool mouse_hover)
+bool InsetMathNest::setMouseHover(BufferView const * bv, bool mouse_hover)
 {
-       mouse_hover_ = mouse_hover;
+       mouse_hover_[bv] = mouse_hover;
        return true;
 }
 
index 49b90eb8b6e185d2009643f677d3191d8bee6220..39fa62b630c1482a7b62336533a312d5ef63336f 100644 (file)
@@ -17,6 +17,8 @@
 // FIXME: remove
 #include "support/docstring.h"
 
+#include <map>
+
 namespace lyx {
 
 /** Abstract base class for all math objects that contain nested items.
@@ -111,9 +113,10 @@ public:
        ///
        int latex(odocstream & os, OutputParams const & runparams) const;
        ///
-       bool setMouseHover(bool mouse_hover);
+       bool setMouseHover(BufferView const * bv, bool mouse_hover);
        ///
-       bool mouseHovered() const { return mouse_hover_; }
+       bool mouseHovered(BufferView const * bv) const 
+               { return mouse_hover_[bv]; }
 
        ///
        bool completionSupported(Cursor const &) const;
@@ -194,8 +197,8 @@ protected:
        /// if the inset is locked, it can't be entered with the cursor
        bool lock_;
        ///
-       bool mouse_hover_;
-};
+       mutable std::map<BufferView const *, bool> mouse_hover_;
+};