| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_utils.h" | 5 #include "ash/common/system/tray/tray_utils.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_constants.h" |
| 7 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 11 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "ash/common/system/tray/tray_item_view.h" | 12 #include "ash/common/system/tray/tray_item_view.h" |
| 13 #include "ash/common/system/tray/tray_popup_label_button_border.h" |
| 12 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 13 #include "ui/accessibility/ax_view_state.h" | 15 #include "ui/accessibility/ax_view_state.h" |
| 14 #include "ui/gfx/font_list.h" | 16 #include "ui/gfx/font_list.h" |
| 15 #include "ui/gfx/geometry/vector2d.h" | 17 #include "ui/gfx/geometry/vector2d.h" |
| 16 #include "ui/views/border.h" | 18 #include "ui/views/border.h" |
| 19 #include "ui/views/controls/button/label_button.h" |
| 20 #include "ui/views/controls/button/md_text_button.h" |
| 17 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
| 18 #include "ui/views/controls/separator.h" | 22 #include "ui/views/controls/separator.h" |
| 19 | 23 |
| 20 namespace ash { | 24 namespace ash { |
| 21 | 25 |
| 26 views::LabelButton* CreateTrayPopupBorderlessButton( |
| 27 views::ButtonListener* listener, |
| 28 const base::string16& text) { |
| 29 auto* button = new views::LabelButton(listener, text); |
| 30 button->SetBorder( |
| 31 std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder)); |
| 32 button->SetFocusForPlatform(); |
| 33 button->set_animate_on_state_change(false); |
| 34 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 35 button->SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 36 kFocusBorderColor, gfx::Insets(1, 1, 2, 2))); |
| 37 return button; |
| 38 } |
| 39 |
| 40 views::LabelButton* CreateTrayPopupButton(views::ButtonListener* listener, |
| 41 const base::string16& text) { |
| 42 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 43 return CreateTrayPopupBorderlessButton(listener, text); |
| 44 |
| 45 auto* button = views::MdTextButton::Create(listener, text); |
| 46 button->SetProminent(true); |
| 47 return button; |
| 48 } |
| 49 |
| 22 void SetupLabelForTray(views::Label* label) { | 50 void SetupLabelForTray(views::Label* label) { |
| 23 if (MaterialDesignController::IsShelfMaterial()) { | 51 if (MaterialDesignController::IsShelfMaterial()) { |
| 24 // The text is drawn on an transparent bg, so we must disable subpixel | 52 // The text is drawn on an transparent bg, so we must disable subpixel |
| 25 // rendering. | 53 // rendering. |
| 26 label->SetSubpixelRenderingEnabled(false); | 54 label->SetSubpixelRenderingEnabled(false); |
| 27 label->SetFontList(gfx::FontList().Derive(2, gfx::Font::NORMAL, | 55 label->SetFontList(gfx::FontList().Derive(2, gfx::Font::NORMAL, |
| 28 gfx::Font::Weight::MEDIUM)); | 56 gfx::Font::Weight::MEDIUM)); |
| 29 } else { | 57 } else { |
| 30 label->SetFontList( | 58 label->SetFontList( |
| 31 gfx::FontList().Derive(1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); | 59 gfx::FontList().Derive(1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 131 |
| 104 views::Separator* CreateVerticalSeparator() { | 132 views::Separator* CreateVerticalSeparator() { |
| 105 views::Separator* separator = | 133 views::Separator* separator = |
| 106 new views::Separator(views::Separator::HORIZONTAL); | 134 new views::Separator(views::Separator::HORIZONTAL); |
| 107 separator->SetPreferredSize(kHorizontalSeparatorHeight); | 135 separator->SetPreferredSize(kHorizontalSeparatorHeight); |
| 108 separator->SetColor(kHorizontalSeparatorColor); | 136 separator->SetColor(kHorizontalSeparatorColor); |
| 109 return separator; | 137 return separator; |
| 110 } | 138 } |
| 111 | 139 |
| 112 } // namespace ash | 140 } // namespace ash |
| OLD | NEW |