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

PixelPaint: Make Guides' visibility optional

Whether Guides are drawn or not is now controlled via the menu-entry
View->Show Guides.
This commit is contained in:
Tobias Christiansen 2021-08-05 15:48:59 +02:00 committed by Ali Mohammad Pur
parent 193f1e01cf
commit 0ca085910e
3 changed files with 21 additions and 7 deletions

View file

@ -83,13 +83,15 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
painter.draw_rect(enclosing_int_rect(image_rect_to_editor_rect(m_active_layer->relative_rect())).inflated(2, 2), Color::Black);
}
for (auto& guide : m_guides) {
if (guide.orientation() == Guide::Orientation::Horizontal) {
int y_coordinate = (int)image_position_to_editor_position({ 0.0f, guide.offset() }).y();
painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
} else if (guide.orientation() == Guide::Orientation::Vertical) {
int x_coordinate = (int)image_position_to_editor_position({ guide.offset(), 0.0f }).x();
painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
if (m_show_guides) {
for (auto& guide : m_guides) {
if (guide.orientation() == Guide::Orientation::Horizontal) {
int y_coordinate = (int)image_position_to_editor_position({ 0.0f, guide.offset() }).y();
painter.draw_line({ 0, y_coordinate }, { rect().width(), y_coordinate }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
} else if (guide.orientation() == Guide::Orientation::Vertical) {
int x_coordinate = (int)image_position_to_editor_position({ guide.offset(), 0.0f }).x();
painter.draw_line({ x_coordinate, 0 }, { x_coordinate, rect().height() }, Color::Cyan, 1, Gfx::Painter::LineStyle::Dashed, Color::LightGray);
}
}
}