mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
Magnifier: Make window resizable
Instead of having the window non-resizable, it now defaults to a frame size of 200 x 200 pixels but is user-resizable. The shown screenshot updates its size accordingly. :^) Sometimes we might need a larger view, or a non-square shape.
This commit is contained in:
parent
1c1b106f6c
commit
8afcd22900
2 changed files with 7 additions and 10 deletions
|
@ -8,8 +8,7 @@
|
|||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGUI/WindowServerConnection.h>
|
||||
#include <LibGfx/AffineTransform.h>
|
||||
#include <math.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
MagnifierWidget::MagnifierWidget()
|
||||
{
|
||||
|
@ -46,12 +45,9 @@ void MagnifierWidget::paint_event(GUI::PaintEvent&)
|
|||
{
|
||||
GUI::Painter painter(*this);
|
||||
|
||||
int grab_frame_size = 200;
|
||||
|
||||
grab_frame_size /= m_scale_factor;
|
||||
|
||||
// Paint our screenshot
|
||||
Gfx::Rect region { m_mouse_position.x() - (grab_frame_size / 2), m_mouse_position.y() - (grab_frame_size / 2), grab_frame_size, grab_frame_size };
|
||||
// Grab and paint our screenshot.
|
||||
Gfx::IntSize region_size { size().width() / m_scale_factor, size().height() / m_scale_factor };
|
||||
Gfx::Rect region { m_mouse_position.x() - (region_size.width() / 2), m_mouse_position.y() - (region_size.height() / 2), region_size.width(), region_size.height() };
|
||||
auto map = GUI::WindowServerConnection::the().get_screen_bitmap(region);
|
||||
painter.draw_scaled_bitmap(rect(), *map.bitmap(), map.bitmap()->rect());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue