1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

PixelPaint: Add menu action to toggle pixel grid visibility

You can now toggle on/off the visibility of the pixel grid from
the View menu, if you don't want it shown for some reason.
This commit is contained in:
Mustafa Quraish 2021-09-10 23:12:25 -04:00 committed by Andreas Kling
parent 4af0a99634
commit 79bcb90887
3 changed files with 24 additions and 1 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -100,7 +101,7 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
m_selection.paint(painter);
const float pixel_grid_threshold = 15.0f;
if (m_scale > pixel_grid_threshold) {
if (m_show_pixel_grid && m_scale > pixel_grid_threshold) {
auto grid_rect = m_editor_image_rect.intersected(event.rect());
auto image_rect = enclosing_int_rect(editor_rect_to_image_rect(grid_rect)).inflated(1, 1);
@ -354,6 +355,14 @@ void ImageEditor::set_guide_visibility(bool show_guides)
update();
}
void ImageEditor::set_pixel_grid_visibility(bool show_pixel_grid)
{
if (m_show_pixel_grid == show_pixel_grid)
return;
m_show_pixel_grid = show_pixel_grid;
update();
}
void ImageEditor::layers_did_change()
{
update();