CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UICheckbox.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "UIControl.hpp"
11
14
15namespace CeresEngine {
16
17 enum class UICheckboxState {
18 Active = 1 << 0,
19 Hover = 1 << 1,
20 Clicked = 1 << 2,
21 };
24
32 class UICheckbox : public UIControl {
33 public:
37
38 public:
40
43 explicit UICheckbox(bool state);
44 ~UICheckbox() override;
45
46 public:
48 bool isToggled() const { return getState().contains(State::Selected); }
49
51 void setToggled(bool state);
52
53 protected: // UIControl
54 void didChangeState(const State& oldState, const State& newState) override;
55
56 public: // UIView
59
61 void draw(UIGraphicsContext& context, const UIRect& dirtyRect) override;
62
64 [[nodiscard]] bool getClearsContextBeforeDrawing() const noexcept override { return false; }
65
66 public: // UIResponder
68 void mouseUp(const UIMouseEvent& event) override;
69
70 public:
73
76 };
77} // namespace CeresEngine
#define CE_FLAGS_OPERATORS(Enum)
Defines global operators for a Flags<Enum, Storage> implementation.
Definition Flags.hpp:216
An object that represents a graphics context.
Definition GraphicsContext.hpp:45
Base template for the event class.
Definition Event.hpp:27
A control that defines an area on the screen that can be used to trigger actions.
Definition UICheckbox.hpp:32
bool isToggled() const
Definition UICheckbox.hpp:48
void mouseUp(const UIMouseEvent &event) override
Informs the receiver that the user has released the left mouse button.
Event< void(bool)> didToggle
A signal dispatched by the button whenever the user toggles the checkbox.
Definition UICheckbox.hpp:36
UISize getIntrinsicContentSize() const override
The natural size for the receiving view, considering only properties of the view itself.
void draw(UIGraphicsContext &context, const UIRect &dirtyRect) override
Displays the view and all its subviews if possible.
void didChangeState(const State &oldState, const State &newState) override
A internal method called whenever the internal control state changes.
void setToggled(bool state)
UICheckbox(bool state)
Creates a new checkbox with the given initial value.
static const UIColorAppearanceProperty endingShadowColorProperty
Definition UICheckbox.hpp:72
static const UIFloatAppearanceProperty widthProperty
Definition UICheckbox.hpp:74
static const UIFloatAppearanceProperty heightProperty
Definition UICheckbox.hpp:75
bool getClearsContextBeforeDrawing() const noexcept override
A Boolean value that determines whether the view's bounds should be automatically cleared before draw...
Definition UICheckbox.hpp:64
static const UIColorAppearanceProperty startingShadowColorProperty
Definition UICheckbox.hpp:71
A definition of the fundamental behavior for controls, which are specialized views that notify your a...
Definition UIControl.hpp:30
const State & getState() const noexcept
The state of the control, specified as a bit mask value.
Definition UIControl.hpp:225
Definition Application.hpp:19
Size2 UISize
A type that contains width and height values.
Definition UIUtility.hpp:30
UICheckboxState
Definition UICheckbox.hpp:17
struct CeresEngine::GLState state
Rect2 UIRect
A structure that contains the location and dimensions of a rectangle.
Definition UIUtility.hpp:33
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Wrapper around an enum that allows simple use of bitwise logic operations.
Definition Flags.hpp:19
A UI appearance property that returns a color.
Definition UIAppearance.hpp:30
Constants describing the state of a control.
Definition UIControl.hpp:38
constexpr bool contains(const State &member) const noexcept
Returns a Boolean value that indicates whether a given element is a member of the option set.
Definition UIControl.hpp:79
Definition UIEvent.hpp:173