mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18: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
|
@ -123,6 +123,8 @@ public:
|
|||
void resize(int width, int height) { resize({ width, height }); }
|
||||
void resize(const Gfx::IntSize& size) { set_rect({ position(), size }); }
|
||||
|
||||
void center_on_screen();
|
||||
|
||||
virtual void event(Core::Event&) override;
|
||||
|
||||
bool is_visible() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue