Bläddra i källkod

Fixes close button overlapping window title

Bernhard Liebl 7 år sedan
förälder
incheckning
2616e2b3c6
1 ändrade filer med 10 tillägg och 3 borttagningar
  1. 10 3
      scene/gui/dialogs.cpp

+ 10 - 3
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() {