diff options
-rw-r--r-- | avmedia/source/viewer/mediawindow.cxx | 8 | ||||
-rw-r--r-- | include/avmedia/mediawindow.hxx | 1 | ||||
-rw-r--r-- | svx/inc/sdr/contact/viewobjectcontactofsdrmediaobj.hxx | 4 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx | 65 |
4 files changed, 47 insertions, 31 deletions
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx index 6c61a7e9b361..c251f020225e 100644 --- a/avmedia/source/viewer/mediawindow.cxx +++ b/avmedia/source/viewer/mediawindow.cxx @@ -142,30 +142,30 @@ bool MediaWindow::start() return mpImpl->start(); } - void MediaWindow::updateMediaItem( MediaItem& rItem ) const { mpImpl->updateMediaItem( rItem ); } - void MediaWindow::executeMediaItem( const MediaItem& rItem ) { mpImpl->executeMediaItem( rItem ); } - void MediaWindow::show() { mpImpl->Show(); } - void MediaWindow::hide() { mpImpl->Hide(); } +bool MediaWindow::isVisible() const +{ + return mpImpl->IsVisible(); +} vcl::Window* MediaWindow::getWindow() const { diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx index 78e0b1a299a3..d031f51adaf0 100644 --- a/include/avmedia/mediawindow.hxx +++ b/include/avmedia/mediawindow.hxx @@ -74,6 +74,7 @@ namespace avmedia void show(); void hide(); + bool isVisible() const; public: diff --git a/svx/inc/sdr/contact/viewobjectcontactofsdrmediaobj.hxx b/svx/inc/sdr/contact/viewobjectcontactofsdrmediaobj.hxx index 21fbed38142c..d362048df3db 100644 --- a/svx/inc/sdr/contact/viewobjectcontactofsdrmediaobj.hxx +++ b/svx/inc/sdr/contact/viewobjectcontactofsdrmediaobj.hxx @@ -51,7 +51,11 @@ namespace sdr::contact void updateMediaItem( ::avmedia::MediaItem& rItem ) const; void executeMediaItem( const ::avmedia::MediaItem& rItem ); + virtual void ActionChanged() override; + private: + void updateMediaWindow() const; + #if HAVE_FEATURE_AVMEDIA std::unique_ptr<sdr::contact::SdrMediaWindow> mpMediaWindow; #endif diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx index 27768ff0777f..0241fabd5661 100644 --- a/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx @@ -84,6 +84,43 @@ Size ViewObjectContactOfSdrMediaObj::getPreferredSize() const return aRet; } +void ViewObjectContactOfSdrMediaObj::ActionChanged() +{ + ViewObjectContactOfSdrObj::ActionChanged(); + if (mpMediaWindow && mpMediaWindow->isVisible()) + updateMediaWindow(); +} + +void ViewObjectContactOfSdrMediaObj::updateMediaWindow() const +{ + basegfx::B2DRange aViewRange(getObjectRange()); + aViewRange.transform(GetObjectContact().getViewInformation2D().getViewTransformation()); + + const tools::Rectangle aViewRectangle( + static_cast<sal_Int32>(floor(aViewRange.getMinX())), static_cast<sal_Int32>(floor(aViewRange.getMinY())), + static_cast<sal_Int32>(ceil(aViewRange.getMaxX())), static_cast<sal_Int32>(ceil(aViewRange.getMaxY()))); + + // mpMediaWindow contains a SalObject window and gtk won't accept + // the size until after the SalObject widget is shown but if we + // show it before setting a size then vcl will detect that the + // vcl::Window has no size and make it invisible instead. If we + // call setPosSize twice with the same size before and after show + // then the second attempt is a no-op as vcl caches the size. + + // so call it initially with a size arbitrarily 1 pixel wider than + // we want so we have an initial size to make vcl happy + tools::Rectangle aInitialRect(aViewRectangle); + aInitialRect.AdjustRight(1); + mpMediaWindow->setPosSize(aInitialRect); + + // then make it visible + mpMediaWindow->show(); + + // set the final desired size which is different to let vcl send it + // through to gtk which will now accept it as the underlying + // m_pSocket of GtkSalObject::SetPosSize is now visible + mpMediaWindow->setPosSize(aViewRectangle); +} void ViewObjectContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const { @@ -100,33 +137,7 @@ void ViewObjectContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rIte } else { - basegfx::B2DRange aViewRange(getObjectRange()); - aViewRange.transform(GetObjectContact().getViewInformation2D().getViewTransformation()); - - const tools::Rectangle aViewRectangle( - static_cast<sal_Int32>(floor(aViewRange.getMinX())), static_cast<sal_Int32>(floor(aViewRange.getMinY())), - static_cast<sal_Int32>(ceil(aViewRange.getMaxX())), static_cast<sal_Int32>(ceil(aViewRange.getMaxY()))); - - // mpMediaWindow contains a SalObject window and gtk won't accept - // the size until after the SalObject widget is shown but if we - // show it before setting a size then vcl will detect that the - // vcl::Window has no size and make it invisible instead. If we - // call setPosSize twice with the same size before and after show - // then the second attempt is a no-op as vcl caches the size. - - // so call it initially with a size arbitrarily 1 pixel wider than - // we want so we have an initial size to make vcl happy - tools::Rectangle aInitialRect(aViewRectangle); - aInitialRect.AdjustRight(1); - mpMediaWindow->setPosSize(aInitialRect); - - // then make it visible - mpMediaWindow->show(); - - // set the final desired size which is different to let vcl send it - // through to gtk which will now accept it as the underlying - // m_pSocket of GtkSalObject::SetPosSize is now visible - mpMediaWindow->setPosSize(aViewRectangle); + updateMediaWindow(); } #else (void) rItem; |