| 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" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 class BorderlessLabelButton : public views::LabelButton { | 106 class BorderlessLabelButton : public views::LabelButton { |
| 107 public: | 107 public: |
| 108 BorderlessLabelButton(views::ButtonListener* listener, | 108 BorderlessLabelButton(views::ButtonListener* listener, |
| 109 const base::string16& text) | 109 const base::string16& text) |
| 110 : LabelButton(listener, text) { | 110 : LabelButton(listener, text) { |
| 111 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 111 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 112 SetInkDropMode(views::InkDropHostView::InkDropMode::ON); | 112 SetInkDropMode(views::InkDropHostView::InkDropMode::ON); |
| 113 set_has_ink_drop_action_on_click(true); | 113 set_has_ink_drop_action_on_click(true); |
| 114 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); | 114 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); |
| 115 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); | 115 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); |
| 116 const int kHorizontalPadding = 8; | 116 const int kHorizontalPadding = 20; |
| 117 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding))); | 117 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding))); |
| 118 TrayPopupItemStyle style(nullptr, TrayPopupItemStyle::FontStyle::BUTTON); | 118 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON); |
| 119 style.SetupLabel(label()); | 119 style.SetupLabel(label()); |
| 120 // TODO(tdanderson): Update focus rect for material design. See | 120 // TODO(tdanderson): Update focus rect for material design. See |
| 121 // crbug.com/615892 | 121 // crbug.com/615892 |
| 122 // Hack alert: CreateSolidFocusPainter should add 0.5f to all insets to | 122 // Hack alert: CreateSolidFocusPainter should add 0.5f to all insets to |
| 123 // make the lines align to pixel centers, but for now it doesn't. We can | 123 // make the lines align to pixel centers, but for now it doesn't. We can |
| 124 // get around this by relying on Skia rounding up integer coordinates. | 124 // get around this by relying on Skia rounding up integer coordinates. |
| 125 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 125 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 126 kFocusBorderColor, gfx::Insets(0, 0, 1, 1))); | 126 kFocusBorderColor, gfx::Insets(0, 0, 1, 1))); |
| 127 } else { | 127 } else { |
| 128 SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder)); | 128 SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder)); |
| 129 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 129 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 130 kFocusBorderColor, gfx::Insets(1, 1, 2, 2))); | 130 kFocusBorderColor, gfx::Insets(1, 1, 2, 2))); |
| 131 set_animate_on_state_change(false); | 131 set_animate_on_state_change(false); |
| 132 } | 132 } |
| 133 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 133 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 134 SetFocusForPlatform(); | 134 SetFocusForPlatform(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 ~BorderlessLabelButton() override {} | 137 ~BorderlessLabelButton() override {} |
| 138 | 138 |
| 139 // views::LabelButton: | 139 // views::LabelButton: |
| 140 int GetHeightForWidth(int width) const override { | 140 int GetHeightForWidth(int width) const override { |
| 141 if (MaterialDesignController::IsSystemTrayMenuMaterial()) | 141 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 142 return kMenuButtonSize - 2 * kTrayPopupInkDropInset; | 142 return kMenuButtonSize; |
| 143 | 143 |
| 144 return LabelButton::GetHeightForWidth(width); | 144 return LabelButton::GetHeightForWidth(width); |
| 145 } | 145 } |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 std::unique_ptr<views::InkDrop> CreateInkDrop() override { | 148 std::unique_ptr<views::InkDrop> CreateInkDrop() override { |
| 149 return TrayPopupUtils::CreateInkDrop(TrayPopupInkDropStyle::INSET_BOUNDS, | 149 return TrayPopupUtils::CreateInkDrop(TrayPopupInkDropStyle::INSET_BOUNDS, |
| 150 this); | 150 this); |
| 151 } | 151 } |
| 152 | 152 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { | 430 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { |
| 431 // TODO(tdanderson): Consider moving this into WmShell, or introduce a | 431 // TODO(tdanderson): Consider moving this into WmShell, or introduce a |
| 432 // CanShowSettings() method in each delegate type that has a | 432 // CanShowSettings() method in each delegate type that has a |
| 433 // ShowSettings() method. | 433 // ShowSettings() method. |
| 434 return status != LoginStatus::NOT_LOGGED_IN && | 434 return status != LoginStatus::NOT_LOGGED_IN && |
| 435 status != LoginStatus::LOCKED && | 435 status != LoginStatus::LOCKED && |
| 436 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 436 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 437 } | 437 } |
| 438 | 438 |
| 439 } // namespace ash | 439 } // namespace ash |
| OLD | NEW |