From 603034759f9eb52d6ce99af7464fd1e41bc33b9a Mon Sep 17 00:00:00 2001 From: FrHun <28605587+frhun@users.noreply.github.com> Date: Sun, 12 Jun 2022 23:17:42 +0200 Subject: [PATCH] LibGUI: Remove usages of deprecated implicit conversions --- Userland/Libraries/LibGUI/AbstractTableView.cpp | 4 ++-- Userland/Libraries/LibGUI/Application.cpp | 2 +- Userland/Libraries/LibGUI/MessageBox.cpp | 3 ++- Userland/Libraries/LibGUI/Statusbar.cpp | 9 +++++---- Userland/Libraries/LibGUI/Window.cpp | 7 +++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp index 6cfb189b8c..ba9ff35060 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.cpp +++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp @@ -411,7 +411,7 @@ void AbstractTableView::layout_headers() int y = frame_thickness(); int width = max(content_width(), rect().width() - frame_thickness() * 2 - row_header_width - vertical_scrollbar_width); - column_header().set_relative_rect(x, y, width, column_header().min_size().height()); + column_header().set_relative_rect(x, y, width, column_header().effective_min_size().height().as_int()); } if (row_header().is_visible()) { @@ -422,7 +422,7 @@ void AbstractTableView::layout_headers() int y = frame_thickness() + column_header_height - vertical_scrollbar().value(); int height = max(content_height(), rect().height() - frame_thickness() * 2 - column_header_height - horizontal_scrollbar_height); - row_header().set_relative_rect(x, y, row_header().min_size().width(), height); + row_header().set_relative_rect(x, y, row_header().effective_min_size().width().as_int(), height); } if (row_header().is_visible() && column_header().is_visible()) { diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index ded131f1cc..b9574e7f09 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -27,7 +27,7 @@ public: void set_tooltip(String const& tooltip) { m_label->set_text(Gfx::parse_ampersand_string(tooltip)); - int tooltip_width = m_label->min_width() + 10; + int tooltip_width = m_label->effective_min_size().width().as_int() + 10; int line_count = m_label->text().count("\n"); int glyph_height = m_label->font().glyph_height(); int tooltip_height = glyph_height * (1 + line_count) + ((glyph_height + 1) / 2) * line_count + 8; diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index a438e90928..660e6c49bf 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -176,7 +176,8 @@ void MessageBox::build() int width = (button_count * button_width) + ((button_count - 1) * button_container.layout()->spacing()) + 32; width = max(width, text_width + icon_width + 56); - set_rect(x(), y(), width, 80 + label.max_height()); + // FIXME: Use shrink from new layout system + set_rect(x(), y(), width, 80 + label.preferred_height()); set_resizable(false); } diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index f19d9f5c03..75c7fcc841 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -62,9 +62,10 @@ void Statusbar::update_segment(size_t index) segment.set_fixed_width(width); } } else if (segment.mode() == Segment::Mode::Fixed) { - if (segment.max_width() != -1) - segment.set_restored_width(segment.max_width()); - segment.set_fixed_width(segment.max_width()); + if (segment.max_width().is_int()) { + segment.set_restored_width(segment.max_width().as_int()); + segment.set_fixed_width(segment.max_width()); + } } if (segment.override_text().is_null()) { @@ -84,7 +85,7 @@ void Statusbar::update_segment(size_t index) segment.set_text(segment.override_text()); segment.set_frame_shape(Gfx::FrameShape::NoFrame); if (segment.mode() != Segment::Mode::Proportional) - segment.set_fixed_width(-1); + segment.set_fixed_width(SpecialDimension::Grow); } } diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index 386e989d97..3031972ecb 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -723,10 +723,9 @@ void Window::set_main_widget(Widget* widget) if (m_main_widget) { add_child(*widget); auto new_window_rect = rect(); - if (m_main_widget->min_width() >= 0) - new_window_rect.set_width(max(new_window_rect.width(), m_main_widget->min_width())); - if (m_main_widget->min_height() >= 0) - new_window_rect.set_height(max(new_window_rect.height(), m_main_widget->min_height())); + auto new_widget_min_size = m_main_widget->effective_min_size(); + new_window_rect.set_width(max(new_window_rect.width(), MUST(new_widget_min_size.width().shrink_value()))); + new_window_rect.set_height(max(new_window_rect.height(), MUST(new_widget_min_size.height().shrink_value()))); set_rect(new_window_rect); m_main_widget->set_relative_rect({ {}, new_window_rect.size() }); m_main_widget->set_window(this);