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 045bda037d (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 f60ef98e27
(a.k.a. 69521000dc 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.
This commit is contained in:
Ignacio R. Morelle 2014-11-10 22:17:54 -03:00
parent c3c48434fa
commit 0f453ea24c
2 changed files with 4 additions and 3 deletions

View file

@ -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,

View file

@ -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;