48#define _Class _Control
102 $(self, bind, inlets, (Dictionary *) style->
attributes);
119 $(self, bind, inlets, dictionary);
151 assert(simpleSelector);
155 switch (simpleSelector->
type) {
157 if (strcmp(
"highlighted", simpleSelector->
pattern) == 0) {
159 }
else if (strcmp(
"disabled", simpleSelector->
pattern) == 0) {
161 }
else if (strcmp(
"selected", simpleSelector->
pattern) == 0) {
163 }
else if (strcmp(
"focused", simpleSelector->
pattern) == 0) {
165 }
else if (strcmp(
"single", simpleSelector->
pattern) == 0) {
167 }
else if (strcmp(
"multiple", simpleSelector->
pattern) == 0) {
207 points[0].x =
frame.x;
214 points[2].y =
frame.y;
216 $(renderer,
drawLines, points, lengthof(points), &this->bevelLightColor);
218 points[0].x =
frame.x;
221 points[1].x =
frame.x;
222 points[1].y =
frame.y;
225 points[2].y =
frame.y;
227 $(renderer,
drawLines, points, lengthof(points), &this->bevelDarkColor);
233 points[0].x =
frame.x;
240 points[2].y =
frame.y;
242 $(renderer,
drawLines, points, lengthof(points), &this->bevelDarkColor);
244 points[0].x =
frame.x;
247 points[1].x =
frame.x;
248 points[1].y =
frame.y;
251 points[2].y =
frame.y;
253 $(renderer,
drawLines, points, lengthof(points), &this->bevelLightColor);
289 bool consumed =
false;
293 if (consumed && this->state != state) {
306#pragma mark - Control
382#pragma mark - Class lifecycle
389 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
393 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
396 ((ViewInterface *) clazz->interface)->init =
init;
397 ((ViewInterface *) clazz->interface)->matchesSelector =
matchesSelector;
398 ((ViewInterface *) clazz->interface)->render =
render;
400 ((ViewInterface *) clazz->interface)->respondToEvent =
respondToEvent;
402 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
403 ((ControlInterface *) clazz->interface)->initWithFrame =
initWithFrame;
404 ((ControlInterface *) clazz->interface)->isDisabled =
isDisabled;
405 ((ControlInterface *) clazz->interface)->isFocused =
isFocused;
406 ((ControlInterface *) clazz->interface)->isHighlighted =
isHighlighted;
407 ((ControlInterface *) clazz->interface)->isSelected =
isSelected;
408 ((ControlInterface *) clazz->interface)->stateDidChange =
stateDidChange;
420 clazz = _initialize(&(
const ClassDef) {
422 .superclass =
_View(),
423 .instanceSize =
sizeof(
Control),
424 .interfaceSize =
sizeof(ControlInterface),
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)
static bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)
static void applyStyle(View *self, const Style *style)
const EnumName ControlBevelNames[]
const EnumName ControlSelectionNames[]
static void becomeKeyResponder(View *self)
static void stateDidChange(Control *self)
static bool acceptsKeyResponder(const View *self)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static Control * initWithFrame(Control *self, const SDL_Rect *frame)
static bool respondToEvent(View *self, const SDL_Event *event)
const EnumName ControlStateNames[]
static void applyStyle(View *self, const Style *style)
static bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)
static bool captureEvent(Control *self, const SDL_Event *event)
static bool isHighlighted(const Control *self)
static void render(View *self, Renderer *renderer)
static void dealloc(Object *self)
static void resignKeyResponder(View *self)
static bool isDisabled(const Control *self)
static void initialize(Class *clazz)
static bool acceptsTouchResponder(const View *self)
static bool isFocused(const Control *self)
static bool isSelected(const Control *self)
Controls are Views which capture and respond to events.
@ ControlSelectionMultiple
ControlState
Control states, which are bit-masked.
@ ControlStateHighlighted
static void drawLines(const Renderer *self, const SDL_Point *points, size_t count, const SDL_Color *color)
static void drawRoundedRect(const Renderer *self, const SDL_Rect *rect, int radius, int width, const SDL_Color *color)
static void drawRect(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color)
static void drawBevel(const Renderer *self, const SDL_Rect *rect, int radius, int width, const SDL_Color *topLeft, const SDL_Color *bottomRight)
@ SimpleSelectorTypePseudo
@ ViewEventFocus
A Control's state has focus.
@ ViewEventBlur
A Control has lost focus.
#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.
SDL_Color bevelLightColor
The bevel color for the lit edges.
Control initWithFrame(Control *self, const SDL_Rect *frame)
Initializes this Control with the specified frame and style.
SDL_Color bevelDarkColor
The bevel color for the shadowed edges.
Inlets enable inbound data binding of View attributes through JSON.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
SimpleSelectorType type
The SimpleSelectorType.
char * pattern
The pattern, as provided by the user.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
void invalidateStyle(View *self)
Invalidates the computed Style for this View and its descendants.
bool respondToEvent(View *self, const SDL_Event *event)
Responds to the specified event.
void setNeedsLayout(View *self)
Marks this View as needing layout before it is next drawn.
SDL_Rect renderFrame(const View *self)
void becomeKeyResponder(View *self)
Become the key responder in the View hierarchy.
int borderRadius
The corner radius applied to the background, border and bevel.
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.
void render(View *self, Renderer *renderer)
Renders this View using the given renderer.