18class CheckboxBase :
public ComponentBase,
public CheckboxOption {
20 explicit CheckboxBase(CheckboxOption option)
21 : CheckboxOption(std::move(option)) {}
26 const bool is_focused = Focused();
27 const bool is_active = Active();
28 auto entry_state = EntryState{
29 *label, *checked, is_active, is_focused || hovered_, -1,
38 bool OnEvent(Event event)
override {
39 if (!CaptureMouse(event)) {
43 if (event.is_mouse()) {
44 return OnMouseEvent(event);
48 if (event == Event::Character(
' ') || event ==
Event::Return) {
57 bool OnMouseEvent(Event event) {
58 hovered_ = box_.Contain(event.mouse().x, event.mouse().y);
60 if (!CaptureMouse(event)) {
78 bool Focusable() const final {
return true; }
80 bool hovered_ =
false;
135 option.
label = std::move(label);
アダプター。定数文字列を所有または参照します。便宜上、このクラスは複数の不変文字列を共有表現に変換します。
static CheckboxOption Simple()
標準チェックボックスのオプション。
static const Event Return
std::function< Element(const EntryState &)> transform
Component Checkbox(CheckboxOption options)
チェック可能な要素を描画します。
Element focus(Element)
子要素を兄弟要素の中でフォーカスされたものとして設定します。
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
Decorator reflect(Box &box)
std::shared_ptr< ComponentBase > Component