FIX: wxMediaCtrl3 idle image & center pos
Change-Id: Ib9652573e31bfd6229f174c0a1388942d9d98822 Jira: STUDIO-7633
This commit is contained in:
parent
5a2c75d835
commit
d51247c46e
|
@ -125,13 +125,20 @@ void wxMediaCtrl3::paintEvent(wxPaintEvent &evt)
|
||||||
auto size2 = m_frame.GetSize();
|
auto size2 = m_frame.GetSize();
|
||||||
if (size2.x != m_frame_size.x && size2.y == m_frame_size.y)
|
if (size2.x != m_frame_size.x && size2.y == m_frame_size.y)
|
||||||
size2.x = m_frame_size.x;
|
size2.x = m_frame_size.x;
|
||||||
|
auto size3 = (size - size2) / 2;
|
||||||
if (size2.x != size.x && size2.y != size.y) {
|
if (size2.x != size.x && size2.y != size.y) {
|
||||||
auto scale = std::min(double(size.x) / size2.x, double(size.y) / size2.y);
|
double scale = 1.;
|
||||||
dc.SetUserScale(scale, scale);
|
if (size.x * size2.y > size.y * size2.x) {
|
||||||
adjust_frame_size(size2, size2, size);
|
size3 = {size.x * size2.y / size.y, size2.y};
|
||||||
|
scale = double(size.y) / size2.y;
|
||||||
|
} else {
|
||||||
|
size3 = {size2.x, size.y * size2.x / size.x};
|
||||||
|
scale = double(size.x) / size2.x;
|
||||||
}
|
}
|
||||||
size2 = (size - size2) / 2;
|
dc.SetUserScale(scale, scale);
|
||||||
dc.DrawBitmap(m_frame, size2.x, size2.y);
|
size3 = (size3 - size2) / 2;
|
||||||
|
}
|
||||||
|
dc.DrawBitmap(m_frame, size3.x, size3.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMediaCtrl3::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
void wxMediaCtrl3::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
|
@ -141,6 +148,7 @@ void wxMediaCtrl3::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
wxMediaCtrl_OnSize(this, m_video_size, width, height);
|
wxMediaCtrl_OnSize(this, m_video_size, width, height);
|
||||||
std::unique_lock<std::mutex> lk(m_mutex);
|
std::unique_lock<std::mutex> lk(m_mutex);
|
||||||
adjust_frame_size(m_frame_size, m_video_size, GetSize());
|
adjust_frame_size(m_frame_size, m_video_size, GetSize());
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMediaCtrl3::bambu_log(void *ctx, int level, tchar const *msg2)
|
void wxMediaCtrl3::bambu_log(void *ctx, int level, tchar const *msg2)
|
||||||
|
@ -230,16 +238,16 @@ void wxMediaCtrl3::PlayThread()
|
||||||
lk.lock();
|
lk.lock();
|
||||||
}
|
}
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
if (m_url != url) {
|
|
||||||
error = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
auto frame_size = m_frame_size;
|
auto frame_size = m_frame_size;
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
wxBitmap bm;
|
wxBitmap bm;
|
||||||
decoder.decode(sample);
|
decoder.decode(sample);
|
||||||
decoder.toWxBitmap(bm, frame_size);
|
decoder.toWxBitmap(bm, frame_size);
|
||||||
lk.lock();
|
lk.lock();
|
||||||
|
if (m_url != url) {
|
||||||
|
error = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (bm.IsOk())
|
if (bm.IsOk())
|
||||||
m_frame = bm;
|
m_frame = bm;
|
||||||
CallAfter([this] { Refresh(); });
|
CallAfter([this] { Refresh(); });
|
||||||
|
@ -254,6 +262,7 @@ void wxMediaCtrl3::PlayThread()
|
||||||
}
|
}
|
||||||
if (m_url == url)
|
if (m_url == url)
|
||||||
m_error = error;
|
m_error = error;
|
||||||
|
m_frame_size = wxDefaultSize;
|
||||||
m_video_size = wxDefaultSize;
|
m_video_size = wxDefaultSize;
|
||||||
NotifyStopped();
|
NotifyStopped();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue