summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Ledbetter <timledbetter@gmail.com>2023-01-28 01:02:41 +0000
committerAndreas Kling <kling@serenityos.org>2023-02-02 14:40:17 +0100
commit4c617d370e5590347934de89c90455da82867813 (patch)
treea038a451841eb6d8ce11ad4fbf72cd2a31df3e6e
parent7b3bc883f1d46e4e912ea435a150cc50920db60e (diff)
downloadserenity-4c617d370e5590347934de89c90455da82867813.zip
PixelPaint: Highlight active layer when using the move tool
This commit adds a two color border around the currently selected layer when using the move tool.
-rw-r--r--Userland/Applications/PixelPaint/Tools/MoveTool.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp
index 98c4d19c30..3cbf1b3d89 100644
--- a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp
@@ -188,17 +188,18 @@ void MoveTool::on_keyup(GUI::KeyEvent& event)
void MoveTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
{
- if (layer != m_layer_being_moved.ptr() || !m_scaling)
- return;
-
+ VERIFY(m_editor);
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
- auto rect_in_editor = m_editor->content_to_frame_rect(m_new_layer_rect).to_rounded<int>();
- painter.draw_rect(rect_in_editor, Color::Black);
- if (!m_cached_preview_bitmap.is_null() || !update_cached_preview_bitmap(layer).is_error()) {
+ auto content_rect = m_scaling ? m_new_layer_rect : m_editor->active_layer()->relative_rect();
+ auto rect_in_editor = m_editor->content_to_frame_rect(content_rect).to_rounded<int>();
+ if (m_scaling && (!m_cached_preview_bitmap.is_null() || !update_cached_preview_bitmap(layer).is_error())) {
+ Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(m_editor->content_rect());
painter.draw_scaled_bitmap(rect_in_editor, *m_cached_preview_bitmap, m_cached_preview_bitmap->rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend);
}
+ painter.draw_rect_with_thickness(rect_in_editor, Color::Black, 3);
+ painter.draw_rect_with_thickness(rect_in_editor, Color::White, 1);
}
ErrorOr<void> MoveTool::update_cached_preview_bitmap(Layer const* layer)