28#include "../Assets/check.png.h"
30#define _Class _Checkbox
43 memset(&this->delegate, 0,
sizeof(this->delegate));
66 $(self, bind, inlets, dictionary);
87 const View *box = (
View *) this->box;
89 switch (event->type) {
90 case SDL_EVENT_MOUSE_BUTTON_DOWN:
96 case SDL_EVENT_MOUSE_BUTTON_UP:
99 self->
state &= ~ControlStateHighlighted;
100 if (this->delegate.didToggle) {
101 this->delegate.didToggle(
this);
107 case SDL_EVENT_KEY_DOWN:
108 switch (event->key.key) {
114 self->
state &= ~ControlStateHighlighted;
115 if (this->delegate.didToggle) {
116 this->delegate.didToggle(
this);
126#pragma mark - Checkbox
150#pragma mark - Class lifecycle
157 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
160 ((ViewInterface *) clazz->interface)->init =
init;
162 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
185 clazz = _initialize(&(
const ClassDef) {
189 .interfaceSize =
sizeof(CheckboxInterface),
static AtlasImage * initWithImage(AtlasImage *self, ImageAtlas *atlas, Image *image)
static void destroy(Class *clazz)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static bool captureEvent(Control *self, const SDL_Event *event)
static Checkbox * initWithFrame(Checkbox *self, const SDL_Rect *frame)
static void dealloc(Object *self)
static void initialize(Class *clazz)
Checkboxes are toggle Controls that respond to click events.
@ ControlStateHighlighted
static Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length, float pixelDensity)
static void addSubview(View *self, View *subview)
@ ViewEventChange
A Control's input value has changed.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static void emitViewEvent(View *self, ViewEvent code, ident data)
Checkboxes are toggle Controls that respond to click events.
ImageView * check
The check.
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.
ImageViews render an Image in the context of a View hierarchy.
Inlets enable inbound data binding of View attributes through JSON.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
void awakeWithDictionary(View *, const Dictionary *)
Wakes this View with the specified Dictionary.
View * initWithFrame(View *self, const SDL_Rect *frame)
Initializes this View with the specified frame.