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

Side by Side Diff: ash/common/system/tray/tray_popup_utils.cc

Issue 2506133003: [ash-md] Allows ToggleButton to have a border and adds focus rectangle (Closed)
Patch Set: [ash-md] Allows ToggleButton to have a border and adds focus rectangle (rebase) 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/tray/tray_popup_utils.h ('k') | ui/views/controls/button/toggle_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/tray/tray_popup_utils.h" 5 #include "ash/common/system/tray/tray_popup_utils.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/ash_view_ids.h" 8 #include "ash/common/ash_view_ids.h"
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/system/tray/fixed_sized_image_view.h" 11 #include "ash/common/system/tray/fixed_sized_image_view.h"
12 #include "ash/common/system/tray/size_range_layout.h" 12 #include "ash/common/system/tray/size_range_layout.h"
13 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_popup_item_style.h" 14 #include "ash/common/system/tray/tray_popup_item_style.h"
15 #include "ash/common/system/tray/tray_popup_label_button.h" 15 #include "ash/common/system/tray/tray_popup_label_button.h"
16 #include "ash/common/system/tray/tray_popup_label_button_border.h" 16 #include "ash/common/system/tray/tray_popup_label_button_border.h"
17 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 19 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
19 #include "ui/views/animation/ink_drop_highlight.h" 20 #include "ui/views/animation/ink_drop_highlight.h"
20 #include "ui/views/animation/ink_drop_impl.h" 21 #include "ui/views/animation/ink_drop_impl.h"
21 #include "ui/views/animation/ink_drop_mask.h" 22 #include "ui/views/animation/ink_drop_mask.h"
22 #include "ui/views/animation/square_ink_drop_ripple.h" 23 #include "ui/views/animation/square_ink_drop_ripple.h"
23 #include "ui/views/background.h" 24 #include "ui/views/background.h"
24 #include "ui/views/border.h" 25 #include "ui/views/border.h"
25 #include "ui/views/controls/button/button.h" 26 #include "ui/views/controls/button/button.h"
26 #include "ui/views/controls/button/label_button.h" 27 #include "ui/views/controls/button/label_button.h"
27 #include "ui/views/controls/button/md_text_button.h" 28 #include "ui/views/controls/button/md_text_button.h"
29 #include "ui/views/controls/button/toggle_button.h"
28 #include "ui/views/controls/image_view.h" 30 #include "ui/views/controls/image_view.h"
29 #include "ui/views/controls/label.h" 31 #include "ui/views/controls/label.h"
30 #include "ui/views/controls/separator.h" 32 #include "ui/views/controls/separator.h"
31 #include "ui/views/controls/slider.h" 33 #include "ui/views/controls/slider.h"
32 #include "ui/views/layout/box_layout.h" 34 #include "ui/views/layout/box_layout.h"
33 #include "ui/views/layout/fill_layout.h" 35 #include "ui/views/layout/fill_layout.h"
36 #include "ui/views/painter.h"
34 37
35 namespace ash { 38 namespace ash {
36 39
37 namespace { 40 namespace {
38 41
39 // Creates a layout manager that positions Views vertically. The Views will be 42 // Creates a layout manager that positions Views vertically. The Views will be
40 // stretched horizontally and centered vertically. 43 // stretched horizontally and centered vertically.
41 std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() { 44 std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() {
42 // TODO(bruthig): Use constants instead of magic numbers. 45 // TODO(bruthig): Use constants instead of magic numbers.
43 auto box_layout = 46 auto box_layout =
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 if (is_material) { 247 if (is_material) {
245 slider->SetBorder( 248 slider->SetBorder(
246 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD))); 249 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD)));
247 } else { 250 } else {
248 slider->SetBorder( 251 slider->SetBorder(
249 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); 252 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems));
250 } 253 }
251 return slider; 254 return slider;
252 } 255 }
253 256
257 views::ToggleButton* TrayPopupUtils::CreateToggleButton(
258 views::ButtonListener* listener,
259 int accessible_name_id) {
260 views::ToggleButton* toggle = new views::ToggleButton(listener);
261 const gfx::Size toggle_size(toggle->GetPreferredSize());
262 const int vertical_padding = (kMenuButtonSize - toggle_size.height()) / 2;
263 const int horizontal_padding =
264 (kTrayToggleButtonWidth - toggle_size.width()) / 2;
265 toggle->SetBorder(views::CreateEmptyBorder(
266 gfx::Insets(vertical_padding, horizontal_padding)));
267 // TODO(tdanderson): Update the focus rect color, border thickness, and
268 // location for material design.
269 toggle->SetFocusPainter(views::Painter::CreateSolidFocusPainter(
270 kFocusBorderColor, gfx::Insets(1)));
271 toggle->SetAccessibleName(l10n_util::GetStringUTF16(accessible_name_id));
272 return toggle;
273 }
274
254 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { 275 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
255 view->set_id(VIEW_ID_STICKY_HEADER); 276 view->set_id(VIEW_ID_STICKY_HEADER);
256 view->set_background( 277 view->set_background(
257 views::Background::CreateSolidBackground(kBackgroundColor)); 278 views::Background::CreateSolidBackground(kBackgroundColor));
258 view->SetBorder( 279 view->SetBorder(
259 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); 280 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0)));
260 } 281 }
261 282
262 void TrayPopupUtils::ConfigureContainer(TriView::Container container, 283 void TrayPopupUtils::ConfigureContainer(TriView::Container container,
263 views::View* container_view) { 284 views::View* container_view) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { 430 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
410 // TODO(tdanderson): Consider moving this into WmShell, or introduce a 431 // TODO(tdanderson): Consider moving this into WmShell, or introduce a
411 // CanShowSettings() method in each delegate type that has a 432 // CanShowSettings() method in each delegate type that has a
412 // ShowSettings() method. 433 // ShowSettings() method.
413 return status != LoginStatus::NOT_LOGGED_IN && 434 return status != LoginStatus::NOT_LOGGED_IN &&
414 status != LoginStatus::LOCKED && 435 status != LoginStatus::LOCKED &&
415 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 436 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
416 } 437 }
417 438
418 } // namespace ash 439 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_utils.h ('k') | ui/views/controls/button/toggle_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698