GUI: Introduce dynamic layouts

Prior to this change, a GUI layout was only affected by the screen size.
Now, a layout can additionally be influenced by the GUI dialog and widgets
that uses it. This capability is leveraged to implement the following
features:

* Layout elements that are not bound to a GUI widget do not take space.
   This means that dialogs where the widgets shown depend on for example
   a feature being enabled at configure time no longer have blank spaces.
* Widgets can define a minimal required size for their contents not to be
   cut. For now this is only used for buttons so their width is always
   sufficient for their caption not to be cut. This mechanism could be
   applied to other widget types in the future.
This commit is contained in:
Bastien Bouclet 2019-12-28 10:43:58 +01:00
parent 303ee2694f
commit c0d8b6d9fc
36 changed files with 326 additions and 177 deletions

View file

@ -398,8 +398,7 @@ SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String &
_delSupport = _metaInfoSupport = _thumbnailSupport = false;
_container = new ContainerWidget(this, 0, 0, 10, 10);
// _container->setHints(THEME_HINT_USE_SHADOW);
_container = new ContainerWidget(this, "SaveLoadChooser.Thumbnail");
}
int SaveLoadChooserSimple::runIntern() {
@ -472,6 +471,8 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin
}
void SaveLoadChooserSimple::reflowLayout() {
SaveLoadChooserDialog::reflowLayout();
if (g_gui.xmlEval()->getVar("Globals.SaveLoadChooser.ExtInfo.Visible") == 1 && (_thumbnailSupport || _saveDateSupport || _playTimeSupport)) {
int16 x, y;
uint16 w, h;
@ -536,8 +537,6 @@ void SaveLoadChooserSimple::reflowLayout() {
_time->setVisible(false);
_playtime->setVisible(false);
}
SaveLoadChooserDialog::reflowLayout();
}
void SaveLoadChooserSimple::updateSelection(bool redraw) {
@ -745,6 +744,10 @@ SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::String &title, bool saveM
new StaticTextWidget(this, "SaveLoadChooser.Title", title);
// The list widget needs to be bound so it takes space in the layout
ContainerWidget *list = new ContainerWidget(this, "SaveLoadChooser.List");
list->setBackgroundType(ThemeEngine::kWidgetBackgroundNo);
// Buttons
new ButtonWidget(this, "SaveLoadChooser.Delete", _("Cancel"), 0, kCloseCmd);
_nextButton = new ButtonWidget(this, "SaveLoadChooser.Choose", _("Next"), 0, kNextCmd);