From 4c617d370e5590347934de89c90455da82867813 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sat, 28 Jan 2023 01:02:41 +0000 Subject: 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. --- Userland/Applications/PixelPaint/Tools/MoveTool.cpp | 13 +++++++------ 1 file 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(); - 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(); + 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 MoveTool::update_cached_preview_bitmap(Layer const* layer) -- cgit v1.2.3