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. 14 class ASH_EXPORT SystemLabelButton : public views::LabelButton { 15 public: 16 enum class DisplayType { DEFAULT, ALERT_NO_ICON, ALERT_WITH_ICON }; 17 18 SystemLabelButton(PressedCallback callback, 19 const base::string16& text, 20 DisplayType display_type, 21 bool multiline = false); 22 SystemLabelButton(const SystemLabelButton&) = delete; 23 SystemLabelButton& operator=(const SystemLabelButton&) = delete; 24 ~SystemLabelButton() override = default; 25 26 // views::LabelButton: 27 void PaintButtonContents(gfx::Canvas* canvas) override; 28 gfx::Insets GetInsets() const override; 29 30 // Switch display type from {DEFAULT, ALERT_NO_ICON} to 31 // {DEFAULT, ALERT_NO_ICON}. We can't change display type from or to 32 // ALERT_WITH_ICON once it has been set (no UX interest to do so right now). 33 void SetDisplayType(DisplayType display_type); 34 35 private: 36 // Mode could be either default or alert. This methods set the background and 37 // font accordingly. 38 void SetAlertMode(bool alert_mode); 39 40 // Absurd color to show the developer that background color has not been 41 // initialized properly. 42 SkColor background_color_ = SK_ColorGREEN; 43 // Used only to ensure that we do not call SetDisplayType when the current 44 // display type is ALERT_WITH_ICON. 45 DisplayType display_type_ = DisplayType::DEFAULT; 46 }; 47 48 } // namespace ash 49 50 #endif // ASH_LOGIN_UI_SYSTEM_LABEL_BUTTON_H_ 51