mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
PixelPaint: Let Tools have different cursors
This adds support for the Tools in PixelPaint to use different cursors within ImageEditor. For now most of them get the crosshair cursor since it's the most fitting, but in the future we will want to add custom cursors.
This commit is contained in:
parent
657fbc1e6c
commit
b1b6a6d6e8
Notes:
sideshowbarker
2024-07-18 07:12:14 +09:00
Author: https://github.com/metmo
Commit: b1b6a6d6e8
Pull-request: https://github.com/SerenityOS/serenity/pull/9294
14 changed files with 28 additions and 3 deletions
|
@ -181,6 +181,7 @@ void ImageEditor::mousedown_event(GUI::MouseEvent& event)
|
|||
if (event.button() == GUI::MouseButton::Middle) {
|
||||
m_click_position = event.position();
|
||||
m_saved_pan_origin = m_pan_origin;
|
||||
set_override_cursor(Gfx::StandardCursor::Drag);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,6 +228,8 @@ void ImageEditor::mousemove_event(GUI::MouseEvent& event)
|
|||
|
||||
void ImageEditor::mouseup_event(GUI::MouseEvent& event)
|
||||
{
|
||||
set_override_cursor(m_active_cursor);
|
||||
|
||||
if (!m_active_layer || !m_active_tool)
|
||||
return;
|
||||
auto layer_event = event_adjusted_for_layer(event, *m_active_layer);
|
||||
|
@ -265,8 +268,15 @@ void ImageEditor::keyup_event(GUI::KeyEvent& event)
|
|||
m_active_tool->on_keyup(event);
|
||||
}
|
||||
|
||||
void ImageEditor::enter_event(Core::Event&)
|
||||
{
|
||||
set_override_cursor(m_active_cursor);
|
||||
}
|
||||
|
||||
void ImageEditor::leave_event(Core::Event&)
|
||||
{
|
||||
set_override_cursor(Gfx::StandardCursor::None);
|
||||
|
||||
if (on_leave)
|
||||
on_leave();
|
||||
}
|
||||
|
@ -304,8 +314,10 @@ void ImageEditor::set_active_tool(Tool* tool)
|
|||
|
||||
m_active_tool = tool;
|
||||
|
||||
if (m_active_tool)
|
||||
if (m_active_tool) {
|
||||
m_active_tool->setup(*this);
|
||||
m_active_cursor = m_active_tool->cursor();
|
||||
}
|
||||
}
|
||||
|
||||
void ImageEditor::layers_did_change()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue