mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 12:47:35 +00:00
PixelPaint: Allowing drawing line from center, like other shapes
You could draw a Rectangle/Ellipse from the center by pressing down the Alt key, but this was missing for lines. This commit adds it in to keep consistency among the different shapes.
This commit is contained in:
parent
c5b14fce54
commit
c0373c3119
2 changed files with 10 additions and 1 deletions
|
@ -53,6 +53,7 @@ void LineTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|||
|
||||
m_drawing_button = layer_event.button();
|
||||
|
||||
m_drag_start_position = layer_event.position();
|
||||
m_line_start_position = layer_event.position();
|
||||
m_line_end_position = layer_event.position();
|
||||
|
||||
|
@ -85,10 +86,17 @@ void LineTool::on_mousemove(Layer* layer, MouseEvent& event)
|
|||
|
||||
if (layer_event.shift()) {
|
||||
constexpr auto ANGLE_STEP = M_PI / 8;
|
||||
m_line_end_position = constrain_line_angle(m_line_start_position, layer_event.position(), ANGLE_STEP);
|
||||
m_line_end_position = constrain_line_angle(m_drag_start_position, layer_event.position(), ANGLE_STEP);
|
||||
} else {
|
||||
m_line_end_position = layer_event.position();
|
||||
}
|
||||
|
||||
if (layer_event.alt()) {
|
||||
m_line_start_position = m_drag_start_position + (m_drag_start_position - m_line_end_position);
|
||||
} else {
|
||||
m_line_start_position = m_drag_start_position;
|
||||
}
|
||||
|
||||
m_editor->update();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue