diff options
Diffstat (limited to 'indra/newview/llpanelprimmediacontrols.cpp')
-rw-r--r-- | indra/newview/llpanelprimmediacontrols.cpp | 745 |
1 files changed, 465 insertions, 280 deletions
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index e4b32c4820..a53a3ba1ad 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -44,6 +44,7 @@ #include "llbutton.h" #include "llface.h" #include "llcombobox.h" +#include "lllayoutstack.h" #include "llslider.h" #include "llhudview.h" #include "lliconctrl.h" @@ -53,7 +54,10 @@ #include "llpanelprimmediacontrols.h" #include "llpluginclassmedia.h" #include "llprogressbar.h" +#include "llsliderctrl.h" +#include "llstring.h" #include "llviewercontrol.h" +#include "llviewerdisplay.h" #include "llviewerparcelmgr.h" #include "llviewermedia.h" #include "llviewermediafocus.h" @@ -61,12 +65,13 @@ #include "llweb.h" #include "llwindow.h" +#include "llfloatertools.h" // to enable hide if build tools are up + +// Functions pulled from pipeline.cpp glh::matrix4f glh_get_current_modelview(); glh::matrix4f glh_get_current_projection(); - -const F32 ZOOM_NEAR_PADDING = 1.0f; -const F32 ZOOM_MEDIUM_PADDING = 1.15f; -const F32 ZOOM_FAR_PADDING = 1.5f; +// Functions pulled from llviewerdisplay.cpp +bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model); // Warning: make sure these two match! const LLPanelPrimMediaControls::EZoomLevel LLPanelPrimMediaControls::kZoomLevels[] = { ZOOM_NONE, ZOOM_MEDIUM }; @@ -85,13 +90,20 @@ LLPanelPrimMediaControls::LLPanelPrimMediaControls() : mClearFaceOnFade(false), mCurrentRate(0.0), mMovieDuration(0.0), - mUpdatePercent(0) + mTargetObjectID(LLUUID::null), + mTargetObjectFace(0), + mTargetImplID(LLUUID::null), + mTargetObjectNormal(LLVector3::zero), + mZoomObjectID(LLUUID::null), + mZoomObjectFace(0), + mVolumeSliderVisible(0) { mCommitCallbackRegistrar.add("MediaCtrl.Close", boost::bind(&LLPanelPrimMediaControls::onClickClose, this)); mCommitCallbackRegistrar.add("MediaCtrl.Back", boost::bind(&LLPanelPrimMediaControls::onClickBack, this)); mCommitCallbackRegistrar.add("MediaCtrl.Forward", boost::bind(&LLPanelPrimMediaControls::onClickForward, this)); mCommitCallbackRegistrar.add("MediaCtrl.Home", boost::bind(&LLPanelPrimMediaControls::onClickHome, this)); mCommitCallbackRegistrar.add("MediaCtrl.Stop", boost::bind(&LLPanelPrimMediaControls::onClickStop, this)); + mCommitCallbackRegistrar.add("MediaCtrl.MediaStop", boost::bind(&LLPanelPrimMediaControls::onClickMediaStop, this)); mCommitCallbackRegistrar.add("MediaCtrl.Reload", boost::bind(&LLPanelPrimMediaControls::onClickReload, this)); mCommitCallbackRegistrar.add("MediaCtrl.Play", boost::bind(&LLPanelPrimMediaControls::onClickPlay, this)); mCommitCallbackRegistrar.add("MediaCtrl.Pause", boost::bind(&LLPanelPrimMediaControls::onClickPause, this)); @@ -101,7 +113,12 @@ LLPanelPrimMediaControls::LLPanelPrimMediaControls() : mCommitCallbackRegistrar.add("MediaCtrl.JumpProgress", boost::bind(&LLPanelPrimMediaControls::onCommitSlider, this)); mCommitCallbackRegistrar.add("MediaCtrl.CommitVolumeUp", boost::bind(&LLPanelPrimMediaControls::onCommitVolumeUp, this)); mCommitCallbackRegistrar.add("MediaCtrl.CommitVolumeDown", boost::bind(&LLPanelPrimMediaControls::onCommitVolumeDown, this)); + mCommitCallbackRegistrar.add("MediaCtrl.Volume", boost::bind(&LLPanelPrimMediaControls::onCommitVolumeSlider, this)); mCommitCallbackRegistrar.add("MediaCtrl.ToggleMute", boost::bind(&LLPanelPrimMediaControls::onToggleMute, this)); + mCommitCallbackRegistrar.add("MediaCtrl.ShowVolumeSlider", boost::bind(&LLPanelPrimMediaControls::showVolumeSlider, this)); + mCommitCallbackRegistrar.add("MediaCtrl.HideVolumeSlider", boost::bind(&LLPanelPrimMediaControls::hideVolumeSlider, this)); + mCommitCallbackRegistrar.add("MediaCtrl.SkipBack", boost::bind(&LLPanelPrimMediaControls::onClickSkipBack, this)); + mCommitCallbackRegistrar.add("MediaCtrl.SkipForward", boost::bind(&LLPanelPrimMediaControls::onClickSkipForward, this)); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_prim_media_controls.xml"); mInactivityTimer.reset(); @@ -110,37 +127,92 @@ LLPanelPrimMediaControls::LLPanelPrimMediaControls() : mScrollState = SCROLL_NONE; mPanelHandle.bind(this); + + mInactiveTimeout = gSavedSettings.getF32("MediaControlTimeout"); + mControlFadeTime = gSavedSettings.getF32("MediaControlFadeTime"); } + LLPanelPrimMediaControls::~LLPanelPrimMediaControls() { } BOOL LLPanelPrimMediaControls::postBuild() { - LLButton* scroll_up_ctrl = getChild<LLButton>("scrollup"); - scroll_up_ctrl->setClickedCallback(onScrollUp, this); - scroll_up_ctrl->setHeldDownCallback(onScrollUpHeld, this); - scroll_up_ctrl->setMouseUpCallback(onScrollStop, this); - LLButton* scroll_left_ctrl = getChild<LLButton>("scrollleft"); - scroll_left_ctrl->setClickedCallback(onScrollLeft, this); - scroll_left_ctrl->setHeldDownCallback(onScrollLeftHeld, this); - scroll_left_ctrl->setMouseUpCallback(onScrollStop, this); - LLButton* scroll_right_ctrl = getChild<LLButton>("scrollright"); - scroll_right_ctrl->setClickedCallback(onScrollRight, this); - scroll_right_ctrl->setHeldDownCallback(onScrollRightHeld, this); - scroll_right_ctrl->setMouseUpCallback(onScrollStop, this); - LLButton* scroll_down_ctrl = getChild<LLButton>("scrolldown"); - scroll_down_ctrl->setClickedCallback(onScrollDown, this); - scroll_down_ctrl->setHeldDownCallback(onScrollDownHeld, this); - scroll_down_ctrl->setMouseUpCallback(onScrollStop, this); + mMediaRegion = getChild<LLView>("media_region"); + mBackCtrl = getChild<LLUICtrl>("back"); + mFwdCtrl = getChild<LLUICtrl>("fwd"); + mReloadCtrl = getChild<LLUICtrl>("reload"); + mPlayCtrl = getChild<LLUICtrl>("play"); + mPauseCtrl = getChild<LLUICtrl>("pause"); + mStopCtrl = getChild<LLUICtrl>("stop"); + mMediaStopCtrl = getChild<LLUICtrl>("media_stop"); + mHomeCtrl = getChild<LLUICtrl>("home"); + mUnzoomCtrl = getChild<LLUICtrl>("close"); // This is actually "unzoom" + mOpenCtrl = getChild<LLUICtrl>("new_window"); + mZoomCtrl = getChild<LLUICtrl>("zoom_frame"); + mMediaProgressPanel = getChild<LLPanel>("media_progress_indicator"); + mMediaProgressBar = getChild<LLProgressBar>("media_progress_bar"); + mMediaAddressCtrl = getChild<LLUICtrl>("media_address"); + mMediaAddress = getChild<LLUICtrl>("media_address_url"); + mMediaPlaySliderPanel = getChild<LLUICtrl>("media_play_position"); + mMediaPlaySliderCtrl = getChild<LLUICtrl>("media_play_slider"); + mSkipFwdCtrl = getChild<LLUICtrl>("skip_forward"); + mSkipBackCtrl = getChild<LLUICtrl>("skip_back"); + mVolumeCtrl = getChild<LLUICtrl>("media_volume"); + mMuteBtn = getChild<LLButton>("media_mute_button"); + mVolumeSliderCtrl = getChild<LLSliderCtrl>("volume_slider"); + mWhitelistIcon = getChild<LLIconCtrl>("media_whitelist_flag"); + mSecureLockIcon = getChild<LLIconCtrl>("media_secure_lock_flag"); + mMediaControlsStack = getChild<LLLayoutStack>("media_controls"); + mLeftBookend = getChild<LLUICtrl>("left_bookend"); + mRightBookend = getChild<LLUICtrl>("right_bookend"); + mBackgroundImage = LLUI::getUIImage(getString("control_background_image_name")); + mVolumeSliderBackgroundImage = LLUI::getUIImage(getString("control_background_image_name")); + LLStringUtil::convertToF32(getString("skip_step"), mSkipStep); + LLStringUtil::convertToS32(getString("min_width"), mMinWidth); + LLStringUtil::convertToS32(getString("min_height"), mMinHeight); + LLStringUtil::convertToF32(getString("zoom_near_padding"), mZoomNearPadding); + LLStringUtil::convertToF32(getString("zoom_medium_padding"), mZoomMediumPadding); + LLStringUtil::convertToF32(getString("zoom_far_padding"), mZoomFarPadding); + LLStringUtil::convertToS32(getString("top_world_view_avoid_zone"), mTopWorldViewAvoidZone); + + // These are currently removed...but getChild creates a "dummy" widget. + // This class handles them missing. + mMediaPanelScroll = findChild<LLUICtrl>("media_panel_scroll"); + mScrollUpCtrl = findChild<LLButton>("scrollup"); + mScrollLeftCtrl = findChild<LLButton>("scrollleft"); + mScrollRightCtrl = findChild<LLButton>("scrollright"); + mScrollDownCtrl = findChild<LLButton>("scrolldown"); + + if (mScrollUpCtrl) + { + mScrollUpCtrl->setClickedCallback(onScrollUp, this); + mScrollUpCtrl->setHeldDownCallback(onScrollUpHeld, this); + mScrollUpCtrl->setMouseUpCallback(onScrollStop, this); + } + if (mScrollLeftCtrl) + { + mScrollLeftCtrl->setClickedCallback(onScrollLeft, this); + mScrollLeftCtrl->setHeldDownCallback(onScrollLeftHeld, this); + mScrollLeftCtrl->setMouseUpCallback(onScrollStop, this); + } + if (mScrollRightCtrl) + { + mScrollRightCtrl->setClickedCallback(onScrollRight, this); + mScrollRightCtrl->setHeldDownCallback(onScrollRightHeld, this); + mScrollRightCtrl->setMouseUpCallback(onScrollStop, this); + } + if (mScrollDownCtrl) + { + mScrollDownCtrl->setClickedCallback(onScrollDown, this); + mScrollDownCtrl->setHeldDownCallback(onScrollDownHeld, this); + mScrollDownCtrl->setMouseUpCallback(onScrollStop, this); + } + + mMediaAddress->setFocusReceivedCallback(boost::bind(&LLPanelPrimMediaControls::onInputURL, _1, this )); - LLUICtrl* media_address = getChild<LLUICtrl>("media_address"); - media_address->setFocusReceivedCallback(boost::bind(&LLPanelPrimMediaControls::onInputURL, _1, this )); - mInactiveTimeout = gSavedSettings.getF32("MediaControlTimeout"); - mControlFadeTime = gSavedSettings.getF32("MediaControlFadeTime"); - mCurrentZoom = ZOOM_NONE; - // clicks on HUD buttons do not remove keyboard focus from media + // clicks on buttons do not remove keyboard focus from media setIsChrome(TRUE); return TRUE; } @@ -149,11 +221,15 @@ void LLPanelPrimMediaControls::setMediaFace(LLPointer<LLViewerObject> objectp, S { if (media_impl.notNull() && objectp.notNull()) { + LLUUID prev_id = mTargetImplID; mTargetImplID = media_impl->getMediaTextureID(); mTargetObjectID = objectp->getID(); mTargetObjectFace = face; mTargetObjectNormal = pick_normal; mClearFaceOnFade = false; + + if (prev_id != mTargetImplID) + mVolumeSliderCtrl->setValue(media_impl->getVolume()); } else { @@ -206,13 +282,10 @@ LLPluginClassMedia* LLPanelPrimMediaControls::getTargetMediaPlugin() void LLPanelPrimMediaControls::updateShape() { - const S32 MIN_HUD_WIDTH=400; - const S32 MIN_HUD_HEIGHT=120; - LLViewerMediaImpl* media_impl = getTargetMediaImpl(); LLViewerObject* objectp = getTargetObject(); - if(!media_impl) + if(!media_impl || gFloaterTools->getVisible()) { setVisible(FALSE); return; @@ -228,7 +301,11 @@ void LLPanelPrimMediaControls::updateShape() bool can_navigate = parcel->getMediaAllowNavigate(); bool enabled = false; - bool has_focus = media_impl->hasFocus(); + bool is_zoomed = (mCurrentZoom != ZOOM_NONE) && (mTargetObjectID == mZoomObjectID) && (mTargetObjectFace == mZoomObjectFace); + // There is no such thing as "has_focus" being different from normal controls set + // anymore (as of user feedback from bri 10/09). So we cheat here and force 'has_focus' + // to 'true' (or, actually, we use a setting) + bool has_focus = (gSavedSettings.getBOOL("PrimMediaControlsUseHoverControlSet")) ? media_impl->hasFocus() : true; setVisible(enabled); if (objectp) @@ -237,95 +314,76 @@ void LLPanelPrimMediaControls::updateShape() LLMediaEntry *media_data = objectp->getTE(mTargetObjectFace)->getMediaData(); if (media_data && NULL != dynamic_cast<LLVOVolume*>(objectp)) { - // Don't show the media HUD if we do not have permissions + // Don't show the media controls if we do not have permissions enabled = dynamic_cast<LLVOVolume*>(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 // - LLUICtrl* back_ctrl = getChild<LLUICtrl>("back"); - LLUICtrl* fwd_ctrl = getChild<LLUICtrl>("fwd"); - LLUICtrl* reload_ctrl = getChild<LLUICtrl>("reload"); - LLUICtrl* play_ctrl = getChild<LLUICtrl>("play"); - LLUICtrl* pause_ctrl = getChild<LLUICtrl>("pause"); - LLUICtrl* stop_ctrl = getChild<LLUICtrl>("stop"); - LLUICtrl* media_stop_ctrl = getChild<LLUICtrl>("media_stop"); - LLUICtrl* home_ctrl = getChild<LLUICtrl>("home"); - LLUICtrl* close_ctrl = getChild<LLUICtrl>("close"); - LLUICtrl* open_ctrl = getChild<LLUICtrl>("new_window"); - LLUICtrl* zoom_ctrl = getChild<LLUICtrl>("zoom_frame"); - LLPanel* media_loading_panel = getChild<LLPanel>("media_progress_indicator"); - LLUICtrl* media_address_ctrl = getChild<LLUICtrl>("media_address"); - LLUICtrl* media_play_slider_panel = getChild<LLUICtrl>("media_play_position"); - LLUICtrl* media_play_slider_ctrl = getChild<LLUICtrl>("media_play_slider"); - LLUICtrl* volume_ctrl = getChild<LLUICtrl>("media_volume"); - LLButton* volume_btn = getChild<LLButton>("media_volume_button"); - LLUICtrl* volume_up_ctrl = getChild<LLUICtrl>("volume_up"); - LLUICtrl* volume_down_ctrl = getChild<LLUICtrl>("volume_down"); - LLIconCtrl* whitelist_icon = getChild<LLIconCtrl>("media_whitelist_flag"); - LLIconCtrl* secure_lock_icon = getChild<LLIconCtrl>("media_secure_lock_flag"); - LLUICtrl* media_panel_scroll = getChild<LLUICtrl>("media_panel_scroll"); - LLUICtrl* scroll_up_ctrl = getChild<LLUICtrl>("scrollup"); - LLUICtrl* scroll_left_ctrl = getChild<LLUICtrl>("scrollleft"); - LLUICtrl* scroll_right_ctrl = getChild<LLUICtrl>("scrollright"); - LLUICtrl* scroll_down_ctrl = getChild<LLUICtrl>("scrolldown"); - // 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. - back_ctrl->setVisible(has_focus); - fwd_ctrl->setVisible(has_focus); - reload_ctrl->setVisible(has_focus); - stop_ctrl->setVisible(false); - home_ctrl->setVisible(has_focus); - close_ctrl->setVisible(has_focus); - open_ctrl->setVisible(true); - media_address_ctrl->setVisible(has_focus && !mini_controls); - media_play_slider_panel->setVisible(has_focus && !mini_controls); - volume_ctrl->setVisible(false); - volume_up_ctrl->setVisible(false); - volume_down_ctrl->setVisible(false); + mBackCtrl->setVisible(has_focus); + mFwdCtrl->setVisible(has_focus); + mReloadCtrl->setVisible(has_focus); + mStopCtrl->setVisible(false); + mHomeCtrl->setVisible(has_focus); + mZoomCtrl->setVisible(!is_zoomed); + mUnzoomCtrl->setVisible(is_zoomed); + mOpenCtrl->setVisible(true); + mMediaAddressCtrl->setVisible(has_focus && !mini_controls); + mMediaPlaySliderPanel->setVisible(has_focus && !mini_controls); + mVolumeCtrl->setVisible(false); - whitelist_icon->setVisible(!mini_controls && (media_data)?media_data->getWhiteListEnable():false); + mWhitelistIcon->setVisible(!mini_controls && (media_data)?media_data->getWhiteListEnable():false); // Disable zoom if HUD - zoom_ctrl->setEnabled(!objectp->isHUDAttachment()); - secure_lock_icon->setVisible(false); + mZoomCtrl->setEnabled(!is_hud); + mUnzoomCtrl->setEnabled(!is_hud); + mSecureLockIcon->setVisible(false); mCurrentURL = media_impl->getCurrentMediaURL(); - back_ctrl->setEnabled((media_impl != NULL) && media_impl->canNavigateBack() && can_navigate); - fwd_ctrl->setEnabled((media_impl != NULL) && media_impl->canNavigateForward() && can_navigate); - stop_ctrl->setEnabled(has_focus && can_navigate); - home_ctrl->setEnabled(has_focus && can_navigate); + mBackCtrl->setEnabled((media_impl != NULL) && media_impl->canNavigateBack() && can_navigate); + mFwdCtrl->setEnabled((media_impl != NULL) && media_impl->canNavigateForward() && can_navigate); + 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()) { - reload_ctrl->setEnabled(FALSE); - reload_ctrl->setVisible(FALSE); - media_stop_ctrl->setVisible(has_focus); - home_ctrl->setVisible(FALSE); - back_ctrl->setEnabled(has_focus); - fwd_ctrl->setEnabled(has_focus); - media_address_ctrl->setVisible(false); - media_address_ctrl->setEnabled(false); - media_play_slider_panel->setVisible(!mini_controls); - media_play_slider_panel->setEnabled(!mini_controls); - - volume_ctrl->setVisible(has_focus); - volume_up_ctrl->setVisible(has_focus); - volume_down_ctrl->setVisible(has_focus); - volume_ctrl->setEnabled(has_focus); - - whitelist_icon->setVisible(false); - secure_lock_icon->setVisible(false); - scroll_up_ctrl->setVisible(false); - scroll_left_ctrl->setVisible(false); - scroll_right_ctrl->setVisible(false); - scroll_down_ctrl->setVisible(false); - media_panel_scroll->setVisible(false); - + mReloadCtrl->setEnabled(false); + mReloadCtrl->setVisible(false); + mMediaStopCtrl->setVisible(has_focus); + mHomeCtrl->setVisible(has_focus); + mBackCtrl->setVisible(false); + mFwdCtrl->setVisible(false); + mMediaAddressCtrl->setVisible(false); + mMediaAddressCtrl->setEnabled(false); + mMediaPlaySliderPanel->setVisible(has_focus && !mini_controls); + mMediaPlaySliderPanel->setEnabled(has_focus && !mini_controls); + mSkipFwdCtrl->setVisible(has_focus && !mini_controls); + mSkipFwdCtrl->setEnabled(has_focus && !mini_controls); + mSkipBackCtrl->setVisible(has_focus && !mini_controls); + mSkipBackCtrl->setEnabled(has_focus && !mini_controls); + + mVolumeCtrl->setVisible(has_focus); + mVolumeCtrl->setEnabled(has_focus); + mVolumeSliderCtrl->setEnabled(has_focus && shouldVolumeSliderBeVisible()); + mVolumeSliderCtrl->setVisible(has_focus && shouldVolumeSliderBeVisible()); + + mWhitelistIcon->setVisible(false); + mSecureLockIcon->setVisible(false); + if (mMediaPanelScroll) + { + mMediaPanelScroll->setVisible(false); + mScrollUpCtrl->setVisible(false); + mScrollDownCtrl->setVisible(false); + mScrollRightCtrl->setVisible(false); + mScrollDownCtrl->setVisible(false); + } + F32 volume = media_impl->getVolume(); // movie's url changed if(mCurrentURL!=mPreviousURL) @@ -333,61 +391,52 @@ void LLPanelPrimMediaControls::updateShape() mMovieDuration = media_plugin->getDuration(); mPreviousURL = mCurrentURL; } - + if(mMovieDuration == 0) { mMovieDuration = media_plugin->getDuration(); - media_play_slider_ctrl->setValue(0); - media_play_slider_ctrl->setEnabled(false); + mMediaPlaySliderCtrl->setValue(0); + mMediaPlaySliderCtrl->setEnabled(false); } // TODO: What if it's not fully loaded - + if(mUpdateSlider && mMovieDuration!= 0) { F64 current_time = media_plugin->getCurrentTime(); F32 percent = current_time / mMovieDuration; - media_play_slider_ctrl->setValue(percent); - media_play_slider_ctrl->setEnabled(true); + mMediaPlaySliderCtrl->setValue(percent); + mMediaPlaySliderCtrl->setEnabled(true); } - + // video vloume if(volume <= 0.0) { - volume_up_ctrl->setEnabled(TRUE); - volume_down_ctrl->setEnabled(FALSE); - media_impl->setVolume(0.0); - volume_btn->setToggleState(true); + mMuteBtn->setToggleState(true); } else if (volume >= 1.0) { - volume_up_ctrl->setEnabled(FALSE); - volume_down_ctrl->setEnabled(TRUE); - media_impl->setVolume(1.0); - volume_btn->setToggleState(false); + mMuteBtn->setToggleState(false); } else { - volume_up_ctrl->setEnabled(TRUE); - volume_down_ctrl->setEnabled(TRUE); + mMuteBtn->setToggleState(false); } - + switch(result) { case LLPluginClassMediaOwner::MEDIA_PLAYING: - play_ctrl->setEnabled(FALSE); - play_ctrl->setVisible(FALSE); - pause_ctrl->setEnabled(TRUE); - pause_ctrl->setVisible(has_focus); - media_stop_ctrl->setEnabled(TRUE); + mPlayCtrl->setEnabled(FALSE); + mPlayCtrl->setVisible(FALSE); + mPauseCtrl->setEnabled(TRUE); + mPauseCtrl->setVisible(has_focus); break; case LLPluginClassMediaOwner::MEDIA_PAUSED: default: - pause_ctrl->setEnabled(FALSE); - pause_ctrl->setVisible(FALSE); - play_ctrl->setEnabled(TRUE); - play_ctrl->setVisible(has_focus); - media_stop_ctrl->setEnabled(FALSE); + mPauseCtrl->setEnabled(FALSE); + mPauseCtrl->setVisible(FALSE); + mPlayCtrl->setEnabled(TRUE); + mPlayCtrl->setVisible(has_focus); break; } } @@ -401,78 +450,80 @@ void LLPanelPrimMediaControls::updateShape() { mCurrentURL.clear(); } - - play_ctrl->setVisible(FALSE); - pause_ctrl->setVisible(FALSE); - media_stop_ctrl->setVisible(FALSE); - media_address_ctrl->setVisible(has_focus && !mini_controls); - media_address_ctrl->setEnabled(has_focus && !mini_controls); - media_play_slider_panel->setVisible(FALSE); - media_play_slider_panel->setEnabled(FALSE); - - volume_ctrl->setVisible(FALSE); - volume_up_ctrl->setVisible(FALSE); - volume_down_ctrl->setVisible(FALSE); - volume_ctrl->setEnabled(FALSE); - volume_up_ctrl->setEnabled(FALSE); - volume_down_ctrl->setEnabled(FALSE); - - scroll_up_ctrl->setVisible(has_focus); - scroll_left_ctrl->setVisible(has_focus); - scroll_right_ctrl->setVisible(has_focus); - scroll_down_ctrl->setVisible(has_focus); - media_panel_scroll->setVisible(has_focus); + + mPlayCtrl->setVisible(FALSE); + mPauseCtrl->setVisible(FALSE); + mMediaStopCtrl->setVisible(FALSE); + mMediaAddressCtrl->setVisible(has_focus && !mini_controls); + mMediaAddressCtrl->setEnabled(has_focus && !mini_controls); + mMediaPlaySliderPanel->setVisible(FALSE); + mMediaPlaySliderPanel->setEnabled(FALSE); + mSkipFwdCtrl->setVisible(FALSE); + mSkipFwdCtrl->setEnabled(FALSE); + mSkipBackCtrl->setVisible(FALSE); + mSkipBackCtrl->setEnabled(FALSE); + + mVolumeCtrl->setVisible(FALSE); + mVolumeSliderCtrl->setVisible(FALSE); + mVolumeCtrl->setEnabled(FALSE); + mVolumeSliderCtrl->setEnabled(FALSE); + + if (mMediaPanelScroll) + { + mMediaPanelScroll->setVisible(has_focus); + mScrollUpCtrl->setVisible(has_focus); + mScrollDownCtrl->setVisible(has_focus); + mScrollRightCtrl->setVisible(has_focus); + mScrollDownCtrl->setVisible(has_focus); + } // TODO: get the secure lock bool from media plug in std::string prefix = std::string("https://"); std::string test_prefix = mCurrentURL.substr(0, prefix.length()); LLStringUtil::toLower(test_prefix); if(test_prefix == prefix) { - secure_lock_icon->setVisible(has_focus); + mSecureLockIcon->setVisible(has_focus); } - + if(mCurrentURL!=mPreviousURL) { setCurrentURL(); mPreviousURL = mCurrentURL; } - + if(result == LLPluginClassMediaOwner::MEDIA_LOADING) { - reload_ctrl->setEnabled(FALSE); - reload_ctrl->setVisible(FALSE); - stop_ctrl->setEnabled(TRUE); - stop_ctrl->setVisible(has_focus); + mReloadCtrl->setEnabled(FALSE); + mReloadCtrl->setVisible(FALSE); + mStopCtrl->setEnabled(TRUE); + mStopCtrl->setVisible(has_focus); } else { - reload_ctrl->setEnabled(TRUE); - reload_ctrl->setVisible(has_focus); - stop_ctrl->setEnabled(FALSE); - stop_ctrl->setVisible(FALSE); + mReloadCtrl->setEnabled(TRUE); + mReloadCtrl->setVisible(has_focus); + mStopCtrl->setEnabled(FALSE); + mStopCtrl->setVisible(FALSE); } } - + if(media_plugin) { // // Handle progress bar // - mUpdatePercent = media_plugin->getProgressPercent(); - if(mUpdatePercent<100.0f) - { - media_loading_panel->setVisible(true); - getChild<LLProgressBar>("media_progress_bar")->setPercent(mUpdatePercent); - gFocusMgr.setTopCtrl(media_loading_panel); + if(LLPluginClassMediaOwner::MEDIA_LOADING == media_plugin->getStatus()) + { + mMediaProgressPanel->setVisible(true); + mMediaProgressBar->setPercent(media_plugin->getProgressPercent()); } else { - media_loading_panel->setVisible(false); - gFocusMgr.setTopCtrl(NULL); + mMediaProgressPanel->setVisible(false); } } - + if(media_impl) { // @@ -480,44 +531,43 @@ 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 // - glh::matrix4f mat = glh_get_current_projection()*glh_get_current_modelview(); std::vector<LLVector3>::iterator vert_it; std::vector<LLVector3>::iterator vert_end; std::vector<LLVector3> 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[] = @@ -531,17 +581,27 @@ void LLPanelPrimMediaControls::updateShape() 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])); + vect_face.push_back(vo->volumePositionToAgent(vert[i])); } } vert_it = vect_face.begin(); vert_end = vect_face.end(); - + + glh::matrix4f mat; + if (!is_hud) + { + mat = glh_get_current_projection() * glh_get_current_modelview(); + } + else { + glh::matrix4f proj, modelview; + if (get_hud_matrices(proj, modelview)) + mat = proj * modelview; + } LLVector3 min = LLVector3(1,1,1); LLVector3 max = LLVector3(-1,-1,-1); for(; vert_it != vert_end; ++vert_it) @@ -549,47 +609,60 @@ 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->getWorldViewWidth() * (min.mV[VX] + 1.f) * 0.5f); - screen_min.mY = llround((F32)gViewerWindow->getWorldViewHeight() * (min.mV[VY] + 1.f) * 0.5f); - + + // convert screenspace bbox to pixels (in screen coords) + LLRect window_rect = gViewerWindow->getWorldViewRectScaled(); + LLCoordGL screen_min; + screen_min.mX = llround((F32)window_rect.getWidth() * (min.mV[VX] + 1.f) * 0.5f); + screen_min.mY = llround((F32)window_rect.getHeight() * (min.mV[VY] + 1.f) * 0.5f); + LLCoordGL screen_max; - screen_max.mX = llround((F32)gViewerWindow->getWorldViewWidth() * (max.mV[VX] + 1.f) * 0.5f); - screen_max.mY = llround((F32)gViewerWindow->getWorldViewHeight() * (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; - getParent()->screenRectToLocal(LLRect(screen_min.mX, screen_max.mY, screen_max.mX, screen_min.mY), &media_controls_rect); - LLView* media_region = getChild<LLView>("media_region"); - media_controls_rect.mLeft -= media_region->getRect().mLeft; - media_controls_rect.mBottom -= media_region->getRect().mBottom; - media_controls_rect.mTop += getRect().getHeight() - media_region->getRect().mTop; - media_controls_rect.mRight += getRect().getWidth() - media_region->getRect().mRight; - - LLRect old_hud_rect = media_controls_rect; - // keep all parts of HUD on-screen - media_controls_rect.intersectWith(getParent()->getLocalRect()); - - // clamp to minimum size, keeping centered - media_controls_rect.setCenterAndSize(media_controls_rect.getCenterX(), media_controls_rect.getCenterY(), - llmax(MIN_HUD_WIDTH, media_controls_rect.getWidth()), llmax(MIN_HUD_HEIGHT, media_controls_rect.getHeight())); - - setShape(media_controls_rect, true); - + screen_max.mX = llround((F32)window_rect.getWidth() * (max.mV[VX] + 1.f) * 0.5f); + screen_max.mY = llround((F32)window_rect.getHeight() * (max.mV[VY] + 1.f) * 0.5f); + + // grow panel so that screenspace bounding box fits inside "media_region" element of panel + LLRect media_panel_rect; + // Get the height of the controls (less the volume slider) + S32 controls_height = mMediaControlsStack->getRect().getHeight() - mVolumeSliderCtrl->getRect().getHeight(); + getParent()->screenRectToLocal(LLRect(screen_min.mX, screen_max.mY, screen_max.mX, screen_min.mY), &media_panel_rect); + media_panel_rect.mTop += controls_height; + + // keep all parts of panel on-screen + // Area of the top of the world view to avoid putting the controls + window_rect.mTop -= mTopWorldViewAvoidZone; + // Don't include "spacing" bookends on left & right of the media controls + window_rect.mLeft -= mLeftBookend->getRect().getWidth(); + window_rect.mRight += mRightBookend->getRect().getWidth(); + // Don't include the volume slider + window_rect.mBottom -= mVolumeSliderCtrl->getRect().getHeight(); + media_panel_rect.intersectWith(window_rect); + + // clamp to minimum size, keeping rect inside window + S32 centerX = media_panel_rect.getCenterX(); + S32 centerY = media_panel_rect.getCenterY(); + // Shrink screen rect by min width and height, to ensure containment + window_rect.stretch(-mMinWidth/2, -mMinHeight/2); + window_rect.clampPointToRect(centerX, centerY); + media_panel_rect.setCenterAndSize(centerX, centerY, + llmax(mMinWidth, media_panel_rect.getWidth()), + llmax(mMinHeight, media_panel_rect.getHeight())); + + // Finally set the size of the panel + setShape(media_panel_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; @@ -614,7 +687,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); } } } @@ -622,13 +695,13 @@ void LLPanelPrimMediaControls::updateShape() /*virtual*/ void LLPanelPrimMediaControls::draw() { - F32 alpha = 1.f; + F32 alpha = getDrawContext().mAlpha; if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); - alpha = llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); + alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); - if(mFadeTimer.getElapsedTimeF32() >= mControlFadeTime) + if(time >= mControlFadeTime) { if(mClearFaceOnFade) { @@ -638,6 +711,7 @@ void LLPanelPrimMediaControls::draw() setVisible(FALSE); mClearFaceOnFade = false; + mVolumeSliderVisible = 0; mTargetImplID = LLUUID::null; mTargetObjectID = LLUUID::null; mTargetObjectFace = 0; @@ -645,6 +719,36 @@ void LLPanelPrimMediaControls::draw() } } + // Build rect for icon area in coord system of this panel + // Assumes layout_stack is a direct child of this panel + mMediaControlsStack->updateLayout(); + + // adjust for layout stack spacing + S32 space = mMediaControlsStack->getPanelSpacing() + 2; + LLRect controls_bg_area = mMediaControlsStack->getRect(); + + controls_bg_area.mTop += space + 2; + + // adjust to ignore space from volume slider + controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); + + // adjust to ignore space from left bookend padding + controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; + + // ignore space from right bookend padding + controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; + + // draw control background UI image + mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); + + // draw volume slider background UI image + if (mVolumeSliderCtrl->getVisible()) + { + LLRect volume_slider_rect; + screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); + mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); + } + { LLViewDrawContext context(alpha); LLPanel::draw(); @@ -687,25 +791,29 @@ bool LLPanelPrimMediaControls::isMouseOver() S32 x, y; getWindow()->getCursorPosition(&cursor_pos_window); getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl); - - LLPanel* controls_panel = NULL; - controls_panel = getChild<LLPanel>("media_hover_controls"); - if(controls_panel && !controls_panel->getVisible()) - { - // The hover controls aren't visible -- use the focused controls instead. - controls_panel = getChild<LLPanel>("media_focused_controls"); - } - - if(controls_panel && controls_panel->getVisible()) + + if(mMediaControlsStack->getVisible()) { - controls_panel->screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &x, &y); + mMediaControlsStack->screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &x, &y); - LLView *hit_child = controls_panel->childFromPoint(x, y); - if(hit_child) + LLView *hit_child = mMediaControlsStack->childFromPoint(x, y); + if(hit_child && hit_child->getVisible()) { // This was useful for debugging both coordinate translation and view hieararchy problems... -// llinfos << "mouse coords: " << x << ", " << y << " hit child " << hit_child->getName() << llendl; - result = true; + // llinfos << "mouse coords: " << x << ", " << y << " hit child " << hit_child->getName() << llendl; + + // This will be a direct child of the LLLayoutStack, which should be a layout_panel. + // These may not shown/hidden by the logic in updateShape(), so we need to do another hit test on the children of the layout panel, + // which are the actual controls. + hit_child->screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &x, &y); + + LLView *hit_child_2 = hit_child->childFromPoint(x, y); + if(hit_child_2 && hit_child_2->getVisible()) + { + // This was useful for debugging both coordinate translation and view hieararchy problems... + // llinfos << " mouse coords: " << x << ", " << y << " hit child 2 " << hit_child_2->getName() << llendl; + result = true; + } } } } @@ -721,8 +829,8 @@ void LLPanelPrimMediaControls::onClickClose() void LLPanelPrimMediaControls::close() { + resetZoomLevel(true); LLViewerMediaFocus::getInstance()->clearFocus(); - resetZoomLevel(); setVisible(FALSE); } @@ -744,7 +852,7 @@ void LLPanelPrimMediaControls::onClickForward() focusOnTarget(); LLViewerMediaImpl* impl = getTargetMediaImpl(); - + if (impl) { impl->navigateForward(); @@ -817,16 +925,56 @@ void LLPanelPrimMediaControls::onClickStop() if(impl) { + impl->navigateStop(); + } +} + +void LLPanelPrimMediaControls::onClickMediaStop() +{ + focusOnTarget(); + + LLViewerMediaImpl* impl = getTargetMediaImpl(); + + if(impl) + { impl->stop(); } } -void LLPanelPrimMediaControls::onClickZoom() +void LLPanelPrimMediaControls::onClickSkipBack() { focusOnTarget(); - nextZoomLevel(); + LLViewerMediaImpl* impl =getTargetMediaImpl(); + + if (impl) + { + impl->skipBack(mSkipStep); + } } + +void LLPanelPrimMediaControls::onClickSkipForward() +{ + focusOnTarget(); + + LLViewerMediaImpl* impl = getTargetMediaImpl(); + + if (impl) + { + impl->skipForward(mSkipStep); + } +} + +void LLPanelPrimMediaControls::onClickZoom() +{ + focusOnTarget(); + + if(mCurrentZoom == ZOOM_NONE) + { + nextZoomLevel(); + } +} + void LLPanelPrimMediaControls::nextZoomLevel() { int index = 0; @@ -843,12 +991,15 @@ void LLPanelPrimMediaControls::nextZoomLevel() updateZoom(); } -void LLPanelPrimMediaControls::resetZoomLevel() +void LLPanelPrimMediaControls::resetZoomLevel(bool reset_camera) { if(mCurrentZoom != ZOOM_NONE) { mCurrentZoom = ZOOM_NONE; - updateZoom(); + if(reset_camera) + { + updateZoom(); + } } } @@ -864,17 +1015,17 @@ void LLPanelPrimMediaControls::updateZoom() } case ZOOM_FAR: { - zoom_padding = ZOOM_FAR_PADDING; + zoom_padding = mZoomFarPadding; break; } case ZOOM_MEDIUM: { - zoom_padding = ZOOM_MEDIUM_PADDING; + zoom_padding = mZoomMediumPadding; break; } case ZOOM_NEAR: { - zoom_padding = ZOOM_NEAR_PADDING; + zoom_padding = mZoomNearPadding; break; } default: @@ -884,9 +1035,17 @@ void LLPanelPrimMediaControls::updateZoom() } } - if (zoom_padding > 0.0f) - LLViewerMediaFocus::setCameraZoom(getTargetObject(), mTargetObjectNormal, zoom_padding); + if (zoom_padding > 0.0f) + { + // since we only zoom into medium for now, always set zoom_in constraint to true + LLViewerMediaFocus::setCameraZoom(getTargetObject(), mTargetObjectNormal, zoom_padding, true); + } + + // Remember the object ID/face we zoomed into, so we can update the zoom icon appropriately + mZoomObjectID = mTargetObjectID; + mZoomObjectFace = mTargetObjectFace; } + void LLPanelPrimMediaControls::onScrollUp(void* user_data) { LLPanelPrimMediaControls* this_panel = static_cast<LLPanelPrimMediaControls*> (user_data); @@ -970,8 +1129,7 @@ void LLPanelPrimMediaControls::onCommitURL() { focusOnTarget(); - LLUICtrl *media_address_ctrl = getChild<LLUICtrl>("media_address_url"); - std::string url = media_address_ctrl->getValue().asString(); + std::string url = mMediaAddress->getValue().asString(); if(getTargetMediaImpl() && !url.empty()) { getTargetMediaImpl()->navigateTo( url, "", true); @@ -1000,19 +1158,18 @@ void LLPanelPrimMediaControls::onInputURL(LLFocusableElement* caller, void *user void LLPanelPrimMediaControls::setCurrentURL() { #ifdef USE_COMBO_BOX_FOR_MEDIA_URL - LLComboBox* media_address_combo = getChild<LLComboBox>("media_address_combo"); - // redirects will navigate momentarily to about:blank, don't add to history - if (media_address_combo && mCurrentURL != "about:blank") - { - media_address_combo->remove(mCurrentURL); - media_address_combo->add(mCurrentURL, ADD_SORTED); - media_address_combo->selectByValue(mCurrentURL); - } +// LLComboBox* media_address_combo = getChild<LLComboBox>("media_address_combo"); +// // redirects will navigate momentarily to about:blank, don't add to history +// if (media_address_combo && mCurrentURL != "about:blank") +// { +// media_address_combo->remove(mCurrentURL); +// media_address_combo->add(mCurrentURL, ADD_SORTED); +// media_address_combo->selectByValue(mCurrentURL); +// } #else // USE_COMBO_BOX_FOR_MEDIA_URL - LLLineEditor* media_address_url = getChild<LLLineEditor>("media_address_url"); - if (media_address_url && mCurrentURL != "about:blank") + if (mMediaAddress && mCurrentURL != "about:blank") { - media_address_url->setValue(mCurrentURL); + mMediaAddress->setValue(mCurrentURL); } #endif // USE_COMBO_BOX_FOR_MEDIA_URL } @@ -1021,12 +1178,11 @@ void LLPanelPrimMediaControls::onCommitSlider() { focusOnTarget(); - LLSlider* media_play_slider_ctrl = getChild<LLSlider>("media_play_slider"); LLViewerMediaImpl* media_impl = getTargetMediaImpl(); if (media_impl) { // get slider value - F64 slider_value = media_play_slider_ctrl->getValue().asReal(); + F64 slider_value = mMediaPlaySliderCtrl->getValue().asReal(); if(slider_value <= 0.0) { media_impl->stop(); @@ -1055,7 +1211,7 @@ void LLPanelPrimMediaControls::onCommitVolumeUp() } media_impl->setVolume(volume); - getChild<LLButton>("media_volume")->setToggleState(false); + mMuteBtn->setToggleState(false); } } @@ -1075,10 +1231,20 @@ void LLPanelPrimMediaControls::onCommitVolumeDown() } media_impl->setVolume(volume); - getChild<LLButton>("media_volume")->setToggleState(false); + mMuteBtn->setToggleState(false); } } +void LLPanelPrimMediaControls::onCommitVolumeSlider() +{ + focusOnTarget(); + + LLViewerMediaImpl* media_impl = getTargetMediaImpl(); + if (media_impl) + { + media_impl->setVolume(mVolumeSliderCtrl->getValueF32()); + } +} void LLPanelPrimMediaControls::onToggleMute() { @@ -1093,10 +1259,29 @@ void LLPanelPrimMediaControls::onToggleMute() { media_impl->setVolume(0.0); } + else if (mVolumeSliderCtrl->getValueF32() == 0.0) + { + media_impl->setVolume(1.0); + mVolumeSliderCtrl->setValue(1.0); + } else { - media_impl->setVolume(0.5); + media_impl->setVolume(mVolumeSliderCtrl->getValueF32()); } } } +void LLPanelPrimMediaControls::showVolumeSlider() +{ + mVolumeSliderVisible++; +} + +void LLPanelPrimMediaControls::hideVolumeSlider() +{ + mVolumeSliderVisible--; +} + +bool LLPanelPrimMediaControls::shouldVolumeSliderBeVisible() +{ + return mVolumeSliderVisible > 0; +} |