mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 12:27:35 +00:00
LibGUI: Convert GWidget to ObjectPtr
This commit is contained in:
parent
e4e92980a1
commit
ff6ce422dd
41 changed files with 115 additions and 107 deletions
|
@ -17,7 +17,7 @@ int main(int argc, char** argv)
|
|||
window->set_resizable(false);
|
||||
window->set_rect(window_rect);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
auto widget = GWidget::construct();
|
||||
window->set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
|
|
@ -17,7 +17,7 @@ int main(int argc, char** argv)
|
|||
window->set_rect(100, 100, 800, 500);
|
||||
window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png"));
|
||||
|
||||
auto* widget = new GWidget;
|
||||
auto widget = GWidget::construct();
|
||||
window->set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
|
|
@ -75,7 +75,7 @@ void DisplayPropertiesWidget::create_resolution_list()
|
|||
|
||||
void DisplayPropertiesWidget::create_root_widget()
|
||||
{
|
||||
m_root_widget = new GWidget;
|
||||
m_root_widget = GWidget::construct();
|
||||
m_root_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
m_root_widget->set_fill_with_background_color(true);
|
||||
m_root_widget->layout()->set_margins({ 4, 4, 4, 16 });
|
||||
|
@ -97,7 +97,7 @@ void DisplayPropertiesWidget::create_frame()
|
|||
auto background_splitter = GSplitter::construct(Orientation::Vertical, nullptr);
|
||||
tab_widget->add_widget("Wallpaper", background_splitter);
|
||||
|
||||
auto* background_content = new GWidget(background_splitter);
|
||||
auto background_content = GWidget::construct(background_splitter);
|
||||
background_content->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
background_content->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
|
@ -120,7 +120,7 @@ void DisplayPropertiesWidget::create_frame()
|
|||
auto settings_splitter = GSplitter::construct(Orientation::Vertical, nullptr);
|
||||
tab_widget->add_widget("Settings", settings_splitter);
|
||||
|
||||
auto* settings_content = new GWidget(settings_splitter);
|
||||
auto settings_content = GWidget::construct(settings_splitter);
|
||||
settings_content->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
settings_content->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
|
@ -135,7 +135,7 @@ void DisplayPropertiesWidget::create_frame()
|
|||
settings_content->layout()->add_spacer();
|
||||
|
||||
// Add the apply and cancel buttons
|
||||
auto* bottom_widget = new GWidget(m_root_widget);
|
||||
auto bottom_widget = GWidget::construct(m_root_widget);
|
||||
bottom_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
bottom_widget->layout()->add_spacer();
|
||||
bottom_widget->set_size_policy(Orientation::Vertical, SizePolicy::Fixed);
|
||||
|
|
|
@ -29,7 +29,8 @@ public:
|
|||
void send_settings_to_window_server(int tabIndex);
|
||||
void create_frame();
|
||||
|
||||
inline GWidget* get_root_widget() const { return m_root_widget; }
|
||||
const GWidget* root_widget() const { return m_root_widget; }
|
||||
GWidget* root_widget() { return m_root_widget; }
|
||||
|
||||
private:
|
||||
void create_wallpaper_list();
|
||||
|
@ -39,7 +40,7 @@ private:
|
|||
private:
|
||||
String m_wallpaper_path;
|
||||
RefPtr<CConfigFile> m_wm_config;
|
||||
GWidget* m_root_widget { nullptr };
|
||||
ObjectPtr<GWidget> m_root_widget;
|
||||
Vector<Size> m_resolutions;
|
||||
Vector<String> m_wallpapers;
|
||||
ObjectPtr<GLabel> m_wallpaper_preview;
|
||||
|
|
|
@ -14,7 +14,7 @@ int main(int argc, char** argv)
|
|||
window->set_title("Display Properties");
|
||||
window->resize(400, 448);
|
||||
window->set_resizable(false);
|
||||
window->set_main_widget(instance.get_root_widget());
|
||||
window->set_main_widget(instance.root_widget());
|
||||
window->set_icon(load_png("/res/icons/16x16/app-display-properties.png"));
|
||||
|
||||
window->show();
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
|||
window->set_title("File Manager");
|
||||
window->set_rect(20, 200, 640, 480);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
auto widget = GWidget::construct();
|
||||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
widget->layout()->set_spacing(0);
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ void IRCAppWindow::setup_menus()
|
|||
|
||||
void IRCAppWindow::setup_widgets()
|
||||
{
|
||||
auto* widget = new GWidget(nullptr);
|
||||
auto widget = GWidget::construct();
|
||||
set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_background_color(Color::WarmGray);
|
||||
|
@ -171,7 +171,7 @@ void IRCAppWindow::setup_widgets()
|
|||
toolbar->add_action(*m_open_query_action);
|
||||
toolbar->add_action(*m_close_query_action);
|
||||
|
||||
auto* outer_container = new GWidget(widget);
|
||||
auto outer_container = GWidget::construct(widget);
|
||||
outer_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
outer_container->layout()->set_margins({ 2, 0, 2, 2 });
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ GWindow* make_launcher_window()
|
|||
window->set_show_titlebar(false);
|
||||
window->set_window_type(GWindowType::Launcher);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
auto widget = GWidget::construct();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GBoxLayout>(vertical ? Orientation::Vertical : Orientation::Horizontal));
|
||||
widget->layout()->set_spacing(0);
|
||||
|
|
|
@ -19,16 +19,16 @@ ColorDialog::~ColorDialog()
|
|||
|
||||
void ColorDialog::build()
|
||||
{
|
||||
auto* horizontal_container = new GWidget;
|
||||
auto horizontal_container = GWidget::construct();
|
||||
horizontal_container->set_fill_with_background_color(true);
|
||||
horizontal_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
set_main_widget(horizontal_container);
|
||||
|
||||
auto* left_vertical_container = new GWidget(horizontal_container);
|
||||
auto left_vertical_container = GWidget::construct(horizontal_container);
|
||||
left_vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
||||
auto* right_vertical_container = new GWidget(horizontal_container);
|
||||
auto right_vertical_container = GWidget::construct(horizontal_container);
|
||||
right_vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
||||
enum RGBComponent {
|
||||
|
|
|
@ -81,16 +81,16 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent)
|
|||
set_secondary_color(color);
|
||||
};
|
||||
|
||||
auto* color_container = new GWidget(this);
|
||||
auto color_container = GWidget::construct(this);
|
||||
color_container->set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 32);
|
||||
color_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
color_container->layout()->set_spacing(1);
|
||||
|
||||
auto* top_color_container = new GWidget(color_container);
|
||||
auto top_color_container = GWidget::construct(color_container);
|
||||
top_color_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
top_color_container->layout()->set_spacing(1);
|
||||
|
||||
auto* bottom_color_container = new GWidget(color_container);
|
||||
auto bottom_color_container = GWidget::construct(color_container);
|
||||
bottom_color_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
bottom_color_container->layout()->set_spacing(1);
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ int main(int argc, char** argv)
|
|||
window->set_title("PaintBrush");
|
||||
window->set_rect(100, 100, 640, 480);
|
||||
|
||||
auto* horizontal_container = new GWidget(nullptr);
|
||||
auto horizontal_container = GWidget::construct(nullptr);
|
||||
window->set_main_widget(horizontal_container);
|
||||
horizontal_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
horizontal_container->layout()->set_spacing(0);
|
||||
|
||||
new ToolboxWidget(horizontal_container);
|
||||
|
||||
auto* vertical_container = new GWidget(horizontal_container);
|
||||
auto vertical_container = GWidget::construct(horizontal_container);
|
||||
vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
vertical_container->layout()->set_spacing(0);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
|||
window->set_title("SoundPlayer");
|
||||
window->set_rect(300, 300, 300, 200);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
auto widget = GWidget::construct();
|
||||
window->set_main_widget(widget);
|
||||
|
||||
widget->set_fill_with_background_color(true);
|
||||
|
|
|
@ -23,7 +23,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
|
|||
layout()->set_spacing(3);
|
||||
|
||||
auto build_widgets_for_label = [this](const String& description) -> ObjectPtr<GLabel> {
|
||||
auto* container = new GWidget(this);
|
||||
auto container = GWidget::construct(this);
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
container->set_preferred_size(275, 12);
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
GApplication app(argc, argv);
|
||||
|
||||
auto* keeper = new GWidget;
|
||||
auto keeper = GWidget::construct();
|
||||
keeper->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
keeper->set_fill_with_background_color(true);
|
||||
keeper->set_background_color(Color::WarmGray);
|
||||
|
@ -58,9 +58,9 @@ int main(int argc, char** argv)
|
|||
auto process_container_splitter = GSplitter::construct(Orientation::Vertical, nullptr);
|
||||
tabwidget->add_widget("Processes", process_container_splitter);
|
||||
|
||||
auto* process_table_container = new GWidget(process_container_splitter);
|
||||
auto process_table_container = GWidget::construct(process_container_splitter);
|
||||
|
||||
auto* graphs_container = new GWidget;
|
||||
auto graphs_container = GWidget::construct();
|
||||
graphs_container->set_fill_with_background_color(true);
|
||||
graphs_container->set_background_color(Color::WarmGray);
|
||||
graphs_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
@ -236,7 +236,7 @@ public:
|
|||
|
||||
GWidget* build_file_systems_tab()
|
||||
{
|
||||
auto* fs_widget = new GWidget(nullptr);
|
||||
auto fs_widget = GWidget::construct();
|
||||
fs_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
fs_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto fs_table_view = GTableView::construct(fs_widget);
|
||||
|
@ -301,7 +301,7 @@ GWidget* build_file_systems_tab()
|
|||
|
||||
GWidget* build_pci_devices_tab()
|
||||
{
|
||||
auto* pci_widget = new GWidget(nullptr);
|
||||
auto pci_widget = GWidget::construct(nullptr);
|
||||
pci_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
pci_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto pci_table_view = GTableView::construct(pci_widget);
|
||||
|
@ -355,7 +355,7 @@ GWidget* build_pci_devices_tab()
|
|||
|
||||
GWidget* build_devices_tab()
|
||||
{
|
||||
auto* devices_widget = new GWidget(nullptr);
|
||||
auto devices_widget = GWidget::construct();
|
||||
devices_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
devices_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ GWindow* create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> co
|
|||
window->set_title("Terminal Settings");
|
||||
window->set_rect(50, 50, 200, 140);
|
||||
|
||||
auto* settings = new GWidget;
|
||||
auto settings = GWidget::construct();
|
||||
window->set_main_widget(settings);
|
||||
settings->set_fill_with_background_color(true);
|
||||
settings->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
|
|
@ -34,7 +34,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
update_title();
|
||||
};
|
||||
|
||||
m_find_widget = new GWidget(this);
|
||||
m_find_widget = GWidget::construct(this);
|
||||
m_find_widget->set_fill_with_background_color(true);
|
||||
m_find_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_find_widget->set_preferred_size(0, 22);
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
ObjectPtr<GTextBox> m_find_textbox;
|
||||
GButton* m_find_previous_button { nullptr };
|
||||
GButton* m_find_next_button { nullptr };
|
||||
GWidget* m_find_widget { nullptr };
|
||||
ObjectPtr<GWidget> m_find_widget;
|
||||
|
||||
bool m_document_dirty { false };
|
||||
};
|
||||
|
|
|
@ -94,13 +94,13 @@ int main(int argc, char** argv)
|
|||
// main section
|
||||
//
|
||||
|
||||
auto* main_section = new GWidget(background);
|
||||
auto main_section = GWidget::construct(background);
|
||||
main_section->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
main_section->layout()->set_margins({ 0, 0, 0, 0 });
|
||||
main_section->layout()->set_spacing(8);
|
||||
main_section->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
|
||||
auto* menu = new GWidget(main_section);
|
||||
auto menu = GWidget::construct(main_section);
|
||||
menu->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
menu->layout()->set_margins({ 0, 0, 0, 0 });
|
||||
menu->layout()->set_spacing(8);
|
||||
|
@ -111,7 +111,7 @@ int main(int argc, char** argv)
|
|||
stack->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
|
||||
for (auto& page : pages) {
|
||||
auto* content = new GWidget(stack);
|
||||
auto content = GWidget::construct(stack);
|
||||
content->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
content->layout()->set_margins({ 0, 0, 0, 0 });
|
||||
content->layout()->set_spacing(8);
|
||||
|
@ -139,7 +139,7 @@ int main(int argc, char** argv)
|
|||
menu_option->set_text_alignment(TextAlignment::CenterLeft);
|
||||
menu_option->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
menu_option->set_preferred_size(0, 20);
|
||||
menu_option->on_click = [stack, content](GButton&) {
|
||||
menu_option->on_click = [&](auto&) {
|
||||
stack->set_active_widget(content);
|
||||
content->invalidate_layout();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue