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 c10e31c7f7
commit a8bcd2a528
2 changed files with 5 additions and 2 deletions

View file

@ -3,6 +3,9 @@ Version 1.11.19+dev:
* Updated translations: German
* Fixed encoding and other issues with the system default language option
on builds using Boost.locale (bugs #22921, #22928).
* User interface:
* Fixed lower button row padding for GUI1 dialogs including Statistics and
the Add-ons Manager (bugs #22379, #22791).
* Miscellaneous and bug fixes:
* Fixed recursive directory creation failing for working dir-relative paths
without an explicit `./` at the start (e.g. in `wesnoth -p data/core foo`)

View file

@ -624,7 +624,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;
@ -675,7 +675,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;