From: <wel...@us...> - 2011-01-22 19:18:59
|
Revision: 6824 http://planeshift.svn.sourceforge.net/planeshift/?rev=6824&view=rev Author: weltall2 Date: 2011-01-22 19:18:53 +0000 (Sat, 22 Jan 2011) Log Message: ----------- improvement to the config window handling. now pressing the x to close it will restore the previous settings. Also activating it when already open will avoid doing anything. Modified Paths: -------------- trunk/src/common/paws/pawswidget.cpp trunk/src/common/paws/widgetconfigwindow.cpp trunk/src/common/paws/widgetconfigwindow.h Modified: trunk/src/common/paws/pawswidget.cpp =================================================================== --- trunk/src/common/paws/pawswidget.cpp 2011-01-22 18:55:50 UTC (rev 6823) +++ trunk/src/common/paws/pawswidget.cpp 2011-01-22 19:18:53 UTC (rev 6824) @@ -1431,7 +1431,7 @@ // there can only be one config window active for each widget WidgetConfigWindow* configWindow = dynamic_cast<WidgetConfigWindow*>(widget); - if ( widget ==NULL) + if(widget == NULL) { configWindow = new WidgetConfigWindow(); configWindow->LoadFromFile("widgetconfigwindow.xml"); Modified: trunk/src/common/paws/widgetconfigwindow.cpp =================================================================== --- trunk/src/common/paws/widgetconfigwindow.cpp 2011-01-22 18:55:50 UTC (rev 6823) +++ trunk/src/common/paws/widgetconfigwindow.cpp 2011-01-22 19:18:53 UTC (rev 6824) @@ -120,6 +120,16 @@ } +void WidgetConfigWindow::restoreSettings() +{ + // restore settings + configWidget->SetMinAlpha((int)oldMinAlpha); + configWidget->SetMaxAlpha((int)oldMaxAlpha); + configWidget->SetFadeSpeed(oldFadeSpeed); + configWidget->SetFade(oldFadeStatus); + configWidget->SetFontScaling(oldFontStatus); +} + /** * @brief Handle all button presses. */ @@ -138,16 +148,9 @@ } else if (widget == buttonCancel) { - // restore settings - configWidget->SetMinAlpha((int)oldMinAlpha); - configWidget->SetMaxAlpha((int)oldMaxAlpha); - configWidget->SetFadeSpeed(oldFadeSpeed); - configWidget->SetFade(oldFadeStatus); - configWidget->SetFontScaling(oldFontStatus); - - // close this window - //PawsManager::GetSingleton().GetMainWidget()->DeleteChild(this); - Hide(); + //just act like if the user closed the window. + //it will restore the previous settings and hide the widget. + Close(); return true; } else if (widget == checkboxFade) @@ -192,6 +195,14 @@ */ void WidgetConfigWindow::SetConfigurableWidget(pawsWidget *configWidget) { + //if it's the same widget we ignore the input we are already open with this. + if(this->configWidget == configWidget) + return; + //if we were working on a different widget we restore the previous widget setting + //before proceeding. + else if(this->configWidget != NULL) + restoreSettings(); + this->configWidget = configWidget; // get new values @@ -220,12 +231,12 @@ oldFontStatus = currentFontStatus; oldFadeStatus = currentFadeStatus; + scrollBarMaxAlpha->SetCurrentValue(currentMaxAlpha); + progressBarMaxAlpha->SetCurrentValue(currentMaxAlpha); + scrollBarMinAlpha->SetCurrentValue(currentMinAlpha); progressBarMinAlpha->SetCurrentValue(currentMinAlpha); - scrollBarMaxAlpha->SetCurrentValue(currentMaxAlpha); - progressBarMaxAlpha->SetCurrentValue(currentMaxAlpha); - scrollBarFadeSpeed->SetCurrentValue(currentFadeSpeed); progressBarFadeSpeed->SetCurrentValue(currentFadeSpeed); Modified: trunk/src/common/paws/widgetconfigwindow.h =================================================================== --- trunk/src/common/paws/widgetconfigwindow.h 2011-01-22 18:55:50 UTC (rev 6823) +++ trunk/src/common/paws/widgetconfigwindow.h 2011-01-22 19:18:53 UTC (rev 6824) @@ -43,6 +43,13 @@ bool PostSetup(); bool OnScroll( int direction, pawsScrollBar* widget ); bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ); + /** Restores the settings of the widget being configured to their previous values. + */ + void restoreSettings(); + /** Overrides the pawsWidget Close() in order to restore settings and null out + * the widget being configured. + */ + void Close() { restoreSettings(); configWidget = NULL; Hide(); } void SetConfigurableWidget(pawsWidget* w); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |