diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-13 20:16:22 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-14 09:58:14 +0900 |
commit | 9128ef6850984924c27e6f794d05fc70d3243527 (patch) | |
tree | e5d4eacd69e0af940170ba300bbd6e1ef0ca37ac | |
parent | dcaef20266ef3511f71d3c4b8962af5f03860feb (diff) |
refactor MediaWindow to use RenderContext
Change-Id: I6488e360ad51478c6305c4647255e61a80c64195
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.cxx | 395 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.hxx | 200 |
2 files changed, 270 insertions, 325 deletions
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index a2510d79da51..9f0591bb0919 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -45,44 +45,32 @@ using namespace ::com::sun::star; namespace avmedia { namespace priv { - -// - MediaWindowControl - - - -MediaWindowControl::MediaWindowControl( vcl::Window* pParent ) : - MediaControl( pParent, MEDIACONTROLSTYLE_MULTILINE ) +MediaWindowControl::MediaWindowControl(vcl::Window* pParent) + : MediaControl(pParent, MEDIACONTROLSTYLE_MULTILINE) { } - - void MediaWindowControl::update() { MediaItem 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::MediaChildWindow( vcl::Window* pParent ) : - SystemChildWindow( pParent, WB_CLIPCHILDREN ) +MediaChildWindow::MediaChildWindow(vcl::Window* pParent) + : SystemChildWindow(pParent, WB_CLIPCHILDREN) { } #if HAVE_FEATURE_GLTF -MediaChildWindow::MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData ) : - SystemChildWindow( pParent, WB_CLIPCHILDREN, pData ) +MediaChildWindow::MediaChildWindow(vcl::Window* pParent, SystemWindowData* pData) + : SystemChildWindow(pParent, WB_CLIPCHILDREN, pData) { } #endif @@ -96,8 +84,6 @@ void MediaChildWindow::MouseMove( const MouseEvent& rMEvt ) GetParent()->MouseMove( aTransformedEvent ); } - - void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) { const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), @@ -107,8 +93,6 @@ void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) GetParent()->MouseButtonDown( aTransformedEvent ); } - - void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) { const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), @@ -118,24 +102,18 @@ void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) GetParent()->MouseButtonUp( aTransformedEvent ); } - - void MediaChildWindow::KeyInput( const KeyEvent& rKEvt ) { SystemChildWindow::KeyInput( rKEvt ); GetParent()->KeyInput( rKEvt ); } - - void MediaChildWindow::KeyUp( const KeyEvent& rKEvt ) { SystemChildWindow::KeyUp( rKEvt ); GetParent()->KeyUp( rKEvt ); } - - void MediaChildWindow::Command( const CommandEvent& rCEvt ) { const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), @@ -145,30 +123,24 @@ void MediaChildWindow::Command( const CommandEvent& rCEvt ) GetParent()->Command( aTransformedEvent ); } - -// - MediaWindowImpl - - - -MediaWindowImpl::MediaWindowImpl( vcl::Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl ) : - Control( pParent ), - DropTargetHelper( this ), - DragSourceHelper( this ), - mpMediaWindow( pMediaWindow ), - mpEvents( NULL ), - mbEventTransparent(true), - mpMediaWindowControl( bInternalMediaControl ? VclPtr<MediaWindowControl>::Create( this ) : nullptr ), - mpEmptyBmpEx( NULL ), - mpAudioBmpEx( NULL ) +MediaWindowImpl::MediaWindowImpl(vcl::Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl) + : Control(pParent) + , DropTargetHelper(this) + , DragSourceHelper(this) + , mpMediaWindow(pMediaWindow) + , mpEvents(nullptr) + , mbEventTransparent(true) + , mpMediaWindowControl(bInternalMediaControl ? VclPtr<MediaWindowControl>::Create(this) : nullptr) + , mpEmptyBmpEx(nullptr) + , mpAudioBmpEx(nullptr) { - if( mpMediaWindowControl ) + if (mpMediaWindowControl) { - mpMediaWindowControl->SetSizePixel( mpMediaWindowControl->getMinSizePixel() ); + mpMediaWindowControl->SetSizePixel(mpMediaWindowControl->getMinSizePixel()); mpMediaWindowControl->Show(); } } - - MediaWindowImpl::~MediaWindowImpl() { disposeOnce(); @@ -176,24 +148,24 @@ MediaWindowImpl::~MediaWindowImpl() void MediaWindowImpl::dispose() { - if( mpEvents ) + if (mpEvents) mpEvents->cleanUp(); - if( mxPlayerWindow.is() ) + if (mxPlayerWindow.is()) { mxPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); mxPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); mxPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY ); - if( xComponent.is() ) + if (xComponent.is()) xComponent->dispose(); mxPlayerWindow.clear(); } 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(); mxPlayer.clear(); @@ -210,23 +182,24 @@ void MediaWindowImpl::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() ) return xPlayer; - if (SvtSecurityOptions().isUntrustedReferer(rReferer)) { + if (SvtSecurityOptions().isUntrustedReferer(rReferer)) + { 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_NAME, // a fallback path just for gstreamer which has @@ -240,11 +213,11 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& #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 ], - strlen( aServiceManagers[ i ] ), - RTL_TEXTENCODING_ASCII_US ); + const OUString aServiceName(aServiceManagers[i], + strlen( aServiceManagers[i]), + RTL_TEXTENCODING_ASCII_US); xPlayer = createPlayer(rURL, aServiceName, xContext); } @@ -370,51 +343,50 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem ) const AVMediaSetMask nMaskSet = rItem.getMaskSet(); // set URL first - if( nMaskSet & AVMediaSetMask::URL ) + if (nMaskSet & AVMediaSetMask::URL) { m_sMimeType = rItem.getMimeType(); - setURL( rItem.getURL(), rItem.getTempURL(), rItem.getReferer() ); + setURL(rItem.getURL(), rItem.getTempURL(), rItem.getReferer()); } // set different states next - if( nMaskSet & AVMediaSetMask::TIME ) - setMediaTime( ::std::min( rItem.getTime(), getDuration() ) ); + if (nMaskSet & AVMediaSetMask::TIME) + setMediaTime(std::min(rItem.getTime(), getDuration())); - if( nMaskSet & AVMediaSetMask::LOOP ) - setPlaybackLoop( rItem.isLoop() ); + if (nMaskSet & AVMediaSetMask::LOOP) + setPlaybackLoop(rItem.isLoop()); - if( nMaskSet & AVMediaSetMask::MUTE ) - setMute( rItem.isMute() ); + if (nMaskSet & AVMediaSetMask::MUTE) + setMute(rItem.isMute()); - if( nMaskSet & AVMediaSetMask::VOLUMEDB ) - setVolumeDB( rItem.getVolumeDB() ); + if (nMaskSet & AVMediaSetMask::VOLUMEDB) + setVolumeDB(rItem.getVolumeDB()); - if( nMaskSet & AVMediaSetMask::ZOOM ) - setZoom( rItem.getZoom() ); + if (nMaskSet & AVMediaSetMask::ZOOM) + setZoom(rItem.getZoom()); // 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(); } break; - case( MEDIASTATE_PAUSE ): + case MEDIASTATE_PAUSE: { - if( isPlaying() ) + if (isPlaying()) stop(); } break; - case( MEDIASTATE_STOP ): + case MEDIASTATE_STOP: { - if( isPlaying() ) + if (isPlaying()) { setMediaTime( 0.0 ); stop(); @@ -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 ); } -::com::sun::star::media::ZoomLevel MediaWindowImpl::getZoom() const +css::media::ZoomLevel MediaWindowImpl::getZoom() const { return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : media::ZoomLevel_NOT_AVAILABLE ); } @@ -493,12 +465,12 @@ void MediaWindowImpl::setVolumeDB( sal_Int16 nVolumeDB ) 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(); } @@ -506,13 +478,13 @@ void MediaWindowImpl::stopPlayingInternal( bool bStop ) void MediaWindowImpl::onURLChanged() { - if( m_sMimeType == AVMEDIA_MIMETYPE_COMMON ) + if (m_sMimeType == AVMEDIA_MIMETYPE_COMMON) { mpChildWindow.disposeAndClear(); - mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this) ); + mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this)); } #if HAVE_FEATURE_GLTF - else if ( m_sMimeType == AVMEDIA_MIMETYPE_JSON ) + else if (m_sMimeType == AVMEDIA_MIMETYPE_JSON) { SystemWindowData aWinData = OpenGLContext::generateWinData(this, false); mpChildWindow.disposeAndClear(); @@ -520,22 +492,22 @@ void MediaWindowImpl::onURLChanged() mbEventTransparent = false; } #endif - if( !mpChildWindow ) + if (!mpChildWindow) return; - mpChildWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW ); - mxEventsIf.set( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( *mpChildWindow.get() ) ) ); + mpChildWindow->SetHelpId(HID_AVMEDIA_PLAYERWINDOW); + mxEventsIf.set(static_cast<cppu::OWeakObject*>(mpEvents = new MediaEventListenersImpl(*mpChildWindow.get()))); - if( mxPlayer.is() ) + if (mxPlayer.is()) { Resize(); - uno::Sequence< uno::Any > aArgs( 3 ); - uno::Reference< media::XPlayerWindow > xPlayerWindow; - const Point aPoint; - const Size aSize( mpChildWindow->GetSizePixel() ); + uno::Sequence<uno::Any> aArgs( 3 ); + uno::Reference<media::XPlayerWindow> xPlayerWindow; + const Point aPoint; + const Size aSize(mpChildWindow->GetSizePixel()); - aArgs[ 0 ] = uno::makeAny( mpChildWindow->GetParentWindowHandle() ); - 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[0] = uno::makeAny(mpChildWindow->GetParentWindowHandle()); + aArgs[1] = uno::makeAny(awt::Rectangle(aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height())); + aArgs[2] = uno::makeAny(reinterpret_cast<sal_IntPtr>(mpChildWindow.get())); try { @@ -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 ); - if( mpChildWindow ) - mpChildWindow->SetPointer( rPointer ); + SetPointer(rPointer); - if( mxPlayerWindow.is() ) + if (mpChildWindow) + mpChildWindow->SetPointer(rPointer); + + if (mxPlayerWindow.is()) { long nPointer; - switch( rPointer.GetStyle() ) + switch (rPointer.GetStyle()) { - case( POINTER_CROSS ): nPointer = awt::SystemPointer::CROSS; break; - case( POINTER_HAND ): nPointer = awt::SystemPointer::HAND; break; - case( POINTER_MOVE ): nPointer = awt::SystemPointer::MOVE; break; - case( POINTER_WAIT ): nPointer = awt::SystemPointer::WAIT; break; - - default: nPointer = awt::SystemPointer::ARROW; break; + case POINTER_CROSS: + nPointer = awt::SystemPointer::CROSS; + break; + case POINTER_HAND: + nPointer = awt::SystemPointer::HAND; + 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() { - const Size aCurSize( GetOutputSizePixel() ); - const sal_Int32 nOffset( mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0 ); - Size aPlayerWindowSize( aCurSize.Width() - ( nOffset << 1 ), - aCurSize.Height() - ( nOffset << 1 ) ); + const Size aCurSize(GetOutputSizePixel()); + const sal_Int32 nOffset(mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0); - if( mpMediaWindowControl ) + Size aPlayerWindowSize(aCurSize.Width() - (nOffset << 1), + aCurSize.Height() - (nOffset << 1)); + + if (mpMediaWindowControl) { 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 ) ); - mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) ); + aPlayerWindowSize.Height() = (nControlY - (nOffset << 1)); + mpMediaWindowControl->SetPosSizePixel(Point(nOffset, nControlY ), Size(aCurSize.Width() - (nOffset << 1), nControlHeight)); } - if( mpChildWindow ) - mpChildWindow->SetPosSizePixel( Point( 0, 0 ), aPlayerWindowSize ); + if (mpChildWindow) + mpChildWindow->SetPosSizePixel(Point(0, 0), aPlayerWindowSize); - if( mxPlayerWindow.is() ) - mxPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 ); + if (mxPlayerWindow.is()) + 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 - switch( eType ) + switch (eType) { case StateChangedType::Visible: { - stopPlayingInternal( !IsVisible() ); - mxPlayerWindow->setVisible( IsVisible() ); + stopPlayingInternal(!IsVisible()); + mxPlayerWindow->setVisible(IsVisible()); } break; case StateChangedType::Enable: { - stopPlayingInternal( !IsEnabled() ); - mxPlayerWindow->setEnable( IsEnabled() ); + stopPlayingInternal(!IsEnabled()); + mxPlayerWindow->setEnable(IsEnabled()); } break; @@ -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(); BitmapEx* pLogo = NULL; - if( !mxPlayer.is() ) + if (!mxPlayer.is()) { - if( !mpEmptyBmpEx ) - mpEmptyBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) ); + if (!mpEmptyBmpEx) + mpEmptyBmpEx = new BitmapEx(AVMEDIA_RESID(AVMEDIA_BMP_EMPTYLOGO)); pLogo = mpEmptyBmpEx; } - else if( !mxPlayerWindow.is() ) + else if (!mxPlayerWindow.is()) { - if( !mpAudioBmpEx ) - mpAudioBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) ); + if (!mpAudioBmpEx) + mpAudioBmpEx = new BitmapEx(AVMEDIA_RESID(AVMEDIA_BMP_AUDIOLOGO)); pLogo = mpAudioBmpEx; } - if( !mpChildWindow ) + if (!mpChildWindow) 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() ); - const Color aBackgroundColor( 67, 67, 67 ); + Size aLogoSize(pLogo->GetSizePixel()); + const Color aBackgroundColor(67, 67, 67); - SetLineColor( aBackgroundColor ); - SetFillColor( aBackgroundColor ); - DrawRect( aVideoRect ); + rRenderContext.SetLineColor(aBackgroundColor); + rRenderContext.SetFillColor(aBackgroundColor); + rRenderContext.DrawRect(aVideoRect); - if( ( aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) && - ( aLogoSize.Height() > 0 ) ) + if ((aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) && + (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.Height()= aVideoRect.GetHeight(); + aLogoSize.Width() = long(aVideoRect.GetHeight() * fLogoWH); + aLogoSize.Height() = aVideoRect.GetHeight(); } else { 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 ), - aBasePos.Y() + ( ( aVideoRect.GetHeight() - aLogoSize.Height() ) >> 1 ) ), - aLogoSize, *pLogo ); + Point aPoint(aBasePos.X() + ((aVideoRect.GetWidth() - aLogoSize.Width()) >> 1), + aBasePos.Y() + ((aVideoRect.GetHeight() - aLogoSize.Height()) >> 1)); + + rRenderContext.DrawBitmapEx(aPoint, aLogoSize, *pLogo); } } - - void MediaWindowImpl::GetFocus() { } - - -void MediaWindowImpl::MouseMove( const MouseEvent& rMEvt ) +void MediaWindowImpl::MouseMove(const MouseEvent& rMEvt) { - if( mpMediaWindow && mbEventTransparent ) - mpMediaWindow->MouseMove( rMEvt ); + if (mpMediaWindow && mbEventTransparent) + mpMediaWindow->MouseMove(rMEvt); } - - -void MediaWindowImpl::MouseButtonDown( const MouseEvent& rMEvt ) +void MediaWindowImpl::MouseButtonDown(const MouseEvent& rMEvt) { - if( mpMediaWindow && mbEventTransparent ) - mpMediaWindow->MouseButtonDown( rMEvt ); + if (mpMediaWindow && mbEventTransparent) + mpMediaWindow->MouseButtonDown(rMEvt); } - - -void MediaWindowImpl::MouseButtonUp( const MouseEvent& rMEvt ) +void MediaWindowImpl::MouseButtonUp(const MouseEvent& rMEvt) { - if( mpMediaWindow && mbEventTransparent ) - mpMediaWindow->MouseButtonUp( rMEvt ); + if (mpMediaWindow && mbEventTransparent) + mpMediaWindow->MouseButtonUp(rMEvt); } - - -void MediaWindowImpl::KeyInput( const KeyEvent& rKEvt ) +void MediaWindowImpl::KeyInput(const KeyEvent& rKEvt) { - if( mpMediaWindow && mbEventTransparent ) - mpMediaWindow->KeyInput( rKEvt ); + if (mpMediaWindow && mbEventTransparent) + mpMediaWindow->KeyInput(rKEvt); } - - -void MediaWindowImpl::KeyUp( const KeyEvent& rKEvt ) +void MediaWindowImpl::KeyUp(const KeyEvent& rKEvt) { - if( mpMediaWindow && mbEventTransparent ) - mpMediaWindow->KeyUp( rKEvt ); + if (mpMediaWindow && mbEventTransparent) + mpMediaWindow->KeyUp(rKEvt); } - - -void MediaWindowImpl::Command( const CommandEvent& rCEvt ) +void MediaWindowImpl::Command(const CommandEvent& rCEvt) { - if( mpMediaWindow && mbEventTransparent ) - mpMediaWindow->Command( rCEvt ); + if (mpMediaWindow && mbEventTransparent) + 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 ) - mpMediaWindow->StartDrag( nAction, rPosPixel ); + if (mpMediaWindow && mbEventTransparent) + mpMediaWindow->StartDrag(nAction, rPosPixel); } } // namespace priv diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx index 11a95d878e89..b73413d8e36e 100644 --- a/avmedia/source/viewer/mediawindow_impl.hxx +++ b/avmedia/source/viewer/mediawindow_impl.hxx @@ -28,157 +28,147 @@ namespace com { namespace sun { namespace star { namespace media { class XPlayer; class XPlayerWindow; -} } } } +}}}} + namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; -} } } } +}}}} + class BitmapEx; namespace avmedia { - class MediaWindow; - - namespace priv - { - - // - MediaWindowControl - - - - class MediaWindowControl : public MediaControl - { - public: - explicit MediaWindowControl( vcl::Window* pParent ); - - protected: - - void update() SAL_OVERRIDE; - void execute( const MediaItem& rItem ) SAL_OVERRIDE; - }; +class MediaWindow; +namespace priv +{ - // - MediaChildWindow - +class MediaWindowControl : public MediaControl +{ +public: + explicit MediaWindowControl( vcl::Window* pParent ); - class MediaChildWindow : public SystemChildWindow - { - public: +protected: - explicit MediaChildWindow( vcl::Window* pParent ); - MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData ); + void update() SAL_OVERRIDE; + void execute( const MediaItem& rItem ) SAL_OVERRIDE; +}; - protected: +class MediaChildWindow : public SystemChildWindow +{ +public: - 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; - }; + explicit MediaChildWindow( vcl::Window* pParent ); + MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData ); - // ------------------. - // - MediaWindowImpl - +protected: + 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, - public DropTargetHelper, - public DragSourceHelper +class MediaWindowImpl : public Control, public DropTargetHelper, public DragSourceHelper +{ +public: + MediaWindowImpl(vcl::Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl); + virtual ~MediaWindowImpl(); - { - public: + virtual void dispose() SAL_OVERRIDE; - MediaWindowImpl( vcl::Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl ); - virtual ~MediaWindowImpl(); - virtual void dispose() SAL_OVERRIDE; + static css::uno::Reference<css::media::XPlayer> createPlayer(const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = 0); - 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 executeMediaItem( const MediaItem& rItem ); + void setPosSize( const Rectangle& rRect ); - 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 - 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; + // DropTargetHelper + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE; - // DropTargetHelper - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE; - virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE; + // DragSourceHelper + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE; - // DragSourceHelper - virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE; + bool setZoom(css::media::ZoomLevel eLevel); + css::media::ZoomLevel getZoom() const; - bool setZoom( ::com::sun::star::media::ZoomLevel eLevel ); - ::com::sun::star::media::ZoomLevel getZoom() const; + void stop(); - 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 ); - double getMediaTime() const; + void setPlaybackLoop( bool bSet ); + bool isPlaybackLoop() const; - void setPlaybackLoop( bool bSet ); - bool isPlaybackLoop() const; + void setMute( bool bSet ); + bool isMute() const; - void setMute( bool bSet ); - bool isMute() const; + void setVolumeDB( sal_Int16 nVolumeDB ); + sal_Int16 getVolumeDB() const; - void setVolumeDB( sal_Int16 nVolumeDB ); - sal_Int16 getVolumeDB() const; + void stopPlayingInternal( bool ); - 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; - OUString mTempFileURL; - OUString maReferer; - OUString m_sMimeType; - ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer; - ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow; - MediaWindow* mpMediaWindow; + css::uno::Reference<css::uno::XInterface> mxEventsIf; + MediaEventListenersImpl* mpEvents; + bool mbEventTransparent; + VclPtr<MediaChildWindow> mpChildWindow; + VclPtr<MediaWindowControl> mpMediaWindowControl; + BitmapEx* mpEmptyBmpEx; + BitmapEx* mpAudioBmpEx; +}; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf; - MediaEventListenersImpl* mpEvents; - bool mbEventTransparent; - VclPtr<MediaChildWindow> mpChildWindow; - VclPtr<MediaWindowControl> mpMediaWindowControl; - BitmapEx* mpEmptyBmpEx; - BitmapEx* mpAudioBmpEx; - }; - } -} +}} // end namespace avmedia::priv #endif |