/*virtual*/
void LLPanelPrimMediaControls::draw()
{
	LLViewerMediaImpl* impl = getTargetMediaImpl();
	if (impl)
	{
		LLNotificationPtr notification = impl->getCurrentNotification();
		if (notification != mActiveNotification)
		{
			mActiveNotification = notification;
			if (notification)
			{
				showNotification(notification);
			}
			else
			{
				hideNotification();
			}
		}
	}

	F32 alpha = getDrawContext().mAlpha;
	if(mHideImmediately)
	{
		//hide this panel
		clearFaceOnFade();

		mHideImmediately = false;
	}
	else if(mFadeTimer.getStarted())
	{
		F32 time = mFadeTimer.getElapsedTimeF32();
		alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f);

		if(time >= mControlFadeTime)
		{
			//hide this panel
			clearFaceOnFade();
		}
	}
	
	// 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();
	}
}
/*virtual*/
void LLPanelPrimMediaControls::draw()
{
	LLViewerMediaImpl* impl = getTargetMediaImpl();
	if (impl)
	{
		LLNotificationPtr notification = impl->getCurrentNotification();
		if (notification != mActiveNotification)
		{
			mActiveNotification = notification;
			if (notification)
			{
				showNotification(notification);
			}
			else
			{
				hideNotification();
			}
		}
	}

	F32 alpha = getDrawContext().mAlpha;
	if(mHideImmediately)
	{
		//hide this panel
		clearFaceOnFade();

		mHideImmediately = false;
	}
	else if(mFadeTimer.getStarted())
	{
		F32 time = mFadeTimer.getElapsedTimeF32();
		alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f);

		if(time >= mControlFadeTime)
		{
			//hide this panel
			clearFaceOnFade();
		}
	}

    // Show/hide the lock icon for secure browsing
    mSecureLockIcon->setVisible(mSecureURL && !mMediaAddress->hasFocus());
	
	// 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

	// <FS:ND> VWR-29449; Only draw mBackgroundImage when the user has MEDIA_PERM_CONTROL. Otherwise we did hide all media controls above and drawing mBackgroundImage draws a useless grey square.
	
	// mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha);

	LLViewerObject* objectp = getTargetObject();
	LLMediaEntry *media_data(0);

	if( objectp )
		media_data = objectp->getTE(mTargetObjectFace)->getMediaData();
	if( !dynamic_cast<LLVOVolume*>(objectp) || !media_data || dynamic_cast<LLVOVolume*>(objectp)->hasMediaPermission(media_data, LLVOVolume::MEDIA_PERM_CONTROL) )
		mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha);
 
	// </FS:ND>

	// 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();
	}
}