39 memset(&this->delegate, 0,
sizeof(this->delegate));
63 $(self, bind, inlets, dictionary);
86 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
93 if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
98 if (event->button.clicks) {
99 if (this->delegate.didClick) {
100 this->delegate.didClick(
this);
108 if (event->type == SDL_EVENT_MOUSE_MOTION) {
114 if (event->type == SDL_EVENT_KEY_DOWN) {
115 switch (event->key.key) {
120 if (this->delegate.didClick) {
121 this->delegate.didClick(
this);
184#pragma mark - Class lifecycle
191 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
194 ((ViewInterface *) clazz->interface)->init =
init;
196 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
198 ((ButtonInterface *) clazz->interface)->initWithFrame =
initWithFrame;
199 ((ButtonInterface *) clazz->interface)->initWithImage =
initWithImage;
200 ((ButtonInterface *) clazz->interface)->initWithTitle =
initWithTitle;
212 clazz = _initialize(&(
const ClassDef) {
215 .instanceSize =
sizeof(
Button),
216 .interfaceSize =
sizeof(ButtonInterface),
static AtlasImage * initWithImage(AtlasImage *self, ImageAtlas *atlas, Image *image)
static void initialize(Class *clazz)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static void dealloc(Object *self)
static Box * initWithFrame(Box *self, const SDL_Rect *frame)
@ ControlStateHighlighted
static void setImage(ImageView *self, Image *image)
static Label * initWithText(Label *self, const char *text, Font *font)
static void setText(Text *self, const char *text)
static Image * image(Theme *self, const char *name, float pixelDensity)
@ 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.
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.
bool captureEvent(Control *self, const SDL_Event *event)
Captures a given event, potentially altering the state of this Control.
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 addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
bool didReceiveEvent(const View *self, const SDL_Event *event)
void resignKeyResponder(View *self)
Resigns key responder priority.
SDL_Rect frame
The frame, relative to the superview.
void emitViewEvent(View *self, ViewEvent code, ident data)
Emits a ViewEvent originating from this View.