]> git.lyx.org Git - features.git/commitdiff
have pointing cursor when hovering something clickable
authorEdwin Leuven <e.leuven@gmail.com>
Sun, 24 Oct 2010 21:41:47 +0000 (21:41 +0000)
committerEdwin Leuven <e.leuven@gmail.com>
Sun, 24 Oct 2010 21:41:47 +0000 (21:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35806 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/frontends/qt4/GuiWorkArea.cpp

index b0dc5d47b5ca7224f406d9f5b3cfaa1d3a9de20c..8dbd511defb020024a0ad72edd33b5a843098603 100644 (file)
@@ -220,7 +220,8 @@ struct BufferView::Private
        Private(BufferView & bv): wh_(0), cursor_(bv),
                anchor_pit_(0), anchor_ypos_(0),
                inlineCompletionUniqueChars_(0),
-               last_inset_(0), mouse_position_cache_(),
+               last_inset_(0), clickable_inset_(false), 
+               mouse_position_cache_(),
                bookmark_edit_position_(-1), gui_(0)
        {}
 
@@ -263,6 +264,8 @@ struct BufferView::Private
          * Not owned, so don't delete.
          */
        Inset * last_inset_;
+       /// are we hovering something that we can click
+       bool clickable_inset_;
 
        /// position of the mouse at the time of the last mouse move
        /// This is used to update the hovering status of inset in
@@ -1959,8 +1962,12 @@ Inset const * BufferView::getCoveringInset(Text const & text,
 void BufferView::updateHoveredInset() const
 {
        // Get inset under mouse, if there is one.
-       Inset const * covering_inset = getCoveringInset(buffer_.text(),
-                       d->mouse_position_cache_.x_, d->mouse_position_cache_.y_);
+       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);
+
+       d->clickable_inset_ = covering_inset && covering_inset->clickable(x, y);
+
        if (covering_inset == d->last_inset_)
                // Same inset, no need to do anything...
                return;
@@ -2888,4 +2895,10 @@ void BufferView::setInlineCompletion(Cursor & cur, DocIterator const & pos,
        }
 }
 
+
+bool BufferView::clickableInset() const
+{ 
+       return d->clickable_inset_; 
+}
+
 } // namespace lyx
index 1880a583692158c7408593b70559b57cb8471e50..0672c9ddd16800c320dbd5bb8ae36ea8bb9ca6f1 100644 (file)
@@ -311,6 +311,8 @@ public:
        void editInset(std::string const & name, Inset * inset);
        ///
        void clearLastInset(Inset * inset) const;
+       /// Is the mouse hovering a clickable inset or element?
+       bool clickableInset() const;
 
 private:
        /// noncopyable
index 0c1eeed670db8e63f50cd20fdabc0100da47ca3d..667dd6f4fa6f328361b416f0b9f6c68f7257468d 100644 (file)
@@ -527,6 +527,9 @@ void GuiWorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod)
                // Show the cursor immediately after any operation
                startBlinkingCursor();
        }
+
+       setCursorShape(buffer_view_->clickableInset() 
+               ? Qt::PointingHandCursor : Qt::IBeamCursor);
 }