From 0f453ea24cf9f6d88ef6659e96dc0f6fc1702800 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Mon, 10 Nov 2014 22:17:54 -0300 Subject: [PATCH] gui1: Fix bogus dialog option buttons layout (bug #22791, #22379) Formerly, the option buttons at the bottom of the dialog were laid out by redoing some math instead of tracking the dialog's menu position, which is always valid (even when there is no menu!). I'm not entirely sure why, but the math reprised here became bogus with the introduction of top buttons in commit 045bda037d78056866bdd918b51708d44d2bf515 (for the Add-ons Manager dialog), in particular for dialogs *not* using them (such as the in-game Statistics dialog), even though the menu is still laid out correctly. So instead of reinventing the wheel, we really should just take the menu's position and height as a baseline for the bottom option buttons. At worst the height is 0, but the position is still within the dialog's boundaries (but see below for an unsolved corner case). This commit reverts commit f60ef98e275fd3d16733f7d5dfd7314920841fd5 (a.k.a. 69521000dc5c45f9745131ee13e76493e14fefaa in 1.12) that's part of PR #263, because it turns out that the solution proposed there is only a convenient workaround that solves a layout issue for a single dialog (Statistics, see bug #22379) and introduces a new bug for another (Add-ons Manager, see bug #22791). Regardless of the cause for #22791, the approach put forward by this commit is more consistent with best practice (laying out widgets from top to bottom each row's geometry depending on the previous row's), so I have decided to not look too much into it. It should be noted that the layout of bottom option buttons breaks entirely for dialogs missing a menu, both before and after the introduction of top buttons. Currently there is no GUI1 dialog that attempts to insert option buttons while lacking menu entries, so I'm not too concerned about this bug (which affects 1.10 too!). Besides, some day GUI1 is supposed to go the way of the dodo and stop bothering us with its marvelous inflexibility and arcane logic. --- changelog | 3 ++- src/construct_dialog.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changelog b/changelog index c512e6734b0..819d4de1203 100644 --- a/changelog +++ b/changelog @@ -159,7 +159,8 @@ Version 1.13.0-dev: * Added new wml attributes to listbox: has_minimum and has_maximum. * Added a "Disable automatic moves" preference to disable automatic movements at the begining of a turn. - * In the dialog layout code, fixed the button padding (bug #22379). + * Fixed lower button row padding for GUI1 dialogs including Statistics and + the Add-ons Manager (bugs #22379, #22791). * Fixed mouse tracking issue with workaround by changing the default window resolution for OS X to 800 x 600 (bug #20332). * Removed the "Replay viewer" text label from the replay controller theme, diff --git a/src/construct_dialog.cpp b/src/construct_dialog.cpp index f45c29238c2..5adc3ddf53f 100644 --- a/src/construct_dialog.cpp +++ b/src/construct_dialog.cpp @@ -626,7 +626,7 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc) } } - const int text_widget_y = dim.y + top_padding + text_and_image_height - (text_and_image_height > 0 ? 6 : 0) + menu_hpadding; + const int text_widget_y = dim.y + top_padding + text_and_image_height - 6 + menu_hpadding; if(use_textbox) { dim.textbox.x = dim.x + left_padding + text_widget_width - dim.textbox.w; @@ -677,7 +677,7 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc) //set the position of any tick boxes. by default, they go right below the menu, //slammed against the right side of the dialog if(extra_buttons_.empty() == false) { - int options_y = text_widget_y + top_widgets_height + menu_->height() + button_height_padding + menu_hpadding; + int options_y = dim.menu_y + menu_->height() + menu_hpadding + button_height_padding; int options_left_y = options_y; for(button_pool_const_iterator b = button_pool_.begin(); b != button_pool_.end(); ++b) { dialog_button const *const btn = b->first;