summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Applications/PixelPaint/Tools')
-rw-r--r--Userland/Applications/PixelPaint/Tools/CloneTool.cpp2
-rw-r--r--Userland/Applications/PixelPaint/Tools/EllipseTool.cpp4
-rw-r--r--Userland/Applications/PixelPaint/Tools/GuideTool.cpp2
-rw-r--r--Userland/Applications/PixelPaint/Tools/MoveTool.cpp19
-rw-r--r--Userland/Applications/PixelPaint/Tools/MoveTool.h3
-rw-r--r--Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp2
-rw-r--r--Userland/Applications/PixelPaint/Tools/Tool.cpp2
-rw-r--r--Userland/Applications/PixelPaint/Tools/ZoomTool.cpp3
8 files changed, 14 insertions, 23 deletions
diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp
index d06084eee6..0ed7f141dd 100644
--- a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp
@@ -102,7 +102,7 @@ void CloneTool::on_second_paint(Layer const*, GUI::PaintEvent& event)
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
- auto sample_pos = m_editor->image_position_to_editor_position(m_sample_location.value());
+ auto sample_pos = m_editor->content_to_frame_position(m_sample_location.value());
// We don't want the marker to be a single pixel and hide the color.
auto offset = AK::max(2, size() / 2);
Gfx::IntRect rect = {
diff --git a/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp b/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp
index 18b7a6b0a3..2eca8ec643 100644
--- a/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp
@@ -107,8 +107,8 @@ void EllipseTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
- auto preview_start = m_editor->layer_position_to_editor_position(*layer, m_ellipse_start_position).to_type<int>();
- auto preview_end = m_editor->layer_position_to_editor_position(*layer, m_ellipse_end_position).to_type<int>();
+ auto preview_start = m_editor->content_to_frame_position(m_ellipse_start_position).to_type<int>();
+ auto preview_end = m_editor->content_to_frame_position(m_ellipse_end_position).to_type<int>();
draw_using(painter, preview_start, preview_end, AK::max(m_thickness * m_editor->scale(), 1));
}
diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp
index edb09bfef5..9a7e422955 100644
--- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp
@@ -171,7 +171,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event)
editor()));
}
- auto image_position = editor()->editor_position_to_image_position(event.position());
+ auto image_position = editor()->frame_to_content_position(event.position());
m_context_menu_guide = closest_guide({ (int)image_position.x(), (int)image_position.y() });
if (m_context_menu_guide)
m_context_menu->popup(event.screen_position());
diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp
index 6106b2b774..9690715c6a 100644
--- a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp
@@ -24,11 +24,8 @@ MoveTool::~MoveTool()
void MoveTool::on_mousedown(Layer* layer, MouseEvent& event)
{
- if (event.image_event().button() == GUI::MouseButton::Secondary && !m_is_panning) {
- m_is_panning = true;
- m_event_origin = event.raw_event().position();
- m_saved_pan_origin = m_editor->pan_origin();
- m_editor->set_override_cursor(Gfx::StandardCursor::Drag);
+ if (event.image_event().button() == GUI::MouseButton::Secondary) {
+ m_editor->start_panning(event.raw_event().position());
return;
}
@@ -48,12 +45,8 @@ void MoveTool::on_mousedown(Layer* layer, MouseEvent& event)
void MoveTool::on_mousemove(Layer* layer, MouseEvent& event)
{
- if (m_is_panning) {
- auto& raw_event = event.raw_event();
- auto delta = raw_event.position() - m_event_origin;
- m_editor->set_pan_origin(m_saved_pan_origin.translated(
- -delta.x(),
- -delta.y()));
+ if (m_editor->is_panning()) {
+ m_editor->pan_to(event.raw_event().position());
return;
}
@@ -70,8 +63,8 @@ void MoveTool::on_mousemove(Layer* layer, MouseEvent& event)
void MoveTool::on_mouseup(Layer* layer, MouseEvent& event)
{
- if (event.image_event().button() == GUI::MouseButton::Secondary && m_is_panning) {
- m_is_panning = false;
+ if (event.image_event().button() == GUI::MouseButton::Secondary) {
+ m_editor->stop_panning();
m_editor->set_override_cursor(cursor());
return;
}
diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.h b/Userland/Applications/PixelPaint/Tools/MoveTool.h
index 4fa391b7c5..d62d554258 100644
--- a/Userland/Applications/PixelPaint/Tools/MoveTool.h
+++ b/Userland/Applications/PixelPaint/Tools/MoveTool.h
@@ -25,9 +25,6 @@ private:
RefPtr<Layer> m_layer_being_moved;
Gfx::IntPoint m_event_origin;
Gfx::IntPoint m_layer_origin;
-
- bool m_is_panning { false };
- Gfx::FloatPoint m_saved_pan_origin;
};
}
diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp
index 7f7d536506..fa52524495 100644
--- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp
@@ -134,7 +134,7 @@ void RectangleSelectTool::on_second_paint(Layer const*, GUI::PaintEvent& event)
painter.add_clip_rect(event.rect());
auto rect_in_image = Gfx::IntRect::from_two_points(m_selection_start, m_selection_end);
- auto rect_in_editor = m_editor->image_rect_to_editor_rect(rect_in_image);
+ auto rect_in_editor = m_editor->content_to_frame_rect(rect_in_image);
m_editor->selection().draw_marching_ants(painter, rect_in_editor.to_type<int>());
}
diff --git a/Userland/Applications/PixelPaint/Tools/Tool.cpp b/Userland/Applications/PixelPaint/Tools/Tool.cpp
index 566b00218b..e1dde2fa05 100644
--- a/Userland/Applications/PixelPaint/Tools/Tool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/Tool.cpp
@@ -55,7 +55,7 @@ void Tool::on_keydown(GUI::KeyEvent& event)
Gfx::IntPoint Tool::editor_stroke_position(Gfx::IntPoint const& pixel_coords, int stroke_thickness) const
{
- auto position = m_editor->image_position_to_editor_position(pixel_coords);
+ auto position = m_editor->content_to_frame_position(pixel_coords);
auto offset = (stroke_thickness % 2 == 0) ? 0 : m_editor->scale() / 2;
position = position.translated(offset, offset);
return position.to_type<int>();
diff --git a/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp b/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp
index d7792db0e4..b1ca6dc28f 100644
--- a/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp
@@ -27,7 +27,8 @@ void ZoomTool::on_mousedown(Layer*, MouseEvent& event)
return;
auto scale_factor = (raw_event.button() == GUI::MouseButton::Primary) ? m_sensitivity : -m_sensitivity;
- m_editor->scale_centered_on_position(raw_event.position(), scale_factor);
+ auto new_scale = AK::exp2(scale_factor);
+ m_editor->scale_centered(new_scale, raw_event.position());
}
GUI::Widget* ZoomTool::get_properties_widget()