| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/tabs/dragged_tab_gtk.h" | 5 #include "chrome/browser/gtk/tabs/dragged_tab_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 gint x, y, width, height; | 120 gint x, y, width, height; |
| 121 gdk_window_get_origin(container_->window, &x, &y); | 121 gdk_window_get_origin(container_->window, &x, &y); |
| 122 gdk_window_get_geometry(container_->window, NULL, NULL, | 122 gdk_window_get_geometry(container_->window, NULL, NULL, |
| 123 &width, &height, NULL); | 123 &width, &height, NULL); |
| 124 | 124 |
| 125 animation_start_bounds_ = gfx::Rect(x, y, width, height); | 125 animation_start_bounds_ = gfx::Rect(x, y, width, height); |
| 126 animation_end_bounds_ = bounds; | 126 animation_end_bounds_ = bounds; |
| 127 | 127 |
| 128 close_animation_.SetSlideDuration(kAnimateToBoundsDurationMs); | 128 close_animation_.SetSlideDuration(kAnimateToBoundsDurationMs); |
| 129 close_animation_.SetTweenType(Tween::EASE_OUT); | 129 close_animation_.SetTweenType(ui::Tween::EASE_OUT); |
| 130 if (!close_animation_.IsShowing()) { | 130 if (!close_animation_.IsShowing()) { |
| 131 close_animation_.Reset(); | 131 close_animation_.Reset(); |
| 132 close_animation_.Show(); | 132 close_animation_.Show(); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
| 137 // DraggedTabGtk, AnimationDelegate implementation: | 137 // DraggedTabGtk, ui::AnimationDelegate implementation: |
| 138 | 138 |
| 139 void DraggedTabGtk::AnimationProgressed(const Animation* animation) { | 139 void DraggedTabGtk::AnimationProgressed(const ui::Animation* animation) { |
| 140 int delta_x = (animation_end_bounds_.x() - animation_start_bounds_.x()); | 140 int delta_x = (animation_end_bounds_.x() - animation_start_bounds_.x()); |
| 141 int x = animation_start_bounds_.x() + | 141 int x = animation_start_bounds_.x() + |
| 142 static_cast<int>(delta_x * animation->GetCurrentValue()); | 142 static_cast<int>(delta_x * animation->GetCurrentValue()); |
| 143 int y = animation_end_bounds_.y(); | 143 int y = animation_end_bounds_.y(); |
| 144 gdk_window_move(container_->window, x, y); | 144 gdk_window_move(container_->window, x, y); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void DraggedTabGtk::AnimationEnded(const Animation* animation) { | 147 void DraggedTabGtk::AnimationEnded(const ui::Animation* animation) { |
| 148 animation_callback_->Run(); | 148 animation_callback_->Run(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void DraggedTabGtk::AnimationCanceled(const Animation* animation) { | 151 void DraggedTabGtk::AnimationCanceled(const ui::Animation* animation) { |
| 152 AnimationEnded(animation); | 152 AnimationEnded(animation); |
| 153 } | 153 } |
| 154 | 154 |
| 155 //////////////////////////////////////////////////////////////////////////////// | 155 //////////////////////////////////////////////////////////////////////////////// |
| 156 // DraggedTabGtk, private: | 156 // DraggedTabGtk, private: |
| 157 | 157 |
| 158 void DraggedTabGtk::Layout() { | 158 void DraggedTabGtk::Layout() { |
| 159 if (attached_) { | 159 if (attached_) { |
| 160 renderer_->SetBounds(gfx::Rect(GetPreferredSize())); | 160 renderer_->SetBounds(gfx::Rect(GetPreferredSize())); |
| 161 } else { | 161 } else { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 cairo_set_source_surface(cr, surface, 0, 0); | 330 cairo_set_source_surface(cr, surface, 0, 0); |
| 331 cairo_paint(cr); | 331 cairo_paint(cr); |
| 332 | 332 |
| 333 cairo_destroy(cr); | 333 cairo_destroy(cr); |
| 334 | 334 |
| 335 cairo_surface_destroy(surface); | 335 cairo_surface_destroy(surface); |
| 336 | 336 |
| 337 // We've already drawn the tab, so don't propagate the expose-event signal. | 337 // We've already drawn the tab, so don't propagate the expose-event signal. |
| 338 return TRUE; | 338 return TRUE; |
| 339 } | 339 } |
| OLD | NEW |