Commit 91278f54 authored by estade@chromium.org's avatar estade@chromium.org

Fix SlideAnimatorGtk::OpenWithoutAnimation().

We weren't sizing the GtkFixed widget because the animation delegate callbacks weren't being called. Now we artificially call AnimationProgressed() once we know what size the GtkFixed should be.

TEST=switching back to a tab that has an infobar open should properly display that infobar.

Review URL: http://codereview.chromium.org/99110

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14893 0039d316-1c4b-4281-b951-d872f2087c98
parent e9eef651
......@@ -4,17 +4,15 @@
#include "chrome/browser/gtk/slide_animator_gtk.h"
#include <gtk/gtk.h>
#include "base/logging.h"
#include "chrome/common/animation.h"
#include "chrome/common/slide_animation.h"
namespace {
void OnSizeAllocate(GtkWidget* fixed,
GtkAllocation* allocation,
GtkWidget* child) {
void OnFixedSizeAllocate(GtkWidget* fixed,
GtkAllocation* allocation,
GtkWidget* child) {
gint height;
gtk_widget_get_size_request(child, NULL, &height);
// The size of the GtkFixed has changed. We want |child_| to match widths,
......@@ -31,7 +29,8 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child,
Delegate* delegate)
: child_(child),
direction_(direction),
delegate_(delegate) {
delegate_(delegate),
fixed_needs_resize_(false) {
widget_.Own(gtk_fixed_new());
// We need to give the GtkFixed its own window so that painting will clip
// correctly.
......@@ -41,7 +40,15 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child,
// We have to manually set the size request for |child_| every time the
// GtkFixed changes sizes.
g_signal_connect(widget_.get(), "size-allocate",
G_CALLBACK(OnSizeAllocate), child_);
G_CALLBACK(OnFixedSizeAllocate), child_);
// The size of the GtkFixed widget is set during animation. When we open
// without showing the animation, we have to call AnimationProgressed
// ourselves to properly set the size of the GtkFixed. We can't do this until
// after the child has been allocated, hence we connect to "size-allocate" on
// the child.
g_signal_connect(child, "size-allocate",
G_CALLBACK(OnChildSizeAllocate), this);
animation_.reset(new SlideAnimation(this));
// Default tween type is EASE_OUT.
......@@ -63,6 +70,7 @@ void SlideAnimatorGtk::Open() {
void SlideAnimatorGtk::OpenWithoutAnimation() {
animation_->Reset(1.0);
Open();
fixed_needs_resize_ = true;
}
void SlideAnimatorGtk::Close() {
......@@ -87,3 +95,14 @@ void SlideAnimatorGtk::AnimationEnded(const Animation* animation) {
if (!animation_->IsShowing() && delegate_)
delegate_->Closed();
}
// static
void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child,
GtkAllocation* allocation,
SlideAnimatorGtk* slider) {
if (!slider->fixed_needs_resize_)
return;
slider->fixed_needs_resize_ = false;
slider->AnimationProgressed(slider->animation_.get());
}
......@@ -9,14 +9,14 @@
#ifndef CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_
#define CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_
#include <gtk/gtk.h>
#include "base/scoped_ptr.h"
#include "chrome/common/animation.h"
#include "chrome/common/owned_widget_gtk.h"
class SlideAnimation;
typedef struct _GtkWidget GtkWidget;
class SlideAnimatorGtk : public AnimationDelegate {
public:
class Delegate {
......@@ -64,6 +64,10 @@ class SlideAnimatorGtk : public AnimationDelegate {
void AnimationEnded(const Animation* animation);
private:
static void OnChildSizeAllocate(GtkWidget* child,
GtkAllocation* allocation,
SlideAnimatorGtk* slider);
scoped_ptr<SlideAnimation> animation_;
// The top level widget of the SlideAnimatorGtk. It is a GtkFixed.
......@@ -78,6 +82,10 @@ 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_;
};
#endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment