1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46

ash / system / tray / tray_toggle_button.h [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_TRAY_TRAY_TOGGLE_BUTTON_H_
#define ASH_SYSTEM_TRAY_TRAY_TOGGLE_BUTTON_H_

#include <optional>

#include "ash/ash_export.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/button/toggle_button.h"

namespace ui {
class Event;
}  // namespace ui

namespace ash {

// A toggle button configured for the system tray menu's layout. Also gets the
// colors from AshColorProvider.
class ASH_EXPORT TrayToggleButton : public views::ToggleButton {
  METADATA_HEADER(TrayToggleButton, views::ToggleButton)

 public:
  // Creates a button that invokes `callback` when pressed. Sets the accessible
  // name to the string with resource id `accessible_name_id`, unless that
  // parameter is nullopt. If `use_empty_border` is false, adds an empty border
  // to pad the toggle to 68x48 pixels (for legacy status area). If
  // `use_empty_border` is true, the toggle button is just the size of the
  // underlying button.
  TrayToggleButton(PressedCallback callback,
                   std::optional<int> accessible_name_id,
                   bool use_empty_border = false);
  TrayToggleButton(const TrayToggleButton&) = delete;
  TrayToggleButton& operator=(const TrayToggleButton&) = delete;
  ~TrayToggleButton() override = default;

  // views::ToggleButton:
  void OnThemeChanged() override;
  void NotifyClick(const ui::Event& event) override;
};

}  // namespace ash

#endif  // ASH_SYSTEM_TRAY_TRAY_TOGGLE_BUTTON_H_