diff options
author | Rick Pasetto <rick@lindenlab.com> | 2009-11-30 16:01:20 -0800 |
---|---|---|
committer | Rick Pasetto <rick@lindenlab.com> | 2009-11-30 16:01:20 -0800 |
commit | 5040a726755939704a3de14187d9d020caea4d9d (patch) | |
tree | 9518caffd498fd1677cab72ba2646f0d4ad4539f /indra/newview | |
parent | 8671bfb930f5fdaec8e2c0338b376bc41224199e (diff) |
DEV-43041 DEV-41648 - disable OK and Apply if the media data is the same as the initial
Review #48
This change kills two birds with one stone: every frame, we check to see if the media data is the same as the one we 'initialize' with. If it is, we disable OK and Cancel. Otherwise we enable them. This makes it very difficult to set empty media data, as well as fixing the "apply button doesn't grey out" bug.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloatermediasettings.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llfloatermediasettings.h | 12 | ||||
-rw-r--r-- | indra/newview/llpanelmediasettingsgeneral.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llpanelmediasettingssecurity.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_media_settings_general.xml | 23 |
5 files changed, 82 insertions, 28 deletions
diff --git a/indra/newview/llfloatermediasettings.cpp b/indra/newview/llfloatermediasettings.cpp index 44e68d7745..f7ce826a39 100644 --- a/indra/newview/llfloatermediasettings.cpp +++ b/indra/newview/llfloatermediasettings.cpp @@ -41,6 +41,7 @@ #include "lluictrlfactory.h" #include "llbutton.h" #include "llselectmgr.h" +#include "llsdutil.h" LLFloaterMediaSettings* LLFloaterMediaSettings::sInstance = NULL; @@ -145,15 +146,15 @@ LLFloaterMediaSettings* LLFloaterMediaSettings::getInstance() //static void LLFloaterMediaSettings::apply() { - LLSD settings; + LLSD settings; sInstance->mPanelMediaSettingsGeneral->preApply(); - sInstance->mPanelMediaSettingsGeneral->getValues( settings ); + sInstance->mPanelMediaSettingsGeneral->getValues( settings ); sInstance->mPanelMediaSettingsSecurity->preApply(); sInstance->mPanelMediaSettingsSecurity->getValues( settings ); sInstance->mPanelMediaSettingsPermissions->preApply(); - sInstance->mPanelMediaSettingsPermissions->getValues( settings ); + sInstance->mPanelMediaSettingsPermissions->getValues( settings ); LLSelectMgr::getInstance()->selectionSetMedia( LLTextureEntry::MF_HAS_MEDIA ); - LLSelectMgr::getInstance()->selectionSetMediaData(settings); + LLSelectMgr::getInstance()->selectionSetMediaData(settings); sInstance->mPanelMediaSettingsGeneral->postApply(); sInstance->mPanelMediaSettingsSecurity->postApply(); sInstance->mPanelMediaSettingsPermissions->postApply(); @@ -183,7 +184,12 @@ void LLFloaterMediaSettings::initValues( const LLSD& media_settings, bool editab sInstance->mPanelMediaSettingsPermissions-> initValues( sInstance->mPanelMediaSettingsPermissions, media_settings, editable ); - + + // Squirrel away initial values + sInstance->mInitialValues.clear(); + sInstance->mPanelMediaSettingsGeneral->getValues( sInstance->mInitialValues ); + sInstance->mPanelMediaSettingsSecurity->getValues( sInstance->mInitialValues ); + sInstance->mPanelMediaSettingsPermissions->getValues( sInstance->mInitialValues ); } //////////////////////////////////////////////////////////////////////////////// @@ -206,7 +212,7 @@ void LLFloaterMediaSettings::clearValues( bool editable) { // clean up all panels before updating sInstance->mPanelMediaSettingsGeneral ->clearValues(sInstance->mPanelMediaSettingsGeneral, editable); - sInstance->mPanelMediaSettingsSecurity ->clearValues(sInstance->mPanelMediaSettingsSecurity, editable); + sInstance->mPanelMediaSettingsSecurity ->clearValues(sInstance->mPanelMediaSettingsSecurity, editable); sInstance->mPanelMediaSettingsPermissions->clearValues(sInstance->mPanelMediaSettingsPermissions, editable); } @@ -235,7 +241,7 @@ void LLFloaterMediaSettings::onBtnApply( void* userdata ) // static void LLFloaterMediaSettings::onBtnCancel( void* userdata ) { - sInstance->closeFloater(); + sInstance->closeFloater(); } //////////////////////////////////////////////////////////////////////////////// @@ -250,7 +256,6 @@ void LLFloaterMediaSettings::onTabChanged(void* user_data, bool from_click) // void LLFloaterMediaSettings::enableOkApplyBtns( bool enable ) { - setCtrlsEnabled( enable ); childSetEnabled( "OK", enable ); childSetEnabled( "Apply", enable ); } @@ -265,7 +270,6 @@ const std::string LLFloaterMediaSettings::getHomeUrl() return std::string( "" ); } - //////////////////////////////////////////////////////////////////////////////// // bool LLFloaterMediaSettings::passesWhiteList( const std::string& test_url ) @@ -279,3 +283,36 @@ bool LLFloaterMediaSettings::passesWhiteList( const std::string& test_url ) // this is all we can do return false; } + +//////////////////////////////////////////////////////////////////////////////// +// virtual +void LLFloaterMediaSettings::draw() +{ + // *NOTE: The code below is very inefficient. Better to do this + // only when data change. + // Every frame, check to see what the values are. If they are not + // the same as the default media data, enable the OK/Apply buttons + LLSD settings; + sInstance->mPanelMediaSettingsGeneral->getValues( settings ); + sInstance->mPanelMediaSettingsSecurity->getValues( settings ); + sInstance->mPanelMediaSettingsPermissions->getValues( settings ); + + bool values_changed = false; + + LLSD::map_const_iterator iter = settings.beginMap(); + LLSD::map_const_iterator end = settings.endMap(); + for ( ; iter != end; ++iter ) + { + const std::string ¤t_key = iter->first; + const LLSD ¤t_value = iter->second; + if ( ! llsd_equals(current_value, mInitialValues[current_key])) + { + values_changed = true; + break; + } + } + + enableOkApplyBtns(values_changed); + + LLFloater::draw(); +} diff --git a/indra/newview/llfloatermediasettings.h b/indra/newview/llfloatermediasettings.h index 17a47cb0f5..e2af1705bf 100644 --- a/indra/newview/llfloatermediasettings.h +++ b/indra/newview/llfloatermediasettings.h @@ -54,11 +54,13 @@ public: static void apply(); static void initValues( const LLSD& media_settings , bool editable); static void clearValues( bool editable); - void enableOkApplyBtns( bool enable ); - LLPanelMediaSettingsSecurity* getPanelSecurity(){return mPanelMediaSettingsSecurity;}; - const std::string getHomeUrl(); + + LLPanelMediaSettingsSecurity* getPanelSecurity(){return mPanelMediaSettingsSecurity;}; + const std::string getHomeUrl(); bool passesWhiteList( const std::string& test_url ); + virtual void draw(); + bool mIdenticalHasMediaInfo; bool mMultipleMedia; bool mMultipleValidMedia; @@ -83,6 +85,10 @@ protected: static LLFloaterMediaSettings* sInstance; private: + + void enableOkApplyBtns( bool enable ); + + LLSD mInitialValues; bool mWaitingToClose; }; diff --git a/indra/newview/llpanelmediasettingsgeneral.cpp b/indra/newview/llpanelmediasettingsgeneral.cpp index 5bb266a01d..b1e7dd3d50 100644 --- a/indra/newview/llpanelmediasettingsgeneral.cpp +++ b/indra/newview/llpanelmediasettingsgeneral.cpp @@ -392,19 +392,19 @@ void LLPanelMediaSettingsGeneral::preApply() // void LLPanelMediaSettingsGeneral::getValues( LLSD &fill_me_in ) { - fill_me_in[LLMediaEntry::AUTO_LOOP_KEY] = mAutoLoop->getValue(); - fill_me_in[LLMediaEntry::AUTO_PLAY_KEY] = mAutoPlay->getValue(); - fill_me_in[LLMediaEntry::AUTO_SCALE_KEY] = mAutoScale->getValue(); - fill_me_in[LLMediaEntry::AUTO_ZOOM_KEY] = mAutoZoom->getValue(); - fill_me_in[LLMediaEntry::CONTROLS_KEY] = mControls->getCurrentIndex(); + fill_me_in[LLMediaEntry::AUTO_LOOP_KEY] = (LLSD::Boolean)mAutoLoop->getValue(); + fill_me_in[LLMediaEntry::AUTO_PLAY_KEY] = (LLSD::Boolean)mAutoPlay->getValue(); + fill_me_in[LLMediaEntry::AUTO_SCALE_KEY] = (LLSD::Boolean)mAutoScale->getValue(); + fill_me_in[LLMediaEntry::AUTO_ZOOM_KEY] = (LLSD::Boolean)mAutoZoom->getValue(); + fill_me_in[LLMediaEntry::CONTROLS_KEY] = (LLSD::Integer)mControls->getCurrentIndex(); //Don't fill in current URL: this is only supposed to get changed via navigate // fill_me_in[LLMediaEntry::CURRENT_URL_KEY] = mCurrentURL->getValue(); - fill_me_in[LLMediaEntry::HEIGHT_PIXELS_KEY] = mHeightPixels->getValue(); + fill_me_in[LLMediaEntry::HEIGHT_PIXELS_KEY] = (LLSD::Integer)mHeightPixels->getValue(); // Don't fill in the home URL if it is the special "Multiple Media" string! if (LLTrans::getString("Multiple Media") != mHomeURL->getValue()) - fill_me_in[LLMediaEntry::HOME_URL_KEY] = mHomeURL->getValue(); - fill_me_in[LLMediaEntry::FIRST_CLICK_INTERACT_KEY] = mFirstClick->getValue(); - fill_me_in[LLMediaEntry::WIDTH_PIXELS_KEY] = mWidthPixels->getValue(); + fill_me_in[LLMediaEntry::HOME_URL_KEY] = (LLSD::String)mHomeURL->getValue(); + fill_me_in[LLMediaEntry::FIRST_CLICK_INTERACT_KEY] = (LLSD::Boolean)mFirstClick->getValue(); + fill_me_in[LLMediaEntry::WIDTH_PIXELS_KEY] = (LLSD::Integer)mWidthPixels->getValue(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpanelmediasettingssecurity.cpp b/indra/newview/llpanelmediasettingssecurity.cpp index 94e137b0f4..7ec53ed57a 100644 --- a/indra/newview/llpanelmediasettingssecurity.cpp +++ b/indra/newview/llpanelmediasettingssecurity.cpp @@ -213,7 +213,7 @@ void LLPanelMediaSettingsSecurity::preApply() // void LLPanelMediaSettingsSecurity::getValues( LLSD &fill_me_in ) { - fill_me_in[LLMediaEntry::WHITELIST_ENABLE_KEY] = mEnableWhiteList->getValue(); + fill_me_in[LLMediaEntry::WHITELIST_ENABLE_KEY] = (LLSD::Boolean)mEnableWhiteList->getValue(); // iterate over white list and extract items std::vector< LLScrollListItem* > white_list_items = mWhiteListList->getAllData(); diff --git a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml index e00f654750..89f1fe35ca 100644 --- a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml +++ b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml @@ -221,12 +221,23 @@ width="50" /> <text bottom_delta="0" follows="top|left" height="15" left_delta="60" name="X_label"> - X + X </text> - <spinner bottom_delta="0" - decimal_digits="0" enabled="true" follows="left|top" height="16" - increment="1" initial_val="256" label="" label_width="0" - left_delta="20" max_val="2048" min_val="0" mouse_opaque="true" - name="height_pixels" width="50" /> + <spinner + bottom_delta="0" + decimal_digits="0" + enabled="true" + follows="left|top" + height="16" + increment="1" + initial_val="256" + label="" + label_width="0" + left_delta="20" + max_val="2048" + min_val="0" + mouse_opaque="true" + name="height_pixels" + width="50" /> </panel> |