Skip to content

Commit

Permalink
gui2/tmessage: Hide title and image widgets when unused
Browse files Browse the repository at this point in the history
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 b9b199f 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.
  • Loading branch information
irydacea committed Mar 13, 2014
1 parent 4968a4b commit 8498786
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/gui/dialogs/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8498786

Please sign in to comment.