mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
LibGUI+WindowServer: Add resize_aspect_ratio()
When a resize_aspect_ratio is specified, and window will only be resized to a multiple of that ratio. When resize_aspect_ratio is set, windows cannot be tiled.
This commit is contained in:
parent
c68537271c
commit
45ed58865e
8 changed files with 51 additions and 1 deletions
|
@ -107,6 +107,7 @@ void Window::show()
|
|||
m_opacity_when_windowless,
|
||||
m_base_size,
|
||||
m_size_increment,
|
||||
m_resize_aspect_ratio,
|
||||
(i32)m_window_type,
|
||||
m_title_when_windowless,
|
||||
parent_window ? parent_window->window_id() : 0);
|
||||
|
@ -837,6 +838,16 @@ void Window::set_size_increment(const Gfx::IntSize& size_increment)
|
|||
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
|
||||
}
|
||||
|
||||
void Window::set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio)
|
||||
{
|
||||
if (m_resize_aspect_ratio == ratio)
|
||||
return;
|
||||
|
||||
m_resize_aspect_ratio = ratio;
|
||||
if (is_visible())
|
||||
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowResizeAspectRatio>(m_window_id, m_resize_aspect_ratio);
|
||||
}
|
||||
|
||||
void Window::did_add_widget(Badge<Widget>, Widget& widget)
|
||||
{
|
||||
if (!m_focused_widget && widget.accepts_focus())
|
||||
|
|
|
@ -179,6 +179,10 @@ public:
|
|||
void set_size_increment(const Gfx::IntSize&);
|
||||
Gfx::IntSize base_size() const { return m_base_size; }
|
||||
void set_base_size(const Gfx::IntSize&);
|
||||
const Optional<Gfx::IntSize>& resize_aspect_ratio() const { return m_resize_aspect_ratio; }
|
||||
void set_resize_aspect_ratio(int width, int height) { set_resize_aspect_ratio(Gfx::IntSize(width, height)); }
|
||||
void set_no_resize_aspect_ratio() { set_resize_aspect_ratio({}); }
|
||||
void set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio);
|
||||
|
||||
void set_override_cursor(StandardCursor);
|
||||
void set_override_cursor(const Gfx::Bitmap&);
|
||||
|
@ -260,6 +264,7 @@ private:
|
|||
bool m_double_buffering_enabled { true };
|
||||
bool m_modal { false };
|
||||
bool m_resizable { true };
|
||||
Optional<Gfx::IntSize> m_resize_aspect_ratio {};
|
||||
bool m_minimizable { true };
|
||||
bool m_fullscreen { false };
|
||||
bool m_frameless { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue