From 149f3804a895ceaa05feccb0118de5ac0efbaa5b Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Fri, 22 Oct 2021 20:10:14 -0400 Subject: [PATCH] Add style for manually resizing wxMediaCtrl Previously, wxMediaCtrl would always automatically resize itself whenever a video was loaded. If a wide video was loaded, this could cause wxMediaCtrl to take up the entire space, hiding any other widget(s) that might exist within the same sizer. Allow avoiding this behavior by adding a new style, wxMC_NO_AUTORESIZE, which disables this automatic resize behavior and allows handling the resize behavior manually. --- include/wx/mediactrl.h | 2 ++ interface/wx/mediactrl.h | 12 ++++++++++++ src/common/mediactrlcmn.cpp | 3 +++ 3 files changed, 17 insertions(+) diff --git a/include/wx/mediactrl.h b/include/wx/mediactrl.h index 17b359dc15..ff159817ee 100644 --- a/include/wx/mediactrl.h +++ b/include/wx/mediactrl.h @@ -37,6 +37,8 @@ #include "wx/control.h" #include "wx/uri.h" +#define wxMC_NO_AUTORESIZE 0x0001 + // ============================================================================ // Declarations // ============================================================================ diff --git a/interface/wx/mediactrl.h b/interface/wx/mediactrl.h index 27eb3b0761..4287ab8588 100644 --- a/interface/wx/mediactrl.h +++ b/interface/wx/mediactrl.h @@ -5,6 +5,8 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +#define wxMC_NO_AUTORESIZE 0x0001 + /** Describes the current state of the media. @@ -225,6 +227,16 @@ public: wxActiveXContainer documentation. + @beginStyleTable + @style{wxMC_NO_AUTORESIZE} + By default, the control will automatically adjust its size to + exactly fit the size of a loaded video as soon as a video is loaded. + If this flag is given, the control will not change its size + automatically and must be done manually (if desired) using Layout(). + It is strongly recommended to use this flag and handle control + resizing manually. + @endStyleTable + @library{wxmedia} @category{media} diff --git a/src/common/mediactrlcmn.cpp b/src/common/mediactrlcmn.cpp index 70413a28ca..e4bc3f2a7e 100644 --- a/src/common/mediactrlcmn.cpp +++ b/src/common/mediactrlcmn.cpp @@ -466,6 +466,9 @@ void wxMediaCtrl::DoMoveWindow(int x, int y, int w, int h) void wxMediaBackendCommonBase::NotifyMovieSizeChanged() { + if ( m_ctrl->HasFlag(wxMC_NO_AUTORESIZE) ) + return; + // our best size changed after opening a new file m_ctrl->InvalidateBestSize(); m_ctrl->SetSize(m_ctrl->GetSize());