39 memset(&this->delegate, 0,
sizeof(this->delegate));
62 $(self, bind, inlets, dictionary);
85 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
92 if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
95 self->
state &= ~ControlStateHighlighted;
97 if (event->button.clicks) {
98 if (this->delegate.didClick) {
99 this->delegate.didClick(
this);
107 if (event->type == SDL_EVENT_MOUSE_MOTION) {
113 if (event->type == SDL_EVENT_KEY_DOWN) {
114 switch (event->key.key) {
119 if (this->delegate.didClick) {
120 this->delegate.didClick(
this);
183#pragma mark - Class lifecycle
190 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
193 ((ViewInterface *) clazz->interface)->init =
init;
195 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
211 clazz = _initialize(&(
const ClassDef) {
214 .instanceSize =
sizeof(
Button),
215 .interfaceOffset = offsetof(
Button, interface),
216 .interfaceSize =
sizeof(ButtonInterface),
static void resignKeyResponder(View *self)
@ ControlStateHighlighted
static void setImage(ImageView *self, Image *image)
static Label * initWithText(Label *self, const char *text, Font *font)
static void addSubview(View *self, View *subview)
static void setText(Text *self, const char *text)
@ ViewEventClick
A Control received one or more click events.
#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)
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.
Text rendered with TrueType fonts.
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.