From 72569c42ba850faf87b68dc738a7b283c6dad4ee Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sun, 24 Oct 2010 19:25:36 +0000 Subject: [PATCH] Implement mouse hovering for InsetExternal. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35803 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetExternal.cpp | 16 ++++++++++++++++ src/insets/InsetExternal.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 7225da7472..426aee5891 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -371,6 +371,7 @@ InsetExternal::InsetExternal(Buffer * buf) } +// Mouse hover is not copied and remains empty InsetExternal::InsetExternal(InsetExternal const & other) : Inset(other), boost::signals::trackable(), @@ -382,6 +383,19 @@ InsetExternal::InsetExternal(InsetExternal const & other) InsetExternal::~InsetExternal() { hideDialogs("external", this); + + map::iterator it = mouse_hover_.begin(); + map::iterator end = mouse_hover_.end(); + for (; it != end; ++it) + if (it->second) + it->first->clearLastInset(this); +} + + +bool InsetExternal::setMouseHover(BufferView const * bv, bool mouse_hover) +{ + mouse_hover_[bv] = mouse_hover; + return true; } @@ -454,6 +468,8 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const void InsetExternal::draw(PainterInfo & pi, int x, int y) const { + if (renderer_->asButton()) + renderer_->setRenderState(mouse_hover_[pi.base.bv]); renderer_->draw(pi, x, y); } diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 22c909b0e2..d5a2bc8feb 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -113,6 +113,8 @@ public: int latex(odocstream &, OutputParams const &) const; /// docstring contextMenu(BufferView const & bv, int x, int y) const; + /// + bool setMouseHover(BufferView const * bv, bool mouse_hover); private: /// @@ -161,6 +163,8 @@ private: InsetExternalParams params_; /// The thing that actually draws the image on LyX's screen. boost::scoped_ptr renderer_; + /// changes color of the button when mouse enters/leaves this inset + mutable std::map mouse_hover_; }; } // namespace lyx -- 2.39.5