Kaydet (Commit) 9128ef68 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor MediaWindow to use RenderContext

Change-Id: I6488e360ad51478c6305c4647255e61a80c64195
üst dcaef202
...@@ -45,44 +45,32 @@ using namespace ::com::sun::star; ...@@ -45,44 +45,32 @@ using namespace ::com::sun::star;
namespace avmedia { namespace priv { namespace avmedia { namespace priv {
MediaWindowControl::MediaWindowControl(vcl::Window* pParent)
// - MediaWindowControl - : MediaControl(pParent, MEDIACONTROLSTYLE_MULTILINE)
MediaWindowControl::MediaWindowControl( vcl::Window* pParent ) :
MediaControl( pParent, MEDIACONTROLSTYLE_MULTILINE )
{ {
} }
void MediaWindowControl::update() void MediaWindowControl::update()
{ {
MediaItem aItem; MediaItem aItem;
static_cast< MediaWindowImpl* >( GetParent() )->updateMediaItem( aItem ); static_cast< MediaWindowImpl* >( GetParent() )->updateMediaItem( aItem );
setState( aItem ); setState(aItem);
} }
void MediaWindowControl::execute(const MediaItem& rItem)
void MediaWindowControl::execute( const MediaItem& rItem )
{ {
static_cast< MediaWindowImpl* >( GetParent() )->executeMediaItem( rItem ); static_cast<MediaWindowImpl*>(GetParent())->executeMediaItem(rItem);
} }
MediaChildWindow::MediaChildWindow(vcl::Window* pParent)
// - MediaChildWindow - : SystemChildWindow(pParent, WB_CLIPCHILDREN)
MediaChildWindow::MediaChildWindow( vcl::Window* pParent ) :
SystemChildWindow( pParent, WB_CLIPCHILDREN )
{ {
} }
#if HAVE_FEATURE_GLTF #if HAVE_FEATURE_GLTF
MediaChildWindow::MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData ) : MediaChildWindow::MediaChildWindow(vcl::Window* pParent, SystemWindowData* pData)
SystemChildWindow( pParent, WB_CLIPCHILDREN, pData ) : SystemChildWindow(pParent, WB_CLIPCHILDREN, pData)
{ {
} }
#endif #endif
...@@ -96,8 +84,6 @@ void MediaChildWindow::MouseMove( const MouseEvent& rMEvt ) ...@@ -96,8 +84,6 @@ void MediaChildWindow::MouseMove( const MouseEvent& rMEvt )
GetParent()->MouseMove( aTransformedEvent ); GetParent()->MouseMove( aTransformedEvent );
} }
void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt )
{ {
const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
...@@ -107,8 +93,6 @@ void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -107,8 +93,6 @@ void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt )
GetParent()->MouseButtonDown( aTransformedEvent ); GetParent()->MouseButtonDown( aTransformedEvent );
} }
void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt )
{ {
const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
...@@ -118,24 +102,18 @@ void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -118,24 +102,18 @@ void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt )
GetParent()->MouseButtonUp( aTransformedEvent ); GetParent()->MouseButtonUp( aTransformedEvent );
} }
void MediaChildWindow::KeyInput( const KeyEvent& rKEvt ) void MediaChildWindow::KeyInput( const KeyEvent& rKEvt )
{ {
SystemChildWindow::KeyInput( rKEvt ); SystemChildWindow::KeyInput( rKEvt );
GetParent()->KeyInput( rKEvt ); GetParent()->KeyInput( rKEvt );
} }
void MediaChildWindow::KeyUp( const KeyEvent& rKEvt ) void MediaChildWindow::KeyUp( const KeyEvent& rKEvt )
{ {
SystemChildWindow::KeyUp( rKEvt ); SystemChildWindow::KeyUp( rKEvt );
GetParent()->KeyUp( rKEvt ); GetParent()->KeyUp( rKEvt );
} }
void MediaChildWindow::Command( const CommandEvent& rCEvt ) void MediaChildWindow::Command( const CommandEvent& rCEvt )
{ {
const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
...@@ -145,30 +123,24 @@ void MediaChildWindow::Command( const CommandEvent& rCEvt ) ...@@ -145,30 +123,24 @@ void MediaChildWindow::Command( const CommandEvent& rCEvt )
GetParent()->Command( aTransformedEvent ); GetParent()->Command( aTransformedEvent );
} }
MediaWindowImpl::MediaWindowImpl(vcl::Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl)
// - MediaWindowImpl - : Control(pParent)
, DropTargetHelper(this)
, DragSourceHelper(this)
MediaWindowImpl::MediaWindowImpl( vcl::Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl ) : , mpMediaWindow(pMediaWindow)
Control( pParent ), , mpEvents(nullptr)
DropTargetHelper( this ), , mbEventTransparent(true)
DragSourceHelper( this ), , mpMediaWindowControl(bInternalMediaControl ? VclPtr<MediaWindowControl>::Create(this) : nullptr)
mpMediaWindow( pMediaWindow ), , mpEmptyBmpEx(nullptr)
mpEvents( NULL ), , mpAudioBmpEx(nullptr)
mbEventTransparent(true),
mpMediaWindowControl( bInternalMediaControl ? VclPtr<MediaWindowControl>::Create( this ) : nullptr ),
mpEmptyBmpEx( NULL ),
mpAudioBmpEx( NULL )
{ {
if( mpMediaWindowControl ) if (mpMediaWindowControl)
{ {
mpMediaWindowControl->SetSizePixel( mpMediaWindowControl->getMinSizePixel() ); mpMediaWindowControl->SetSizePixel(mpMediaWindowControl->getMinSizePixel());
mpMediaWindowControl->Show(); mpMediaWindowControl->Show();
} }
} }
MediaWindowImpl::~MediaWindowImpl() MediaWindowImpl::~MediaWindowImpl()
{ {
disposeOnce(); disposeOnce();
...@@ -176,24 +148,24 @@ MediaWindowImpl::~MediaWindowImpl() ...@@ -176,24 +148,24 @@ MediaWindowImpl::~MediaWindowImpl()
void MediaWindowImpl::dispose() void MediaWindowImpl::dispose()
{ {
if( mpEvents ) if (mpEvents)
mpEvents->cleanUp(); mpEvents->cleanUp();
if( mxPlayerWindow.is() ) if (mxPlayerWindow.is())
{ {
mxPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); mxPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) );
mxPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); mxPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) );
mxPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); mxPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) );
uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY ); uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY );
if( xComponent.is() ) if (xComponent.is())
xComponent->dispose(); xComponent->dispose();
mxPlayerWindow.clear(); mxPlayerWindow.clear();
} }
uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY );
if( xComponent.is() ) // this stops the player if (xComponent.is()) // this stops the player
xComponent->dispose(); xComponent->dispose();
mxPlayer.clear(); mxPlayer.clear();
...@@ -210,23 +182,24 @@ void MediaWindowImpl::dispose() ...@@ -210,23 +182,24 @@ void MediaWindowImpl::dispose()
Control::dispose(); Control::dispose();
} }
uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType ) uno::Reference<media::XPlayer> MediaWindowImpl::createPlayer(const OUString& rURL, const OUString& rReferer, const OUString* pMimeType)
{ {
uno::Reference<media::XPlayer> xPlayer;
uno::Reference< media::XPlayer > xPlayer;
if( rURL.isEmpty() ) if( rURL.isEmpty() )
return xPlayer; return xPlayer;
if (SvtSecurityOptions().isUntrustedReferer(rReferer)) { if (SvtSecurityOptions().isUntrustedReferer(rReferer))
{
return xPlayer; return xPlayer;
} }
uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
if ( !pMimeType || *pMimeType == AVMEDIA_MIMETYPE_COMMON ) if (!pMimeType || *pMimeType == AVMEDIA_MIMETYPE_COMMON)
{ {
static const char * aServiceManagers[] = { static const char * aServiceManagers[] =
{
AVMEDIA_MANAGER_SERVICE_PREFERRED, AVMEDIA_MANAGER_SERVICE_PREFERRED,
AVMEDIA_MANAGER_SERVICE_NAME, AVMEDIA_MANAGER_SERVICE_NAME,
// a fallback path just for gstreamer which has // a fallback path just for gstreamer which has
...@@ -240,11 +213,11 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& ...@@ -240,11 +213,11 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString&
#endif #endif
}; };
for( sal_uInt32 i = 0; !xPlayer.is() && i < SAL_N_ELEMENTS( aServiceManagers ); ++i ) for (sal_uInt32 i = 0; !xPlayer.is() && i < SAL_N_ELEMENTS( aServiceManagers ); ++i)
{ {
const OUString aServiceName( aServiceManagers[ i ], const OUString aServiceName(aServiceManagers[i],
strlen( aServiceManagers[ i ] ), strlen( aServiceManagers[i]),
RTL_TEXTENCODING_ASCII_US ); RTL_TEXTENCODING_ASCII_US);
xPlayer = createPlayer(rURL, aServiceName, xContext); xPlayer = createPlayer(rURL, aServiceName, xContext);
} }
...@@ -370,51 +343,50 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem ) ...@@ -370,51 +343,50 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
const AVMediaSetMask nMaskSet = rItem.getMaskSet(); const AVMediaSetMask nMaskSet = rItem.getMaskSet();
// set URL first // set URL first
if( nMaskSet & AVMediaSetMask::URL ) if (nMaskSet & AVMediaSetMask::URL)
{ {
m_sMimeType = rItem.getMimeType(); m_sMimeType = rItem.getMimeType();
setURL( rItem.getURL(), rItem.getTempURL(), rItem.getReferer() ); setURL(rItem.getURL(), rItem.getTempURL(), rItem.getReferer());
} }
// set different states next // set different states next
if( nMaskSet & AVMediaSetMask::TIME ) if (nMaskSet & AVMediaSetMask::TIME)
setMediaTime( ::std::min( rItem.getTime(), getDuration() ) ); setMediaTime(std::min(rItem.getTime(), getDuration()));
if( nMaskSet & AVMediaSetMask::LOOP ) if (nMaskSet & AVMediaSetMask::LOOP)
setPlaybackLoop( rItem.isLoop() ); setPlaybackLoop(rItem.isLoop());
if( nMaskSet & AVMediaSetMask::MUTE ) if (nMaskSet & AVMediaSetMask::MUTE)
setMute( rItem.isMute() ); setMute(rItem.isMute());
if( nMaskSet & AVMediaSetMask::VOLUMEDB ) if (nMaskSet & AVMediaSetMask::VOLUMEDB)
setVolumeDB( rItem.getVolumeDB() ); setVolumeDB(rItem.getVolumeDB());
if( nMaskSet & AVMediaSetMask::ZOOM ) if (nMaskSet & AVMediaSetMask::ZOOM)
setZoom( rItem.getZoom() ); setZoom(rItem.getZoom());
// set play state at last // set play state at last
if( nMaskSet & AVMediaSetMask::STATE ) if (nMaskSet & AVMediaSetMask::STATE)
{ {
switch( rItem.getState() ) switch (rItem.getState())
{ {
case( MEDIASTATE_PLAY ): case MEDIASTATE_PLAY:
{ {
if (!isPlaying())
if( !isPlaying() )
start(); start();
} }
break; break;
case( MEDIASTATE_PAUSE ): case MEDIASTATE_PAUSE:
{ {
if( isPlaying() ) if (isPlaying())
stop(); stop();
} }
break; break;
case( MEDIASTATE_STOP ): case MEDIASTATE_STOP:
{ {
if( isPlaying() ) if (isPlaying())
{ {
setMediaTime( 0.0 ); setMediaTime( 0.0 );
stop(); stop();
...@@ -426,12 +398,12 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem ) ...@@ -426,12 +398,12 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
} }
} }
bool MediaWindowImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel ) bool MediaWindowImpl::setZoom(css::media::ZoomLevel eLevel)
{ {
return mxPlayerWindow.is() && mxPlayerWindow->setZoomLevel( eLevel ); return mxPlayerWindow.is() && mxPlayerWindow->setZoomLevel( eLevel );
} }
::com::sun::star::media::ZoomLevel MediaWindowImpl::getZoom() const css::media::ZoomLevel MediaWindowImpl::getZoom() const
{ {
return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : media::ZoomLevel_NOT_AVAILABLE ); return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : media::ZoomLevel_NOT_AVAILABLE );
} }
...@@ -493,12 +465,12 @@ void MediaWindowImpl::setVolumeDB( sal_Int16 nVolumeDB ) ...@@ -493,12 +465,12 @@ void MediaWindowImpl::setVolumeDB( sal_Int16 nVolumeDB )
sal_Int16 MediaWindowImpl::getVolumeDB() const sal_Int16 MediaWindowImpl::getVolumeDB() const
{ {
return( mxPlayer.is() ? mxPlayer->getVolumeDB() : 0 ); return (mxPlayer.is() ? mxPlayer->getVolumeDB() : 0);
} }
void MediaWindowImpl::stopPlayingInternal( bool bStop ) void MediaWindowImpl::stopPlayingInternal(bool bStop)
{ {
if( isPlaying() ) if (isPlaying())
{ {
bStop ? mxPlayer->stop() : mxPlayer->start(); bStop ? mxPlayer->stop() : mxPlayer->start();
} }
...@@ -506,13 +478,13 @@ void MediaWindowImpl::stopPlayingInternal( bool bStop ) ...@@ -506,13 +478,13 @@ void MediaWindowImpl::stopPlayingInternal( bool bStop )
void MediaWindowImpl::onURLChanged() void MediaWindowImpl::onURLChanged()
{ {
if( m_sMimeType == AVMEDIA_MIMETYPE_COMMON ) if (m_sMimeType == AVMEDIA_MIMETYPE_COMMON)
{ {
mpChildWindow.disposeAndClear(); mpChildWindow.disposeAndClear();
mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this) ); mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this));
} }
#if HAVE_FEATURE_GLTF #if HAVE_FEATURE_GLTF
else if ( m_sMimeType == AVMEDIA_MIMETYPE_JSON ) else if (m_sMimeType == AVMEDIA_MIMETYPE_JSON)
{ {
SystemWindowData aWinData = OpenGLContext::generateWinData(this, false); SystemWindowData aWinData = OpenGLContext::generateWinData(this, false);
mpChildWindow.disposeAndClear(); mpChildWindow.disposeAndClear();
...@@ -520,22 +492,22 @@ void MediaWindowImpl::onURLChanged() ...@@ -520,22 +492,22 @@ void MediaWindowImpl::onURLChanged()
mbEventTransparent = false; mbEventTransparent = false;
} }
#endif #endif
if( !mpChildWindow ) if (!mpChildWindow)
return; return;
mpChildWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW ); mpChildWindow->SetHelpId(HID_AVMEDIA_PLAYERWINDOW);
mxEventsIf.set( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( *mpChildWindow.get() ) ) ); mxEventsIf.set(static_cast<cppu::OWeakObject*>(mpEvents = new MediaEventListenersImpl(*mpChildWindow.get())));
if( mxPlayer.is() ) if (mxPlayer.is())
{ {
Resize(); Resize();
uno::Sequence< uno::Any > aArgs( 3 ); uno::Sequence<uno::Any> aArgs( 3 );
uno::Reference< media::XPlayerWindow > xPlayerWindow; uno::Reference<media::XPlayerWindow> xPlayerWindow;
const Point aPoint; const Point aPoint;
const Size aSize( mpChildWindow->GetSizePixel() ); const Size aSize(mpChildWindow->GetSizePixel());
aArgs[ 0 ] = uno::makeAny( mpChildWindow->GetParentWindowHandle() ); aArgs[0] = uno::makeAny(mpChildWindow->GetParentWindowHandle());
aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) ); aArgs[1] = uno::makeAny(awt::Rectangle(aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height()));
aArgs[ 2 ] = uno::makeAny( reinterpret_cast< sal_IntPtr >( mpChildWindow.get() ) ); aArgs[2] = uno::makeAny(reinterpret_cast<sal_IntPtr>(mpChildWindow.get()));
try try
{ {
...@@ -573,83 +545,86 @@ void MediaWindowImpl::onURLChanged() ...@@ -573,83 +545,86 @@ void MediaWindowImpl::onURLChanged()
} }
} }
void MediaWindowImpl::setPosSize(const Rectangle& rRect)
void MediaWindowImpl::setPosSize( const Rectangle& rRect )
{ {
SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() ); SetPosSizePixel(rRect.TopLeft(), rRect.GetSize());
} }
void MediaWindowImpl::setPointer(const Pointer& rPointer)
void MediaWindowImpl::setPointer( const Pointer& rPointer )
{ {
SetPointer( rPointer ); SetPointer(rPointer);
if( mpChildWindow )
mpChildWindow->SetPointer( rPointer );
if( mxPlayerWindow.is() ) if (mpChildWindow)
mpChildWindow->SetPointer(rPointer);
if (mxPlayerWindow.is())
{ {
long nPointer; long nPointer;
switch( rPointer.GetStyle() ) switch (rPointer.GetStyle())
{ {
case( POINTER_CROSS ): nPointer = awt::SystemPointer::CROSS; break; case POINTER_CROSS:
case( POINTER_HAND ): nPointer = awt::SystemPointer::HAND; break; nPointer = awt::SystemPointer::CROSS;
case( POINTER_MOVE ): nPointer = awt::SystemPointer::MOVE; break; break;
case( POINTER_WAIT ): nPointer = awt::SystemPointer::WAIT; break; case POINTER_HAND:
nPointer = awt::SystemPointer::HAND;
default: nPointer = awt::SystemPointer::ARROW; break; break;
case POINTER_MOVE:
nPointer = awt::SystemPointer::MOVE;
break;
case POINTER_WAIT:
nPointer = awt::SystemPointer::WAIT;
break;
default:
nPointer = awt::SystemPointer::ARROW;
break;
} }
mxPlayerWindow->setPointerType( nPointer ); mxPlayerWindow->setPointerType(nPointer);
} }
} }
void MediaWindowImpl::Resize() void MediaWindowImpl::Resize()
{ {
const Size aCurSize( GetOutputSizePixel() ); const Size aCurSize(GetOutputSizePixel());
const sal_Int32 nOffset( mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0 ); const sal_Int32 nOffset(mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0);
Size aPlayerWindowSize( aCurSize.Width() - ( nOffset << 1 ),
aCurSize.Height() - ( nOffset << 1 ) );
if( mpMediaWindowControl ) Size aPlayerWindowSize(aCurSize.Width() - (nOffset << 1),
aCurSize.Height() - (nOffset << 1));
if (mpMediaWindowControl)
{ {
const sal_Int32 nControlHeight = mpMediaWindowControl->GetSizePixel().Height(); const sal_Int32 nControlHeight = mpMediaWindowControl->GetSizePixel().Height();
const sal_Int32 nControlY = ::std::max( aCurSize.Height() - nControlHeight - nOffset, 0L ); const sal_Int32 nControlY = ::std::max(aCurSize.Height() - nControlHeight - nOffset, 0L);
aPlayerWindowSize.Height() = ( nControlY - ( nOffset << 1 ) ); aPlayerWindowSize.Height() = (nControlY - (nOffset << 1));
mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) ); mpMediaWindowControl->SetPosSizePixel(Point(nOffset, nControlY ), Size(aCurSize.Width() - (nOffset << 1), nControlHeight));
} }
if( mpChildWindow ) if (mpChildWindow)
mpChildWindow->SetPosSizePixel( Point( 0, 0 ), aPlayerWindowSize ); mpChildWindow->SetPosSizePixel(Point(0, 0), aPlayerWindowSize);
if( mxPlayerWindow.is() ) if (mxPlayerWindow.is())
mxPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 ); mxPlayerWindow->setPosSize(0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0);
} }
void MediaWindowImpl::StateChanged(StateChangedType eType)
void MediaWindowImpl::StateChanged( StateChangedType eType )
{ {
if( mxPlayerWindow.is() ) if (mxPlayerWindow.is())
{ {
// stop playing when going disabled or hidden // stop playing when going disabled or hidden
switch( eType ) switch (eType)
{ {
case StateChangedType::Visible: case StateChangedType::Visible:
{ {
stopPlayingInternal( !IsVisible() ); stopPlayingInternal(!IsVisible());
mxPlayerWindow->setVisible( IsVisible() ); mxPlayerWindow->setVisible(IsVisible());
} }
break; break;
case StateChangedType::Enable: case StateChangedType::Enable:
{ {
stopPlayingInternal( !IsEnabled() ); stopPlayingInternal(!IsEnabled());
mxPlayerWindow->setEnable( IsEnabled() ); mxPlayerWindow->setEnable(IsEnabled());
} }
break; break;
...@@ -659,141 +634,121 @@ void MediaWindowImpl::StateChanged( StateChangedType eType ) ...@@ -659,141 +634,121 @@ void MediaWindowImpl::StateChanged( StateChangedType eType )
} }
} }
void MediaWindowImpl::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
void MediaWindowImpl::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
{ {
if( mxPlayerWindow.is() ) if (mxPlayerWindow.is())
mxPlayerWindow->update(); mxPlayerWindow->update();
BitmapEx* pLogo = NULL; BitmapEx* pLogo = NULL;
if( !mxPlayer.is() ) if (!mxPlayer.is())
{ {
if( !mpEmptyBmpEx ) if (!mpEmptyBmpEx)
mpEmptyBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) ); mpEmptyBmpEx = new BitmapEx(AVMEDIA_RESID(AVMEDIA_BMP_EMPTYLOGO));
pLogo = mpEmptyBmpEx; pLogo = mpEmptyBmpEx;
} }
else if( !mxPlayerWindow.is() ) else if (!mxPlayerWindow.is())
{ {
if( !mpAudioBmpEx ) if (!mpAudioBmpEx)
mpAudioBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) ); mpAudioBmpEx = new BitmapEx(AVMEDIA_RESID(AVMEDIA_BMP_AUDIOLOGO));
pLogo = mpAudioBmpEx; pLogo = mpAudioBmpEx;
} }
if( !mpChildWindow ) if (!mpChildWindow)
return; return;
const Point aBasePos( mpChildWindow->GetPosPixel() );
const Rectangle aVideoRect( aBasePos, mpChildWindow->GetSizePixel() );
if( pLogo && !pLogo->IsEmpty() && ( aVideoRect.GetWidth() > 0 ) && ( aVideoRect.GetHeight() > 0 ) ) const Point aBasePos(mpChildWindow->GetPosPixel());
const Rectangle aVideoRect(aBasePos, mpChildWindow->GetSizePixel());
if (pLogo && !pLogo->IsEmpty() && (aVideoRect.GetWidth() > 0) && (aVideoRect.GetHeight() > 0))
{ {
Size aLogoSize( pLogo->GetSizePixel() ); Size aLogoSize(pLogo->GetSizePixel());
const Color aBackgroundColor( 67, 67, 67 ); const Color aBackgroundColor(67, 67, 67);
SetLineColor( aBackgroundColor ); rRenderContext.SetLineColor(aBackgroundColor);
SetFillColor( aBackgroundColor ); rRenderContext.SetFillColor(aBackgroundColor);
DrawRect( aVideoRect ); rRenderContext.DrawRect(aVideoRect);
if( ( aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) && if ((aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) &&
( aLogoSize.Height() > 0 ) ) (aLogoSize.Height() > 0))
{ {
const double fLogoWH = (double) aLogoSize.Width() / aLogoSize.Height(); const double fLogoWH = double(aLogoSize.Width()) / aLogoSize.Height();
if( fLogoWH < ( (double) aVideoRect.GetWidth() / aVideoRect.GetHeight() ) ) if (fLogoWH < (double(aVideoRect.GetWidth()) / aVideoRect.GetHeight()))
{ {
aLogoSize.Width() = (long) ( aVideoRect.GetHeight() * fLogoWH ); aLogoSize.Width() = long(aVideoRect.GetHeight() * fLogoWH);
aLogoSize.Height()= aVideoRect.GetHeight(); aLogoSize.Height() = aVideoRect.GetHeight();
} }
else else
{ {
aLogoSize.Width() = aVideoRect.GetWidth(); aLogoSize.Width() = aVideoRect.GetWidth();
aLogoSize.Height()= (long) ( aVideoRect.GetWidth() / fLogoWH ); aLogoSize.Height()= long(aVideoRect.GetWidth() / fLogoWH);
} }
} }
DrawBitmapEx( Point( aBasePos.X() + ( ( aVideoRect.GetWidth() - aLogoSize.Width() ) >> 1 ), Point aPoint(aBasePos.X() + ((aVideoRect.GetWidth() - aLogoSize.Width()) >> 1),
aBasePos.Y() + ( ( aVideoRect.GetHeight() - aLogoSize.Height() ) >> 1 ) ), aBasePos.Y() + ((aVideoRect.GetHeight() - aLogoSize.Height()) >> 1));
aLogoSize, *pLogo );
rRenderContext.DrawBitmapEx(aPoint, aLogoSize, *pLogo);
} }
} }
void MediaWindowImpl::GetFocus() void MediaWindowImpl::GetFocus()
{ {
} }
void MediaWindowImpl::MouseMove(const MouseEvent& rMEvt)
void MediaWindowImpl::MouseMove( const MouseEvent& rMEvt )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->MouseMove( rMEvt ); mpMediaWindow->MouseMove(rMEvt);
} }
void MediaWindowImpl::MouseButtonDown(const MouseEvent& rMEvt)
void MediaWindowImpl::MouseButtonDown( const MouseEvent& rMEvt )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->MouseButtonDown( rMEvt ); mpMediaWindow->MouseButtonDown(rMEvt);
} }
void MediaWindowImpl::MouseButtonUp(const MouseEvent& rMEvt)
void MediaWindowImpl::MouseButtonUp( const MouseEvent& rMEvt )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->MouseButtonUp( rMEvt ); mpMediaWindow->MouseButtonUp(rMEvt);
} }
void MediaWindowImpl::KeyInput(const KeyEvent& rKEvt)
void MediaWindowImpl::KeyInput( const KeyEvent& rKEvt )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->KeyInput( rKEvt ); mpMediaWindow->KeyInput(rKEvt);
} }
void MediaWindowImpl::KeyUp(const KeyEvent& rKEvt)
void MediaWindowImpl::KeyUp( const KeyEvent& rKEvt )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->KeyUp( rKEvt ); mpMediaWindow->KeyUp(rKEvt);
} }
void MediaWindowImpl::Command(const CommandEvent& rCEvt)
void MediaWindowImpl::Command( const CommandEvent& rCEvt )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->Command( rCEvt ); mpMediaWindow->Command(rCEvt);
} }
sal_Int8 MediaWindowImpl::AcceptDrop(const AcceptDropEvent& rEvt)
sal_Int8 MediaWindowImpl::AcceptDrop( const AcceptDropEvent& rEvt )
{ {
return( mpMediaWindow && mbEventTransparent ? mpMediaWindow->AcceptDrop( rEvt ) : 0 ); return (mpMediaWindow && mbEventTransparent ? mpMediaWindow->AcceptDrop(rEvt) : 0);
} }
sal_Int8 MediaWindowImpl::ExecuteDrop(const ExecuteDropEvent& rEvt)
sal_Int8 MediaWindowImpl::ExecuteDrop( const ExecuteDropEvent& rEvt )
{ {
return( mpMediaWindow && mbEventTransparent ? mpMediaWindow->ExecuteDrop( rEvt ) : 0 ); return (mpMediaWindow && mbEventTransparent ? mpMediaWindow->ExecuteDrop(rEvt) : 0);
} }
void MediaWindowImpl::StartDrag(sal_Int8 nAction, const Point& rPosPixel)
void MediaWindowImpl::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
{ {
if( mpMediaWindow && mbEventTransparent ) if (mpMediaWindow && mbEventTransparent)
mpMediaWindow->StartDrag( nAction, rPosPixel ); mpMediaWindow->StartDrag(nAction, rPosPixel);
} }
} // namespace priv } // namespace priv
......
...@@ -28,157 +28,147 @@ ...@@ -28,157 +28,147 @@
namespace com { namespace sun { namespace star { namespace media { namespace com { namespace sun { namespace star { namespace media {
class XPlayer; class XPlayer;
class XPlayerWindow; class XPlayerWindow;
} } } } }}}}
namespace com { namespace sun { namespace star { namespace uno { namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext; class XComponentContext;
} } } } }}}}
class BitmapEx; class BitmapEx;
namespace avmedia namespace avmedia
{ {
class MediaWindow;
namespace priv
{
// - MediaWindowControl -
class MediaWindowControl : public MediaControl
{
public:
explicit MediaWindowControl( vcl::Window* pParent ); class MediaWindow;
protected:
void update() SAL_OVERRIDE;
void execute( const MediaItem& rItem ) SAL_OVERRIDE;
};
namespace priv
{
// - MediaChildWindow - class MediaWindowControl : public MediaControl
{
public:
explicit MediaWindowControl( vcl::Window* pParent );
class MediaChildWindow : public SystemChildWindow protected:
{
public:
explicit MediaChildWindow( vcl::Window* pParent ); void update() SAL_OVERRIDE;
MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData ); void execute( const MediaItem& rItem ) SAL_OVERRIDE;
};
protected: class MediaChildWindow : public SystemChildWindow
{
public:
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE; explicit MediaChildWindow( vcl::Window* pParent );
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData );
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
};
// ------------------. protected:
// - MediaWindowImpl -
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
};
class MediaEventListenersImpl; class MediaEventListenersImpl;
class MediaWindowImpl : public Control, class MediaWindowImpl : public Control, public DropTargetHelper, public DragSourceHelper
public DropTargetHelper, {
public DragSourceHelper public:
MediaWindowImpl(vcl::Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl);
virtual ~MediaWindowImpl();
{ virtual void dispose() SAL_OVERRIDE;
public:
MediaWindowImpl( vcl::Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl ); static css::uno::Reference<css::media::XPlayer> createPlayer(const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = 0);
virtual ~MediaWindowImpl();
virtual void dispose() SAL_OVERRIDE;
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = 0 ); void setURL(const OUString& rURL, OUString const& rTempURL, OUString const& rReferer);
void setURL( const OUString& rURL, OUString const& rTempURL, OUString const& rReferer ); const OUString& getURL() const;
const OUString& getURL() const; bool isValid() const;
bool isValid() const; Size getPreferredSize() const;
Size getPreferredSize() const; bool start();
bool start(); void updateMediaItem( MediaItem& rItem ) const;
void executeMediaItem( const MediaItem& rItem );
void updateMediaItem( MediaItem& rItem ) const; void setPosSize( const Rectangle& rRect );
void executeMediaItem( const MediaItem& rItem );
void setPosSize( const Rectangle& rRect ); void setPointer( const Pointer& rPointer );
void setPointer( const Pointer& rPointer ); private:
private: // Window
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
virtual void StateChanged( StateChangedType ) SAL_OVERRIDE;
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) SAL_OVERRIDE; // const
virtual void GetFocus() SAL_OVERRIDE;
// Window // DropTargetHelper
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
virtual void StateChanged( StateChangedType ) SAL_OVERRIDE;
virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) SAL_OVERRIDE; // const
virtual void GetFocus() SAL_OVERRIDE;
// DropTargetHelper // DragSourceHelper
virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE; virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
// DragSourceHelper bool setZoom(css::media::ZoomLevel eLevel);
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE; css::media::ZoomLevel getZoom() const;
bool setZoom( ::com::sun::star::media::ZoomLevel eLevel ); void stop();
::com::sun::star::media::ZoomLevel getZoom() const;
void stop(); bool isPlaying() const;
bool isPlaying() const; double getDuration() const;
double getDuration() const; void setMediaTime( double fTime );
double getMediaTime() const;
void setMediaTime( double fTime ); void setPlaybackLoop( bool bSet );
double getMediaTime() const; bool isPlaybackLoop() const;
void setPlaybackLoop( bool bSet ); void setMute( bool bSet );
bool isPlaybackLoop() const; bool isMute() const;
void setMute( bool bSet ); void setVolumeDB( sal_Int16 nVolumeDB );
bool isMute() const; sal_Int16 getVolumeDB() const;
void setVolumeDB( sal_Int16 nVolumeDB ); void stopPlayingInternal( bool );
sal_Int16 getVolumeDB() const;
void stopPlayingInternal( bool ); void onURLChanged();
void onURLChanged(); static css::uno::Reference<css::media::XPlayer> createPlayer(const OUString& rURL, const OUString& rManagerServName,
css::uno::Reference<css::uno::XComponentContext> xContext);
static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rManagerServName, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext); OUString maFileURL;
OUString mTempFileURL;
OUString maReferer;
OUString m_sMimeType;
css::uno::Reference<css::media::XPlayer> mxPlayer;
css::uno::Reference<css::media::XPlayerWindow> mxPlayerWindow;
MediaWindow* mpMediaWindow;
OUString maFileURL; css::uno::Reference<css::uno::XInterface> mxEventsIf;
OUString mTempFileURL; MediaEventListenersImpl* mpEvents;
OUString maReferer; bool mbEventTransparent;
OUString m_sMimeType; VclPtr<MediaChildWindow> mpChildWindow;
::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer; VclPtr<MediaWindowControl> mpMediaWindowControl;
::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow; BitmapEx* mpEmptyBmpEx;
MediaWindow* mpMediaWindow; BitmapEx* mpAudioBmpEx;
};
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf; }} // end namespace avmedia::priv
MediaEventListenersImpl* mpEvents;
bool mbEventTransparent;
VclPtr<MediaChildWindow> mpChildWindow;
VclPtr<MediaWindowControl> mpMediaWindowControl;
BitmapEx* mpEmptyBmpEx;
BitmapEx* mpAudioBmpEx;
};
}
}
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment