diff options
author | Marcus Nilsson <brainbomb@gmail.com> | 2021-09-17 22:29:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-17 23:48:42 +0200 |
commit | 401ea85655cada0dfb7e39c7dc4a2e68a356ff2e (patch) | |
tree | c0be563509e5991a18a2faa8159b9a94bca7a9ab | |
parent | 6bdd62b51b65675151d44f60219b45f927bb5f9b (diff) | |
download | serenity-401ea85655cada0dfb7e39c7dc4a2e68a356ff2e.zip |
Magnifier: Add 8x magnification and pausing
This adds an option for even more magnification, when you really need to
count pixels, as well as pausing the capture by pressing Space and
switching between magnification levels with keys 2, 4 & 8.
-rw-r--r-- | Userland/Applications/Magnifier/MagnifierWidget.cpp | 5 | ||||
-rw-r--r-- | Userland/Applications/Magnifier/MagnifierWidget.h | 2 | ||||
-rw-r--r-- | Userland/Applications/Magnifier/main.cpp | 19 |
3 files changed, 23 insertions, 3 deletions
diff --git a/Userland/Applications/Magnifier/MagnifierWidget.cpp b/Userland/Applications/Magnifier/MagnifierWidget.cpp index 814c91b311..a7f6cc925b 100644 --- a/Userland/Applications/Magnifier/MagnifierWidget.cpp +++ b/Userland/Applications/Magnifier/MagnifierWidget.cpp @@ -22,13 +22,16 @@ MagnifierWidget::~MagnifierWidget() void MagnifierWidget::set_scale_factor(int scale_factor) { - VERIFY(scale_factor == 2 || scale_factor == 4); + VERIFY(scale_factor == 2 || scale_factor == 4 || scale_factor == 8); m_scale_factor = scale_factor; update(); } void MagnifierWidget::sync() { + if (m_pause_capture) + return; + auto size = frame_inner_rect().size(); Gfx::IntSize grab_size { size.width() / m_scale_factor, size.height() / m_scale_factor }; m_grabbed_bitmap = GUI::WindowServerConnection::the().get_screen_bitmap_around_cursor(grab_size).bitmap(); diff --git a/Userland/Applications/Magnifier/MagnifierWidget.h b/Userland/Applications/Magnifier/MagnifierWidget.h index 1e8ea8b543..447449584c 100644 --- a/Userland/Applications/Magnifier/MagnifierWidget.h +++ b/Userland/Applications/Magnifier/MagnifierWidget.h @@ -14,6 +14,7 @@ class MagnifierWidget final : public GUI::Frame { public: virtual ~MagnifierWidget(); void set_scale_factor(int scale_factor); + void pause_capture(bool pause) { m_pause_capture = pause; } private: MagnifierWidget(); @@ -24,4 +25,5 @@ private: int m_scale_factor { 2 }; RefPtr<Gfx::Bitmap> m_grabbed_bitmap; + bool m_pause_capture { false }; }; diff --git a/Userland/Applications/Magnifier/main.cpp b/Userland/Applications/Magnifier/main.cpp index 783cc93cd7..1d7fc7d31c 100644 --- a/Userland/Applications/Magnifier/main.cpp +++ b/Userland/Applications/Magnifier/main.cpp @@ -56,24 +56,39 @@ int main(int argc, char** argv) auto size_action_group = make<GUI::ActionGroup>(); auto two_x_action = GUI::Action::create_checkable( - "&2x", [&](auto&) { + "&2x", { Key_2 }, [&](auto&) { magnifier.set_scale_factor(2); }); auto four_x_action = GUI::Action::create_checkable( - "&4x", [&](auto&) { + "&4x", { Key_4 }, [&](auto&) { magnifier.set_scale_factor(4); }); + auto eight_x_action = GUI::Action::create_checkable( + "&8x", { Key_8 }, [&](auto&) { + magnifier.set_scale_factor(8); + }); + + auto pause_action = GUI::Action::create_checkable( + "&Pause Capture", { Key_Space }, [&](auto& action) { + magnifier.pause_capture(action.is_checked()); + }); + size_action_group->add_action(two_x_action); size_action_group->add_action(four_x_action); + size_action_group->add_action(eight_x_action); size_action_group->set_exclusive(true); auto& view_menu = window->add_menu("&View"); view_menu.add_action(two_x_action); view_menu.add_action(four_x_action); + view_menu.add_action(eight_x_action); two_x_action->set_checked(true); + view_menu.add_separator(); + view_menu.add_action(pause_action); + auto& help_menu = window->add_menu("&Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Magnifier", app_icon, window)); |