[go: nahoru, domu]

blob: 7d801685de0b7604d34081f7257c68fd829c68d2 [file] [log] [blame]
Thomas Tellier5e5f4162020-01-28 20:20:491// 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
11namespace ash {
12
13// SystemLabelButton provides styled buttons with label for the login screen.
Thomas Tellier7ebeff92021-01-11 15:10:1514// 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 Tellier5e5f4162020-01-28 20:20:4916class ASH_EXPORT SystemLabelButton : public views::LabelButton {
17 public:
18 enum class DisplayType { DEFAULT, ALERT_NO_ICON, ALERT_WITH_ICON };
19
Peter Kastinga5e46632020-11-04 19:43:3720 SystemLabelButton(PressedCallback callback,
Jan Wilken Dörrie85285b02021-03-11 23:38:4721 const std::u16string& text,
Renato Silva697a12b2020-08-20 14:28:0522 DisplayType display_type,
23 bool multiline = false);
Thomas Tellier5e5f4162020-01-28 20:20:4924 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 Tellier8ffb18d02020-01-30 18:22:5432 // 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 Tellier06c5a332021-03-11 18:08:1537 // views::View:
38 void OnThemeChanged() override;
39
Thomas Tellier5e5f4162020-01-28 20:20:4940 private:
Thomas Tellier8ffb18d02020-01-30 18:22:5441 // Mode could be either default or alert. This methods set the background and
42 // font accordingly.
43 void SetAlertMode(bool alert_mode);
44
Thomas Tellier56fa7b22020-11-11 10:37:4645 // Absurd color to show the developer that background color has not been
46 // initialized properly.
Thomas Tellier5e5f4162020-01-28 20:20:4947 SkColor background_color_ = SK_ColorGREEN;
Thomas Tellier8ffb18d02020-01-30 18:22:5448 // 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 Tellier5e5f4162020-01-28 20:20:4951};
52
53} // namespace ash
54
55#endif // ASH_LOGIN_UI_SYSTEM_LABEL_BUTTON_H_