mirror of
https://github.com/xenia-project/elemental-forms.git
synced 2026-01-31 01:25:17 +01:00
Adding utility to center windows in their parent container.
This commit is contained in:
@@ -180,6 +180,14 @@ void Window::set_settings(WindowSettings settings) {
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void Window::CenterInParent() {
|
||||
if (!parent()) {
|
||||
return;
|
||||
}
|
||||
Rect bounds(0, 0, parent()->rect().w, parent()->rect().h);
|
||||
set_rect(rect().CenterIn(bounds).MoveIn(bounds).Clip(bounds));
|
||||
}
|
||||
|
||||
int Window::title_bar_height() {
|
||||
if (any(window_settings_ & WindowSettings::kTitleBar)) {
|
||||
return title_mover_.GetPreferredSize().pref_h;
|
||||
|
||||
@@ -77,6 +77,8 @@ class Window : public Element {
|
||||
// Sets settings for how this window should look and behave.
|
||||
void set_settings(WindowSettings settings);
|
||||
|
||||
void CenterInParent();
|
||||
|
||||
// ResizeFit specifies how ResizeToFitContent should resize the window.
|
||||
enum class ResizeFit {
|
||||
kPreferred, // Fit the preferred size of all content.
|
||||
|
||||
Reference in New Issue
Block a user