[Scummvm-cvs-logs] scummvm master -> 6b17507b76e3ac1efd8aa5dc12684a233d52046b

eriktorbjorn eriktorbjorn at telia.com
Fri Feb 24 22:29:13 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6b17507b76 GUI: Fix "clear" buttons after theme switch (bug #3482459)


Commit: 6b17507b76e3ac1efd8aa5dc12684a233d52046b
    https://github.com/scummvm/scummvm/commit/6b17507b76e3ac1efd8aa5dc12684a233d52046b
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2012-02-24T13:20:50-08:00

Commit Message:
GUI: Fix "clear" buttons after theme switch (bug #3482459)

Because the "clear" buttons are very different between themes (in
the Modern theme they have a graphical symbol, while in the Classic
theme they have a letter), they have to be removed and re-added
when reflowing the layout. This is patterned after how the
LauncherDialog class handles the larger changes in layout.

Removing widgets from a tab turned out to be trickier than I first
thought, so I had to move the removeWidget() method from Dialog to
GuiObject.

Changed paths:
    gui/dialog.cpp
    gui/object.cpp
    gui/object.h
    gui/options.cpp
    gui/options.h



diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 0522b40..fd15ba5 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -334,25 +334,7 @@ void Dialog::removeWidget(Widget *del) {
 	if (del == _dragWidget)
 		_dragWidget = NULL;
 
-	Widget *w = _firstWidget;
-
-	if (del == _firstWidget) {
-		Widget *del_next = del->_next;
-		del->_next = 0;
-		_firstWidget = del_next;
-		return;
-	}
-
-	w = _firstWidget;
-	while (w) {
-		if (w->_next == del) {
-			Widget *del_next = del->_next;
-			del->_next = 0;
-			w->_next = del_next;
-			return;
-		}
-		w = w->_next;
-	}
+	GuiObject::removeWidget(del);
 }
 
 } // End of namespace GUI
diff --git a/gui/object.cpp b/gui/object.cpp
index 2ec42df..73c4f74 100644
--- a/gui/object.cpp
+++ b/gui/object.cpp
@@ -59,4 +59,24 @@ void GuiObject::reflowLayout() {
 	}
 }
 
+void GuiObject::removeWidget(Widget *del) {
+	if (del == _firstWidget) {
+		Widget *del_next = del->next();
+		del->setNext(0);
+		_firstWidget = del_next;
+		return;
+	}
+
+	Widget *w = _firstWidget;
+	while (w) {
+		if (w->next() == del) {
+			Widget *del_next = del->next();
+			del->setNext(0);
+			w->setNext(del_next);
+			return;
+		}
+		w = w->next();
+	}
+}
+
 } // End of namespace GUI
diff --git a/gui/object.h b/gui/object.h
index 34ff0d4..bce3cd7 100644
--- a/gui/object.h
+++ b/gui/object.h
@@ -83,6 +83,8 @@ public:
 
 	virtual void	reflowLayout();
 
+	virtual void	removeWidget(Widget *widget);
+
 protected:
 	virtual void	releaseFocus() = 0;
 };
diff --git a/gui/options.cpp b/gui/options.cpp
index be1c091..fbbb938 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -79,7 +79,7 @@ static const char *outputRateLabels[] = { _s("<default>"), _s("8 kHz"), _s("11kH
 static const int outputRateValues[] = { 0, 8000, 11025, 22050, 44100, 48000, -1 };
 
 OptionsDialog::OptionsDialog(const Common::String &domain, int x, int y, int w, int h)
-	: Dialog(x, y, w, h), _domain(domain), _graphicsTabId(-1), _tabWidget(0) {
+	: Dialog(x, y, w, h), _domain(domain), _graphicsTabId(-1), _midiTabId(-1), _pathsTabId(-1), _tabWidget(0) {
 	init();
 }
 
@@ -1120,7 +1120,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()
 	//
 	// 3) The MIDI tab
 	//
-	tab->addTab(_("MIDI"));
+	_midiTabId = tab->addTab(_("MIDI"));
 	addMIDIControls(tab, "GlobalOptions_MIDI.");
 
 	//
@@ -1133,9 +1133,9 @@ GlobalOptionsDialog::GlobalOptionsDialog()
 	// 5) The Paths tab
 	//
 	if (g_system->getOverlayWidth() > 320)
-		tab->addTab(_("Paths"));
+		_pathsTabId = tab->addTab(_("Paths"));
 	else
-		tab->addTab(_c("Paths", "lowres"));
+		_pathsTabId = tab->addTab(_c("Paths", "lowres"));
 
 #if !( defined(__DC__) || defined(__GP32__) )
 	// These two buttons have to be extra wide, or the text will be
@@ -1494,4 +1494,39 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
 	}
 }
 
+void GlobalOptionsDialog::reflowLayout() {
+	int activeTab = _tabWidget->getActiveTab();
+
+	if (_midiTabId != -1) {
+		_tabWidget->setActiveTab(_midiTabId);
+
+		_tabWidget->removeWidget(_soundFontClearButton);
+		_soundFontClearButton->setNext(0);
+		delete _soundFontClearButton;
+		_soundFontClearButton = addClearButton(_tabWidget, "GlobalOptions_MIDI.mcFontClearButton", kClearSoundFontCmd);
+	}
+
+	if (_pathsTabId != -1) {
+		_tabWidget->setActiveTab(_pathsTabId);
+
+		_tabWidget->removeWidget(_savePathClearButton);
+		_savePathClearButton->setNext(0);
+		delete _savePathClearButton;
+		_savePathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.SavePathClearButton", kSavePathClearCmd);
+
+		_tabWidget->removeWidget(_themePathClearButton);
+		_themePathClearButton->setNext(0);
+		delete _themePathClearButton;
+		_themePathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.ThemePathClearButton", kThemePathClearCmd);
+
+		_tabWidget->removeWidget(_extraPathClearButton);
+		_extraPathClearButton->setNext(0);
+		delete _extraPathClearButton;
+		_extraPathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.ExtraPathClearButton", kExtraPathClearCmd);
+	}
+
+	_tabWidget->setActiveTab(activeTab);
+	OptionsDialog::reflowLayout();
+}
+
 } // End of namespace GUI
diff --git a/gui/options.h b/gui/options.h
index 4e0187f..83c9d60 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -89,6 +89,8 @@ protected:
 
 	TabWidget *_tabWidget;
 	int _graphicsTabId;
+	int _midiTabId;
+	int _pathsTabId;
 
 private:
 	//
@@ -193,6 +195,8 @@ public:
 	void close();
 	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
 
+	virtual void reflowLayout();
+
 protected:
 #ifdef SMALL_SCREEN_DEVICE
 	KeysDialog *_keysDialog;






More information about the Scummvm-git-logs mailing list