mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
PixelPaint: Add rulers
This commit is contained in:
parent
9bc8707cda
commit
e56764bd74
4 changed files with 103 additions and 0 deletions
|
@ -80,6 +80,7 @@ MainWidget::MainWidget()
|
|||
}
|
||||
});
|
||||
m_show_guides_action->set_checked(image_editor.guide_visibility());
|
||||
m_show_rulers_action->set_checked(image_editor.ruler_visibility());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -367,6 +368,15 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
|||
show_pixel_grid_action->set_checked(true);
|
||||
view_menu.add_action(*show_pixel_grid_action);
|
||||
|
||||
m_show_rulers_action = GUI::Action::create_checkable(
|
||||
"Show Rulers", { Mod_Ctrl, Key_R }, [&](auto& action) {
|
||||
if (auto* editor = current_image_editor()) {
|
||||
editor->set_ruler_visibility(action.is_checked());
|
||||
}
|
||||
});
|
||||
m_show_rulers_action->set_checked(true);
|
||||
view_menu.add_action(*m_show_rulers_action);
|
||||
|
||||
auto& tool_menu = window.add_menu("&Tool");
|
||||
m_toolbox->for_each_tool([&](auto& tool) {
|
||||
if (tool.action())
|
||||
|
@ -776,6 +786,10 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
|
|||
m_show_guides_action->set_checked(show_guides);
|
||||
};
|
||||
|
||||
image_editor.on_set_ruler_visibility = [&](bool show_rulers) {
|
||||
m_show_rulers_action->set_checked(show_rulers);
|
||||
};
|
||||
|
||||
// NOTE: We invoke the above hook directly here to make sure the tab title is set up.
|
||||
image_editor.on_image_title_change(image->title());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue