have pointing cursor when hovering something clickable

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35806 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Edwin Leuven 2010-10-24 21:41:47 +00:00
parent 943288066d
commit 4e5d3469f6
3 changed files with 21 additions and 3 deletions

View 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

View 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

View 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);
}