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

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

Issue 2816193002: Introduce a type of View background that stays in sync with its host (Closed)
Patch Set: one more Created 3 years, 8 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 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 #include <utility> 8 #include <utility>
9 9
10 #include "ash/multi_profile_uma.h" 10 #include "ash/multi_profile_uma.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). 74 // Creates the view shown in the user switcher popup ("AddUserMenuOption").
75 views::View* CreateAddUserView(AddUserSessionPolicy policy, 75 views::View* CreateAddUserView(AddUserSessionPolicy policy,
76 views::ButtonListener* listener) { 76 views::ButtonListener* listener) {
77 auto* view = new views::View; 77 auto* view = new views::View;
78 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; 78 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2;
79 auto* layout = 79 auto* layout =
80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
81 kTrayPopupLabelHorizontalPadding + icon_padding); 81 kTrayPopupLabelHorizontalPadding + icon_padding);
82 layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); 82 layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight);
83 view->SetLayoutManager(layout); 83 view->SetLayoutManager(layout);
84 view->set_background( 84 view->set_background(views::Background::CreateThemedSolidBackground(
85 views::Background::CreateSolidBackground(kBackgroundColor)); 85 view, ui::NativeTheme::kColorId_BubbleBackground));
86 86
87 int message_id = 0; 87 int message_id = 0;
88 switch (policy) { 88 switch (policy) {
89 case AddUserSessionPolicy::ALLOWED: { 89 case AddUserSessionPolicy::ALLOWED: {
90 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT; 90 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT;
91 91
92 auto* icon = new views::ImageView(); 92 auto* icon = new views::ImageView();
93 icon->SetImage( 93 icon->SetImage(
94 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor)); 94 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor));
95 view->AddChildView(icon); 95 view->AddChildView(icon);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 // Position the widget on top of the user card view (which is still in the 358 // Position the widget on top of the user card view (which is still in the
359 // system menu). The top half of the widget will be transparent to allow 359 // system menu). The top half of the widget will be transparent to allow
360 // the active user to show through. 360 // the active user to show through.
361 gfx::Rect bounds = user_card_view_->GetBoundsInScreen(); 361 gfx::Rect bounds = user_card_view_->GetBoundsInScreen();
362 bounds.set_width(bounds.width() + kSeparatorWidth); 362 bounds.set_width(bounds.width() + kSeparatorWidth);
363 int row_height = bounds.height(); 363 int row_height = bounds.height();
364 364
365 views::View* container = new AddUserWidgetContents( 365 views::View* container = new AddUserWidgetContents(
366 base::Bind(&UserView::RemoveAddUserMenuOption, base::Unretained(this))); 366 base::Bind(&UserView::RemoveAddUserMenuOption, base::Unretained(this)));
367 views::View* add_user_view = CreateAddUserView(add_user_policy, this);
367 container->SetBorder(views::CreatePaddedBorder( 368 container->SetBorder(views::CreatePaddedBorder(
368 views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth, kBackgroundColor), 369 views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth,
370 add_user_view->background()->get_color()),
369 gfx::Insets(row_height, 0, 0, 0))); 371 gfx::Insets(row_height, 0, 0, 0)));
370 views::View* add_user_padding = new views::View(); 372 views::View* add_user_padding = new views::View();
371 add_user_padding->SetBorder(views::CreateSolidSidedBorder( 373 add_user_padding->SetBorder(
372 kMenuSeparatorVerticalPadding, 0, 0, 0, kBackgroundColor)); 374 views::CreateSolidSidedBorder(kMenuSeparatorVerticalPadding, 0, 0, 0,
373 views::View* add_user_view = CreateAddUserView(add_user_policy, this); 375 add_user_view->background()->get_color()));
374 add_user_padding->AddChildView(add_user_view); 376 add_user_padding->AddChildView(add_user_view);
375 add_user_padding->SetLayoutManager(new views::FillLayout()); 377 add_user_padding->SetLayoutManager(new views::FillLayout());
376 container->AddChildView(add_user_padding); 378 container->AddChildView(add_user_padding);
377 container->SetLayoutManager(new views::FillLayout()); 379 container->SetLayoutManager(new views::FillLayout());
378 add_menu_option_->SetContentsView(container); 380 add_menu_option_->SetContentsView(container);
379 381
380 bounds.set_height(container->GetPreferredSize().height()); 382 bounds.set_height(container->GetPreferredSize().height());
381 add_menu_option_->SetBounds(bounds); 383 add_menu_option_->SetBounds(bounds);
382 384
383 // Show the content. 385 // Show the content.
(...skipping 12 matching lines...) Expand all
396 return; 398 return;
397 focus_manager_->RemoveFocusChangeListener(this); 399 focus_manager_->RemoveFocusChangeListener(this);
398 focus_manager_ = nullptr; 400 focus_manager_ = nullptr;
399 if (user_card_view_->GetFocusManager()) 401 if (user_card_view_->GetFocusManager())
400 user_card_view_->GetFocusManager()->ClearFocus(); 402 user_card_view_->GetFocusManager()->ClearFocus();
401 add_menu_option_.reset(); 403 add_menu_option_.reset();
402 } 404 }
403 405
404 } // namespace tray 406 } // namespace tray
405 } // namespace ash 407 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698