Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1086)

Unified Diff: chrome/browser/gtk/slide_animator_gtk.cc

Issue 99110: Fix SlideAnimatorGtk::OpenWithoutAnimation().... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/slide_animator_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/slide_animator_gtk.cc
===================================================================
--- chrome/browser/gtk/slide_animator_gtk.cc (revision 14624)
+++ chrome/browser/gtk/slide_animator_gtk.cc (working copy)
@@ -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 @@
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,8 +40,16 @@
// 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.
if (linear)
@@ -63,6 +70,7 @@
void SlideAnimatorGtk::OpenWithoutAnimation() {
animation_->Reset(1.0);
Open();
+ fixed_needs_resize_ = true;
}
void SlideAnimatorGtk::Close() {
@@ -87,3 +95,14 @@
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());
+}
« no previous file with comments | « chrome/browser/gtk/slide_animator_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698