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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/tray_item_view.h ('k') | ash/system/tray/tray_popup_header_button.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/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/compositor/layer.h" 10 #include "ui/compositor/layer.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (!set_visible) { 68 if (!set_visible) {
69 animation_->Hide(); 69 animation_->Hide();
70 AnimationProgressed(animation_.get()); 70 AnimationProgressed(animation_.get());
71 } else { 71 } else {
72 animation_->Show(); 72 animation_->Show();
73 AnimationProgressed(animation_.get()); 73 AnimationProgressed(animation_.get());
74 views::View::SetVisible(true); 74 views::View::SetVisible(true);
75 } 75 }
76 } 76 }
77 77
78 gfx::Size TrayItemView::DesiredSize() { 78 gfx::Size TrayItemView::DesiredSize() const {
79 return views::View::GetPreferredSize(); 79 return views::View::GetPreferredSize();
80 } 80 }
81 81
82 int TrayItemView::GetAnimationDurationMS() { 82 int TrayItemView::GetAnimationDurationMS() {
83 return kTrayItemAnimationDurationMS; 83 return kTrayItemAnimationDurationMS;
84 } 84 }
85 85
86 gfx::Size TrayItemView::GetPreferredSize() { 86 gfx::Size TrayItemView::GetPreferredSize() const {
87 gfx::Size size = DesiredSize(); 87 gfx::Size size = DesiredSize();
88 if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || 88 if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ||
89 owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) 89 owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP)
90 size.set_height(kTrayIconHeight); 90 size.set_height(kTrayIconHeight);
91 else 91 else
92 size.set_width(kTrayIconWidth); 92 size.set_width(kTrayIconWidth);
93 if (!animation_.get() || !animation_->is_animating()) 93 if (!animation_.get() || !animation_->is_animating())
94 return size; 94 return size;
95 if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || 95 if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ||
96 owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) { 96 owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) {
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) { 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 (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || 116 if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ||
(...skipping 13 matching lines...) Expand all
130 void TrayItemView::AnimationEnded(const gfx::Animation* animation) { 130 void TrayItemView::AnimationEnded(const gfx::Animation* animation) {
131 if (animation->GetCurrentValue() < 0.1) 131 if (animation->GetCurrentValue() < 0.1)
132 views::View::SetVisible(false); 132 views::View::SetVisible(false);
133 } 133 }
134 134
135 void TrayItemView::AnimationCanceled(const gfx::Animation* animation) { 135 void TrayItemView::AnimationCanceled(const gfx::Animation* animation) {
136 AnimationEnded(animation); 136 AnimationEnded(animation);
137 } 137 }
138 138
139 } // namespace ash 139 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_item_view.h ('k') | ash/system/tray/tray_popup_header_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698