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

Side by Side Diff: ash/system/tray/tray_item_view.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 | « ash/system/tray/tray_item_view.h ('k') | ash/system/user/tray_user_unittest.cc » ('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 "ash/system/tray/tray_item_view.h" 5 #include "ash/system/tray/tray_item_view.h"
6 6
7 #include "ash/shelf/shelf_types.h" 7 #include "ash/shelf/shelf_types.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_item.h" 9 #include "ash/system/tray/system_tray_item.h"
10 #include "ui/base/animation/slide_animation.h"
11 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
11 #include "ui/gfx/animation/slide_animation.h"
12 #include "ui/views/controls/image_view.h" 12 #include "ui/views/controls/image_view.h"
13 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
14 #include "ui/views/layout/box_layout.h" 14 #include "ui/views/layout/box_layout.h"
15 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
16 16
17 namespace { 17 namespace {
18 const int kTrayIconHeight = 29; 18 const int kTrayIconHeight = 29;
19 const int kTrayIconWidth = 29; 19 const int kTrayIconWidth = 29;
20 const int kTrayItemAnimationDurationMS = 200; 20 const int kTrayItemAnimationDurationMS = 200;
21 21
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 AddChildView(image_view_); 53 AddChildView(image_view_);
54 } 54 }
55 55
56 void TrayItemView::SetVisible(bool set_visible) { 56 void TrayItemView::SetVisible(bool set_visible) {
57 if (!GetWidget() || !animations_enabled) { 57 if (!GetWidget() || !animations_enabled) {
58 views::View::SetVisible(set_visible); 58 views::View::SetVisible(set_visible);
59 return; 59 return;
60 } 60 }
61 61
62 if (!animation_) { 62 if (!animation_) {
63 animation_.reset(new ui::SlideAnimation(this)); 63 animation_.reset(new gfx::SlideAnimation(this));
64 animation_->SetSlideDuration(GetAnimationDurationMS()); 64 animation_->SetSlideDuration(GetAnimationDurationMS());
65 animation_->SetTweenType(ui::Tween::LINEAR); 65 animation_->SetTweenType(gfx::Tween::LINEAR);
66 animation_->Reset(visible() ? 1.0 : 0.0); 66 animation_->Reset(visible() ? 1.0 : 0.0);
67 } 67 }
68 68
69 if (!set_visible) { 69 if (!set_visible) {
70 animation_->Hide(); 70 animation_->Hide();
71 AnimationProgressed(animation_.get()); 71 AnimationProgressed(animation_.get());
72 } else { 72 } else {
73 animation_->Show(); 73 animation_->Show();
74 AnimationProgressed(animation_.get()); 74 AnimationProgressed(animation_.get());
75 views::View::SetVisible(true); 75 views::View::SetVisible(true);
(...skipping 23 matching lines...) Expand all
99 } 99 }
100 100
101 int TrayItemView::GetHeightForWidth(int width) { 101 int TrayItemView::GetHeightForWidth(int width) {
102 return GetPreferredSize().height(); 102 return GetPreferredSize().height();
103 } 103 }
104 104
105 void TrayItemView::ChildPreferredSizeChanged(views::View* child) { 105 void TrayItemView::ChildPreferredSizeChanged(views::View* child) {
106 PreferredSizeChanged(); 106 PreferredSizeChanged();
107 } 107 }
108 108
109 void TrayItemView::AnimationProgressed(const ui::Animation* animation) { 109 void TrayItemView::AnimationProgressed(const gfx::Animation* animation) {
110 gfx::Transform transform; 110 gfx::Transform transform;
111 transform.Translate(0, animation->CurrentValueBetween( 111 transform.Translate(0, animation->CurrentValueBetween(
112 static_cast<double>(height()) / 2, 0.)); 112 static_cast<double>(height()) / 2, 0.));
113 transform.Scale(animation->GetCurrentValue(), 113 transform.Scale(animation->GetCurrentValue(),
114 animation->GetCurrentValue()); 114 animation->GetCurrentValue());
115 layer()->SetTransform(transform); 115 layer()->SetTransform(transform);
116 PreferredSizeChanged(); 116 PreferredSizeChanged();
117 } 117 }
118 118
119 void TrayItemView::AnimationEnded(const ui::Animation* animation) { 119 void TrayItemView::AnimationEnded(const gfx::Animation* animation) {
120 if (animation->GetCurrentValue() < 0.1) 120 if (animation->GetCurrentValue() < 0.1)
121 views::View::SetVisible(false); 121 views::View::SetVisible(false);
122 } 122 }
123 123
124 void TrayItemView::AnimationCanceled(const ui::Animation* animation) { 124 void TrayItemView::AnimationCanceled(const gfx::Animation* animation) {
125 AnimationEnded(animation); 125 AnimationEnded(animation);
126 } 126 }
127 127
128 } // namespace internal 128 } // namespace internal
129 } // namespace ash 129 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_item_view.h ('k') | ash/system/user/tray_user_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698