From ebbb468a795d503a8869467d642d5f4962a3d7bf Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 9 Nov 2009 16:56:33 -0800 Subject: FIX DEV-42093 - Make sure to navigate home if current URL is empty on "Apply" This change gets rid of the crufty (and confusing) "apply()" functions from llpanelmediasettings*. Those functions were never being called, yet changes were being made in them. Instead, I added "preApply()" and "postApply()" to each of these panels, which the floater (who really does the "apply()"ing) now calls before and after it applies the changes to the media data. --- indra/newview/llpanelmediasettingsgeneral.cpp | 69 +++++++++++++++------------ 1 file changed, 39 insertions(+), 30 deletions(-) (limited to 'indra/newview/llpanelmediasettingsgeneral.cpp') diff --git a/indra/newview/llpanelmediasettingsgeneral.cpp b/indra/newview/llpanelmediasettingsgeneral.cpp index 5186a5888b..2cf56d5571 100644 --- a/indra/newview/llpanelmediasettingsgeneral.cpp +++ b/indra/newview/llpanelmediasettingsgeneral.cpp @@ -366,21 +366,15 @@ void LLPanelMediaSettingsGeneral::onCommitHomeURL( LLUICtrl* ctrl, void *userdat void LLPanelMediaSettingsGeneral::onBtnResetCurrentUrl(LLUICtrl* ctrl, void *userdata) { LLPanelMediaSettingsGeneral* self =(LLPanelMediaSettingsGeneral *)userdata; - self->navigateHomeSelectedFace(); + self->navigateHomeSelectedFace(false); } //////////////////////////////////////////////////////////////////////////////// -// static -void LLPanelMediaSettingsGeneral::apply( void* userdata ) +// +void LLPanelMediaSettingsGeneral::preApply() { - LLPanelMediaSettingsGeneral *self =(LLPanelMediaSettingsGeneral *)userdata; - self->mHomeURL->onCommit(); - // build LLSD Fragment - LLSD media_data_general; - self->getValues(media_data_general); - - // this merges contents of LLSD passed in with what's there so this is ok - LLSelectMgr::getInstance()->selectionSetMediaData( media_data_general ); + // Make sure the home URL entry is committed + mHomeURL->onCommit(); } //////////////////////////////////////////////////////////////////////////////// @@ -392,13 +386,24 @@ void LLPanelMediaSettingsGeneral::getValues( LLSD &fill_me_in ) 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::CURRENT_URL_KEY] = mCurrentURL->getValue(); + //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::HOME_URL_KEY] = mHomeURL->getValue(); fill_me_in[LLMediaEntry::FIRST_CLICK_INTERACT_KEY] = mFirstClick->getValue(); fill_me_in[LLMediaEntry::WIDTH_PIXELS_KEY] = mWidthPixels->getValue(); } +//////////////////////////////////////////////////////////////////////////////// +// +void LLPanelMediaSettingsGeneral::postApply() +{ + // Make sure to navigate to the home URL if the current URL is empty and + // autoplay is on + navigateHomeSelectedFace(true); +} + + //////////////////////////////////////////////////////////////////////////////// // void LLPanelMediaSettingsGeneral::setParent( LLFloaterMediaSettings* parent ) @@ -406,33 +411,37 @@ void LLPanelMediaSettingsGeneral::setParent( LLFloaterMediaSettings* parent ) mParent = parent; }; -bool LLPanelMediaSettingsGeneral::navigateHomeSelectedFace() +//////////////////////////////////////////////////////////////////////////////// +// +bool LLPanelMediaSettingsGeneral::navigateHomeSelectedFace(bool only_if_current_is_empty) { - // HACK: This is directly referencing an impl name. BAD! - // This can be removed when we have a truly generic media browser that only - // builds an impl based on the type of url it is passed. struct functor_navigate_media : public LLSelectedTEGetFunctor< bool> { + functor_navigate_media(bool flag) : only_if_current_is_empty(flag) {} bool get( LLViewerObject* object, S32 face ) { - if ( object ) - if ( object->getTE(face) ) - if ( object->getTE(face)->getMediaData() ) + if ( object && object->getTE(face) && object->permModify() ) + { + const LLMediaEntry *media_data = object->getTE(face)->getMediaData(); + if ( media_data ) + { + if (!only_if_current_is_empty || (media_data->getCurrentURL().empty() && media_data->getAutoPlay())) { - if(object->permModify()) + viewer_media_t media_impl = + LLViewerMedia::getMediaImplFromTextureID(object->getTE(face)->getMediaData()->getMediaID()); + if(media_impl) { - viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(object->getTE(face)->getMediaData()->getMediaID()); - if(media_impl) - { - media_impl->navigateHome(); - return true; - } - } + media_impl->navigateHome(); + return true; + } } - return false; - }; + } + } + return false; + }; + bool only_if_current_is_empty; - } functor_navigate_media; + } functor_navigate_media(only_if_current_is_empty); bool all_face_media_navigated = false; LLObjectSelectionHandle selected_objects =LLSelectMgr::getInstance()->getSelection(); -- cgit v1.2.3