gui2/tmessage: Hide title and image widgets when unused

When the title or image widget labels are left empty, the widgets
continue to take up space in the grid, which is particularly conspicuous
with our current border,border_size=all,5 convention.

Commit b9b199f4f1 exposes the underlying
problem quite clearly in most dialogs because the image widget's cell
takes up extra space to the left of the dialog while empty -- see the
"you have not started your turn yet, do you really want to end your
turn" prompt for an example.

Hiding the relevant widgets when missing label values is trivial to do.
In the gui2::tmessage case it required a minor internal refactoring to
keep a find_widget<>() reference around for a second method call for
each widget. This should be a good solution as any until cell borders
gain the ability to become null when the contained widget is otherwise
unused.
This commit is contained in:
Ignacio R. Morelle 2014-03-13 01:59:51 -03:00
parent fa9f75b627
commit 403ccb10c7

View file

@ -73,12 +73,18 @@ void tmessage::pre_show(CVideo& /*video*/, twindow& window)
window, buttons_[right_1], "right_side");
// ***** ***** ***** ***** Set up the widgets ***** ***** ***** *****
tcontrol& title_widget = find_widget<tlabel>(&window, "title", false);
if(!title_.empty()) {
find_widget<tlabel>(&window, "title", false).set_label(title_);
title_widget.set_label(title_);
} else {
title_widget.set_visible(twidget::tvisible::invisible);
}
tcontrol& img_widget = find_widget<timage>(&window, "image", false);
if(!image_.empty()) {
find_widget<timage>(&window, "image", false).set_label(image_);
img_widget.set_label(image_);
} else {
img_widget.set_visible(twidget::tvisible::invisible);
}
tcontrol& label = find_widget<tcontrol>(&window, "label", false);