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
bool need_redraw = false;
if (d->last_inset_)
// Remove the hint on the last hovered inset (if any).
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).
// 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);
void Inset::drawMarkers(PainterInfo & pi, int x, int y) 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);
Color_mathframe : Color_mathcorners;
Dimension const dim = dimension(*pi.base.bv);
void Inset::drawMarkers2(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);
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; }
/// \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.
/// 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 {}
/// request "external features"
virtual void validate(LaTeXFeatures &) const {}
namespace lyx {
InsetCollapsable::InsetCollapsable(Buffer * buf, InsetText::UsePlain ltype)
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);
{
setAutoBreakRows(true);
setDrawFrame(true);
openinlined_(rhs.openinlined_),
auto_open_(rhs.auto_open_),
// the sole purpose of this copy constructor
openinlined_(rhs.openinlined_),
auto_open_(rhs.auto_open_),
// the sole purpose of this copy constructor
-bool InsetCollapsable::setMouseHover(bool mouse_hover)
+bool InsetCollapsable::setMouseHover(BufferView const * bv, bool mouse_hover)
- mouse_hover_ = mouse_hover;
+ mouse_hover_[bv] = mouse_hover;
FontInfo labelfont = getLayout().labelfont();
labelfont.setColor(labelColor());
pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
FontInfo labelfont = getLayout().labelfont();
labelfont.setColor(labelColor());
pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
} else {
button_dim.x1 = 0;
button_dim.y1 = 0;
} else {
button_dim.x1 = 0;
button_dim.y1 = 0;
setButtonLabel();
if (status_ == Collapsed) {
cur.leaveInset(*this);
setButtonLabel();
if (status_ == Collapsed) {
cur.leaveInset(*this);
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
///
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(); }
///
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
/// dependent on the bufferview, compare with MathMacro::editing_.
mutable std::map<BufferView const *, bool> auto_open_;
/// changes color when mouse enters/leaves this inset
+ mutable std::map<BufferView const *, bool> mouse_hover_;
-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
{
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);
}
button_.draw(pi, x, y);
}
///
RenderButton & button() const { return button_; }
///
///
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);
/// 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
///
std::string mailer_name_;
/// changes color when mouse enters/leaves this inset
+ mutable std::map<BufferView const *, bool> mouse_hover_;
///
mutable RenderButton button_;
};
///
mutable RenderButton button_;
};
InsetMathNest::InsetMathNest(Buffer * buf, idx_type nargs)
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)
{
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_;
{
cells_ = inset.cells_;
lock_ = inset.lock_;
InsetMath::operator=(inset);
return *this;
}
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;
// FIXME: remove
#include "support/docstring.h"
// FIXME: remove
#include "support/docstring.h"
namespace lyx {
/** Abstract base class for all math objects that contain nested items.
namespace lyx {
/** Abstract base class for all math objects that contain nested items.
///
int latex(odocstream & os, OutputParams const & runparams) const;
///
///
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;
///
bool completionSupported(Cursor const &) const;
/// if the inset is locked, it can't be entered with the cursor
bool lock_;
///
/// if the inset is locked, it can't be entered with the cursor
bool lock_;
///
+ mutable std::map<BufferView const *, bool> mouse_hover_;
+};