diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 03:51:32 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 03:51:32 +0000 |
commit | 1c5fe5c35c2c6b49ca8af0434eb9447747968f7d (patch) | |
tree | c329dc26d0d206ac9eb396d7ebdc940c0ebb080b | |
parent | 7146860795fd1bb85d9804968a5c9532e0e12cee (diff) | |
download | chromium_src-1c5fe5c35c2c6b49ca8af0434eb9447747968f7d.zip chromium_src-1c5fe5c35c2c6b49ca8af0434eb9447747968f7d.tar.gz chromium_src-1c5fe5c35c2c6b49ca8af0434eb9447747968f7d.tar.bz2 |
Gtk: Update slide animation progress in a cleaner way.
BUG=none
TEST=animations still work: infobar, findbar, download shelf
Review URL: http://codereview.chromium.org/255071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27934 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/slide_animator_gtk.cc | 24 | ||||
-rw-r--r-- | chrome/browser/gtk/slide_animator_gtk.h | 4 |
2 files changed, 6 insertions, 22 deletions
diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc index b6837fc..7a51451f 100644 --- a/chrome/browser/gtk/slide_animator_gtk.cc +++ b/chrome/browser/gtk/slide_animator_gtk.cc @@ -28,8 +28,7 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child, Delegate* delegate) : child_(child), direction_(direction), - delegate_(delegate), - fixed_needs_resize_(false) { + delegate_(delegate) { widget_.Own(gtk_fixed_new()); gtk_fixed_put(GTK_FIXED(widget_.get()), child, 0, 0); gtk_widget_set_size_request(widget_.get(), -1, 0); @@ -71,16 +70,7 @@ void SlideAnimatorGtk::Open() { void SlideAnimatorGtk::OpenWithoutAnimation() { animation_->Reset(1.0); Open(); - - // This checks to see if |child_| has been allocated yet. If it has been - // allocated already, we can go ahead and reposition everything by calling - // AnimationProgressed(). If it has not been allocated, we have to delay - // this call until it has been allocated (see OnChildSizeAllocate). - if (child_->allocation.x != -1) { - AnimationProgressed(animation_.get()); - } else { - fixed_needs_resize_ = true; - } + AnimationProgressed(animation_.get()); } void SlideAnimatorGtk::Close() { @@ -111,7 +101,10 @@ bool SlideAnimatorGtk::IsAnimating() { } void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) { - int showing_height = static_cast<int>(child_->allocation.height * + GtkRequisition req; + gtk_widget_size_request(child_, &req); + + int showing_height = static_cast<int>(req.height * animation_->GetCurrentValue()); if (direction_ == DOWN) { gtk_fixed_move(GTK_FIXED(widget_.get()), child_, 0, @@ -136,9 +129,4 @@ void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child, gtk_fixed_move(GTK_FIXED(slider->widget()), child, 0, -allocation->height); slider->child_needs_move_ = false; } - - if (slider->fixed_needs_resize_) { - slider->AnimationProgressed(slider->animation_.get()); - slider->fixed_needs_resize_ = false; - } } diff --git a/chrome/browser/gtk/slide_animator_gtk.h b/chrome/browser/gtk/slide_animator_gtk.h index b2f6677..9e53ba8 100644 --- a/chrome/browser/gtk/slide_animator_gtk.h +++ b/chrome/browser/gtk/slide_animator_gtk.h @@ -102,10 +102,6 @@ class SlideAnimatorGtk : public AnimationDelegate { // The object to inform about certain events. It may be NULL. Delegate* delegate_; - // If true, we should resize |widget_| on the next "size-allocate" event that - // is received by |child_|. See the comment in SlideAnimatorGtk constructor. - bool fixed_needs_resize_; - // We need to move the child widget to (0, -height), but we don't know its // height until it has been allocated. This variable will be true until the // child widget has been allocated, at which point we will move it, and then |