diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 5b18deb367c..b57f20c9ade 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -272,7 +272,7 @@ ConfigDialog::ConfigDialog() : // The game specific options tab // - int tabId = tab->addTab(_("Game"), "GlobalConfig_Engine"); + int tabId = tab->addTab(_("Game"), "GlobalConfig_Engine", false); if (g_engine->hasFeature(Engine::kSupportsChangingOptionsDuringRuntime)) { _engineOptions = metaEngine->buildEngineOptionsWidgetDynamic(tab, "GlobalConfig_Engine.Container", gameDomain); @@ -315,14 +315,14 @@ ConfigDialog::ConfigDialog() : Common::KeymapArray keymaps = metaEngine->initKeymaps(gameDomain.c_str()); if (!keymaps.empty()) { - tab->addTab(_("Keymaps"), "GlobalConfig_KeyMapper"); + tab->addTab(_("Keymaps"), "GlobalConfig_KeyMapper", false); addKeyMapperControls(tab, "GlobalConfig_KeyMapper.", keymaps, gameDomain); } // // The backend tab (shown only if the backend implements one) // - int backendTabId = tab->addTab(_("Backend"), "GlobalConfig_Backend"); + int backendTabId = tab->addTab(_("Backend"), "GlobalConfig_Backend", false); _backendOptions = g_system->buildBackendOptionsWidget(tab, "GlobalConfig_Backend.Container", _domain); @@ -337,11 +337,11 @@ ConfigDialog::ConfigDialog() : // AchMan.setActiveDomain(metaEngine->getAchievementsInfo(gameDomain)); if (AchMan.getAchievementCount()) { - tab->addTab(_("Achievements"), "GlobalConfig_Achievements"); + tab->addTab(_("Achievements"), "GlobalConfig_Achievements", false); addAchievementsControls(tab, "GlobalConfig_Achievements."); } if (AchMan.getStatCount()) { - tab->addTab(_("Statistics"), "GlobalConfig_Achievements"); + tab->addTab(_("Statistics"), "GlobalConfig_Achievements", false); addStatisticsControls(tab, "GlobalConfig_Achievements."); } diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp index 437dab466b8..259f7b2e7c1 100644 --- a/gui/editgamedialog.cpp +++ b/gui/editgamedialog.cpp @@ -138,7 +138,7 @@ EditGameDialog::EditGameDialog(const Common::String &domain) // // 1) The game tab // - tab->addTab(_("Game"), "GameOptions_Game", true); + tab->addTab(_("Game"), "GameOptions_Game"); // GUI: Label & edit widget for the game ID if (g_system->getOverlayWidth() > 320) @@ -204,7 +204,7 @@ EditGameDialog::EditGameDialog(const Common::String &domain) // // 3) The graphics tab // - _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"), "GameOptions_Graphics"); + _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"), "GameOptions_Graphics", false); ScrollContainerWidget *graphicsContainer = new ScrollContainerWidget(tab, "GameOptions_Graphics.Container", "GameOptions_Graphics_Container", kGraphicsTabContainerReflowCmd); graphicsContainer->setBackgroundType(ThemeEngine::kWidgetBackgroundNo); graphicsContainer->setTarget(this); @@ -241,14 +241,14 @@ EditGameDialog::EditGameDialog(const Common::String &domain) } if (!keymaps.empty()) { - tab->addTab(_("Keymaps"), "GameOptions_KeyMapper"); + tab->addTab(_("Keymaps"), "GameOptions_KeyMapper", false); addKeyMapperControls(tab, "GameOptions_KeyMapper.", keymaps, domain); } // // The backend tab (shown only if the backend implements one) // - int backendTabId = tab->addTab(_("Backend"), "GameOptions_Backend"); + int backendTabId = tab->addTab(_("Backend"), "GameOptions_Backend", false); if (g_system->getOverlayWidth() > 320) _globalBackendOverride = new CheckboxWidget(tab, "GameOptions_Backend.EnableTabCheckbox", _("Override global backend settings"), Common::U32String(), kCmdGlobalBackendOverride); @@ -367,11 +367,11 @@ EditGameDialog::EditGameDialog(const Common::String &domain) const MetaEngine &metaEngine = enginePlugin->get(); AchMan.setActiveDomain(metaEngine.getAchievementsInfo(domain)); if (AchMan.getAchievementCount()) { - tab->addTab(_("Achievements"), "GameOptions_Achievements"); + tab->addTab(_("Achievements"), "GameOptions_Achievements", false); addAchievementsControls(tab, "GameOptions_Achievements."); } if (AchMan.getStatCount()) { - tab->addTab(_("Statistics"), "GameOptions_Achievements"); + tab->addTab(_("Statistics"), "GameOptions_Achievements", false); addStatisticsControls(tab, "GameOptions_Achievements."); } } diff --git a/gui/options.cpp b/gui/options.cpp index 5a2bb6217a0..9e1cb848ccd 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1981,7 +1981,7 @@ void GlobalOptionsDialog::build() { // // 1) The graphics tab // - _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"), "GlobalOptions_Graphics"); + _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"), "GlobalOptions_Graphics", false); ScrollContainerWidget *graphicsContainer = new ScrollContainerWidget(tab, "GlobalOptions_Graphics.Container", "GlobalOptions_Graphics_Container", kGraphicsTabContainerReflowCmd); graphicsContainer->setTarget(this); graphicsContainer->setBackgroundType(ThemeEngine::kWidgetBackgroundNo); @@ -2026,14 +2026,14 @@ void GlobalOptionsDialog::build() { } if (!keymaps.empty()) { - tab->addTab(_("Keymaps"), "GlobalOptions_KeyMapper"); + tab->addTab(_("Keymaps"), "GlobalOptions_KeyMapper", false); addKeyMapperControls(tab, "GlobalOptions_KeyMapper.", keymaps, Common::ConfigManager::kKeymapperDomain); } // // The backend tab (shown only if the backend implements one) // - int backendTabId = tab->addTab(_("Backend"), "GlobalOptions_Backend"); + int backendTabId = tab->addTab(_("Backend"), "GlobalOptions_Backend", false); g_system->registerDefaultSettings(_domain); _backendOptions = g_system->buildBackendOptionsWidget(tab, "GlobalOptions_Backend.Container", _domain); @@ -2084,9 +2084,9 @@ void GlobalOptionsDialog::build() { // 6) The miscellaneous tab // if (g_system->getOverlayWidth() > 320) - tab->addTab(_("Misc"), "GlobalOptions_Misc"); + tab->addTab(_("Misc"), "GlobalOptions_Misc", false); else - tab->addTab(_c("Misc", "lowres"), "GlobalOptions_Misc"); + tab->addTab(_c("Misc", "lowres"), "GlobalOptions_Misc", false); ScrollContainerWidget *miscContainer = new ScrollContainerWidget(tab, "GlobalOptions_Misc.Container", "GlobalOptions_Misc_Container"); miscContainer->setTarget(this); miscContainer->setBackgroundType(ThemeEngine::kWidgetBackgroundNo); @@ -2098,9 +2098,9 @@ void GlobalOptionsDialog::build() { // 7) The Cloud tab (remote storages) // if (g_system->getOverlayWidth() > 320) - tab->addTab(_("Cloud"), "GlobalOptions_Cloud"); + tab->addTab(_("Cloud"), "GlobalOptions_Cloud", false); else - tab->addTab(_c("Cloud", "lowres"), "GlobalOptions_Cloud"); + tab->addTab(_c("Cloud", "lowres"), "GlobalOptions_Cloud", false); ScrollContainerWidget *container = new ScrollContainerWidget(tab, "GlobalOptions_Cloud.Container", "GlobalOptions_Cloud_Container", kCloudTabContainerReflowCmd); container->setTarget(this); diff --git a/gui/widget.cpp b/gui/widget.cpp index 79bccccd6a0..87bc6c24d28 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -1044,7 +1044,7 @@ void OptionsContainerWidget::reflowLayout() { Widget *w = _firstWidget; int16 minY = getAbsY(); - int maxY = minY; + int maxY = minY + _h; while (w) { w->reflowLayout(); minY = MIN(minY, w->getAbsY()); diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index 7cdc8ba39a3..08770b47c36 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -161,6 +161,14 @@ Widget *TabWidget::addChild(Widget *newChild) { return _tabs[_activeTab].scrollWidget->addChild(newChild); } +void TabWidget::removeWidget(Widget *del) { + if (_activeTab == -1 || _tabs[_activeTab].scrollWidget == nullptr){ + Widget::removeWidget(del); + return; + } + _tabs[_activeTab].scrollWidget->removeWidget(del); +} + void TabWidget::removeTab(int tabID) { assert(0 <= tabID && tabID < (int)_tabs.size()); @@ -171,7 +179,11 @@ void TabWidget::removeTab(int tabID) { } // Dispose the widgets in that tab and then the tab itself - delete _tabs[tabID].scrollWidget; + if (_tabs[tabID].scrollWidget) { + delete _tabs[tabID].scrollWidget; + } else { + delete _tabs[tabID].firstWidget; + } _tabs.remove_at(tabID); // Adjust _firstVisibleTab if necessary @@ -201,7 +213,10 @@ void TabWidget::setActiveTab(int tabID) { releaseFocus(); } _activeTab = tabID; - _firstWidget = _tabs[tabID].firstWidget; + if (_tabs[tabID].scrollWidget) + _firstWidget = _tabs[_activeTab].scrollWidget; + else + _firstWidget = _tabs[tabID].firstWidget; // Also ensure the tab is visible in the tab bar if (_firstVisibleTab > tabID) diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index 7b7a7f71f01..da89917cda9 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -76,9 +76,10 @@ public: * Add a new tab with the given title. Returns a unique ID which can be used * to identify the tab (to remove it / activate it etc.). */ - int addTab(const Common::U32String &title, const Common::String &dialogName, bool withScroll = false); + int addTab(const Common::U32String &title, const Common::String &dialogName, bool withScroll = true); virtual Widget *addChild(Widget *newChild); + virtual void removeWidget(Widget *del); /** * Remove the tab with the given tab ID. Disposes all child widgets of that tab.