From 8e31171ee3e5ecfff5f0e5edddcd19cb8e36473f Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 8 Dec 2009 16:49:47 -0800 Subject: DEV-43866: Fix mute button when you slide volume slider Trivial fix, plus some minor refactoring --- indra/newview/llpanelprimmediacontrols.cpp | 136 ++++++++++----------- indra/newview/llpanelprimmediacontrols.h | 2 +- .../default/xui/en/panel_prim_media_controls.xml | 2 +- 3 files changed, 70 insertions(+), 70 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index aa2b7d4554..b4cc1b78ad 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -150,7 +150,7 @@ BOOL LLPanelPrimMediaControls::postBuild() mSkipFwdCtrl = getChild("skip_forward"); mSkipBackCtrl = getChild("skip_back"); mVolumeCtrl = getChild("media_volume"); - mVolumeBtn = getChild("media_volume_button"); + mMuteBtn = getChild("media_mute_button"); mVolumeUpCtrl = getChild("volume_up"); mVolumeDownCtrl = getChild("volume_down"); mVolumeSliderCtrl = getChild("volume_slider"); @@ -308,13 +308,12 @@ void LLPanelPrimMediaControls::updateShape() enabled = dynamic_cast(objectp)->hasMediaPermission(media_data, LLVOVolume::MEDIA_PERM_CONTROL); mini_controls = (LLMediaEntry::MINI == media_data->getControls()); } - const bool is_hud = objectp->isHUDAttachment(); // // Set the state of the buttons // - + // XXX RSP: TODO: FIXME: clean this up so that it is clearer what mode we are in, // and that only the proper controls get made visible/enabled according to that mode. mBackCtrl->setVisible(has_focus); @@ -343,7 +342,7 @@ void LLPanelPrimMediaControls::updateShape() mStopCtrl->setEnabled(has_focus && can_navigate); mHomeCtrl->setEnabled(has_focus && can_navigate); LLPluginClassMediaOwner::EMediaStatus result = ((media_impl != NULL) && media_impl->hasMedia()) ? media_plugin->getStatus() : LLPluginClassMediaOwner::MEDIA_NONE; - + if(media_plugin && media_plugin->pluginSupportsMediaTime()) { mReloadCtrl->setEnabled(false); @@ -360,14 +359,14 @@ void LLPanelPrimMediaControls::updateShape() mSkipFwdCtrl->setEnabled(has_focus && !mini_controls); mSkipBackCtrl->setVisible(has_focus && !mini_controls); mSkipBackCtrl->setEnabled(has_focus && !mini_controls); - + mVolumeCtrl->setVisible(has_focus); mVolumeUpCtrl->setVisible(has_focus); mVolumeDownCtrl->setVisible(has_focus); mVolumeCtrl->setEnabled(has_focus); mVolumeSliderCtrl->setEnabled(has_focus && mVolumeSliderVisible); mVolumeSliderCtrl->setVisible(has_focus && mVolumeSliderVisible); - + mWhitelistIcon->setVisible(false); mSecureLockIcon->setVisible(false); if (mMediaPanelScroll) @@ -378,7 +377,7 @@ void LLPanelPrimMediaControls::updateShape() mScrollRightCtrl->setVisible(false); mScrollDownCtrl->setVisible(false); } - + F32 volume = media_impl->getVolume(); // movie's url changed if(mCurrentURL!=mPreviousURL) @@ -386,7 +385,7 @@ void LLPanelPrimMediaControls::updateShape() mMovieDuration = media_plugin->getDuration(); mPreviousURL = mCurrentURL; } - + if(mMovieDuration == 0) { mMovieDuration = media_plugin->getDuration(); @@ -394,7 +393,7 @@ void LLPanelPrimMediaControls::updateShape() mMediaPlaySliderCtrl->setEnabled(false); } // TODO: What if it's not fully loaded - + if(mUpdateSlider && mMovieDuration!= 0) { F64 current_time = media_plugin->getCurrentTime(); @@ -402,29 +401,30 @@ void LLPanelPrimMediaControls::updateShape() mMediaPlaySliderCtrl->setValue(percent); mMediaPlaySliderCtrl->setEnabled(true); } - + // video vloume if(volume <= 0.0) { mVolumeUpCtrl->setEnabled(TRUE); mVolumeDownCtrl->setEnabled(FALSE); media_impl->setVolume(0.0); - mVolumeBtn->setToggleState(true); + mMuteBtn->setToggleState(true); } else if (volume >= 1.0) { mVolumeUpCtrl->setEnabled(FALSE); mVolumeDownCtrl->setEnabled(TRUE); media_impl->setVolume(1.0); - mVolumeBtn->setToggleState(false); + mMuteBtn->setToggleState(false); } else { + mMuteBtn->setToggleState(false); mVolumeUpCtrl->setEnabled(TRUE); mVolumeDownCtrl->setEnabled(TRUE); } mVolumeSliderCtrl->setValue(volume); - + switch(result) { case LLPluginClassMediaOwner::MEDIA_PLAYING: @@ -453,7 +453,7 @@ void LLPanelPrimMediaControls::updateShape() { mCurrentURL.clear(); } - + mPlayCtrl->setVisible(FALSE); mPauseCtrl->setVisible(FALSE); mMediaStopCtrl->setVisible(FALSE); @@ -465,7 +465,7 @@ void LLPanelPrimMediaControls::updateShape() mSkipFwdCtrl->setEnabled(FALSE); mSkipBackCtrl->setVisible(FALSE); mSkipBackCtrl->setEnabled(FALSE); - + mVolumeCtrl->setVisible(FALSE); mVolumeUpCtrl->setVisible(FALSE); mVolumeDownCtrl->setVisible(FALSE); @@ -491,13 +491,13 @@ void LLPanelPrimMediaControls::updateShape() { mSecureLockIcon->setVisible(has_focus); } - + if(mCurrentURL!=mPreviousURL) { setCurrentURL(); mPreviousURL = mCurrentURL; } - + if(result == LLPluginClassMediaOwner::MEDIA_LOADING) { mReloadCtrl->setEnabled(FALSE); @@ -513,7 +513,7 @@ void LLPanelPrimMediaControls::updateShape() mStopCtrl->setVisible(FALSE); } } - + if(media_plugin) { @@ -530,7 +530,7 @@ void LLPanelPrimMediaControls::updateShape() mMediaProgressPanel->setVisible(false); } } - + if(media_impl) { // @@ -538,28 +538,28 @@ void LLPanelPrimMediaControls::updateShape() // switch (mScrollState) { - case SCROLL_UP: - media_impl->scrollWheel(0, -1, MASK_NONE); - break; - case SCROLL_DOWN: - media_impl->scrollWheel(0, 1, MASK_NONE); - break; - case SCROLL_LEFT: - media_impl->scrollWheel(1, 0, MASK_NONE); -// media_impl->handleKeyHere(KEY_LEFT, MASK_NONE); - break; - case SCROLL_RIGHT: - media_impl->scrollWheel(-1, 0, MASK_NONE); -// media_impl->handleKeyHere(KEY_RIGHT, MASK_NONE); - break; - case SCROLL_NONE: - default: - break; + case SCROLL_UP: + media_impl->scrollWheel(0, -1, MASK_NONE); + break; + case SCROLL_DOWN: + media_impl->scrollWheel(0, 1, MASK_NONE); + break; + case SCROLL_LEFT: + media_impl->scrollWheel(1, 0, MASK_NONE); + // media_impl->handleKeyHere(KEY_LEFT, MASK_NONE); + break; + case SCROLL_RIGHT: + media_impl->scrollWheel(-1, 0, MASK_NONE); + // media_impl->handleKeyHere(KEY_RIGHT, MASK_NONE); + break; + case SCROLL_NONE: + default: + break; } } setVisible(enabled); - + // // Calculate position and shape of the controls // @@ -569,31 +569,31 @@ void LLPanelPrimMediaControls::updateShape() std::vector::iterator vert_it; std::vector::iterator vert_end; std::vector vect_face; - + LLVolume* volume = objectp->getVolume(); - + if (volume) { const LLVolumeFace& vf = volume->getVolumeFace(mTargetObjectFace); - + const LLVector3* ext = vf.mExtents; - + LLVector3 center = (ext[0]+ext[1])*0.5f; LLVector3 size = (ext[1]-ext[0])*0.5f; LLVector3 vert[] = - { - center + size.scaledVec(LLVector3(1,1,1)), - center + size.scaledVec(LLVector3(-1,1,1)), - center + size.scaledVec(LLVector3(1,-1,1)), - center + size.scaledVec(LLVector3(-1,-1,1)), - center + size.scaledVec(LLVector3(1,1,-1)), - center + size.scaledVec(LLVector3(-1,1,-1)), - center + size.scaledVec(LLVector3(1,-1,-1)), - center + size.scaledVec(LLVector3(-1,-1,-1)), - }; - + { + center + size.scaledVec(LLVector3(1,1,1)), + center + size.scaledVec(LLVector3(-1,1,1)), + center + size.scaledVec(LLVector3(1,-1,1)), + center + size.scaledVec(LLVector3(-1,-1,1)), + center + size.scaledVec(LLVector3(1,1,-1)), + center + size.scaledVec(LLVector3(-1,1,-1)), + center + size.scaledVec(LLVector3(1,-1,-1)), + center + size.scaledVec(LLVector3(-1,-1,-1)), + }; + LLVOVolume* vo = (LLVOVolume*) objectp; - + for (U32 i = 0; i < 8; i++) { vect_face.push_back(vo->volumePositionToAgent(vert[i])); @@ -601,7 +601,7 @@ void LLPanelPrimMediaControls::updateShape() } vert_it = vect_face.begin(); vert_end = vect_face.end(); - + min = LLVector3(1,1,1); max = LLVector3(-1,-1,-1); for(; vert_it != vert_end; ++vert_it) @@ -609,19 +609,19 @@ void LLPanelPrimMediaControls::updateShape() // project silhouette vertices into screen space glh::vec3f screen_vert = glh::vec3f(vert_it->mV); mat.mult_matrix_vec(screen_vert); - + // add to screenspace bounding box update_min_max(min, max, LLVector3(screen_vert.v)); } - + LLCoordGL screen_min; screen_min.mX = llround((F32)gViewerWindow->getWorldViewWidthScaled() * (min.mV[VX] + 1.f) * 0.5f); screen_min.mY = llround((F32)gViewerWindow->getWorldViewHeightScaled() * (min.mV[VY] + 1.f) * 0.5f); - + LLCoordGL screen_max; screen_max.mX = llround((F32)gViewerWindow->getWorldViewWidthScaled() * (max.mV[VX] + 1.f) * 0.5f); screen_max.mY = llround((F32)gViewerWindow->getWorldViewHeightScaled() * (max.mV[VY] + 1.f) * 0.5f); - + // grow panel so that screenspace bounding box fits inside "media_region" element of HUD LLRect media_controls_rect; S32 volume_slider_height = mVolumeSliderCtrl->getRect().getHeight() - /*fudge*/ 2; @@ -636,19 +636,19 @@ void LLPanelPrimMediaControls::updateShape() // clamp to minimum size, keeping centered media_controls_rect.setCenterAndSize(media_controls_rect.getCenterX(), media_controls_rect.getCenterY(), - llmax(mMinWidth, media_controls_rect.getWidth()), llmax(mMinHeight, media_controls_rect.getHeight())); - + llmax(mMinWidth, media_controls_rect.getWidth()), llmax(mMinHeight, media_controls_rect.getHeight())); + setShape(media_controls_rect, true); - + // Test mouse position to see if the cursor is stationary LLCoordWindow cursor_pos_window; getWindow()->getCursorPosition(&cursor_pos_window); - + // If last pos is not equal to current pos, the mouse has moved // We need to reset the timer, and make sure the panel is visible if(cursor_pos_window.mX != mLastCursorPos.mX || - cursor_pos_window.mY != mLastCursorPos.mY || - mScrollState != SCROLL_NONE) + cursor_pos_window.mY != mLastCursorPos.mY || + mScrollState != SCROLL_NONE) { mInactivityTimer.start(); mLastCursorPos = cursor_pos_window; @@ -673,7 +673,7 @@ void LLPanelPrimMediaControls::updateShape() else { // I don't think this is correct anymore. This is done in draw() after the fade has completed. -// setVisible(FALSE); + // setVisible(FALSE); } } } @@ -1193,7 +1193,7 @@ void LLPanelPrimMediaControls::onCommitVolumeUp() } media_impl->setVolume(volume); - mVolumeBtn->setToggleState(false); + mMuteBtn->setToggleState(false); } } @@ -1213,7 +1213,7 @@ void LLPanelPrimMediaControls::onCommitVolumeDown() } media_impl->setVolume(volume); - mVolumeBtn->setToggleState(false); + mMuteBtn->setToggleState(false); } } @@ -1243,7 +1243,7 @@ void LLPanelPrimMediaControls::onToggleMute() } else { - media_impl->setVolume(0.5); + media_impl->setVolume(mVolumeSliderCtrl->getValueF32()); } } } diff --git a/indra/newview/llpanelprimmediacontrols.h b/indra/newview/llpanelprimmediacontrols.h index 06163051a5..17e65b8b0c 100644 --- a/indra/newview/llpanelprimmediacontrols.h +++ b/indra/newview/llpanelprimmediacontrols.h @@ -153,7 +153,7 @@ private: LLUICtrl *mMediaPlaySliderPanel; LLUICtrl *mMediaPlaySliderCtrl; LLUICtrl *mVolumeCtrl; - LLButton *mVolumeBtn; + LLButton *mMuteBtn; LLUICtrl *mVolumeUpCtrl; LLUICtrl *mVolumeDownCtrl; LLSliderCtrl *mVolumeSliderCtrl; diff --git a/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml b/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml index e21de31498..b4f72a48bc 100644 --- a/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml +++ b/indra/newview/skins/default/xui/en/panel_prim_media_controls.xml @@ -380,7 +380,7 @@ image_selected="AudioMute_Off" image_unselected="Audio_Off" hover_glow_amount="0.15" - name="media_volume_button" + name="media_mute_button" height="22" is_toggle="true" layout="topleft" -- cgit v1.2.3