summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-18 21:09:30 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-02-19 12:01:54 +0100
commit6f938dce6eaa927cfde39491ef7a0bc1d07df66b (patch)
treec866f70da6f4d1f4a47c5bb871fd98aaaf2cc994 /svx
parentf10ac3e5bd720e363e5c76a2c841dded4859a7a0 (diff)
update video pos and size after change if currently playing
I'd prefer if it changed size during the resizing/repositioning, but at least make it immediately take the final size after the resize/reposition has happened. Change-Id: Ic3b4dd23921ad5cf6092f1514dd6538f9946998a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130178 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/sdr/contact/viewobjectcontactofsdrmediaobj.hxx4
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx65
2 files changed, 42 insertions, 27 deletions
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;