Add background to media controls

This actually required some help from James and Richard.  Thanks, guys!

This adds custom-drawing of a background image underneath the
icons that make up the media controls in the layout stack.
In order to have this work, we had to publicize API in lllayoutstack
to force relayout to calculate the size.

I also did another cleanup pass ("Boy Scout Rule") that
squirreled away all pertinent controls into membed variables,
instead of doing a getChild() every time updateShape() is called.

Readjusted a bunch of components as well.
master
Rick Pasetto 2009-11-13 11:52:12 -08:00
parent 230f28080c
commit ca630bf6bb
4 changed files with 381 additions and 314 deletions

View File

@ -81,8 +81,8 @@ public:
S32 getNumPanels() { return mPanels.size(); }
void updatePanelAutoResize(const std::string& panel_name, BOOL auto_resize);
void updateLayout(BOOL force_resize = FALSE);
static void updateClass();
protected:
@ -92,7 +92,6 @@ protected:
private:
struct LayoutPanel;
void updateLayout(BOOL force_resize = FALSE);
void calcMinExtents();
S32 getDefaultHeight(S32 cur_height);
S32 getDefaultWidth(S32 cur_width);

View File

@ -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"
@ -84,8 +85,7 @@ LLPanelPrimMediaControls::LLPanelPrimMediaControls() :
mUpdateSlider(true),
mClearFaceOnFade(false),
mCurrentRate(0.0),
mMovieDuration(0.0),
mUpdatePercent(0)
mMovieDuration(0.0)
{
mCommitCallbackRegistrar.add("MediaCtrl.Close", boost::bind(&LLPanelPrimMediaControls::onClickClose, this));
mCommitCallbackRegistrar.add("MediaCtrl.Back", boost::bind(&LLPanelPrimMediaControls::onClickBack, this));
@ -117,37 +117,69 @@ LLPanelPrimMediaControls::~LLPanelPrimMediaControls()
BOOL LLPanelPrimMediaControls::postBuild()
{
LLButton* scroll_up_ctrl = getChild<LLButton>("scrollup");
if (scroll_up_ctrl)
mMediaRegion = getChild<LLView>("media_region"); assert(mMediaRegion);
mBackCtrl = getChild<LLUICtrl>("back"); assert(mBackCtrl);
mFwdCtrl = getChild<LLUICtrl>("fwd"); assert(mFwdCtrl);
mReloadCtrl = getChild<LLUICtrl>("reload"); assert(mReloadCtrl);
mPlayCtrl = getChild<LLUICtrl>("play"); assert(mPlayCtrl);
mPauseCtrl = getChild<LLUICtrl>("pause"); assert(mPauseCtrl);
mStopCtrl = getChild<LLUICtrl>("stop"); assert(mStopCtrl);
mMediaStopCtrl = getChild<LLUICtrl>("media_stop"); assert(mMediaStopCtrl);
mHomeCtrl = getChild<LLUICtrl>("home"); assert(mHomeCtrl);
mUnzoomCtrl = getChild<LLUICtrl>("close"); assert(mUnzoomCtrl); // This is actually "unzoom"
mOpenCtrl = getChild<LLUICtrl>("new_window"); assert(mOpenCtrl);
mZoomCtrl = getChild<LLUICtrl>("zoom_frame"); assert(mZoomCtrl);
mMediaProgressPanel = getChild<LLPanel>("media_progress_indicator"); assert(mMediaProgressPanel);
mMediaProgressBar = getChild<LLProgressBar>("media_progress_bar"); assert(mMediaProgressBar);
mMediaAddressCtrl = getChild<LLUICtrl>("media_address"); assert(mMediaAddressCtrl);
mMediaAddress = getChild<LLUICtrl>("media_address_url"); assert(mMediaAddress);
mMediaPlaySliderPanel = getChild<LLUICtrl>("media_play_position"); assert(mMediaPlaySliderPanel);
mMediaPlaySliderCtrl = getChild<LLUICtrl>("media_play_slider"); assert(mMediaPlaySliderCtrl);
mVolumeCtrl = getChild<LLUICtrl>("media_volume"); assert(mVolumeCtrl);
mVolumeBtn = getChild<LLButton>("media_volume_button"); assert(mVolumeBtn);
mVolumeUpCtrl = getChild<LLUICtrl>("volume_up"); assert(mVolumeUpCtrl);
mVolumeDownCtrl = getChild<LLUICtrl>("volume_down"); assert(mVolumeDownCtrl);
mWhitelistIcon = getChild<LLIconCtrl>("media_whitelist_flag"); assert(mWhitelistIcon);
mSecureLockIcon = getChild<LLIconCtrl>("media_secure_lock_flag"); assert(mSecureLockIcon);
mMediaControlsStack = getChild<LLLayoutStack>("media_controls"); assert(mMediaControlsStack);
mLeftBookend = getChild<LLUICtrl>("left_bookend"); assert(mLeftBookend);
mRightBookend = getChild<LLUICtrl>("right_bookend"); assert(mRightBookend);
mBackgroundImage = LLUI::getUIImage(getString("control_background_image_name")); assert(mBackgroundImage);
// 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)
{
scroll_up_ctrl->setClickedCallback(onScrollUp, this);
scroll_up_ctrl->setHeldDownCallback(onScrollUpHeld, this);
scroll_up_ctrl->setMouseUpCallback(onScrollStop, this);
mScrollUpCtrl->setClickedCallback(onScrollUp, this);
mScrollUpCtrl->setHeldDownCallback(onScrollUpHeld, this);
mScrollUpCtrl->setMouseUpCallback(onScrollStop, this);
}
LLButton* scroll_left_ctrl = getChild<LLButton>("scrollleft");
if (scroll_left_ctrl)
if (mScrollLeftCtrl)
{
scroll_left_ctrl->setClickedCallback(onScrollLeft, this);
scroll_left_ctrl->setHeldDownCallback(onScrollLeftHeld, this);
scroll_left_ctrl->setMouseUpCallback(onScrollStop, this);
mScrollLeftCtrl->setClickedCallback(onScrollLeft, this);
mScrollLeftCtrl->setHeldDownCallback(onScrollLeftHeld, this);
mScrollLeftCtrl->setMouseUpCallback(onScrollStop, this);
}
LLButton* scroll_right_ctrl = getChild<LLButton>("scrollright");
if (scroll_right_ctrl)
if (mScrollRightCtrl)
{
scroll_right_ctrl->setClickedCallback(onScrollRight, this);
scroll_right_ctrl->setHeldDownCallback(onScrollRightHeld, this);
scroll_right_ctrl->setMouseUpCallback(onScrollStop, this);
mScrollRightCtrl->setClickedCallback(onScrollRight, this);
mScrollRightCtrl->setHeldDownCallback(onScrollRightHeld, this);
mScrollRightCtrl->setMouseUpCallback(onScrollStop, this);
}
LLButton* scroll_down_ctrl = getChild<LLButton>("scrolldown");
if (scroll_down_ctrl)
if (mScrollDownCtrl)
{
scroll_down_ctrl->setClickedCallback(onScrollDown, this);
scroll_down_ctrl->setHeldDownCallback(onScrollDownHeld, this);
scroll_down_ctrl->setMouseUpCallback(onScrollStop, this);
mScrollDownCtrl->setClickedCallback(onScrollDown, this);
mScrollDownCtrl->setHeldDownCallback(onScrollDownHeld, this);
mScrollDownCtrl->setMouseUpCallback(onScrollStop, this);
}
LLUICtrl* media_address = getChild<LLUICtrl>("media_address");
media_address->setFocusReceivedCallback(boost::bind(&LLPanelPrimMediaControls::onInputURL, _1, this ));
mMediaAddress->setFocusReceivedCallback(boost::bind(&LLPanelPrimMediaControls::onInputURL, _1, this ));
mInactiveTimeout = gSavedSettings.getF32("MediaControlTimeout");
mControlFadeTime = gSavedSettings.getF32("MediaControlFadeTime");
@ -261,90 +293,63 @@ void LLPanelPrimMediaControls::updateShape()
//
// 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* unzoom_ctrl = getChild<LLUICtrl>("close"); // This is actually "unzoom"
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);
zoom_ctrl->setVisible(!is_zoomed);
unzoom_ctrl->setVisible(has_focus && is_zoomed);
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(has_focus && is_zoomed);
mOpenCtrl->setVisible(true);
mMediaAddressCtrl->setVisible(has_focus && !mini_controls);
mMediaPlaySliderPanel->setVisible(has_focus && !mini_controls);
mVolumeCtrl->setVisible(false);
mVolumeUpCtrl->setVisible(false);
mVolumeDownCtrl->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());
unzoom_ctrl->setEnabled(!objectp->isHUDAttachment());
secure_lock_icon->setVisible(false);
mZoomCtrl->setEnabled(!objectp->isHUDAttachment());
mUnzoomCtrl->setEnabled(!objectp->isHUDAttachment());
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(has_focus && !mini_controls);
media_play_slider_panel->setEnabled(has_focus && !mini_controls);
mReloadCtrl->setEnabled(FALSE);
mReloadCtrl->setVisible(FALSE);
mMediaStopCtrl->setVisible(has_focus);
mHomeCtrl->setVisible(FALSE);
mBackCtrl->setEnabled(has_focus);
mFwdCtrl->setEnabled(has_focus);
mMediaAddressCtrl->setVisible(false);
mMediaAddressCtrl->setEnabled(false);
mMediaPlaySliderPanel->setVisible(has_focus && !mini_controls);
mMediaPlaySliderPanel->setEnabled(has_focus && !mini_controls);
volume_ctrl->setVisible(has_focus);
volume_up_ctrl->setVisible(has_focus);
volume_down_ctrl->setVisible(has_focus);
volume_ctrl->setEnabled(has_focus);
mVolumeCtrl->setVisible(has_focus);
mVolumeUpCtrl->setVisible(has_focus);
mVolumeDownCtrl->setVisible(has_focus);
mVolumeCtrl->setEnabled(has_focus);
whitelist_icon->setVisible(false);
secure_lock_icon->setVisible(false);
if (media_panel_scroll)
mWhitelistIcon->setVisible(false);
mSecureLockIcon->setVisible(false);
if (mMediaPanelScroll)
{
media_panel_scroll->setVisible(false);
scroll_up_ctrl->setVisible(false);
scroll_left_ctrl->setVisible(false);
scroll_right_ctrl->setVisible(false);
scroll_down_ctrl->setVisible(false);
mMediaPanelScroll->setVisible(false);
mScrollUpCtrl->setVisible(false);
mScrollDownCtrl->setVisible(false);
mScrollRightCtrl->setVisible(false);
mScrollDownCtrl->setVisible(false);
}
F32 volume = media_impl->getVolume();
@ -358,8 +363,8 @@ void LLPanelPrimMediaControls::updateShape()
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
@ -367,48 +372,48 @@ void LLPanelPrimMediaControls::updateShape()
{
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);
mVolumeUpCtrl->setEnabled(TRUE);
mVolumeDownCtrl->setEnabled(FALSE);
media_impl->setVolume(0.0);
volume_btn->setToggleState(true);
mVolumeBtn->setToggleState(true);
}
else if (volume >= 1.0)
{
volume_up_ctrl->setEnabled(FALSE);
volume_down_ctrl->setEnabled(TRUE);
mVolumeUpCtrl->setEnabled(FALSE);
mVolumeDownCtrl->setEnabled(TRUE);
media_impl->setVolume(1.0);
volume_btn->setToggleState(false);
mVolumeBtn->setToggleState(false);
}
else
{
volume_up_ctrl->setEnabled(TRUE);
volume_down_ctrl->setEnabled(TRUE);
mVolumeUpCtrl->setEnabled(TRUE);
mVolumeDownCtrl->setEnabled(TRUE);
}
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);
mMediaStopCtrl->setEnabled(TRUE);
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);
mMediaStopCtrl->setEnabled(FALSE);
break;
}
}
@ -423,28 +428,28 @@ 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);
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);
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);
mVolumeCtrl->setVisible(FALSE);
mVolumeUpCtrl->setVisible(FALSE);
mVolumeDownCtrl->setVisible(FALSE);
mVolumeCtrl->setEnabled(FALSE);
mVolumeUpCtrl->setEnabled(FALSE);
mVolumeDownCtrl->setEnabled(FALSE);
if (media_panel_scroll)
if (mMediaPanelScroll)
{
media_panel_scroll->setVisible(has_focus);
scroll_up_ctrl->setVisible(has_focus);
scroll_left_ctrl->setVisible(has_focus);
scroll_right_ctrl->setVisible(has_focus);
scroll_down_ctrl->setVisible(has_focus);
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://");
@ -452,7 +457,7 @@ void LLPanelPrimMediaControls::updateShape()
LLStringUtil::toLower(test_prefix);
if(test_prefix == prefix)
{
secure_lock_icon->setVisible(has_focus);
mSecureLockIcon->setVisible(has_focus);
}
if(mCurrentURL!=mPreviousURL)
@ -463,17 +468,17 @@ void LLPanelPrimMediaControls::updateShape()
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);
}
}
@ -483,16 +488,15 @@ void LLPanelPrimMediaControls::updateShape()
//
// 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());
gFocusMgr.setTopCtrl(mMediaProgressPanel);
}
else
{
media_loading_panel->setVisible(false);
mMediaProgressPanel->setVisible(false);
gFocusMgr.setTopCtrl(NULL);
}
}
@ -589,11 +593,10 @@ void LLPanelPrimMediaControls::updateShape()
// 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;
media_controls_rect.mLeft -= mMediaRegion->getRect().mLeft;
media_controls_rect.mBottom -= mMediaRegion->getRect().mBottom;
media_controls_rect.mTop += getRect().getHeight() - mMediaRegion->getRect().mTop;
media_controls_rect.mRight += getRect().getWidth() - mMediaRegion->getRect().mRight;
LLRect old_hud_rect = media_controls_rect;
// keep all parts of HUD on-screen
@ -669,6 +672,20 @@ 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();
LLRect icon_area = mMediaControlsStack->getRect();
// adjust to ignore space from left bookend padding
icon_area.mLeft += mLeftBookend->getRect().getWidth();
// ignore space from right bookend padding
icon_area.mRight -= mRightBookend->getRect().getWidth();
// get UI image
mBackgroundImage->draw( icon_area, UI_VERTEX_COLOR % alpha);
{
LLViewDrawContext context(alpha);
LLPanel::draw();
@ -711,16 +728,13 @@ bool LLPanelPrimMediaControls::isMouseOver()
S32 x, y;
getWindow()->getCursorPosition(&cursor_pos_window);
getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
LLView* controls_view = NULL;
controls_view = getChild<LLView>("media_controls");
//FIXME: rewrite as LLViewQuery or get hover set from LLViewerWindow?
if(controls_view && controls_view->getVisible())
if(mMediaControlsStack && mMediaControlsStack->getVisible())
{
controls_view->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_view->childFromPoint(x, y);
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...
@ -1002,8 +1016,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);
@ -1032,19 +1045,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
}
@ -1053,12 +1065,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();
@ -1087,7 +1098,7 @@ void LLPanelPrimMediaControls::onCommitVolumeUp()
}
media_impl->setVolume(volume);
getChild<LLButton>("media_volume")->setToggleState(false);
mVolumeBtn->setToggleState(false);
}
}
@ -1107,7 +1118,7 @@ void LLPanelPrimMediaControls::onCommitVolumeDown()
}
media_impl->setVolume(volume);
getChild<LLButton>("media_volume")->setToggleState(false);
mVolumeBtn->setToggleState(false);
}
}

View File

@ -35,7 +35,11 @@
#include "llpanel.h"
#include "llviewermedia.h"
class LLButton;
class LLCoordWindow;
class LLIconCtrl;
class LLLayoutStack;
class LLProgressBar;
class LLViewerMediaImpl;
class LLPanelPrimMediaControls : public LLPanel
@ -119,6 +123,44 @@ private:
LLViewerMediaImpl* getTargetMediaImpl();
LLViewerObject* getTargetObject();
LLPluginClassMedia* getTargetMediaPlugin();
private:
LLView *mMediaRegion;
LLUICtrl *mBackCtrl;
LLUICtrl *mFwdCtrl;
LLUICtrl *mReloadCtrl;
LLUICtrl *mPlayCtrl;
LLUICtrl *mPauseCtrl;
LLUICtrl *mStopCtrl;
LLUICtrl *mMediaStopCtrl;
LLUICtrl *mHomeCtrl;
LLUICtrl *mUnzoomCtrl;
LLUICtrl *mOpenCtrl;
LLUICtrl *mZoomCtrl;
LLPanel *mMediaProgressPanel;
LLProgressBar *mMediaProgressBar;
LLUICtrl *mMediaAddressCtrl;
LLUICtrl *mMediaAddress;
LLUICtrl *mMediaPlaySliderPanel;
LLUICtrl *mMediaPlaySliderCtrl;
LLUICtrl *mVolumeCtrl;
LLButton *mVolumeBtn;
LLUICtrl *mVolumeUpCtrl;
LLUICtrl *mVolumeDownCtrl;
LLIconCtrl *mWhitelistIcon;
LLIconCtrl *mSecureLockIcon;
LLLayoutStack *mMediaControlsStack;
LLUICtrl *mLeftBookend;
LLUICtrl *mRightBookend;
LLUIImage* mBackgroundImage;
LLUICtrl *mMediaPanelScroll;
LLButton *mScrollUpCtrl;
LLButton *mScrollLeftCtrl;
LLButton *mScrollRightCtrl;
LLButton *mScrollDownCtrl;
bool mPauseFadeout;
bool mUpdateSlider;
bool mClearFaceOnFade;
@ -137,8 +179,7 @@ private:
std::string mPreviousURL;
F64 mCurrentRate;
F64 mMovieDuration;
int mUpdatePercent;
LLUUID mTargetObjectID;
S32 mTargetObjectFace;
LLUUID mTargetImplID;

View File

@ -2,19 +2,18 @@
<panel
follows="left|right|top|bottom"
name="MediaControls"
bg_alpha_color="1 1 1 0"
background_visible="false"
height="160"
layout="topleft"
mouse_opaque="false"
width="800">
<string name="control_background_image_name">Inspector_Background</string>
<panel
name="media_region"
bottom="125"
follows="left|right|top|bottom"
layout="topleft"
left="20"
mouse_opaque="false"
right="-20"
top="20" />
<layout_stack
follows="left|right|bottom"
@ -33,6 +32,7 @@
name="media_progress_indicator"
height="22"
layout="topleft"
visible="false"
left="0"
top="0"
auto_resize="false"
@ -64,6 +64,7 @@
top="128">
<!-- outer layout_panels center the inner one -->
<layout_panel
name="left_bookend"
width="0"
layout="topleft"
user_resize="false" />
@ -83,6 +84,7 @@
layout="topleft"
tool_tip="Step back"
width="22"
left="0"
top_delta="4">
<button.commit_callback
function="MediaCtrl.Back" />
@ -109,22 +111,22 @@
function="MediaCtrl.Forward" />
</button>
</layout_panel>
<!--
<panel
<!--
<panel
height="22"
layout="topleft"
auto_resize="false"
min_width="3"
width="3">
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<layout_panel
name="home"
auto_resize="false"
@ -165,22 +167,22 @@
function="MediaCtrl.Stop" />
</button>
</layout_panel>
<!--
<panel
<!--
<panel
height="22"
layout="topleft"
auto_resize="false"
min_width="3"
width="3">
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<layout_panel
name="reload"
auto_resize="false"
@ -294,31 +296,43 @@ function="MediaCtrl.CommitURL" />
function="MediaCtrl.CommitURL"/>
</line_editor>
<layout_stack
name="media_address_url_icons"
animate="false"
follows="right"
width="32"
min_width="32"
height="16"
top="3"
orientation="horizontal"
left_pad="-38">
<icon
name="media_whitelist_flag"
follows="top|right"
height="16"
image_name="smicon_warn.tga"
height="20"
width="38"
right="-2"
top="-1"
orientation="horizontal">
<layout_panel
layout="topleft"
tool_tip="White List enabled"
min_width="16"
width="16" />
<icon
name="media_secure_lock_flag"
height="16"
image_name="inv_item_eyes.tga"
width="16"
auto_resize="false"
user_resize="false">
<icon
name="media_whitelist_flag"
follows="top|right"
height="16"
image_name="smicon_warn.tga"
layout="topleft"
tool_tip="White List enabled"
min_width="16"
width="16" />
</layout_panel>
<layout_panel
layout="topleft"
tool_tip="Secured Browsing"
min_width="16"
width="16" />
width="16"
auto_resize="false"
user_resize="false">
<icon
name="media_secure_lock_flag"
height="16"
image_name="icon_lock.tga"
layout="topleft"
tool_tip="Secured Browsing"
min_width="16"
width="16" />
</layout_panel>
</layout_stack>
</layout_panel>
<layout_panel
@ -412,9 +426,9 @@ function="MediaCtrl.CommitURL" />
</button>
</layout_panel>
<!-- Scroll pad -->
<!--
disabled
<layout_panel
<!--
disabled
<layout_panel
name="media_panel_scroll"
auto_resize="false"
user_resize="false"
@ -423,64 +437,64 @@ disabled
layout="topleft"
min_width="32"
width="32">
<icon
height="32"
image_name="media_panel_scrollbg.png"
layout="topleft"
top="0"
min_width="32"
width="32" />
<button
name="scrollup"
height="8"
image_selected="media_btn_scrollup.png"
image_unselected="media_btn_scrollup.png"
layout="topleft"
tool_tip="Scroll up"
scale_image="false"
left="12"
top_delta="4"
min_width="8"
width="8" />
<button
name="scrollleft"
height="8"
image_selected="media_btn_scrollleft.png"
image_unselected="media_btn_scrollleft.png"
layout="topleft"
left="3"
tool_tip="Scroll left"
scale_image="false"
top="12"
min_width="8"
width="8" />
<button
name="scrollright"
height="8"
image_selected="media_btn_scrollright.png"
image_unselected="media_btn_scrollright.png"
layout="topleft"
left_pad="9"
tool_tip="Scroll right"
scale_image="false"
top_delta="0"
min_width="8"
width="8" />
<button
name="scrolldown"
height="8"
image_selected="media_btn_scrolldown.png"
image_unselected="media_btn_scrolldown.png"
layout="topleft"
left="12"
tool_tip="Scroll down"
scale_image="false"
top="20"
min_width="8"
width="8" />
</layout_panel>
disabled
-->
<icon
height="32"
image_name="media_panel_scrollbg.png"
layout="topleft"
top="0"
min_width="32"
width="32" />
<button
name="scrollup"
height="8"
image_selected="media_btn_scrollup.png"
image_unselected="media_btn_scrollup.png"
layout="topleft"
tool_tip="Scroll up"
scale_image="false"
left="12"
top_delta="4"
min_width="8"
width="8" />
<button
name="scrollleft"
height="8"
image_selected="media_btn_scrollleft.png"
image_unselected="media_btn_scrollleft.png"
layout="topleft"
left="3"
tool_tip="Scroll left"
scale_image="false"
top="12"
min_width="8"
width="8" />
<button
name="scrollright"
height="8"
image_selected="media_btn_scrollright.png"
image_unselected="media_btn_scrollright.png"
layout="topleft"
left_pad="9"
tool_tip="Scroll right"
scale_image="false"
top_delta="0"
min_width="8"
width="8" />
<button
name="scrolldown"
height="8"
image_selected="media_btn_scrolldown.png"
image_unselected="media_btn_scrolldown.png"
layout="topleft"
left="12"
tool_tip="Scroll down"
scale_image="false"
top="20"
min_width="8"
width="8" />
</layout_panel>
disabled
-->
<layout_panel
name="zoom_frame"
auto_resize="false"
@ -520,22 +534,22 @@ disabled
function="MediaCtrl.Close" />
</button>
</layout_panel>
<!--
<panel
<!--
<panel
height="22"
layout="topleft"
auto_resize="false"
min_width="3"
width="3">
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<layout_panel
name="new_window"
auto_resize="false"
@ -556,23 +570,25 @@ disabled
function="MediaCtrl.Open" />
</button>
</layout_panel>
<!--
<panel
<!--
<panel
height="22"
layout="topleft"
auto_resize="false"
min_width="3"
width="3">
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<icon
height="22"
image_name="media_panel_divider.png"
layout="topleft"
top="0"
min_width="3"
width="3" />
</panel>
-->
<!-- bookend panel -->
<layout_panel
name="right_bookend"
width="0"
layout="topleft"
user_resize="false" />