mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:58:12 +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
|
@ -29,7 +29,6 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/RadioButton.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
@ -62,9 +61,8 @@ Vector<char const*> ShutdownDialog::show()
|
|||
ShutdownDialog::ShutdownDialog()
|
||||
: Dialog(nullptr)
|
||||
{
|
||||
Gfx::IntRect rect({ 0, 0, 180, 180 + ((static_cast<int>(options.size()) - 3) * 16) });
|
||||
rect.center_within(GUI::Desktop::the().rect());
|
||||
set_rect(rect);
|
||||
resize(180, 180 + ((static_cast<int>(options.size()) - 3) * 16));
|
||||
center_on_screen();
|
||||
set_resizable(false);
|
||||
set_title("SerenityOS");
|
||||
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue