summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
70fc30a)
version
- fix wxAnimationCtrl::GetAnimation for GTK version (modifying correctly the
constructor which takes a GdkPixbufAnimation)
- fix the generic wxAnimationCtrl::SetAnimation() when it's used with a
wxNullAnimation.
- moves the frame counter reset in Stop() as it's more sensed to always have
m_currentFrame cleared immediately when the animation has been stopped
- fix a problem with transparent bitmaps drawing in wxAnimationCtrl::OnPaint
(part of patch
1598005)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43475
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void SetInactiveBitmap(const wxBitmap &bmp);
void SetInactiveBitmap(const wxBitmap &bmp);
+ // override base class method
+ virtual bool SetBackgroundColour(const wxColour& col);
+
public: // event handlers
void OnPaint(wxPaintEvent& event);
public: // event handlers
void OnPaint(wxPaintEvent& event);
class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
{
public:
class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
{
public:
- wxAnimation(GdkPixbufAnimation *p = NULL) { m_pixbuf = p; }
+ wxAnimation(GdkPixbufAnimation *p = NULL);
wxAnimation(const wxAnimation&);
~wxAnimation() { UnRef(); }
wxAnimation(const wxAnimation&);
~wxAnimation() { UnRef(); }
// for preventing duplicate additions. If someone ever has
// a good reason to add and remove duplicate handlers (and they
// may) we should probably refcount the duplicates.
// for preventing duplicate additions. If someone ever has
// a good reason to add and remove duplicate handlers (and they
// may) we should probably refcount the duplicates.
- // also an issue in InsertHandler below.
wxLogDebug( _T("Adding duplicate animation handler for '%d' type"),
handler->GetType() );
wxLogDebug( _T("Adding duplicate animation handler for '%d' type"),
handler->GetType() );
+ // set new animation even if it's wxNullAnimation
+ if (!m_animation.IsOk())
+ {
+ UpdateBackingStoreWithStaticImage();
+ return;
+ }
if (m_animation.GetBackgroundColour() == wxNullColour)
SetUseWindowBackgroundColour();
if (!this->HasFlag(wxAC_NO_AUTORESIZE))
FitToAnimation();
if (m_animation.GetBackgroundColour() == wxNullColour)
SetUseWindowBackgroundColour();
if (!this->HasFlag(wxAC_NO_AUTORESIZE))
FitToAnimation();
- // reset frame counter
- m_currentFrame = 0;
-
UpdateBackingStoreWithStaticImage();
}
UpdateBackingStoreWithStaticImage();
}
+ // if the bitmap has an associated mask, we need to set our background to
+ // the colour of our parent otherwise when calling DrawCurrentFrame()
+ // (which uses the bitmap's mask), our background colour would be used for
+ // transparent areas - and that's not what we want (at least for
+ // consistency with the GTK version)
+ if ( bmp.GetMask() != NULL && GetParent() != NULL )
+ SetBackgroundColour(GetParent()->GetBackgroundColour());
+
// if not playing, update the backing store now
// if not playing, update the backing store now
UpdateBackingStoreWithStaticImage();
}
UpdateBackingStoreWithStaticImage();
}
SetSize(m_animation.GetSize());
}
SetSize(m_animation.GetSize());
}
+bool wxAnimationCtrl::SetBackgroundColour(const wxColour& colour)
+{
+ if ( !wxWindow::SetBackgroundColour(colour) )
+ return false;
+
+ // if not playing, then this change must be seen immediately (unless
+ // there's an inactive bitmap set which has higher priority than bg colour)
+ if ( !IsPlaying() )
+ UpdateBackingStoreWithStaticImage();
+
+ return true;
+}
+
// ----------------------------------------------------------------------------
// wxAnimationCtrl - stop/play methods
// ----------------------------------------------------------------------------
// wxAnimationCtrl - stop/play methods
m_timer.Stop();
m_isPlaying = false;
m_timer.Stop();
m_isPlaying = false;
+ // reset frame counter
+ m_currentFrame = 0;
+
UpdateBackingStoreWithStaticImage();
}
UpdateBackingStoreWithStaticImage();
}
if (m_bmpStatic.IsOk())
{
// copy the inactive bitmap in the backing store
if (m_bmpStatic.IsOk())
{
// copy the inactive bitmap in the backing store
- m_backingStore = m_bmpStatic;
+ // eventually using the mask if the static bitmap has one
+ if ( m_bmpStatic.GetMask() )
+ {
+ wxMemoryDC temp;
+ temp.SelectObject(m_backingStore);
+ DisposeToBackground(temp);
+ temp.DrawBitmap(m_bmpStatic, 0, 0, true /* use mask */);
+ }
+ else
+ m_backingStore = m_bmpStatic;
wxColour col = IsUsingWindowBackgroundColour()
? GetBackgroundColour()
: m_animation.GetBackgroundColour();
wxColour col = IsUsingWindowBackgroundColour()
? GetBackgroundColour()
: m_animation.GetBackgroundColour();
wxBrush brush(col);
dc.SetBackground(brush);
dc.Clear();
wxBrush brush(col);
dc.SetBackground(brush);
dc.Clear();
wxPaintDC dc(this);
if ( m_backingStore.IsOk() )
wxPaintDC dc(this);
if ( m_backingStore.IsOk() )
+ {
+ // NOTE: we draw the bitmap explicitely ignoring the mask (if any);
+ // i.e. we don't want to combine the backing store with the
+ // possibly wrong preexisting contents of the window!
+ dc.DrawBitmap(m_backingStore, 0, 0, false /* no mask */);
+ }
else
{
// m_animation is not valid and thus we don't have a valid backing store...
else
{
// m_animation is not valid and thus we don't have a valid backing store...
// with the last played frame is wrong in this case
if (IsPlaying())
{
// with the last played frame is wrong in this case
if (IsPlaying())
{
- if (!RebuildBackingStoreUpToFrame(m_currentFrame))
- Stop(); // in case we are playing
+ if (!RebuildBackingStoreUpToFrame(m_currentFrame))
+ Stop(); // in case we are playing
g_object_ref(m_pixbuf);
}
g_object_ref(m_pixbuf);
}
+wxAnimation::wxAnimation(GdkPixbufAnimation *p)
+{
+ m_pixbuf = p;
+ if ( m_pixbuf )
+ g_object_ref(m_pixbuf);
+}
+
wxAnimation& wxAnimation::operator=(const wxAnimation& that)
{
if (this != &that)
wxAnimation& wxAnimation::operator=(const wxAnimation& that)
{
if (this != &that)
h = gdk_pixbuf_animation_get_height(m_anim);
// update our size to fit animation
h = gdk_pixbuf_animation_get_height(m_anim);
// update our size to fit animation
}
void wxAnimationCtrl::ResetAnim()
}
void wxAnimationCtrl::ResetAnim()
// Thus we clear the GtkImage contents to the background colour...
if (!wxControl::SetBackgroundColour(colour))
return false;
// Thus we clear the GtkImage contents to the background colour...
if (!wxControl::SetBackgroundColour(colour))
return false;
- ClearToBackgroundColour();
+
+ // if not playing the change must take place immediately but
+ // remember that the inactive bitmap has higher priority over the background
+ // colour; DisplayStaticImage() will handle that
+ if ( !IsPlaying() )
+ DisplayStaticImage();
+