mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:25:06 +00:00
LibGUI: Add and use Window::center_on_screen()
Various applications were using the same slightly verbose code to center themselves on the screen/desktop: Gfx::IntRect window_rect { 0, 0, width, height }; window_rect.center_within(GUI::Desktop::the().rect()); window->set_rect(window_rect); Which now becomes: window->resize(width, height); window->center_on_screen();
This commit is contained in:
parent
5f724b6ca1
commit
0cab3bca2f
6 changed files with 18 additions and 16 deletions
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/ProcessChooser.h>
|
||||
#include <LibGUI/RunningProcessesModel.h>
|
||||
|
@ -48,9 +47,8 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView&
|
|||
else if (parent_window)
|
||||
set_icon(parent_window->icon());
|
||||
|
||||
Gfx::IntRect window_rect { 0, 0, 300, 340 };
|
||||
window_rect.center_within(GUI::Desktop::the().rect());
|
||||
set_rect(window_rect);
|
||||
resize(300, 340);
|
||||
center_on_screen();
|
||||
|
||||
auto& widget = set_main_widget<GUI::Widget>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue