mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
PixelPaint: Add Zoom Reset button to new View Menubar.
If you lose your image while panning and zooming around, it is handy to have a reset function to get back home. :^)
This commit is contained in:
parent
223472c57f
commit
b48b8c372e
Notes:
sideshowbarker
2024-07-18 20:15:31 +09:00
Author: https://github.com/danielledeleo 🔰 Commit: https://github.com/SerenityOS/serenity/commit/b48b8c372ed Pull-request: https://github.com/SerenityOS/serenity/pull/6368 Issue: https://github.com/SerenityOS/serenity/issues/4138 Reviewed-by: https://github.com/linusg
3 changed files with 18 additions and 0 deletions
|
@ -393,6 +393,15 @@ void ImageEditor::scale_centered_on_position(const Gfx::IntPoint& position, floa
|
|||
relayout();
|
||||
}
|
||||
|
||||
void ImageEditor::reset_scale_and_position()
|
||||
{
|
||||
if (m_scale != 1.0f)
|
||||
m_scale = 1.0f;
|
||||
|
||||
m_pan_origin = Gfx::FloatPoint(0, 0);
|
||||
relayout();
|
||||
}
|
||||
|
||||
void ImageEditor::relayout()
|
||||
{
|
||||
if (!image())
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
Layer* layer_at_editor_position(const Gfx::IntPoint&);
|
||||
|
||||
void scale_centered_on_position(const Gfx::IntPoint&, float);
|
||||
void reset_scale_and_position();
|
||||
|
||||
Color primary_color() const { return m_primary_color; }
|
||||
void set_primary_color(Color);
|
||||
|
|
|
@ -217,6 +217,14 @@ int main(int argc, char** argv)
|
|||
image_editor.redo();
|
||||
});
|
||||
edit_menu.add_action(redo_action);
|
||||
|
||||
auto& view_menu = menubar->add_menu("&View");
|
||||
view_menu.add_action(GUI::Action::create(
|
||||
"&Reset Zoom", { Mod_Ctrl, Key_0 }, [&](auto&) {
|
||||
image_editor.reset_scale_and_position();
|
||||
return;
|
||||
},
|
||||
window));
|
||||
|
||||
auto& tool_menu = menubar->add_menu("&Tool");
|
||||
toolbox.for_each_tool([&](auto& tool) {
|
||||
|
|
Loading…
Add table
Reference in a new issue