mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
PaintBrush: Most tools still care about mousemoves outside layer
This allows you to do things like start a line outside the layer, or spray a little outside but still partly hitting the layer. :^)
This commit is contained in:
parent
96d03546ef
commit
24f9406784
6 changed files with 9 additions and 27 deletions
|
@ -79,14 +79,11 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
void EllipseTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
{
|
{
|
||||||
if (m_drawing_button == GUI::MouseButton::None)
|
if (m_drawing_button == GUI::MouseButton::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!layer.rect().contains(event.position()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_ellipse_end_position = event.position();
|
m_ellipse_end_position = event.position();
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,6 @@ void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
|
||||||
|
|
||||||
void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
{
|
{
|
||||||
if (!m_editor->rect().contains(event.position()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) {
|
if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) {
|
||||||
Gfx::Rect r = build_rect(event.position(), layer.rect());
|
Gfx::Rect r = build_rect(event.position(), layer.rect());
|
||||||
GUI::Painter painter(layer.bitmap());
|
GUI::Painter painter(layer.bitmap());
|
||||||
|
|
|
@ -84,9 +84,6 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
if (m_drawing_button == GUI::MouseButton::None)
|
if (m_drawing_button == GUI::MouseButton::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_editor->rect().contains(event.position()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!m_constrain_angle) {
|
if (!m_constrain_angle) {
|
||||||
m_line_end_position = event.position();
|
m_line_end_position = event.position();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,10 +60,8 @@ void PenTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
|
|
||||||
void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
{
|
{
|
||||||
if (!layer.rect().contains(event.position()))
|
if (!(event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) {
|
|
||||||
GUI::Painter painter(layer.bitmap());
|
GUI::Painter painter(layer.bitmap());
|
||||||
|
|
||||||
if (m_last_drawing_event_position != Gfx::Point(-1, -1))
|
if (m_last_drawing_event_position != Gfx::Point(-1, -1))
|
||||||
|
@ -73,7 +71,6 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
|
|
||||||
m_last_drawing_event_position = event.position();
|
m_last_drawing_event_position = event.position();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PenTool::on_contextmenu(GUI::ContextMenuEvent& event)
|
void PenTool::on_contextmenu(GUI::ContextMenuEvent& event)
|
||||||
|
|
|
@ -90,9 +90,6 @@ void RectangleTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent
|
||||||
if (m_drawing_button == GUI::MouseButton::None)
|
if (m_drawing_button == GUI::MouseButton::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_editor->rect().contains(event.position()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_rectangle_end_position = event.position();
|
m_rectangle_end_position = event.position();
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,6 @@ void SprayTool::paint_it()
|
||||||
|
|
||||||
void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
{
|
{
|
||||||
if (!m_editor->rect().contains(event.position()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_color = m_editor->color_for(event);
|
m_color = m_editor->color_for(event);
|
||||||
m_last_pos = event.position();
|
m_last_pos = event.position();
|
||||||
m_timer->start();
|
m_timer->start();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue