1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:47:36 +00:00

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.
This commit is contained in:
Tim Ledbetter 2023-01-28 01:02:41 +00:00 committed by Andreas Kling
parent 7b3bc883f1
commit 4c617d370e

View file

@ -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)