diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-12-15 23:13:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-15 23:13:41 +0100 |
commit | a0dd3abad9e87a3a9b1c1af0df301c873a934271 (patch) | |
tree | c80a67ddee4c6bec09a7197bb963c7065899cab5 /scene/gui | |
parent | e946fb8cb0a9177c45db5305a26efa52ea8e7907 (diff) | |
parent | 2616e2b3c6edf627834e959526e74a7c88901d0a (diff) |
Merge pull request #14716 from poke1024/fix_window_title
Fixes close button overlapping window title
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/dialogs.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index d4912339da..9a55073bb6 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -289,10 +289,17 @@ bool WindowDialog::get_resizable() const { Size2 WindowDialog::get_minimum_size() const { Ref<Font> font = get_font("title_font", "WindowDialog"); - int msx = close_button->get_combined_minimum_size().x; - msx += font->get_string_size(title).x; - return Size2(msx, 1); + const int button_width = close_button->get_combined_minimum_size().x; + const int title_width = font->get_string_size(title).x; + const int padding = button_width / 2; + const int button_area = button_width + padding; + + // as the title gets centered, title_width + close_button_width is not enough. + // we want a width w, such that w / 2 - title_width / 2 >= button_area, i.e. + // w >= 2 * button_area + title_width + + return Size2(2 * button_area + title_width, 1); } TextureButton *WindowDialog::get_close_button() { |