mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
LibGUI: Use GUI::Window::set_main_widget<WidgetType>() in clients
This commit is contained in:
parent
4697195645
commit
0f3e57a6fb
37 changed files with 203 additions and 246 deletions
|
@ -42,12 +42,11 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
|
|||
set_title(String::format("About %s", m_name.characters()));
|
||||
set_resizable(false);
|
||||
|
||||
auto widget = Widget::construct();
|
||||
set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout<HorizontalBoxLayout>();
|
||||
auto& widget = set_main_widget<Widget>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
widget.set_layout<HorizontalBoxLayout>();
|
||||
|
||||
auto left_container = widget->add<Widget>();
|
||||
auto left_container = widget.add<Widget>();
|
||||
left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
left_container->set_preferred_size(48, 0);
|
||||
left_container->set_layout<VerticalBoxLayout>();
|
||||
|
@ -57,7 +56,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
|
|||
icon_label->set_preferred_size(40, 40);
|
||||
left_container->layout()->add_spacer();
|
||||
|
||||
auto right_container = widget->add<Widget>();
|
||||
auto right_container = widget.add<Widget>();
|
||||
right_container->set_layout<VerticalBoxLayout>();
|
||||
right_container->layout()->set_margins({ 0, 4, 4, 4 });
|
||||
|
||||
|
|
|
@ -122,13 +122,12 @@ private:
|
|||
TooltipWindow()
|
||||
{
|
||||
set_window_type(WindowType::Tooltip);
|
||||
m_label = Label::construct();
|
||||
m_label = set_main_widget<Label>();
|
||||
m_label->set_background_color(Color::from_rgb(0xdac7b5));
|
||||
m_label->set_fill_with_background_color(true);
|
||||
m_label->set_frame_thickness(1);
|
||||
m_label->set_frame_shape(Gfx::FrameShape::Container);
|
||||
m_label->set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||
set_main_widget(m_label);
|
||||
}
|
||||
|
||||
RefPtr<Label> m_label;
|
||||
|
|
|
@ -48,16 +48,15 @@ ColorPicker::~ColorPicker()
|
|||
|
||||
void ColorPicker::build()
|
||||
{
|
||||
auto horizontal_container = Widget::construct();
|
||||
horizontal_container->set_fill_with_background_color(true);
|
||||
horizontal_container->set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
set_main_widget(horizontal_container);
|
||||
auto& horizontal_container = set_main_widget<Widget>();
|
||||
horizontal_container.set_fill_with_background_color(true);
|
||||
horizontal_container.set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto left_vertical_container = horizontal_container->add<Widget>();
|
||||
auto left_vertical_container = horizontal_container.add<Widget>();
|
||||
left_vertical_container->set_layout<VerticalBoxLayout>();
|
||||
|
||||
auto right_vertical_container = horizontal_container->add<Widget>();
|
||||
auto right_vertical_container = horizontal_container.add<Widget>();
|
||||
right_vertical_container->set_layout<VerticalBoxLayout>();
|
||||
|
||||
enum RGBComponent {
|
||||
|
|
|
@ -60,9 +60,8 @@ ComboBox::ComboBox()
|
|||
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
|
||||
m_list_window->set_window_type(WindowType::Tooltip);
|
||||
|
||||
m_list_view = ListView::construct();
|
||||
m_list_view = m_list_window->set_main_widget<ListView>();
|
||||
m_list_view->horizontal_scrollbar().set_visible(false);
|
||||
m_list_window->set_main_widget(m_list_view);
|
||||
|
||||
m_list_view->on_selection = [this](auto& index) {
|
||||
ASSERT(model());
|
||||
|
|
|
@ -81,13 +81,12 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
{
|
||||
set_title(m_mode == Mode::Open ? "Open File" : "Save File");
|
||||
set_rect(200, 200, 700, 400);
|
||||
auto horizontal_container = Widget::construct();
|
||||
set_main_widget(horizontal_container);
|
||||
horizontal_container->set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
horizontal_container->set_fill_with_background_color(true);
|
||||
auto& horizontal_container = set_main_widget<Widget>();
|
||||
horizontal_container.set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
horizontal_container.set_fill_with_background_color(true);
|
||||
|
||||
auto vertical_container = horizontal_container->add<Widget>();
|
||||
auto vertical_container = horizontal_container.add<Widget>();
|
||||
vertical_container->set_layout<VerticalBoxLayout>();
|
||||
vertical_container->layout()->set_spacing(4);
|
||||
|
||||
|
@ -236,7 +235,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
}
|
||||
};
|
||||
|
||||
auto preview_container = horizontal_container->add<Frame>();
|
||||
auto preview_container = horizontal_container.add<Frame>();
|
||||
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
preview_container->set_preferred_size(180, 0);
|
||||
preview_container->set_layout<VerticalBoxLayout>();
|
||||
|
|
|
@ -48,30 +48,29 @@ InputBox::~InputBox()
|
|||
|
||||
void InputBox::build()
|
||||
{
|
||||
auto widget = Widget::construct();
|
||||
set_main_widget(widget);
|
||||
auto& widget = set_main_widget<Widget>();
|
||||
|
||||
int text_width = widget->font().width(m_prompt);
|
||||
int title_width = widget->font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
|
||||
int text_width = widget.font().width(m_prompt);
|
||||
int title_width = widget.font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
|
||||
int max_width = AK::max(text_width, title_width);
|
||||
|
||||
set_rect(x(), y(), max_width + 80, 80);
|
||||
|
||||
widget->set_layout<VerticalBoxLayout>();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget.set_layout<VerticalBoxLayout>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
|
||||
widget->layout()->set_margins({ 8, 8, 8, 8 });
|
||||
widget->layout()->set_spacing(8);
|
||||
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
||||
widget.layout()->set_spacing(8);
|
||||
|
||||
auto label = widget->add<Label>(m_prompt);
|
||||
auto label = widget.add<Label>(m_prompt);
|
||||
label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
label->set_preferred_size(text_width, 16);
|
||||
|
||||
m_text_editor = widget->add<TextBox>();
|
||||
m_text_editor = widget.add<TextBox>();
|
||||
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_text_editor->set_preferred_size(0, 19);
|
||||
|
||||
auto button_container_outer = widget->add<Widget>();
|
||||
auto button_container_outer = widget.add<Widget>();
|
||||
button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button_container_outer->set_preferred_size(0, 20);
|
||||
button_container_outer->set_layout<VerticalBoxLayout>();
|
||||
|
|
|
@ -91,21 +91,20 @@ bool MessageBox::should_include_no_button() const
|
|||
|
||||
void MessageBox::build()
|
||||
{
|
||||
auto widget = Widget::construct();
|
||||
set_main_widget(widget);
|
||||
auto& widget = set_main_widget<Widget>();
|
||||
|
||||
int text_width = widget->font().width(m_text);
|
||||
int text_width = widget.font().width(m_text);
|
||||
int icon_width = 0;
|
||||
|
||||
widget->set_layout<VerticalBoxLayout>();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget.set_layout<VerticalBoxLayout>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
|
||||
widget->layout()->set_margins({ 0, 15, 0, 15 });
|
||||
widget->layout()->set_spacing(15);
|
||||
widget.layout()->set_margins({ 0, 15, 0, 15 });
|
||||
widget.layout()->set_spacing(15);
|
||||
|
||||
RefPtr<Widget> message_container = widget;
|
||||
if (m_type != Type::None) {
|
||||
message_container = widget->add<Widget>();
|
||||
message_container = widget.add<Widget>();
|
||||
message_container->set_layout<HorizontalBoxLayout>();
|
||||
message_container->layout()->set_margins({ 8, 0, 8, 0 });
|
||||
message_container->layout()->set_spacing(8);
|
||||
|
@ -121,7 +120,7 @@ void MessageBox::build()
|
|||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_preferred_size(text_width, 16);
|
||||
|
||||
auto button_container = widget->add<Widget>();
|
||||
auto button_container = widget.add<Widget>();
|
||||
button_container->set_layout<HorizontalBoxLayout>();
|
||||
button_container->layout()->set_spacing(5);
|
||||
button_container->layout()->set_margins({ 15, 0, 15, 0 });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue