ENH: save video ctrl size to reduce layout change

Change-Id: I470f29d7f029d304c9badeeb8f94bed281080b29
Jira: STUDIO-6141
This commit is contained in:
chunmao.guo 2024-02-02 08:52:04 +08:00 committed by Lane.Wei
parent 4bb8c6b373
commit 30dc8b3117
4 changed files with 10 additions and 5 deletions

View File

@ -772,9 +772,7 @@ void wxMediaCtrl2::DoSetSize(int x, int y, int width, int height, int sizeFlags)
wxMediaCtrl::DoSetSize(x, y, width, height, sizeFlags); wxMediaCtrl::DoSetSize(x, y, width, height, sizeFlags);
#endif #endif
if (sizeFlags & wxSIZE_USE_EXISTING) return; if (sizeFlags & wxSIZE_USE_EXISTING) return;
wxSize size = GetVideoSize(); wxSize size = m_video_size;
if (size.GetWidth() <= 0)
size = wxSize{16, 9};
int maxHeight = (width * size.GetHeight() + size.GetHeight() - 1) / size.GetWidth(); int maxHeight = (width * size.GetHeight() + size.GetHeight() - 1) / size.GetWidth();
if (maxHeight != GetMaxHeight()) { if (maxHeight != GetMaxHeight()) {
// BOOST_LOG_TRIVIAL(info) << "wxMediaCtrl2::DoSetSize: width: " << width << ", height: " << height << ", maxHeight: " << maxHeight; // BOOST_LOG_TRIVIAL(info) << "wxMediaCtrl2::DoSetSize: width: " << width << ", height: " << height << ", maxHeight: " << maxHeight;

View File

@ -216,7 +216,10 @@ wxSize wxMediaCtrl2::GetVideoSize() const
// "Loading...". Fake it out for now. // "Loading...". Fake it out for now.
return m_loaded ? wxSize(1280, 720) : wxSize{}; return m_loaded ? wxSize(1280, 720) : wxSize{};
#else #else
return m_imp ? m_imp->GetVideoSize() : wxSize(0, 0); wxSize size = m_imp ? m_imp->GetVideoSize() : wxSize(0, 0);
if (size.GetWidth() > 0)
const_cast<wxSize&>(m_video_size) = size;
return size;
#endif #endif
} }

View File

@ -50,6 +50,7 @@ private:
void * m_player = nullptr; void * m_player = nullptr;
wxMediaState m_state = wxMEDIASTATE_STOPPED; wxMediaState m_state = wxMEDIASTATE_STOPPED;
int m_error = 0; int m_error = 0;
wxSize m_video_size{16, 9};
}; };
#else #else
@ -86,6 +87,7 @@ private:
wxString m_idle_image; wxString m_idle_image;
int m_error = 0; int m_error = 0;
bool m_loaded = false; bool m_loaded = false;
wxSize m_video_size{16, 9};
}; };
#endif #endif

View File

@ -155,6 +155,8 @@ wxSize wxMediaCtrl2::GetVideoSize() const
BambuPlayer * player2 = (BambuPlayer *) m_player; BambuPlayer * player2 = (BambuPlayer *) m_player;
if (player2) { if (player2) {
NSSize size = [player2 videoSize]; NSSize size = [player2 videoSize];
if (size.width > 0)
const_cast<wxSize&>(m_video_size) = {(int) size.width, (int) size.height};
return {(int) size.width, (int) size.height}; return {(int) size.width, (int) size.height};
} else { } else {
return {0, 0}; return {0, 0};