From 2e5c434e22c8f03ebbb16a95c9e8bc88b2a76500 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 15 Aug 2020 17:24:05 +0200 Subject: [PATCH] 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). --- Applications/Browser/Tab.cpp | 8 ++++---- Applications/Terminal/main.cpp | 2 +- Demos/Cube/Cube.cpp | 2 +- Demos/Eyes/main.cpp | 2 +- Demos/Fire/Fire.cpp | 2 +- Demos/HelloWorld/main.cpp | 2 +- Demos/LibGfxDemo/main.cpp | 2 +- Demos/WebView/main.cpp | 2 +- Demos/WidgetGallery/main.cpp | 2 +- DevTools/HackStudio/main.cpp | 2 +- DevTools/Inspector/main.cpp | 2 +- DevTools/Profiler/main.cpp | 4 ++-- Games/2048/main.cpp | 2 +- Games/Minesweeper/main.cpp | 2 +- Games/Snake/main.cpp | 2 +- Games/Solitaire/main.cpp | 2 +- Userland/test-web.cpp | 2 +- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index 16235b54ef5..38e8059a615 100644 --- a/Applications/Browser/Tab.cpp +++ b/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(); } @@ -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(); } diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 696e4e3cf9b..73e3da7e1ac 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -139,7 +139,7 @@ static RefPtr 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(); diff --git a/Demos/Cube/Cube.cpp b/Demos/Cube/Cube.cpp index 8731f6c9481..50f9c357aec 100644 --- a/Demos/Cube/Cube.cpp +++ b/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(); diff --git a/Demos/Eyes/main.cpp b/Demos/Eyes/main.cpp index 80f16e403c0..6cefd4cd62a 100644 --- a/Demos/Eyes/main.cpp +++ b/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(num_eyes, full_rows, extra_columns); diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index 35249e5adf2..51556d3d13b 100644 --- a/Demos/Fire/Fire.cpp +++ b/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(); diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index aea01a2d415..a5510e7ac6f 100644 --- a/Demos/HelloWorld/main.cpp +++ b/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(); diff --git a/Demos/LibGfxDemo/main.cpp b/Demos/LibGfxDemo/main.cpp index 65e9bb3ddc2..1e0e993fa81 100644 --- a/Demos/LibGfxDemo/main.cpp +++ b/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(); window->show(); diff --git a/Demos/WebView/main.cpp b/Demos/WebView/main.cpp index d3c8d7e24ab..d33e8a272ae 100644 --- a/Demos/WebView/main.cpp +++ b/Demos/WebView/main.cpp @@ -42,7 +42,7 @@ int main(int argc, char** argv) auto& view = main_widget.add(); auto& statusbar = main_widget.add(); window->set_title("WebView"); - window->set_rect(100, 100, 640, 480); + window->resize(640, 480); window->show(); view.on_title_change = [&](auto& title) { diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index a8fc74dc98d..9fad2e76799 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/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)); diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 9dc9c79e6a4..515b2e7a9bc 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -186,7 +186,7 @@ int main(int argc, char** argv) Function 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(); diff --git a/DevTools/Inspector/main.cpp b/DevTools/Inspector/main.cpp index ccf94f8f28b..b69576aeeea 100644 --- a/DevTools/Inspector/main.cpp +++ b/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(); diff --git a/DevTools/Profiler/main.cpp b/DevTools/Profiler/main.cpp index d709ce6af37..8412843f207 100644 --- a/DevTools/Profiler/main.cpp +++ b/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(); 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(); widget.set_fill_with_background_color(true); diff --git a/Games/2048/main.cpp b/Games/2048/main.cpp index 6e4c9a52ba6..628270ce282 100644 --- a/Games/2048/main.cpp +++ b/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(); game.set_fill_with_background_color(true); diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 0562bbf2c3f..0f6029376a9 100644 --- a/Games/Minesweeper/main.cpp +++ b/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(); widget.set_layout(); diff --git a/Games/Snake/main.cpp b/Games/Snake/main.cpp index 6abc482e666..31c6fcf94ae 100644 --- a/Games/Snake/main.cpp +++ b/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(); diff --git a/Games/Solitaire/main.cpp b/Games/Solitaire/main.cpp index 99a316ef94f..8a5ac75a822 100644 --- a/Games/Solitaire/main.cpp +++ b/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)); diff --git a/Userland/test-web.cpp b/Userland/test-web.cpp index d1db25b2dd4..e8082483ca8 100644 --- a/Userland/test-web.cpp +++ b/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(); }