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

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

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

Powered by Google App Engine
This is Rietveld 408576698