1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 17:55:08 +00:00

LibGUI: Add Widget override cursor concept

We got ourselves into a mess by making widgets override the window
cursor whenever they wanted a custom cursor. This patch introduces a
better solution to that issue: per-widget override cursors.

Each widget now has an override cursor that overrides the window
cursor when that widget is hovered.
This commit is contained in:
Andreas Kling 2020-09-11 14:17:35 +02:00
parent b4f307f982
commit cf429a788c
4 changed files with 48 additions and 8 deletions

View file

@ -318,12 +318,14 @@ void Widget::handle_mousedoubleclick_event(MouseEvent& event)
void Widget::handle_enter_event(Core::Event& event)
{
window()->update_cursor({});
show_tooltip();
enter_event(event);
}
void Widget::handle_leave_event(Core::Event& event)
{
window()->update_cursor({});
Application::the()->hide_tooltip();
leave_event(event);
}
@ -878,4 +880,14 @@ Gfx::IntRect Widget::children_clip_rect() const
return rect();
}
void Widget::set_override_cursor(Gfx::StandardCursor cursor)
{
if (m_override_cursor == cursor)
return;
m_override_cursor = cursor;
if (auto* window = this->window())
window->update_cursor({});
}
}