mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-24 08:30:21 +00:00
Presenter: Add a "Resize to Fit Content" action
When resizing, it can be hard to get the content to appear nicely without a black border where the window's aspect ratio doesn't match the content's aspect ratio. With this new action, it is possible to automatically adjust the window's size to match the content's aspect ratio. When it is resizing, it will maintain the width of the window, but adjust the height to match the aspect ratio of the content.
This commit is contained in:
parent
72a45799e0
commit
92800cff4a
Notes:
sideshowbarker
2024-07-17 06:51:48 +09:00
Author: https://github.com/caoimhebyrne Commit: https://github.com/SerenityOS/serenity/commit/92800cff4a Pull-request: https://github.com/SerenityOS/serenity/pull/17929
2 changed files with 10 additions and 0 deletions
|
@ -100,8 +100,17 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
auto* window = this->window();
|
||||
window->set_fullscreen(!window->is_fullscreen());
|
||||
});
|
||||
m_resize_to_fit_content_action = GUI::Action::create("Resize to Fit &Content", { KeyModifier::Mod_Alt, KeyCode::Key_C }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/scale.png"sv)), [this](auto&) {
|
||||
if (m_current_presentation) {
|
||||
auto presentation_size = m_current_presentation->normative_size();
|
||||
auto* window = this->window();
|
||||
|
||||
window->resize(window->size().match_aspect_ratio(presentation_size.aspect_ratio(), Orientation::Horizontal));
|
||||
}
|
||||
});
|
||||
|
||||
TRY(view_menu->try_add_action(*m_full_screen_action));
|
||||
TRY(view_menu->try_add_action(*m_resize_to_fit_content_action));
|
||||
|
||||
update_slides_actions();
|
||||
|
||||
|
|
|
@ -49,4 +49,5 @@ private:
|
|||
RefPtr<GUI::Action> m_present_from_first_slide_action;
|
||||
|
||||
RefPtr<GUI::Action> m_full_screen_action;
|
||||
RefPtr<GUI::Action> m_resize_to_fit_content_action;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue