1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:07:34 +00:00

WindowServer+LibGUI: Implement minimizable property to windows

This commit is contained in:
Jami Kettunen 2020-01-04 13:12:02 +02:00 committed by Andreas Kling
parent a641f4d213
commit eab34a7de3
8 changed files with 46 additions and 8 deletions

View file

@ -28,11 +28,12 @@ WSWindow::WSWindow(CObject& parent, WSWindowType type)
WSWindowManager::the().add_window(*this);
}
WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int window_id, bool modal, bool resizable, bool fullscreen)
WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int window_id, bool modal, bool minimizable, bool resizable, bool fullscreen)
: CObject(&client)
, m_client(&client)
, m_type(window_type)
, m_modal(modal)
, m_minimizable(minimizable)
, m_resizable(resizable)
, m_fullscreen(fullscreen)
, m_window_id(window_id)
@ -102,6 +103,8 @@ void WSWindow::set_minimized(bool minimized)
{
if (m_minimized == minimized)
return;
if (minimized && !m_minimizable)
return;
m_minimized = minimized;
start_minimize_animation();
if (!minimized)
@ -110,6 +113,14 @@ void WSWindow::set_minimized(bool minimized)
WSWindowManager::the().notify_minimization_state_changed(*this);
}
void WSWindow::set_minimizable(bool minimizable)
{
if (m_minimizable == minimizable)
return;
m_minimizable = minimizable;
// TODO: Hide/show (or alternatively change enabled state of) window minimize button dynamically depending on value of m_minimizable
}
void WSWindow::set_opacity(float opacity)
{
if (m_opacity == opacity)
@ -130,6 +141,8 @@ void WSWindow::set_maximized(bool maximized)
{
if (m_maximized == maximized)
return;
if (maximized && !is_resizable())
return;
m_maximized = maximized;
auto old_rect = m_rect;
if (maximized) {
@ -142,6 +155,14 @@ void WSWindow::set_maximized(bool maximized)
CEventLoop::current().post_event(*this, make<WSResizeEvent>(old_rect, m_rect));
}
void WSWindow::set_resizable(bool resizable)
{
if (m_resizable == resizable)
return;
m_resizable = resizable;
// TODO: Hide/show (or alternatively change enabled state of) window maximize button dynamically depending on value of is_resizable()
}
void WSWindow::event(CEvent& event)
{
if (!m_client) {