mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
Magnifier: Allow locking location at current cursor position
This commit is contained in:
parent
6d4e37138e
commit
837625e422
3 changed files with 22 additions and 1 deletions
|
@ -24,6 +24,14 @@ void MagnifierWidget::set_scale_factor(int scale_factor)
|
|||
update();
|
||||
}
|
||||
|
||||
void MagnifierWidget::lock_location(bool lock)
|
||||
{
|
||||
if (lock)
|
||||
m_locked_location = GUI::ConnectionToWindowServer::the().get_global_cursor_position();
|
||||
else
|
||||
m_locked_location = {};
|
||||
}
|
||||
|
||||
void MagnifierWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_filter)
|
||||
{
|
||||
m_color_filter = move(color_filter);
|
||||
|
@ -53,7 +61,12 @@ void MagnifierWidget::sync()
|
|||
|
||||
auto size = frame_inner_rect().size();
|
||||
Gfx::IntSize grab_size { size.width() / m_scale_factor, size.height() / m_scale_factor };
|
||||
m_grabbed_bitmap = GUI::ConnectionToWindowServer::the().get_screen_bitmap_around_cursor(grab_size).bitmap();
|
||||
|
||||
if (m_locked_location.has_value()) {
|
||||
m_grabbed_bitmap = GUI::ConnectionToWindowServer::the().get_screen_bitmap_around_location(grab_size, m_locked_location.value()).bitmap();
|
||||
} else {
|
||||
m_grabbed_bitmap = GUI::ConnectionToWindowServer::the().get_screen_bitmap_around_cursor(grab_size).bitmap();
|
||||
}
|
||||
m_grabbed_bitmaps.enqueue(m_grabbed_bitmap);
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
if (!pause)
|
||||
m_frame_offset_from_head = 0;
|
||||
}
|
||||
void lock_location(bool);
|
||||
void display_previous_frame();
|
||||
void display_next_frame();
|
||||
RefPtr<Gfx::Bitmap> current_bitmap() const { return m_grabbed_bitmap; };
|
||||
|
@ -45,4 +46,5 @@ private:
|
|||
CircularQueue<RefPtr<Gfx::Bitmap>, 512> m_grabbed_bitmaps {};
|
||||
ssize_t m_frame_offset_from_head { 0 };
|
||||
bool m_pause_capture { false };
|
||||
Optional<Gfx::IntPoint> m_locked_location {};
|
||||
};
|
||||
|
|
|
@ -111,6 +111,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
magnifier->pause_capture(action.is_checked());
|
||||
});
|
||||
|
||||
auto lock_location_action = GUI::Action::create_checkable(
|
||||
"&Lock Location", { Key_L }, [&](auto& action) {
|
||||
magnifier->lock_location(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);
|
||||
|
@ -124,6 +129,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(view_menu->try_add_separator());
|
||||
TRY(view_menu->try_add_action(pause_action));
|
||||
TRY(view_menu->try_add_action(lock_location_action));
|
||||
|
||||
auto timeline_menu = TRY(window->try_add_menu("&Timeline"));
|
||||
auto previous_frame_action = GUI::Action::create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue