Thomas Tellier | 5e5f416 | 2020-01-28 20:20:49 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ASH_LOGIN_UI_SYSTEM_LABEL_BUTTON_H_ |
| 6 | #define ASH_LOGIN_UI_SYSTEM_LABEL_BUTTON_H_ |
| 7 | |
| 8 | #include "ash/ash_export.h" |
| 9 | #include "ui/views/controls/button/label_button.h" |
| 10 | |
| 11 | namespace ash { |
| 12 | |
| 13 | // SystemLabelButton provides styled buttons with label for the login screen. |
Thomas Tellier | 7ebeff9 | 2021-01-11 15:10:15 | [diff] [blame] | 14 | // It is assumed that it lives in a login bubble, with a defined background; |
| 15 | // ripple effects may be inappropriate for a different usage. |
Thomas Tellier | 5e5f416 | 2020-01-28 20:20:49 | [diff] [blame] | 16 | class ASH_EXPORT SystemLabelButton : public views::LabelButton { |
| 17 | public: |
| 18 | enum class DisplayType { DEFAULT, ALERT_NO_ICON, ALERT_WITH_ICON }; |
| 19 | |
Peter Kasting | a5e4663 | 2020-11-04 19:43:37 | [diff] [blame] | 20 | SystemLabelButton(PressedCallback callback, |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame^] | 21 | const std::u16string& text, |
Renato Silva | 697a12b | 2020-08-20 14:28:05 | [diff] [blame] | 22 | DisplayType display_type, |
| 23 | bool multiline = false); |
Thomas Tellier | 5e5f416 | 2020-01-28 20:20:49 | [diff] [blame] | 24 | SystemLabelButton(const SystemLabelButton&) = delete; |
| 25 | SystemLabelButton& operator=(const SystemLabelButton&) = delete; |
| 26 | ~SystemLabelButton() override = default; |
| 27 | |
| 28 | // views::LabelButton: |
| 29 | void PaintButtonContents(gfx::Canvas* canvas) override; |
| 30 | gfx::Insets GetInsets() const override; |
| 31 | |
Thomas Tellier | 8ffb18d0 | 2020-01-30 18:22:54 | [diff] [blame] | 32 | // Switch display type from {DEFAULT, ALERT_NO_ICON} to |
| 33 | // {DEFAULT, ALERT_NO_ICON}. We can't change display type from or to |
| 34 | // ALERT_WITH_ICON once it has been set (no UX interest to do so right now). |
| 35 | void SetDisplayType(DisplayType display_type); |
| 36 | |
Thomas Tellier | 06c5a33 | 2021-03-11 18:08:15 | [diff] [blame] | 37 | // views::View: |
| 38 | void OnThemeChanged() override; |
| 39 | |
Thomas Tellier | 5e5f416 | 2020-01-28 20:20:49 | [diff] [blame] | 40 | private: |
Thomas Tellier | 8ffb18d0 | 2020-01-30 18:22:54 | [diff] [blame] | 41 | // Mode could be either default or alert. This methods set the background and |
| 42 | // font accordingly. |
| 43 | void SetAlertMode(bool alert_mode); |
| 44 | |
Thomas Tellier | 56fa7b2 | 2020-11-11 10:37:46 | [diff] [blame] | 45 | // Absurd color to show the developer that background color has not been |
| 46 | // initialized properly. |
Thomas Tellier | 5e5f416 | 2020-01-28 20:20:49 | [diff] [blame] | 47 | SkColor background_color_ = SK_ColorGREEN; |
Thomas Tellier | 8ffb18d0 | 2020-01-30 18:22:54 | [diff] [blame] | 48 | // Used only to ensure that we do not call SetDisplayType when the current |
| 49 | // display type is ALERT_WITH_ICON. |
| 50 | DisplayType display_type_ = DisplayType::DEFAULT; |
Thomas Tellier | 5e5f416 | 2020-01-28 20:20:49 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } // namespace ash |
| 54 | |
| 55 | #endif // ASH_LOGIN_UI_SYSTEM_LABEL_BUTTON_H_ |