commit eeb36e808c9726fd3689926a3c20457e3b801341 Author: Enrico Forestieri <for...@lyx.org> Date: Thu Apr 1 16:59:55 2021 +0200
Change cursor shape for clickable math insets Currently, only InsetMathRef and InsetMathSpace are clickable. --- src/BufferView.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/BufferView.h | 3 +++ 2 files changed, 41 insertions(+), 0 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 308cf7f..ed5a09f 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2383,12 +2383,50 @@ Inset const * BufferView::getCoveringInset(Text const & text, } +Inset const * BufferView::clickableMathInset(InsetMathNest const * inset, + CoordCache::Insets const & inset_cache, int x, int y) const +{ + for (size_t i = 0; i < inset->nargs(); ++i) { + MathData const & ar = inset->cell(i); + for (size_t j = 0; j < ar.size(); ++j) { + string const name = lyxerr.debugging(Debug::MATHED) + ? insetName(ar[j].nucleus()->lyxCode()) + : string(); + LYXERR(Debug::MATHED, "Checking inset: " << name); + if (ar[j].nucleus()->clickable(*this, x, y)) { + if (inset_cache.covers(ar[j].nucleus(), x, y)) { + LYXERR(Debug::MATHED, "Clickable inset: " + << name); + return ar[j].nucleus(); + } + } + InsetMathNest const * imn = + ar[j].nucleus()->asNestInset(); + if (imn) { + Inset const * inner = + clickableMathInset(imn, inset_cache, x, y); + if (inner) + return inner; + } + } + } + return nullptr; +} + + void BufferView::updateHoveredInset() const { // Get inset under mouse, if there is one. int const x = d->mouse_position_cache_.x_; int const y = d->mouse_position_cache_.y_; Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y); + if (covering_inset && covering_inset->asInsetMath()) { + Inset const * inner_inset = clickableMathInset( + covering_inset->asInsetMath()->asNestInset(), + coordCache().getInsets(), x, y); + if (inner_inset) + covering_inset = inner_inset; + } d->clickable_inset_ = covering_inset && covering_inset->clickable(*this, x, y); diff --git a/src/BufferView.h b/src/BufferView.h index ab5ba60..88ad636 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -164,6 +164,9 @@ public: /// \return the math inset with a context menu for the given position Inset const * mathContextMenu(InsetMathNest const * inset, CoordCache::Insets const & inset_cache, int x, int y) const; + /// \return the clickable math inset for the given position + Inset const * clickableMathInset(InsetMathNest const * inset, + CoordCache::Insets const & inset_cache, int x, int y) const; /// Save the current position as bookmark. /// if idx == 0, save to temp_bookmark -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs