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

Side by Side Diff: ash/common/system/user/user_view.cc

Issue 2475033003: Add ability to specify extra insets for a view via its border. (Closed)
Patch Set: restore lost changes Created 4 years, 1 month 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/common/system/user/user_view.h ('k') | ui/views/border.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 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/common/system/user/user_view.h" 5 #include "ash/common/system/user/user_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 // The logout button must be added before the user card so that the user card 250 // The logout button must be added before the user card so that the user card
251 // can correctly calculate the remaining available width. 251 // can correctly calculate the remaining available width.
252 // Note that only the current multiprofile user gets a button. 252 // Note that only the current multiprofile user gets a button.
253 if (!user_index_) 253 if (!user_index_)
254 AddLogoutButton(login); 254 AddLogoutButton(login);
255 AddUserCard(login); 255 AddUserCard(login);
256 256
257 if (UseMd()) { 257 if (UseMd()) {
258 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 258 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal,
259 kMenuExtraMarginFromLeftEdge, 259 kMenuExtraMarginFromLeftEdge, 0, 0);
260 kMenuSeparatorVerticalPadding, 0);
261 SetLayoutManager(layout); 260 SetLayoutManager(layout);
262 layout->set_cross_axis_alignment( 261 layout->set_cross_axis_alignment(
263 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 262 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
264 layout->SetFlexForView(user_card_view_, 1); 263 layout->SetFlexForView(user_card_view_, 1);
264 int separator_width = user_index_ == 0 ? kSeparatorWidth : 0;
265 SetBorder(views::Border::CreatePaddedBorder(
266 views::Border::CreateSolidSidedBorder(0, 0, separator_width, 0,
267 kSeparatorColor),
268 gfx::Insets(kMenuSeparatorVerticalPadding, 0,
269 kMenuSeparatorVerticalPadding - separator_width, 0)));
265 } 270 }
266 } 271 }
267 272
268 UserView::~UserView() { 273 UserView::~UserView() {
269 RemoveAddUserMenuOption(); 274 RemoveAddUserMenuOption();
270 } 275 }
271 276
272 void UserView::MouseMovedOutOfHost() { 277 void UserView::MouseMovedOutOfHost() {
273 DCHECK(!UseMd()); 278 DCHECK(!UseMd());
274 RemoveAddUserMenuOption(); 279 RemoveAddUserMenuOption();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 remaining_width -= kTrayPopupPaddingBetweenItems; 359 remaining_width -= kTrayPopupPaddingBetweenItems;
355 } 360 }
356 user_card_area.set_width(remaining_width); 361 user_card_area.set_width(remaining_width);
357 user_card_view_->SetBoundsRect(user_card_area); 362 user_card_view_->SetBoundsRect(user_card_area);
358 logout_button_->SetBoundsRect(logout_area); 363 logout_button_->SetBoundsRect(logout_area);
359 } else { 364 } else {
360 user_card_view_->SetBoundsRect(contents_area); 365 user_card_view_->SetBoundsRect(contents_area);
361 } 366 }
362 } 367 }
363 368
364 void UserView::OnPaintBorder(gfx::Canvas* canvas) {
365 if (!UseMd() || user_index_)
366 return;
367
368 DCHECK(!border());
369 // For the separator below this row, manually paint a border because it should
370 // be drawn *on top* of the vertical padding.
371 gfx::Rect local_bounds = GetLocalBounds();
372 local_bounds.Inset(gfx::Insets(0, 0, kSeparatorWidth, 0));
373 canvas->DrawLine(local_bounds.bottom_left(), local_bounds.bottom_right(),
374 kHorizontalSeparatorColor);
375 }
376
377 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { 369 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) {
378 if (sender == logout_button_) { 370 if (sender == logout_button_) {
379 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_SIGN_OUT); 371 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_SIGN_OUT);
380 RemoveAddUserMenuOption(); 372 RemoveAddUserMenuOption();
381 WmShell::Get()->system_tray_delegate()->SignOut(); 373 WmShell::Get()->system_tray_delegate()->SignOut();
382 } else if (sender == user_card_view_ && 374 } else if (sender == user_card_view_ &&
383 IsMultiProfileSupportedAndUserActive()) { 375 IsMultiProfileSupportedAndUserActive()) {
384 if (!user_index_) { 376 if (!user_index_) {
385 ToggleAddUserMenuOption(); 377 ToggleAddUserMenuOption();
386 } else { 378 } else {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 if (UseMd()) { 558 if (UseMd()) {
567 // Position the widget on top of the user card view (which is still in the 559 // Position the widget on top of the user card view (which is still in the
568 // system menu). The top half of the widget will be transparent to allow 560 // system menu). The top half of the widget will be transparent to allow
569 // the active user to show through. 561 // the active user to show through.
570 gfx::Rect bounds = user_card_view_->GetBoundsInScreen(); 562 gfx::Rect bounds = user_card_view_->GetBoundsInScreen();
571 bounds.set_width(bounds.width() + kSeparatorWidth); 563 bounds.set_width(bounds.width() + kSeparatorWidth);
572 int row_height = bounds.height(); 564 int row_height = bounds.height();
573 bounds.set_height(row_height * 2); 565 bounds.set_height(row_height * 2);
574 add_menu_option_->SetBounds(bounds); 566 add_menu_option_->SetBounds(bounds);
575 567
576 // This nested container is necessary to stack borders.
577 views::View* nested_container = new views::View();
578 nested_container->SetBorder(
579 views::Border::CreateEmptyBorder(row_height, 0, 0, 0));
580 nested_container->SetLayoutManager(new views::FillLayout());
581 nested_container->AddChildView(button);
582
583 views::View* container = new AddUserWidgetContents( 568 views::View* container = new AddUserWidgetContents(
584 base::Bind(&UserView::RemoveAddUserMenuOption, base::Unretained(this))); 569 base::Bind(&UserView::RemoveAddUserMenuOption, base::Unretained(this)));
585 container->SetBorder(views::Border::CreateSolidSidedBorder( 570 container->SetBorder(views::Border::CreatePaddedBorder(
586 0, 0, 0, kSeparatorWidth, kBackgroundColor)); 571 views::Border::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth,
572 kBackgroundColor),
573 gfx::Insets(row_height, 0, 0, 0)));
587 container->SetLayoutManager(new views::FillLayout()); 574 container->SetLayoutManager(new views::FillLayout());
588 container->AddChildView(nested_container); 575 container->AddChildView(button);
589 add_menu_option_->SetContentsView(container); 576 add_menu_option_->SetContentsView(container);
590 } else { 577 } else {
591 add_menu_option_->SetOpacity(1.f); 578 add_menu_option_->SetOpacity(1.f);
592 add_menu_option_->SetContentsView(button); 579 add_menu_option_->SetContentsView(button);
593 // Position it below our user card. 580 // Position it below our user card.
594 gfx::Rect bounds = user_card_view_->GetBoundsInScreen(); 581 gfx::Rect bounds = user_card_view_->GetBoundsInScreen();
595 bounds.set_y(bounds.y() + bounds.height()); 582 bounds.set_y(bounds.y() + bounds.height());
596 add_menu_option_->SetBounds(bounds); 583 add_menu_option_->SetBounds(bounds);
597 } 584 }
598 585
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 focus_manager_ = nullptr; 640 focus_manager_ = nullptr;
654 if (user_card_view_->GetFocusManager()) 641 if (user_card_view_->GetFocusManager())
655 user_card_view_->GetFocusManager()->ClearFocus(); 642 user_card_view_->GetFocusManager()->ClearFocus();
656 popup_message_.reset(); 643 popup_message_.reset();
657 mouse_watcher_.reset(); 644 mouse_watcher_.reset();
658 add_menu_option_.reset(); 645 add_menu_option_.reset();
659 } 646 }
660 647
661 } // namespace tray 648 } // namespace tray
662 } // namespace ash 649 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/user/user_view.h ('k') | ui/views/border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698