diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-12 16:27:06 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-13 09:49:00 +0100 |
commit | 9733174ea00e525c91b4edf1bbc6ab4897f5fbf8 (patch) | |
tree | 57ce3beb1d5d8f8089cb509f9f118ce05aec1d3a /avmedia | |
parent | b8d0c50eff51ebe919680a2023ae807973674f75 (diff) |
inherit MediaControl from InterimItemWindow
to de-dup some code
Change-Id: I8bf20d4b57f3ec7bd2902f01e11278da8ded194b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88550
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/inc/mediacontrol.hxx | 11 | ||||
-rw-r--r-- | avmedia/source/framework/mediacontrol.cxx | 41 | ||||
-rw-r--r-- | avmedia/source/framework/mediatoolbox.cxx | 4 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.cxx | 2 |
4 files changed, 12 insertions, 46 deletions
diff --git a/avmedia/inc/mediacontrol.hxx b/avmedia/inc/mediacontrol.hxx index 9899418a6052..254c29dbc434 100644 --- a/avmedia/inc/mediacontrol.hxx +++ b/avmedia/inc/mediacontrol.hxx @@ -21,7 +21,7 @@ #include <avmedia/mediaitem.hxx> -#include <vcl/ctrl.hxx> +#include <sfx2/InterimItemWindow.hxx> #include <vcl/timer.hxx> #include <vcl/idle.hxx> #include <vcl/weld.hxx> @@ -34,15 +34,13 @@ namespace avmedia class MediaItem; -class MediaControl : public Control, public MediaControlBase +class MediaControl : public InterimItemWindow, public MediaControlBase { public: MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyle ); virtual ~MediaControl() override; virtual void dispose() override; - Size getMinSizePixel() const; - void setState( const MediaItem& rItem ); void UpdateURLField( MediaItem const & maItem ); @@ -51,7 +49,6 @@ protected: virtual void update() = 0; virtual void execute( const MediaItem& rItem ) = 0; - virtual void Resize() override; virtual void InitializeWidgets() override; std::unique_ptr<weld::Label> mxMediaPath; @@ -64,10 +61,6 @@ private: DECL_LINK(implZoomSelectHdl, weld::ComboBox&, void); DECL_LINK(implTimeoutHdl, Timer*, void); - std::unique_ptr<weld::Builder> m_xBuilder; - VclPtr<vcl::Window> m_xVclContentArea; - std::unique_ptr<weld::Container> m_xContainer; - Idle maIdle; Idle maChangeTimeIdle; MediaItem maItem; diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index a9c144b1e455..596234771ef1 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -36,7 +36,12 @@ namespace avmedia { MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyle ) : - Control( pParent ), + // MEDIACONTROLSTYLE_MULTILINE is the normal docking windows of tools->media player + // MEDIACONTROLSTYLE_SINGLELINE is the toolbar of view->toolbar->media playback + InterimItemWindow(pParent, eControlStyle == MEDIACONTROLSTYLE_MULTILINE ? + OUString("svx/ui/mediawindow.ui") : + OUString("svx/ui/medialine.ui"), + "MediaWindow"), MediaControlBase(), maIdle( "avmedia MediaControl Idle" ), maChangeTimeIdle( "avmedia MediaControl Change Time Idle" ), @@ -45,18 +50,6 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl meControlStyle( eControlStyle ), mfTime(0.0) { - SetStyle(GetStyle() | WB_DIALOGCONTROL); - - m_xVclContentArea = VclPtr<VclVBox>::Create(this); - m_xVclContentArea->Show(); - // MEDIACONTROLSTYLE_MULTILINE is the normal docking windows of tools->media player - // MEDIACONTROLSTYLE_SINGLELINE is the toolbar of view->toolbar->media playback - m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, - eControlStyle == MEDIACONTROLSTYLE_MULTILINE ? - OUString("svx/ui/mediawindow.ui") : - OUString("svx/ui/medialine.ui"))); - m_xContainer = m_xBuilder->weld_container("MediaWindow"); - mxPlayToolBox = m_xBuilder->weld_toolbar("playtoolbox"); mxTimeSlider = m_xBuilder->weld_scale("timeslider"); mxMuteToolBox = m_xBuilder->weld_toolbar("mutetoolbox"); @@ -65,9 +58,7 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl mxTimeEdit = m_xBuilder->weld_entry("timeedit"); mxMediaPath = m_xBuilder->weld_label("url"); - SetBackground(); - SetPaintTransparent( true ); - SetParentClipMode( ParentClipMode::NoClip ); + // TODO SetParentClipMode( ParentClipMode::NoClip ); InitializeWidgets(); @@ -123,15 +114,7 @@ void MediaControl::dispose() { disposeWidgets(); mxMediaPath.reset(); - m_xContainer.reset(); - m_xBuilder.reset(); - m_xVclContentArea.disposeAndClear(); - Control::dispose(); -} - -Size MediaControl::getMinSizePixel() const -{ - return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); + InterimItemWindow::dispose(); } void MediaControl::UpdateURLField(MediaItem const & tempItem) @@ -140,14 +123,6 @@ void MediaControl::UpdateURLField(MediaItem const & tempItem) mxMediaPath->set_label(aURL); } -void MediaControl::Resize() -{ - vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); - assert(pChild); - VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel()); - Control::Resize(); -} - void MediaControl::setState( const MediaItem& rItem ) { double fTime = rItem.getTime(); diff --git a/avmedia/source/framework/mediatoolbox.cxx b/avmedia/source/framework/mediatoolbox.cxx index b085d8a77f39..a291218da6c5 100644 --- a/avmedia/source/framework/mediatoolbox.cxx +++ b/avmedia/source/framework/mediatoolbox.cxx @@ -46,15 +46,13 @@ private: MediaToolBoxControl* mpToolBoxControl; }; - MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( vcl::Window& rParent, MediaToolBoxControl& rControl ) : MediaControl( &rParent, MEDIACONTROLSTYLE_SINGLELINE ), mpToolBoxControl( &rControl ) { - SetSizePixel( getMinSizePixel() ); + SetSizePixel(m_xContainer->get_preferred_size()); } - void MediaToolBoxControl_Impl::update() { mpToolBoxControl->implUpdateMediaControl(); diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index fdc78575f8b7..3e95252d6ad0 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -125,7 +125,7 @@ MediaWindowImpl::MediaWindowImpl(vcl::Window* pParent, MediaWindow* pMediaWindow { if (mpMediaWindowControl) { - mpMediaWindowControl->SetSizePixel(mpMediaWindowControl->getMinSizePixel()); + mpMediaWindowControl->SetSizePixel(mpMediaWindowControl->GetOptimalSize()); mpMediaWindowControl->Show(); } } |