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;
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);
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);
/// \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 a 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 {}
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);
openinlined_(rhs.openinlined_),
auto_open_(rhs.auto_open_),
// the sole purpose of this copy constructor
- mouse_hover_(false)
+ mouse_hover_()
{
}
}
-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;
}
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;
setButtonLabel();
if (status_ == Collapsed) {
cur.leaveInset(*this);
- mouse_hover_ = false;
+ mouse_hover_.clear();
}
}
///
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(); }
/// 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
}
-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);
}
///
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);
///
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_;
};
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_)
{}
{
cells_ = inset.cells_;
lock_ = inset.lock_;
- mouse_hover_ = false;
+ mouse_hover_.clear();
InsetMath::operator=(inset);
return *this;
}
}
-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;
}
// FIXME: remove
#include "support/docstring.h"
+#include <map>
+
namespace lyx {
/** Abstract base class for all math objects that contain nested items.
///
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;
/// 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_;
+};