OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/user/user_view.h" | 5 #include "ash/system/user/user_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/multi_profile_uma.h" | 9 #include "ash/multi_profile_uma.h" |
10 #include "ash/popup_message.h" | 10 #include "ash/popup_message.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 public: | 130 public: |
131 // The |owner| is the view for which this view gets created. | 131 // The |owner| is the view for which this view gets created. |
132 AddUserView(ButtonFromView* owner); | 132 AddUserView(ButtonFromView* owner); |
133 virtual ~AddUserView(); | 133 virtual ~AddUserView(); |
134 | 134 |
135 // Get the anchor view for a message. | 135 // Get the anchor view for a message. |
136 views::View* anchor() { return anchor_; } | 136 views::View* anchor() { return anchor_; } |
137 | 137 |
138 private: | 138 private: |
139 // Overridden from views::View. | 139 // Overridden from views::View. |
140 virtual gfx::Size GetPreferredSize() OVERRIDE; | 140 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
141 | 141 |
142 // Create the additional client content for this item. | 142 // Create the additional client content for this item. |
143 void AddContent(); | 143 void AddContent(); |
144 | 144 |
145 // This is the content we create and show. | 145 // This is the content we create and show. |
146 views::View* add_user_; | 146 views::View* add_user_; |
147 | 147 |
148 // This is the owner view of this item. | 148 // This is the owner view of this item. |
149 ButtonFromView* owner_; | 149 ButtonFromView* owner_; |
150 | 150 |
151 // The anchor view for targetted bubble messages. | 151 // The anchor view for targetted bubble messages. |
152 views::View* anchor_; | 152 views::View* anchor_; |
153 | 153 |
154 DISALLOW_COPY_AND_ASSIGN(AddUserView); | 154 DISALLOW_COPY_AND_ASSIGN(AddUserView); |
155 }; | 155 }; |
156 | 156 |
157 AddUserView::AddUserView(ButtonFromView* owner) | 157 AddUserView::AddUserView(ButtonFromView* owner) |
158 : add_user_(NULL), owner_(owner), anchor_(NULL) { | 158 : add_user_(NULL), owner_(owner), anchor_(NULL) { |
159 AddContent(); | 159 AddContent(); |
160 owner_->ForceBorderVisible(true); | 160 owner_->ForceBorderVisible(true); |
161 } | 161 } |
162 | 162 |
163 AddUserView::~AddUserView() { | 163 AddUserView::~AddUserView() { |
164 owner_->ForceBorderVisible(false); | 164 owner_->ForceBorderVisible(false); |
165 } | 165 } |
166 | 166 |
167 gfx::Size AddUserView::GetPreferredSize() { | 167 gfx::Size AddUserView::GetPreferredSize() const { |
168 return owner_->bounds().size(); | 168 return owner_->bounds().size(); |
169 } | 169 } |
170 | 170 |
171 void AddUserView::AddContent() { | 171 void AddUserView::AddContent() { |
172 SetLayoutManager(new views::FillLayout()); | 172 SetLayoutManager(new views::FillLayout()); |
173 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 173 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
174 | 174 |
175 add_user_ = new views::View; | 175 add_user_ = new views::View; |
176 add_user_->SetBorder(views::Border::CreateEmptyBorder( | 176 add_user_->SetBorder(views::Border::CreateEmptyBorder( |
177 kTrayPopupUserCardVerticalPadding, | 177 kTrayPopupUserCardVerticalPadding, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return static_cast<ButtonFromView*>(user_card_view_)->is_hovered_for_test() | 250 return static_cast<ButtonFromView*>(user_card_view_)->is_hovered_for_test() |
251 ? TrayUser::HOVERED | 251 ? TrayUser::HOVERED |
252 : TrayUser::SHOWN; | 252 : TrayUser::SHOWN; |
253 } | 253 } |
254 | 254 |
255 gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() { | 255 gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() { |
256 DCHECK(user_card_view_); | 256 DCHECK(user_card_view_); |
257 return user_card_view_->GetBoundsInScreen(); | 257 return user_card_view_->GetBoundsInScreen(); |
258 } | 258 } |
259 | 259 |
260 gfx::Size UserView::GetPreferredSize() { | 260 gfx::Size UserView::GetPreferredSize() const { |
261 gfx::Size size = views::View::GetPreferredSize(); | 261 gfx::Size size = views::View::GetPreferredSize(); |
262 // Only the active user panel will be forced to a certain height. | 262 // Only the active user panel will be forced to a certain height. |
263 if (!multiprofile_index_) { | 263 if (!multiprofile_index_) { |
264 size.set_height( | 264 size.set_height( |
265 std::max(size.height(), kTrayPopupItemHeight + GetInsets().height())); | 265 std::max(size.height(), kTrayPopupItemHeight + GetInsets().height())); |
266 } | 266 } |
267 return size; | 267 return size; |
268 } | 268 } |
269 | 269 |
270 int UserView::GetHeightForWidth(int width) { | 270 int UserView::GetHeightForWidth(int width) const { |
271 return GetPreferredSize().height(); | 271 return GetPreferredSize().height(); |
272 } | 272 } |
273 | 273 |
274 void UserView::Layout() { | 274 void UserView::Layout() { |
275 gfx::Rect contents_area(GetContentsBounds()); | 275 gfx::Rect contents_area(GetContentsBounds()); |
276 if (user_card_view_ && logout_button_) { | 276 if (user_card_view_ && logout_button_) { |
277 // Give the logout button the space it requests. | 277 // Give the logout button the space it requests. |
278 gfx::Rect logout_area = contents_area; | 278 gfx::Rect logout_area = contents_area; |
279 logout_area.ClampToCenteredSize(logout_button_->GetPreferredSize()); | 279 logout_area.ClampToCenteredSize(logout_button_->GetPreferredSize()); |
280 logout_area.set_x(contents_area.right() - logout_area.width()); | 280 logout_area.set_x(contents_area.right() - logout_area.width()); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // watcher which will close the "menu". | 483 // watcher which will close the "menu". |
484 gfx::Rect area = user_card_view_->GetBoundsInScreen(); | 484 gfx::Rect area = user_card_view_->GetBoundsInScreen(); |
485 area.set_height(2 * area.height()); | 485 area.set_height(2 * area.height()); |
486 mouse_watcher_.reset( | 486 mouse_watcher_.reset( |
487 new views::MouseWatcher(new UserViewMouseWatcherHost(area), this)); | 487 new views::MouseWatcher(new UserViewMouseWatcherHost(area), this)); |
488 mouse_watcher_->Start(); | 488 mouse_watcher_->Start(); |
489 } | 489 } |
490 | 490 |
491 } // namespace tray | 491 } // namespace tray |
492 } // namespace ash | 492 } // namespace ash |
OLD | NEW |