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

Side by Side Diff: chrome/browser/ui/gtk/slide_animator_gtk.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/slide_animator_gtk.h ('k') | chrome/browser/ui/gtk/status_bubble_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" 5 #include "chrome/browser/ui/gtk/slide_animator_gtk.h"
6 6
7 #include "ui/base/animation/animation.h"
8 #include "ui/base/animation/slide_animation.h"
9 #include "ui/base/gtk/gtk_expanded_container.h" 7 #include "ui/base/gtk/gtk_expanded_container.h"
8 #include "ui/gfx/animation/animation.h"
9 #include "ui/gfx/animation/slide_animation.h"
10 10
11 namespace { 11 namespace {
12 12
13 void OnChildSizeRequest(GtkWidget* expanded, 13 void OnChildSizeRequest(GtkWidget* expanded,
14 GtkWidget* child, 14 GtkWidget* child,
15 GtkRequisition* requisition, 15 GtkRequisition* requisition,
16 gpointer control_child_size) { 16 gpointer control_child_size) {
17 // If |control_child_size| is true, then we want |child_| to match the width 17 // If |control_child_size| is true, then we want |child_| to match the width
18 // of the |widget_|, but the height of |child_| should not change. 18 // of the |widget_|, but the height of |child_| should not change.
19 if (!GPOINTER_TO_INT(control_child_size)) { 19 if (!GPOINTER_TO_INT(control_child_size)) {
(...skipping 28 matching lines...) Expand all
48 48
49 // We connect to this signal to set an initial position for our child widget. 49 // We connect to this signal to set an initial position for our child widget.
50 // The reason we connect to this signal rather than setting the initial 50 // The reason we connect to this signal rather than setting the initial
51 // position here is that the widget is currently unallocated and may not 51 // position here is that the widget is currently unallocated and may not
52 // even have a size request. 52 // even have a size request.
53 g_signal_connect(child, "size-allocate", 53 g_signal_connect(child, "size-allocate",
54 G_CALLBACK(OnChildSizeAllocate), this); 54 G_CALLBACK(OnChildSizeAllocate), this);
55 55
56 child_needs_move_ = (direction == DOWN); 56 child_needs_move_ = (direction == DOWN);
57 57
58 animation_.reset(new ui::SlideAnimation(this)); 58 animation_.reset(new gfx::SlideAnimation(this));
59 // Default tween type is EASE_OUT. 59 // Default tween type is EASE_OUT.
60 if (linear) 60 if (linear)
61 animation_->SetTweenType(ui::Tween::LINEAR); 61 animation_->SetTweenType(gfx::Tween::LINEAR);
62 if (duration != 0) 62 if (duration != 0)
63 animation_->SetSlideDuration(duration); 63 animation_->SetSlideDuration(duration);
64 } 64 }
65 65
66 SlideAnimatorGtk::~SlideAnimatorGtk() { 66 SlideAnimatorGtk::~SlideAnimatorGtk() {
67 widget_.Destroy(); 67 widget_.Destroy();
68 } 68 }
69 69
70 void SlideAnimatorGtk::Open() { 70 void SlideAnimatorGtk::Open() {
71 if (!animations_enabled_) 71 if (!animations_enabled_)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 bool SlideAnimatorGtk::IsClosing() { 107 bool SlideAnimatorGtk::IsClosing() {
108 return animation_->IsClosing(); 108 return animation_->IsClosing();
109 } 109 }
110 110
111 bool SlideAnimatorGtk::IsAnimating() { 111 bool SlideAnimatorGtk::IsAnimating() {
112 return animation_->is_animating(); 112 return animation_->is_animating();
113 } 113 }
114 114
115 void SlideAnimatorGtk::AnimationProgressed(const ui::Animation* animation) { 115 void SlideAnimatorGtk::AnimationProgressed(const gfx::Animation* animation) {
116 GtkRequisition req; 116 GtkRequisition req;
117 gtk_widget_size_request(child_, &req); 117 gtk_widget_size_request(child_, &req);
118 118
119 int showing_height = static_cast<int>(req.height * 119 int showing_height = static_cast<int>(req.height *
120 animation_->GetCurrentValue()); 120 animation_->GetCurrentValue());
121 if (direction_ == DOWN) { 121 if (direction_ == DOWN) {
122 if (gtk_widget_get_parent(widget_.get())) { 122 if (gtk_widget_get_parent(widget_.get())) {
123 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()), 123 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()),
124 child_, 0, showing_height - req.height); 124 child_, 0, showing_height - req.height);
125 } 125 }
126 child_needs_move_ = false; 126 child_needs_move_ = false;
127 } 127 }
128 gtk_widget_set_size_request(widget_.get(), -1, showing_height); 128 gtk_widget_set_size_request(widget_.get(), -1, showing_height);
129 } 129 }
130 130
131 void SlideAnimatorGtk::AnimationEnded(const ui::Animation* animation) { 131 void SlideAnimatorGtk::AnimationEnded(const gfx::Animation* animation) {
132 if (!animation_->IsShowing()) { 132 if (!animation_->IsShowing()) {
133 gtk_widget_hide(widget_.get()); 133 gtk_widget_hide(widget_.get());
134 if (delegate_) 134 if (delegate_)
135 delegate_->Closed(); 135 delegate_->Closed();
136 } 136 }
137 } 137 }
138 138
139 // static 139 // static
140 void SlideAnimatorGtk::SetAnimationsForTesting(bool enable) { 140 void SlideAnimatorGtk::SetAnimationsForTesting(bool enable) {
141 animations_enabled_ = enable; 141 animations_enabled_ = enable;
142 } 142 }
143 143
144 // static 144 // static
145 void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child, 145 void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child,
146 GtkAllocation* allocation, 146 GtkAllocation* allocation,
147 SlideAnimatorGtk* slider) { 147 SlideAnimatorGtk* slider) {
148 if (slider->child_needs_move_) { 148 if (slider->child_needs_move_) {
149 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(slider->widget()), 149 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(slider->widget()),
150 child, 0, -allocation->height); 150 child, 0, -allocation->height);
151 slider->child_needs_move_ = false; 151 slider->child_needs_move_ = false;
152 } 152 }
153 } 153 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/slide_animator_gtk.h ('k') | chrome/browser/ui/gtk/status_bubble_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698