mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +00:00
PixelPaint: Add new selection moving modes
If you press "spacebar" while moving a selection, it will now move the origin point of the selection; and if you press "control" it will move it relatively to the center.
This commit is contained in:
parent
e2215cc0e1
commit
90873781c1
2 changed files with 33 additions and 0 deletions
|
@ -37,6 +37,14 @@ void RectangleSelectTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent
|
|||
if (!m_selecting)
|
||||
return;
|
||||
|
||||
if (m_moving_mode != MovingMode::None) {
|
||||
auto delta = m_selection_end - image_event.position();
|
||||
if (m_moving_mode == MovingMode::MovingOrigin)
|
||||
m_selection_start -= delta;
|
||||
else if (m_moving_mode == MovingMode::AroundCenter)
|
||||
m_selection_start += delta;
|
||||
}
|
||||
|
||||
m_selection_end = image_event.position();
|
||||
m_editor->update();
|
||||
}
|
||||
|
@ -55,6 +63,22 @@ void RectangleSelectTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&
|
|||
m_editor->selection().set(rect_in_image);
|
||||
}
|
||||
|
||||
void RectangleSelectTool::on_keydown(GUI::KeyEvent& key_event)
|
||||
{
|
||||
if (key_event.key() == KeyCode::Key_Space)
|
||||
m_moving_mode = MovingMode::MovingOrigin;
|
||||
else if (key_event.key() == KeyCode::Key_Control)
|
||||
m_moving_mode = MovingMode::AroundCenter;
|
||||
}
|
||||
|
||||
void RectangleSelectTool::on_keyup(GUI::KeyEvent& key_event)
|
||||
{
|
||||
if (key_event.key() == KeyCode::Key_Space && m_moving_mode == MovingMode::MovingOrigin)
|
||||
m_moving_mode = MovingMode::None;
|
||||
else if (key_event.key() == KeyCode::Key_Control && m_moving_mode == MovingMode::AroundCenter)
|
||||
m_moving_mode = MovingMode::None;
|
||||
}
|
||||
|
||||
void RectangleSelectTool::on_second_paint(Layer const&, GUI::PaintEvent& event)
|
||||
{
|
||||
if (!m_selecting)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue