Pass a BufferView to Inset::clickable

This commit is contained in:
Jean-Marc Lasgouttes 2016-02-02 17:17:10 +01:00
parent 0576973b8d
commit 6ad2edc381
13 changed files with 13 additions and 13 deletions

View File

@ -2124,7 +2124,7 @@ void BufferView::updateHoveredInset() const
int const y = d->mouse_position_cache_.y_; int const y = d->mouse_position_cache_.y_;
Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y); Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y);
d->clickable_inset_ = covering_inset && covering_inset->clickable(x, y); d->clickable_inset_ = covering_inset && covering_inset->clickable(*this, x, y);
if (covering_inset == d->last_inset_) if (covering_inset == d->last_inset_)
// Same inset, no need to do anything... // Same inset, no need to do anything...

View File

@ -350,7 +350,7 @@ void Inset::doDispatch(Cursor & cur, FuncRequest &cmd)
// if the derived inset did not explicitly handle mouse_release, // if the derived inset did not explicitly handle mouse_release,
// we assume we request the settings dialog // we assume we request the settings dialog
if (!cur.selection() && cmd.button() == mouse_button::button1 if (!cur.selection() && cmd.button() == mouse_button::button1
&& clickable(cmd.x(), cmd.y()) && hasSettings()) { && clickable(cur.bv(), cmd.x(), cmd.y()) && hasSettings()) {
FuncRequest tmpcmd(LFUN_INSET_SETTINGS); FuncRequest tmpcmd(LFUN_INSET_SETTINGS);
dispatch(cur, tmpcmd); dispatch(cur, tmpcmd);
} }

View File

@ -344,7 +344,7 @@ public:
// true for InsetTabular & InsetText // true for InsetTabular & InsetText
virtual bool isActive() const { return nargs() > 0; } virtual bool isActive() const { return nargs() > 0; }
/// can we click at the specified position ? /// can we click at the specified position ?
virtual bool clickable(int, int) const { return false; } virtual bool clickable(BufferView const &, int, int) const { return false; }
/// Move one cell backwards /// Move one cell backwards
virtual bool allowsCaptionVariation(std::string const &) const { return false; } virtual bool allowsCaptionVariation(std::string const &) const { return false; }

View File

@ -414,7 +414,7 @@ bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
} }
bool InsetCollapsable::clickable(int x, int y) const bool InsetCollapsable::clickable(BufferView const &, int x, int y) const
{ {
FuncRequest cmd(LFUN_NOACTION, x, y, mouse_button::none); FuncRequest cmd(LFUN_NOACTION, x, y, mouse_button::none);
return hitButton(cmd); return hitButton(cmd);

View File

@ -69,7 +69,7 @@ public:
/// ///
bool hasSettings() const { return true; } bool hasSettings() const { return true; }
/// ///
bool clickable(int x, int y) const; bool clickable(BufferView const &, int x, int y) const;
/// can we go further down on mouse click? /// can we go further down on mouse click?
bool descendable(BufferView const & bv) const; bool descendable(BufferView const & bv) const;
/// ///

View File

@ -94,7 +94,7 @@ InsetCommand::~InsetCommand()
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
button_.update(screenLabel(), editable() || clickable(0, 0)); button_.update(screenLabel(), editable() || clickable(*mi.base.bv, 0, 0));
button_.metrics(mi, dim); button_.metrics(mi, dim);
} }

View File

@ -87,7 +87,7 @@ public:
/// ///
bool setMouseHover(BufferView const * bv, bool mouse_hover) const; bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
/// ///
bool clickable(int, int) const { return hasSettings(); } bool clickable(BufferView const &, int, int) const { return hasSettings(); }
//@} //@}
protected: protected:

View File

@ -118,7 +118,7 @@ public:
/// ///
bool setMouseHover(BufferView const * bv, bool mouse_hover) const; bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
/// ///
bool clickable(int, int) const { return true; } bool clickable(BufferView const &, int, int) const { return true; }
/// ///
void addToToc(DocIterator const & di, bool output_active, void addToToc(DocIterator const & di, bool output_active,
UpdateType utype) const; UpdateType utype) const;

View File

@ -49,7 +49,7 @@ public:
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///
bool clickable(int, int) const { return true; } bool clickable(BufferView const &, int, int) const { return true; }
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
//@} //@}

View File

@ -53,7 +53,7 @@ public:
InsetGraphicsParams getParams() const { return params_;} InsetGraphicsParams getParams() const { return params_;}
/// ///
bool clickable(int, int) const { return true; } bool clickable(BufferView const &, int, int) const { return true; }
private: private:
/// ///

View File

@ -139,7 +139,7 @@ public:
/// ///
bool hasSettings() const { return true; } bool hasSettings() const { return true; }
/// ///
bool clickable(int, int) const { return true; } bool clickable(BufferView const &, int, int) const { return true; }
/// ///
InsetCode lyxCode() const { return SPACE_CODE; } InsetCode lyxCode() const { return SPACE_CODE; }
/// does this inset try to use all available space (like \\hfill does)? /// does this inset try to use all available space (like \\hfill does)?

View File

@ -49,7 +49,7 @@ public:
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///
bool clickable(int, int) const { return true; } bool clickable(BufferView const &, int, int) const { return true; }
//@} //@}
/// \name Static public methods obligated for InsetCommand derived classes /// \name Static public methods obligated for InsetCommand derived classes

View File

@ -32,7 +32,7 @@ public:
/// ///
bool hasSettings() const { return true; } bool hasSettings() const { return true; }
/// ///
bool clickable(int, int) const { return true; } bool clickable(BufferView const &, int, int) const { return true; }
/// ///
std::string contextMenuName() const; std::string contextMenuName() const;
/// ///