mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibGUI: Add ability to calculate min_size of Window from content widget
This commit is contained in:
parent
13445f5a43
commit
5d25956790
Notes:
sideshowbarker
2024-07-17 09:52:45 +09:00
Author: https://github.com/frhun Commit: https://github.com/SerenityOS/serenity/commit/5d25956790 Pull-request: https://github.com/SerenityOS/serenity/pull/14419 Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 21 additions and 1 deletions
|
@ -90,6 +90,7 @@ Window::Window(Core::Object* parent)
|
|||
REGISTER_RECT_PROPERTY("rect", rect, set_rect);
|
||||
REGISTER_SIZE_PROPERTY("base_size", base_size, set_base_size);
|
||||
REGISTER_SIZE_PROPERTY("size_increment", size_increment, set_size_increment);
|
||||
REGISTER_BOOL_PROPERTY("obey_widget_min_size", is_obeying_widget_min_size, set_obey_widget_min_size);
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
|
@ -1018,6 +1019,14 @@ void Window::set_forced_shadow(bool shadow)
|
|||
ConnectionToWindowServer::the().async_set_forced_shadow(m_window_id, shadow);
|
||||
}
|
||||
|
||||
void Window::set_obey_widget_min_size(bool obey_widget_min_size)
|
||||
{
|
||||
if (m_obey_widget_min_size != obey_widget_min_size) {
|
||||
m_obey_widget_min_size = obey_widget_min_size;
|
||||
schedule_relayout();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::set_maximized(bool maximized)
|
||||
{
|
||||
m_maximized = maximized;
|
||||
|
@ -1033,8 +1042,15 @@ void Window::schedule_relayout()
|
|||
return;
|
||||
m_layout_pending = true;
|
||||
deferred_invoke([this] {
|
||||
if (main_widget())
|
||||
if (main_widget()) {
|
||||
main_widget()->do_layout();
|
||||
if (m_obey_widget_min_size) {
|
||||
auto min_size = main_widget()->effective_min_size();
|
||||
set_minimum_size(
|
||||
(min_size.width() == GUI::SpecialDimension::Shrink ? 0 : min_size.width().as_int()),
|
||||
(min_size.height() == GUI::SpecialDimension::Shrink ? 0 : min_size.height().as_int()));
|
||||
}
|
||||
}
|
||||
update();
|
||||
m_layout_pending = false;
|
||||
});
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
bool is_resizable() const { return m_resizable; }
|
||||
void set_resizable(bool resizable) { m_resizable = resizable; }
|
||||
|
||||
bool is_obeying_widget_min_size() { return m_obey_widget_min_size; }
|
||||
void set_obey_widget_min_size(bool);
|
||||
|
||||
bool is_minimizable() const { return m_minimizable; }
|
||||
void set_minimizable(bool minimizable) { m_minimizable = minimizable; }
|
||||
|
||||
|
@ -287,6 +290,7 @@ private:
|
|||
bool m_double_buffering_enabled { true };
|
||||
bool m_modal { false };
|
||||
bool m_resizable { true };
|
||||
bool m_obey_widget_min_size { true };
|
||||
Optional<Gfx::IntSize> m_resize_aspect_ratio {};
|
||||
bool m_minimizable { true };
|
||||
bool m_closeable { true };
|
||||
|
|
Loading…
Reference in a new issue