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.
This commit is contained in:
Scott Talbert
2021-10-22 20:10:14 -04:00
parent a809b6f058
commit 149f3804a8
3 changed files with 17 additions and 0 deletions

View File

@@ -37,6 +37,8 @@
#include "wx/control.h"
#include "wx/uri.h"
#define wxMC_NO_AUTORESIZE 0x0001
// ============================================================================
// Declarations
// ============================================================================

View File

@@ -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}

View File

@@ -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());