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

Side by Side Diff: ash/system/tray/tray_item_view.cc

Issue 1929023002: Refactors WindowResizers to use ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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/shelf/shelf_util.h" 8 #include "ash/shelf/shelf_util.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/system_tray_item.h" 10 #include "ash/system/tray/system_tray_item.h"
11 #include "ash/wm/common/shelf/wm_shelf_util.h"
11 #include "ui/compositor/layer.h" 12 #include "ui/compositor/layer.h"
12 #include "ui/gfx/animation/slide_animation.h" 13 #include "ui/gfx/animation/slide_animation.h"
13 #include "ui/views/controls/image_view.h" 14 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
15 #include "ui/views/layout/box_layout.h" 16 #include "ui/views/layout/box_layout.h"
16 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
17 18
18 namespace { 19 namespace {
19 const int kTrayIconHeight = 29; 20 const int kTrayIconHeight = 29;
20 const int kTrayIconWidth = 29; 21 const int kTrayIconWidth = 29;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 gfx::Size TrayItemView::DesiredSize() const { 80 gfx::Size TrayItemView::DesiredSize() const {
80 return views::View::GetPreferredSize(); 81 return views::View::GetPreferredSize();
81 } 82 }
82 83
83 int TrayItemView::GetAnimationDurationMS() { 84 int TrayItemView::GetAnimationDurationMS() {
84 return kTrayItemAnimationDurationMS; 85 return kTrayItemAnimationDurationMS;
85 } 86 }
86 87
87 gfx::Size TrayItemView::GetPreferredSize() const { 88 gfx::Size TrayItemView::GetPreferredSize() const {
88 gfx::Size size = DesiredSize(); 89 gfx::Size size = DesiredSize();
89 if (IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) 90 if (wm::IsHorizontalAlignment(owner()->system_tray()->shelf_alignment()))
90 size.set_height(kTrayIconHeight); 91 size.set_height(kTrayIconHeight);
91 else 92 else
92 size.set_width(kTrayIconWidth); 93 size.set_width(kTrayIconWidth);
93 if (!animation_.get() || !animation_->is_animating()) 94 if (!animation_.get() || !animation_->is_animating())
94 return size; 95 return size;
95 if (IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) { 96 if (wm::IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) {
96 size.set_width(std::max(1, 97 size.set_width(std::max(1,
97 static_cast<int>(size.width() * animation_->GetCurrentValue()))); 98 static_cast<int>(size.width() * animation_->GetCurrentValue())));
98 } else { 99 } else {
99 size.set_height(std::max(1, 100 size.set_height(std::max(1,
100 static_cast<int>(size.height() * animation_->GetCurrentValue()))); 101 static_cast<int>(size.height() * animation_->GetCurrentValue())));
101 } 102 }
102 return size; 103 return size;
103 } 104 }
104 105
105 int TrayItemView::GetHeightForWidth(int width) const { 106 int TrayItemView::GetHeightForWidth(int width) const {
106 return GetPreferredSize().height(); 107 return GetPreferredSize().height();
107 } 108 }
108 109
109 void TrayItemView::ChildPreferredSizeChanged(views::View* child) { 110 void TrayItemView::ChildPreferredSizeChanged(views::View* child) {
110 PreferredSizeChanged(); 111 PreferredSizeChanged();
111 } 112 }
112 113
113 void TrayItemView::AnimationProgressed(const gfx::Animation* animation) { 114 void TrayItemView::AnimationProgressed(const gfx::Animation* animation) {
114 gfx::Transform transform; 115 gfx::Transform transform;
115 if (IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) { 116 if (wm::IsHorizontalAlignment(owner()->system_tray()->shelf_alignment())) {
116 transform.Translate(0, animation->CurrentValueBetween( 117 transform.Translate(0, animation->CurrentValueBetween(
117 static_cast<double>(height()) / 2, 0.)); 118 static_cast<double>(height()) / 2, 0.));
118 } else { 119 } else {
119 transform.Translate(animation->CurrentValueBetween( 120 transform.Translate(animation->CurrentValueBetween(
120 static_cast<double>(width() / 2), 0.), 0); 121 static_cast<double>(width() / 2), 0.), 0);
121 } 122 }
122 transform.Scale(animation->GetCurrentValue(), 123 transform.Scale(animation->GetCurrentValue(),
123 animation->GetCurrentValue()); 124 animation->GetCurrentValue());
124 layer()->SetTransform(transform); 125 layer()->SetTransform(transform);
125 PreferredSizeChanged(); 126 PreferredSizeChanged();
126 } 127 }
127 128
128 void TrayItemView::AnimationEnded(const gfx::Animation* animation) { 129 void TrayItemView::AnimationEnded(const gfx::Animation* animation) {
129 if (animation->GetCurrentValue() < 0.1) 130 if (animation->GetCurrentValue() < 0.1)
130 views::View::SetVisible(false); 131 views::View::SetVisible(false);
131 } 132 }
132 133
133 void TrayItemView::AnimationCanceled(const gfx::Animation* animation) { 134 void TrayItemView::AnimationCanceled(const gfx::Animation* animation) {
134 AnimationEnded(animation); 135 AnimationEnded(animation);
135 } 136 }
136 137
137 } // namespace ash 138 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698