#ifndef UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
#define UI_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
#include <memory>
#include <optional>
#include <string>
#include "cc/paint/paint_flags.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/metadata/view_factory.h"
namespace gfx {
struct VectorIcon;
}
namespace views {
class VIEWS_EXPORT Checkbox : public LabelButton {
METADATA_HEADER(Checkbox, LabelButton)
public:
explicit Checkbox(const std::u16string& label = std::u16string(),
PressedCallback callback = PressedCallback(),
int button_context = style::CONTEXT_BUTTON);
Checkbox(const Checkbox&) = delete;
Checkbox& operator=(const Checkbox&) = delete;
~Checkbox() override;
virtual void SetChecked(bool checked);
bool GetChecked() const;
[[nodiscard]] base::CallbackListSubscription AddCheckedChangedCallback(
PropertyChangedCallback callback);
void SetMultiLine(bool multi_line);
bool GetMultiLine() const;
void SetCheckedIconImageColor(SkColor color);
gfx::ImageSkia GetImage(ButtonState for_state) const override;
std::unique_ptr<LabelButtonBorder> CreateDefaultBorder() const override;
std::unique_ptr<ActionViewInterface> GetActionViewInterface() override;
protected:
enum IconState { CHECKED = 0b1, ENABLED = 0b10 };
void UpdateAccessibleCheckedState() override;
void OnThemeChanged() override;
virtual SkPath GetFocusRingPath() const;
virtual SkColor GetIconImageColor(int icon_state) const;
virtual SkColor GetIconCheckColor(int icon_state) const;
int GetIconState(ButtonState for_state) const;
virtual const gfx::VectorIcon& GetVectorIcon() const;
private:
class FocusRingHighlightPathGenerator;
void NotifyClick(const ui::Event& event) override;
ui::NativeTheme::Part GetThemePart() const override;
void GetExtraParams(ui::NativeTheme::ExtraParams* params) const override;
void SetAndUpdateAccessibleDefaultActionVerb();
bool checked_ = false;
std::optional<SkColor> checked_icon_image_color_;
};
class VIEWS_EXPORT CheckboxActionViewInterface
: public LabelButtonActionViewInterface {
public:
explicit CheckboxActionViewInterface(Checkbox* action_view);
~CheckboxActionViewInterface() override = default;
void ActionItemChangedImpl(actions::ActionItem* action_item) override;
void OnViewChangedImpl(actions::ActionItem* action_item) override;
private:
raw_ptr<Checkbox> action_view_;
};
BEGIN_VIEW_BUILDER(VIEWS_EXPORT, Checkbox, LabelButton)
VIEW_BUILDER_PROPERTY(bool, Checked)
VIEW_BUILDER_PROPERTY(bool, MultiLine)
END_VIEW_BUILDER
}
DEFINE_VIEW_BUILDER(VIEWS_EXPORT, Checkbox)
#endif