Jelajahi Sumber

Misc: Use automatic window positioning in more applications

This is a follow up to #2936 / d3e3b4ae56aa79d9bde12ca1f143dcf116f89a4c.

Affected programs:
- Applications: Browser (Download, View source, Inspect DOM tree, JS
  console), Terminal (Settings)
- Demos: Cube, Eyes, Fire, HelloWorld, LibGfxDemo, WebView,
  WidgetGallery
- DevTools: HackStudio, Inspector, Profiler
- Games: 2048, Minesweeper, Snake, Solitaire
- Userland: test-web

A few have been left out where manual positioning is done on purpose,
e.g. ClipboardManager (to be close to the menu bar) or VisualBuilder (to
preserve alignment of the multiple application windows).
Linus Groh 4 tahun lalu
induk
melakukan
2e5c434e22

+ 4 - 4
Applications/Browser/Tab.cpp

@@ -157,7 +157,7 @@ Tab::Tab(Type type)
     m_link_context_menu->add_separator();
     m_link_context_menu->add_action(GUI::Action::create("Download", [this](auto&) {
         auto window = GUI::Window::construct();
-        window->set_rect(300, 300, 300, 150);
+        window->resize(300, 150);
         auto url = m_link_context_menu_url;
         window->set_title(String::format("0%% of %s", url.basename().characters()));
         window->set_resizable(false);
@@ -262,7 +262,7 @@ Tab::Tab(Type type)
                 editor.set_text(source);
                 editor.set_mode(GUI::TextEditor::ReadOnly);
                 editor.set_ruler_visible(true);
-                window->set_rect(150, 150, 640, 480);
+                window->resize(640, 480);
                 window->set_title(url);
                 window->show();
                 (void)window.leak_ref();
@@ -277,7 +277,7 @@ Tab::Tab(Type type)
             if (m_type == Type::InProcessWebView) {
                 if (!m_dom_inspector_window) {
                     m_dom_inspector_window = GUI::Window::construct();
-                    m_dom_inspector_window->set_rect(100, 100, 300, 500);
+                    m_dom_inspector_window->resize(300, 500);
                     m_dom_inspector_window->set_title("DOM inspector");
                     m_dom_inspector_window->set_main_widget<InspectorWidget>();
                 }
@@ -300,7 +300,7 @@ Tab::Tab(Type type)
             if (m_type == Type::InProcessWebView) {
                 if (!m_console_window) {
                     m_console_window = GUI::Window::construct();
-                    m_console_window->set_rect(100, 100, 500, 300);
+                    m_console_window->resize(500, 300);
                     m_console_window->set_title("JS Console");
                     m_console_window->set_main_widget<ConsoleWidget>();
                 }

+ 1 - 1
Applications/Terminal/main.cpp

@@ -139,7 +139,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
     auto window = GUI::Window::construct();
     window->set_title("Terminal Settings");
     window->set_resizable(false);
-    window->set_rect(50, 50, 200, 185);
+    window->resize(200, 185);
     window->set_modal(true);
 
     auto& settings = window->set_main_widget<GUI::Widget>();

+ 1 - 1
Demos/Cube/Cube.cpp

@@ -196,7 +196,7 @@ int main(int argc, char** argv)
     window->set_double_buffering_enabled(true);
     window->set_title("Cube");
     window->set_resizable(false);
-    window->set_rect(100, 100, WIDTH, HEIGHT);
+    window->resize(WIDTH, HEIGHT);
 
     auto& cube = window->set_main_widget<Cube>();
 

+ 1 - 1
Demos/Eyes/main.cpp

@@ -81,7 +81,7 @@ int main(int argc, char* argv[])
     auto window = GUI::Window::construct();
     window->set_title("Eyes");
     window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-eyes.png"));
-    window->set_rect(350, 270, 75 * (full_rows > 0 ? max_in_row : extra_columns), 100 * (full_rows + (extra_columns > 0 ? 1 : 0)));
+    window->resize(75 * (full_rows > 0 ? max_in_row : extra_columns), 100 * (full_rows + (extra_columns > 0 ? 1 : 0)));
     window->set_has_alpha_channel(true);
 
     auto& eyes = window->set_main_widget<EyesWidget>(num_eyes, full_rows, extra_columns);

+ 1 - 1
Demos/Fire/Fire.cpp

@@ -228,7 +228,7 @@ int main(int argc, char** argv)
     window->set_double_buffering_enabled(false);
     window->set_title("Fire");
     window->set_resizable(false);
-    window->set_rect(100, 100, 640, 400);
+    window->resize(640, 400);
 
     auto& fire = window->set_main_widget<Fire>();
 

+ 1 - 1
Demos/HelloWorld/main.cpp

@@ -36,7 +36,7 @@ int main(int argc, char** argv)
     auto app = GUI::Application::construct(argc, argv);
 
     auto window = GUI::Window::construct();
-    window->set_rect(100, 100, 240, 160);
+    window->resize(240, 160);
     window->set_title("Hello World!");
 
     auto& main_widget = window->set_main_widget<GUI::Widget>();

+ 1 - 1
Demos/LibGfxDemo/main.cpp

@@ -202,7 +202,7 @@ int main(int argc, char** argv)
     window->set_double_buffering_enabled(true);
     window->set_title("LibGfx Demo");
     window->set_resizable(false);
-    window->set_rect(100, 100, WIDTH, HEIGHT);
+    window->resize(WIDTH, HEIGHT);
     window->set_main_widget<Canvas>();
     window->show();
 

+ 1 - 1
Demos/WebView/main.cpp

@@ -42,7 +42,7 @@ int main(int argc, char** argv)
     auto& view = main_widget.add<WebContentView>();
     auto& statusbar = main_widget.add<GUI::StatusBar>();
     window->set_title("WebView");
-    window->set_rect(100, 100, 640, 480);
+    window->resize(640, 480);
     window->show();
 
     view.on_title_change = [&](auto& title) {

+ 1 - 1
Demos/WidgetGallery/main.cpp

@@ -90,7 +90,7 @@ int main(int argc, char** argv)
     auto app_icon = GUI::Icon::default_icon("app-widget-gallery");
 
     auto window = GUI::Window::construct();
-    window->set_rect(100, 100, 430, 480);
+    window->resize(430, 480);
     window->set_title("Widget Gallery");
     window->set_icon(app_icon.bitmap_for_size(16));
 

+ 1 - 1
DevTools/HackStudio/main.cpp

@@ -186,7 +186,7 @@ int main(int argc, char** argv)
     Function<void()> update_actions;
 
     g_window = GUI::Window::construct();
-    g_window->set_rect(90, 90, 840, 600);
+    g_window->resize(840, 600);
     g_window->set_title("HackStudio");
 
     auto& widget = g_window->set_main_widget<GUI::Widget>();

+ 1 - 1
DevTools/Inspector/main.cpp

@@ -94,7 +94,7 @@ int main(int argc, char** argv)
 
     auto window = GUI::Window::construct();
     window->set_title("Inspector");
-    window->set_rect(150, 150, 685, 500);
+    window->resize(685, 500);
     window->set_icon(app_icon.bitmap_for_size(16));
 
     auto menubar = GUI::MenuBar::construct();

+ 2 - 2
DevTools/Profiler/main.cpp

@@ -80,8 +80,8 @@ int main(int argc, char** argv)
 
     auto window = GUI::Window::construct();
     window->set_title("Profiler");
-    window->set_rect(100, 100, 800, 600);
     window->set_icon(app_icon.bitmap_for_size(16));
+    window->resize(800, 600);
 
     auto& main_widget = window->set_main_widget<GUI::Widget>();
     main_widget.set_fill_with_background_color(true);
@@ -136,8 +136,8 @@ static bool prompt_to_stop_profiling()
 {
     auto window = GUI::Window::construct();
     window->set_title("Profiling");
-    window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png"));
     window->resize(320, 200);
+    window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png"));
     window->center_on_screen();
     auto& widget = window->set_main_widget<GUI::Widget>();
     widget.set_fill_with_background_color(true);

+ 1 - 1
Games/2048/main.cpp

@@ -63,7 +63,7 @@ int main(int argc, char** argv)
 
     window->set_double_buffering_enabled(false);
     window->set_title("2048");
-    window->set_rect(100, 100, 324, 336);
+    window->resize(324, 336);
 
     auto& game = window->set_main_widget<TwentyFortyEightGame>();
     game.set_fill_with_background_color(true);

+ 1 - 1
Games/Minesweeper/main.cpp

@@ -55,7 +55,7 @@ int main(int argc, char** argv)
     auto window = GUI::Window::construct();
     window->set_resizable(false);
     window->set_title("Minesweeper");
-    window->set_rect(100, 100, 139, 175);
+    window->resize(139, 175);
 
     auto& widget = window->set_main_widget<GUI::Widget>();
     widget.set_layout<GUI::VerticalBoxLayout>();

+ 1 - 1
Games/Snake/main.cpp

@@ -53,7 +53,7 @@ int main(int argc, char** argv)
 
     window->set_double_buffering_enabled(false);
     window->set_title("Snake");
-    window->set_rect(100, 100, 320, 320);
+    window->resize(320, 320);
 
     auto& game = window->set_main_widget<SnakeGame>();
 

+ 1 - 1
Games/Solitaire/main.cpp

@@ -45,7 +45,7 @@ int main(int argc, char** argv)
     auto window = GUI::Window::construct();
 
     window->set_resizable(false);
-    window->set_rect(300, 100, SolitaireWidget::width, SolitaireWidget::height);
+    window->resize(SolitaireWidget::width, SolitaireWidget::height);
 
     auto widget = SolitaireWidget::construct(window, [&](uint32_t score) {
         window->set_title(String::format("Score: %u - Solitaire", score));

+ 1 - 1
Userland/test-web.cpp

@@ -649,7 +649,7 @@ int main(int argc, char** argv)
 
     if (show_window) {
         window->set_title("LibWeb Test Window");
-        window->set_rect(100, 100, 640, 480);
+        window->resize(640, 480);
         window->show();
     }