Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 if (is_material) { | 242 if (is_material) { |
| 240 slider->SetBorder( | 243 slider->SetBorder( |
| 241 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD))); | 244 views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupSliderPaddingMD))); |
| 242 } else { | 245 } else { |
| 243 slider->SetBorder( | 246 slider->SetBorder( |
| 244 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); | 247 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); |
| 245 } | 248 } |
| 246 return slider; | 249 return slider; |
| 247 } | 250 } |
| 248 | 251 |
| 252 views::ToggleButton* TrayPopupUtils::CreateToggleButton( | |
| 253 views::ButtonListener* listener, | |
| 254 int accessible_name_id) { | |
| 255 views::ToggleButton* toggle = new views::ToggleButton(listener); | |
| 256 toggle->SetBorder(views::CreateEmptyBorder(gfx::Insets( | |
| 257 kTrayToggleButtonVerticalPadding, kTrayToggleButtonHorizontalPadding))); | |
| 258 toggle->set_focus_painter(views::Painter::CreateSolidFocusPainter( | |
| 259 kFocusBorderColor, gfx::Insets(1))); | |
|
Evan Stade
2016/11/17 22:32:22
insets should be gfx::Insets(0,0,1,1) (CreateSolid
varkha
2016/11/17 22:51:54
This is probably the right thing to do but it need
| |
| 260 toggle->SetFocusForPlatform(); | |
|
Evan Stade
2016/11/17 22:32:22
seems like this should be part of the base ToggleB
varkha
2016/11/17 22:51:54
Done.
| |
| 261 toggle->SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); | |
|
Evan Stade
2016/11/17 22:32:22
This is a behavioral change. Terry and I decided a
varkha
2016/11/17 22:51:54
Done.
| |
| 262 return toggle; | |
| 263 } | |
| 264 | |
| 249 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { | 265 void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { |
| 250 view->set_id(VIEW_ID_STICKY_HEADER); | 266 view->set_id(VIEW_ID_STICKY_HEADER); |
| 251 view->set_background( | 267 view->set_background( |
| 252 views::Background::CreateSolidBackground(kBackgroundColor)); | 268 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 253 view->SetBorder( | 269 view->SetBorder( |
| 254 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); | 270 views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); |
| 255 } | 271 } |
| 256 | 272 |
| 257 void TrayPopupUtils::ConfigureContainer(TriView::Container container, | 273 void TrayPopupUtils::ConfigureContainer(TriView::Container container, |
| 258 views::View* container_view) { | 274 views::View* container_view) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { | 393 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { |
| 378 // TODO(tdanderson): Consider moving this into WmShell, or introduce a | 394 // TODO(tdanderson): Consider moving this into WmShell, or introduce a |
| 379 // CanShowSettings() method in each delegate type that has a | 395 // CanShowSettings() method in each delegate type that has a |
| 380 // ShowSettings() method. | 396 // ShowSettings() method. |
| 381 return status != LoginStatus::NOT_LOGGED_IN && | 397 return status != LoginStatus::NOT_LOGGED_IN && |
| 382 status != LoginStatus::LOCKED && | 398 status != LoginStatus::LOCKED && |
| 383 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 399 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 384 } | 400 } |
| 385 | 401 |
| 386 } // namespace ash | 402 } // namespace ash |
| OLD | NEW |