From 580ca0a4e10dbd2fb0a144065004394b9d5dcc56 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 3 Nov 2006 22:16:51 +0000 Subject: [PATCH] wxAnimationCtrl fix to display inactive bitmap at start (patch 1590192) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43001 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/animate.h | 2 +- src/common/animatecmn.cpp | 6 ------ src/generic/animateg.cpp | 15 +++++++++++++-- src/gtk/animate.cpp | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/wx/animate.h b/include/wx/animate.h index 583b1afc74..d228b37f19 100644 --- a/include/wx/animate.h +++ b/include/wx/animate.h @@ -82,7 +82,7 @@ public: // public API virtual bool IsPlaying() const = 0; - virtual void SetInactiveBitmap(const wxBitmap &bmp); + virtual void SetInactiveBitmap(const wxBitmap &bmp) = 0; wxBitmap GetInactiveBitmap() const { return m_bmpStatic; } diff --git a/src/common/animatecmn.cpp b/src/common/animatecmn.cpp index e9c0b8678a..512c309942 100644 --- a/src/common/animatecmn.cpp +++ b/src/common/animatecmn.cpp @@ -30,11 +30,5 @@ wxAnimation wxNullAnimation; IMPLEMENT_ABSTRACT_CLASS(wxAnimationBase, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxAnimationCtrlBase, wxControl) -void wxAnimationCtrlBase::SetInactiveBitmap(const wxBitmap &bmp) -{ - m_bmpStatic = bmp; - m_bmpStatic.UnShare(); -} - #endif // wxUSE_ANIMATIONCTRL diff --git a/src/generic/animateg.cpp b/src/generic/animateg.cpp index 2035cbb4f4..8daee51ebf 100644 --- a/src/generic/animateg.cpp +++ b/src/generic/animateg.cpp @@ -343,7 +343,7 @@ void wxAnimationCtrl::SetAnimation(const wxAnimation& animation) void wxAnimationCtrl::SetInactiveBitmap(const wxBitmap &bmp) { - wxAnimationCtrlBase::SetInactiveBitmap(bmp); + m_bmpStatic = bmp; // if not playing, update the backing store now if (!IsPlaying()) @@ -630,10 +630,21 @@ void wxAnimationCtrl::OnSize(wxSizeEvent &WXUNUSED(event)) { // NB: resizing an animation control may take a lot of time // for big animations as the backing store must be - // extended and rebuilt. Try to avoid it!! + // extended and rebuilt. Try to avoid it e.g. using + // a null proportion value for your wxAnimationCtrls + // when using them inside sizers. if (m_animation.IsOk()) + { + // be careful to change the backing store *only* if we are + // playing the animation as otherwise we may be displaying + // the inactive bitmap and overwriting the backing store + // with the last played frame is wrong in this case + if (IsPlaying()) + { if (!RebuildBackingStoreUpToFrame(m_currentFrame)) Stop(); // in case we are playing + } + } } #endif // wxUSE_ANIMATIONCTRL diff --git a/src/gtk/animate.cpp b/src/gtk/animate.cpp index 7b3b798c00..05285756e6 100644 --- a/src/gtk/animate.cpp +++ b/src/gtk/animate.cpp @@ -320,7 +320,7 @@ void wxAnimationCtrl::Stop() void wxAnimationCtrl::SetInactiveBitmap(const wxBitmap &bmp) { - wxAnimationCtrlBase::SetInactiveBitmap(bmp); + m_bmpStatic = bmp; // update the pixbuf associated with m_widget now... if (!IsPlaying()) -- 2.45.2