28#include <Objectively.h>
128 free(this->identifier);
130 release(this->classNames);
131 release(this->computedStyle);
132 release(this->style);
133 release(this->stylesheet);
134 release(this->subviews);
135 release(this->warnings);
137 this->superview = NULL;
150 String *classNames = $((Object *) this->classNames,
description);
151 String *
description = str(
"%s@%p %s [%d, %d, %d, %d]",
152 this->identifier ?: classnameof(self),
187 String *
string = $$(String, stringWithCharacters, className);
212 assert(subview != other);
220 const Array *subviews = (Array *) self->
subviews;
221 const ssize_t index = $(subviews, indexOfObject, other);
224 if (index == (ssize_t) (subviews->count - 1)) {
225 $(self->
subviews, addObject, subview);
227 $(self->
subviews, insertObjectAtIndex, subview, index + 1);
230 $(self->
subviews, insertObjectAtIndex, subview, index);
233 $(self->
subviews, addObject, subview);
258 if (strcmp(identifier, view->
identifier) == 0) {
312 const bool stretch = self->
stretch;
321 $(style->
attributes, objectForKeyPath,
"left")) {
326 $(style->
attributes, objectForKeyPath,
"top")) {
340 assert(computedStyle);
350 self->needsApplyStyle =
false;
353 release(computedStyle);
379 self->needsApplyThemeSubviews =
false;
415 Data *data = $$(Data, dataWithConstMemory, (uint8_t *) chars, strlen(chars));
428 JSONContext *ctx = $(alloc(JSONContext),
init);
429 Dictionary *dictionary = $(ctx, objectFromData, data, 0);
435 MVC_LogError(
"Failed to parse JSON for %s\n", classnameof(self));
456 $(self, bind, inlets, dictionary);
476 Resource *resource = $$(Resource, resourceWithName,
name);
492 SDL_PropertiesID props = SDL_GetWindowProperties(self->
window);
503 SDL_SetPointerProperty(props,
"keyResponder", self);
516 SDL_PropertiesID props = SDL_GetWindowProperties(self->
window);
527 SDL_SetPointerProperty(props,
"touchResponder", self);
535static bool _bind(
View *self,
const Inlet *inlets,
const Dictionary *dictionary) {
554 const SDL_Size
size = $(self,
size);
577 if (last != subview) {
591 return (warning->
type & type) == 0;
611 return this->clippingFrameCache.
frame;
632 if (SDL_GetRectIntersection(&
clippingFrame, &frame, &frame) ==
false) {
633 frame.w = frame.h = 0;
637 this->clippingFrameCache.frame = frame;
651 return (
bool) SDL_PointInRect(point, &frame);
671 if (strcmp(identifier, self->
identifier) == 0) {
672 return (
View *) self;
676 const Array *subviews = (Array *) self->
subviews;
677 for (
size_t i = 0; i < subviews->count; i++) {
679 const View *subview = subviews->elements[i];
729 switch (event->type) {
730 case SDL_EVENT_KEY_DOWN:
731 case SDL_EVENT_KEY_UP:
732 case SDL_EVENT_TEXT_INPUT:
741 switch (event->type) {
742 case SDL_EVENT_MOUSE_BUTTON_DOWN:
743 case SDL_EVENT_MOUSE_BUTTON_UP:
744 point = MakePoint(event->button.x, event->button.y);
746 case SDL_EVENT_MOUSE_MOTION:
747 point = MakePoint(event->motion.x, event->motion.y);
749 case SDL_EVENT_MOUSE_WHEEL: {
751 SDL_GetMouseState(&mx, &my);
752 point = MakePoint(mx, my);
795 SDL_PushEvent((SDL_Event *) &(
const SDL_UserEvent) {
811 enumerator(self, data);
826 const ssize_t index = $(siblings, indexOfObject, (
const ident) self);
828 enumerator($(siblings, objectAtIndex, index - 1), data);
830 if (index < (ssize_t) (siblings->count - 1)) {
831 enumerator($(siblings, objectAtIndex, index + 1), data);
844 for (
View *view = self->
superview; view; view = view->superview) {
845 enumerator(view, data);
870 const Array *subviews = (Array *) self->
subviews;
871 for (
size_t i = 0; i < subviews->count; i++) {
873 View *subview = subviews->elements[i];
874 enumerator(subview, data);
891 for (
size_t i = 0; i < siblings->count; i++) {
892 View *sibling = siblings->elements[i];
893 if (sibling != self) {
894 enumerator(sibling, data);
908 const Array *subviews = (Array *) self->
subviews;
909 for (
size_t i = 0; i < subviews->count; i++) {
910 enumerator((
View *) subviews->elements[i], data);
937 enumerator(self, data);
939 const Array *subviews = (Array *) self->
subviews;
940 for (
size_t i = 0; i < subviews->count; i++) {
942 View *subview = subviews->elements[i];
951 return strcmp(((String *) obj)->chars, (
const char *) data) == 0;
1018 const Array *subviews = (Array *) self->
subviews;
1019 for (
size_t i = subviews->count; i; i--) {
1021 const View *subview = subviews->elements[i - 1];
1024 return (
View *) view;
1049 self = (
View *) super(Object, self,
init);
1053 self->
frame = *frame;
1056 self->
classNames = $$(Set, setWithCapacity, 0);
1062 self->
subviews = $$(Array, arrayWithCapacity, 0);
1066 assert(self->
style);
1068 self->
warnings = $$(Array, arrayWithCapacity, 0);
1083 view->needsApplyStyle =
true;
1129 return SDL_GetPointerProperty(SDL_GetWindowProperties(self->
window),
"keyResponder", NULL) == self;
1142 return SDL_GetPointerProperty(SDL_GetWindowProperties(self->
window),
"touchResponder", NULL) == self;
1154 for (
const View *view = self; view; view = view->
superview) {
1176 if (!self->
needsLayout && !self->needsLayoutSubviews) {
1182 self->needsLayoutSubviews =
false;
1211 const Array *subviews = (Array *) self->
subviews;
1212 for (
size_t i = 0; i < subviews->count; i++) {
1214 View *subview = subviews->elements[i];
1226 subview->
frame.x = 0;
1238 subview->
frame.y = 0;
1282 assert(simpleSelector);
1284 const char *pattern = simpleSelector->
pattern;
1286 switch (simpleSelector->
type) {
1294 const Class *clazz = classForName(pattern);
1296 return $((Object *) self, isKindOfClass, clazz);
1306 return strcmp(self->
identifier, pattern) == 0;
1312 if (strcmp(
"first-child", pattern) == 0) {
1316 }
else if (strcmp(
"last-child", pattern) == 0) {
1320 }
else if (strcmp(
"nth-child(even)", pattern) == 0) {
1322 return ($((Array *) self->
superview->
subviews, indexOfObject, (ident) self) & 1) == 0;
1324 }
else if (strcmp(
"nth-child(odd)", pattern) == 0) {
1328 }
else if (strcmp(
"hover", pattern) == 0) {
1330 SDL_GetMouseState(&mx, &my);
1331 SDL_Point point = MakePoint(mx, my);
1356 SDL_PropertiesID props = SDL_GetWindowProperties(self->
window);
1358 if (SDL_GetPointerProperty(props,
"keyResponder", NULL) == self) {
1359 SDL_SetPointerProperty(props,
"keyResponder", NULL);
1362 if (SDL_GetPointerProperty(props,
"touchResponder", NULL) == self) {
1363 SDL_SetPointerProperty(props,
"touchResponder", NULL);
1380 Array *parts = $$(Array, array);
1382 const View *view = self;
1385 Array *classNames = $((Set *) view->
classNames, allObjects);
1390 }
else if (classNames->count) {
1391 part = str(
".%s", ((String *) $(classNames, firstObject))->chars);
1393 part = str(
"%s", classnameof(view));
1396 release(classNames);
1398 $(parts, insertObjectAtIndex, part, 0);
1408 String *
path = $((Array *) parts, componentsJoinedByCharacters,
" > ");
1448 String *
string = $$(String, stringWithCharacters, className);
1483 $(self->
subviews, removeObject, subview);
1498 const int x1 = rect->x, y1 = rect->y;
1499 const int x2 = rect->x + rect->w, y2 = rect->y + rect->h;
1501 const int w = rect->w;
1503 const int topLeft = clamp(cut->
topLeft, 0, w);
1504 const int topRight = clamp(cut->
topRight, 0, w - topLeft);
1506 const int bottomLeft = clamp(cut->
bottomLeft, 0, w);
1507 const int bottomRight = clamp(cut->
bottomRight, 0, w - bottomLeft);
1509 points[0] = MakePoint(x1 + topLeft, y1);
1510 points[1] = MakePoint(x2 - topRight, y1);
1511 points[2] = MakePoint(x2 - bottomRight, y2);
1512 points[3] = MakePoint(x1 + bottomLeft, y2);
1524 SDL_TriggerBreakpoint();
1535 SDL_Point points[4];
1541 }
else if (gradient) {
1562 frame.w += inset * 2;
1563 frame.h += inset * 2;
1565 SDL_Point points[4];
1634 return this->renderFrameCache.
frame;
1637 SDL_Rect frame = self->
frame;
1642 const SDL_Rect superFrame = $(superview,
renderFrame);
1644 frame.x += superFrame.x;
1645 frame.y += superFrame.y;
1653 this->renderFrameCache.frame = frame;
1666 assert(replacement);
1684 SDL_SetPointerProperty(SDL_GetWindowProperties(self->
window),
"keyResponder", NULL);
1700 SDL_SetPointerProperty(SDL_GetWindowProperties(self->
window),
"touchResponder", NULL);
1713 if (self->
frame.w != w || self->
frame.h != h) {
1737 if (*outlet->view == NULL) {
1739 MVC_LogError(
"Failed to resolve outlet '%s' for %s", outlet->identifier, desc->chars);
1743 assert(*outlet->view);
1758 switch (event->type) {
1759 case SDL_EVENT_MOUSE_BUTTON_DOWN:
1762 case SDL_EVENT_MOUSE_BUTTON_UP:
1766 case SDL_EVENT_KEY_DOWN:
1769 case SDL_EVENT_KEY_UP:
1780 if (event->button.clicks) {
1786 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
1809 Set *selection = $(selector, select, self);
1856 for (
View *view = self->
superview; view && !view->needsApplyThemeSubviews; view = view->superview) {
1857 view->needsApplyThemeSubviews =
true;
1869 for (
View *view = self->
superview; view && !view->needsLayoutSubviews; view = view->superview) {
1870 view->needsLayoutSubviews =
true;
1879 return MakeSize(self->
frame.w, self->
frame.h);
1888 const SDL_Size
size = $(self,
size);
1919 size = MakeSize(0, 0);
1922 for (
size_t i = 0; i < subviews->count; i++) {
1924 View *subview = subviews->elements[i];
1927 const SDL_Size subviewSize = $(subview,
sizeThatSatisfies, unspecified, unspecified);
1929 SDL_Point subviewOrigin = MakePoint(0, 0);
1932 subviewOrigin = MakePoint(subview->
frame.x, subview->
frame.y);
1938 size.w = max(
size.w, subviewOrigin.x + subviewSize.w);
1939 size.h = max(
size.h, subviewOrigin.y + subviewSize.h);
1961 if (!hasAutoresizingBit) {
1965 switch (constraint.
mode) {
1966 case ViewConstraintEqual:
1967 return constraint.
value;
1968 case ViewConstraintMax:
1969 return min(intrinsic, constraint.
value);
2044 const Array *subviews = (Array *) self->
subviews;
2045 for (
size_t i = 0; i < subviews->count; i++) {
2047 View *subview = subviews->elements[i];
2050 if (strcmp(identifier, subview->
identifier) == 0) {
2093 Data *data = $$(Data, dataWithConstMemory, (ident) chars, strlen(chars));
2108 JSONContext *ctx = $(alloc(JSONContext),
init);
2109 Dictionary *dictionary = $(ctx, objectFromData, data, 0);
2114 release(dictionary);
2155 Resource *resource = $$(Resource, resourceWithName,
name);
2189 va_start(args, fmt);
2199 $(self->
warnings, addObject, warning);
2217#pragma mark - View class methods
2224 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
2225 ((ObjectInterface *) clazz->interface)->description =
description;
2229 ((ViewInterface *) clazz->interface)->addClassName =
addClassName;
2230 ((ViewInterface *) clazz->interface)->addSubview =
addSubview;
2234 ((ViewInterface *) clazz->interface)->applyTheme =
applyTheme;
2238 ((ViewInterface *) clazz->interface)->awakeWithData =
awakeWithData;
2244 ((ViewInterface *) clazz->interface)->bind =
_bind;
2245 ((ViewInterface *) clazz->interface)->bounds =
bounds;
2247 ((ViewInterface *) clazz->interface)->clearWarnings =
clearWarnings;
2248 ((ViewInterface *) clazz->interface)->clippingFrame =
clippingFrame;
2249 ((ViewInterface *) clazz->interface)->containsPoint =
containsPoint;
2250 ((ViewInterface *) clazz->interface)->depth =
depth;
2253 ((ViewInterface *) clazz->interface)->didMoveToWindow =
didMoveToWindow;
2254 ((ViewInterface *) clazz->interface)->didReceiveEvent =
didReceiveEvent;
2255 ((ViewInterface *) clazz->interface)->draw =
draw;
2256 ((ViewInterface *) clazz->interface)->emitViewEvent =
emitViewEvent;
2257 ((ViewInterface *) clazz->interface)->enumerate =
enumerate;
2266 ((ViewInterface *) clazz->interface)->hasClassName =
hasClassName;
2267 ((ViewInterface *) clazz->interface)->hasOverflow =
hasOverflow;
2268 ((ViewInterface *) clazz->interface)->hitTest =
hitTest;
2269 ((ViewInterface *) clazz->interface)->
init =
init;
2272 ((ViewInterface *) clazz->interface)->isContainer =
isContainer;
2274 ((ViewInterface *) clazz->interface)->isKeyResponder =
isKeyResponder;
2276 ((ViewInterface *) clazz->interface)->isVisible =
isVisible;
2277 ((ViewInterface *) clazz->interface)->layoutIfNeeded =
layoutIfNeeded;
2278 ((ViewInterface *) clazz->interface)->layoutSubviews =
layoutSubviews;
2280 ((ViewInterface *) clazz->interface)->layoutWithSize =
layoutWithSize;
2281 ((ViewInterface *) clazz->interface)->matchesSelector =
matchesSelector;
2282 ((ViewInterface *) clazz->interface)->moveToWindow =
moveToWindow;
2283 ((ViewInterface *) clazz->interface)->path =
path;
2286 ((ViewInterface *) clazz->interface)->removeClassName =
removeClassName;
2288 ((ViewInterface *) clazz->interface)->removeSubview =
removeSubview;
2289 ((ViewInterface *) clazz->interface)->render =
render;
2292 ((ViewInterface *) clazz->interface)->renderFrame =
renderFrame;
2293 ((ViewInterface *) clazz->interface)->replaceSubview =
replaceSubview;
2296 ((ViewInterface *) clazz->interface)->resize =
resize;
2297 ((ViewInterface *) clazz->interface)->resolve =
resolve;
2298 ((ViewInterface *) clazz->interface)->respondToEvent =
respondToEvent;
2299 ((ViewInterface *) clazz->interface)->select =
_select;
2300 ((ViewInterface *) clazz->interface)->selectFirst =
selectFirst;
2303 ((ViewInterface *) clazz->interface)->setNeedsLayout =
setNeedsLayout;
2304 ((ViewInterface *) clazz->interface)->size =
size;
2306 ((ViewInterface *) clazz->interface)->sizeThatFills =
sizeThatFills;
2307 ((ViewInterface *) clazz->interface)->sizeThatFits =
sizeThatFits;
2309 ((ViewInterface *) clazz->interface)->sizeToContain =
sizeToContain;
2310 ((ViewInterface *) clazz->interface)->sizeToFill =
sizeToFill;
2311 ((ViewInterface *) clazz->interface)->sizeToFit =
sizeToFit;
2312 ((ViewInterface *) clazz->interface)->sizeToSatisfy =
sizeToSatisfy;
2315 ((ViewInterface *) clazz->interface)->viewport =
viewport;
2322 ((ViewInterface *) clazz->interface)->warn =
warn;
2337 static Class *clazz;
2341 clazz = _initialize(&(
const ClassDef) {
2343 .superclass = _Object(),
2344 .instanceSize =
sizeof(
View),
2345 .interfaceSize =
sizeof(ViewInterface),
static String * name(const Font *self)
View logging facilities via SDL_Log.
#define MVC_LogWarn(fmt,...)
#define MVC_LogDebug(fmt,...)
#define MVC_LogError(fmt,...)
static void drawView(Renderer *self, View *view)
static void drawRoundedRectGradientFilled(const Renderer *self, const SDL_Rect *rect, int radius, int angle, const SDL_Color *from, const SDL_Color *to)
static void drawPolygon(const Renderer *self, const SDL_Point *points, size_t count, int width, const SDL_Color *color)
static void drawRoundedRect(const Renderer *self, const SDL_Rect *rect, int radius, int width, const SDL_Color *color)
static void drawRectFilled(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color)
static void drawRect(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color)
static void drawRoundedRectFilled(const Renderer *self, const SDL_Rect *rect, int radius, const SDL_Color *color)
static void drawPolygonFilled(const Renderer *self, const SDL_Point *points, size_t count, int angle, const SDL_Color *from, const SDL_Color *to)
static Selector * initWithRule(Selector *self, const char *rule)
@ SimpleSelectorTypePseudo
@ SimpleSelectorTypeClass
@ SimpleSelectorTypeUniversal
static bool isComputedEqual(const Style *self, const Style *other)
static void addEnumAttribute(Style *self, const char *attr, const EnumName *names, int value)
static Style * initWithAttributes(Style *self, const Dictionary *attributes)
static void addAttributes(Style *self, const Dictionary *attributes)
static Theme * theme(SDL_Window *window)
static void addStylesheet(Theme *self, Stylesheet *stylesheet)
static Style * computeStyle(const Theme *self, const View *view)
static void removeStylesheet(Theme *self, Stylesheet *stylesheet)
ViewEvent
View event relay codes.
@ ViewEventMouseButtonUp
A View has received a mouse button up event.
@ ViewEventMouseButtonDown
A View has received a mouse button down event.
@ ViewEventKeyUp
A View has received a key up event.
@ ViewEventClick
A Control received one or more click events.
@ ViewEventKeyDown
A View has received a key down event.
void(* ViewEnumerator)(View *view, ident data)
A function type for View enumeration.
bool bindInlets(const Inlet *inlets, const Dictionary *dictionary)
Binds each Inlet specified in inlets to the data provided in dictionary.
#define BindInlet(inlet, obj)
Binds the Inlet to obj by invoking the appropriate InletBinding function.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
const EnumName ViewAlignmentNames[]
static SDL_Size size(const View *self)
static View * viewWithResource(const Resource *resource, Outlet *outlets)
static void removeClassName(View *self, const char *className)
static void addClassName(View *self, const char *className)
static View * selectFirst(View *self, const char *rule)
static bool isContainer(const View *self)
static void addSubviewRelativeTo(View *self, View *subview, View *other, ViewPosition position)
static void didMoveToWindow(View *self, SDL_Window *window)
static bool isDescendantOfView(const View *self, const View *view)
static bool filterViewEvents(void *data, SDL_Event *event)
static void becomeKeyResponder(View *self)
static String * path(const View *self)
static void resize(View *self, const SDL_Size *size)
static SDL_Size sizeThatSatisfies(View *self, ViewConstraint width, ViewConstraint height)
static void detachStylesheet(View *self, SDL_Window *window)
static bool isTouchResponder(const View *self)
const EnumName ViewPointerEventsNames[]
static void layoutIfNeeded(View *self)
static void sizeToContain(View *self)
static bool acceptsKeyResponder(const View *self)
static int resolveViewConstraint(int hasAutoresizingBit, ViewConstraint constraint, int intrinsic)
Resolves an axis's sizeThatFits value against an offered ViewConstraint, if the View has opted into t...
static View * init(View *self)
static Set * _select(View *self, const char *rule)
static void enumerateAncestors(const View *self, ViewEnumerator enumerator, ident data)
static void clearWarnings(const View *self, WarningType type)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static int depth(const View *self)
static void enumerateVisible(View *self, ViewEnumerator enumerator, ident data)
static void draw(View *self, Renderer *renderer)
static SDL_Size sizeThatFills(const View *self)
static void removeAllClassNames(View *self)
static void removeSubview(View *self, View *subview)
static void nullifySuperview(View *subview, ident data)
ViewEnumerator to null out superview pointers during parent dealloc.
static void updateBindings_enumerate(View *subview, ident data)
ViewEnumerator for updateBindings recursion.
static void enumerateSubviews(const View *self, ViewEnumerator enumerator, ident data)
static void layoutWithConstraint(View *self, ViewConstraint width, ViewConstraint height)
static void cornerCutPoints(SDL_Point *points, const SDL_Rect *rect, const ViewCornerCut *cut)
Writes the four corners of rect, inset by cut, in clockwise order.
void MVC_InvalidateRenderFrames(void)
Invalidates every View's cached View::renderFrame and View::clippingFrame.
static bool visibleSubviews_filter(ident obj, ident data)
Predicate for visibleSubviews.
static View * viewWithResourceName(const char *name, Outlet *outlets)
static void becomeTouchResponder(View *self)
static void removeAllSubviews_enumerate(const Array *array, ident obj, ident data)
ArrayEnumerator for removeAllSubviews.
static void enumerateSelection(View *self, const char *rule, ViewEnumerator enumerator, ident data)
static void respondToEvent(View *self, const SDL_Event *event)
static void applyStyle(View *self, const Style *style)
static bool isVisible(const View *self)
static void resignTouchResponder(View *self)
static void replaceSubview(View *self, View *subview, View *replacement)
static bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)
static SDL_Size sizeThatFits(const View *self)
static void bringSubviewToFront(View *self, View *subview)
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static View * subviewWithIdentifier(const View *self, const char *identifier)
static void _draw(View *view, ident data)
ViewEnumerator adapter for draw.
static String * description(const Object *self)
static bool hasOverflow(const View *self)
static Array * visibleSubviews(const View *self)
static void invalidateStyle(View *self)
static void sizeToFill(View *self)
static void sizeToSatisfy(View *self, ViewConstraint width, ViewConstraint height)
static void warn(View *self, WarningType type, const char *fmt,...)
static void setNeedsLayout(View *self)
static void awakeWithCharacters(View *self, const char *chars)
static View * descendantWithIdentifier(const View *self, const char *identifier)
static void moveToWindow(View *self, SDL_Window *window)
static View * initWithFrame(View *self, const SDL_Rect *frame)
static void removeFromSuperview(View *self)
static void updateBindings(View *self, ident data)
static bool hasClassName_predicate(const ident obj, ident data)
Predicate for hasClassName.
static unsigned _renderFrameGeneration
The render frame generation; per-View renderFrame and clippingFrame caches are valid only while their...
static void removeAllSubviews(View *self)
static SDL_Size sizeThatContains(const View *self)
static void applyTheme(View *self, const Theme *theme)
static void render(View *self, Renderer *renderer)
static void setVisibility(View *self, ViewVisibility visibility)
static void moveToWindow_enumerate(View *subview, ident data)
ViewEnumerator for moveToWindow recursion.
static void awakeWithResourceName(View *self, const char *name)
static void layoutWithSize(View *self, const SDL_Size *size)
static void setNeedsApplyTheme(View *self)
static void dealloc(Object *self)
static void invalidateStyle_enumerate(View *view, ident data)
ViewEnumerator for invalidateStyle.
static void addSubview(View *self, View *subview)
static SDL_Rect renderFrame(const View *self)
static void renderDeviceWillReset_enumerate(View *subview, ident data)
ViewEnumerator for renderDeviceWillReset recursion.
static void resignKeyResponder(View *self)
static View * viewWithData(const Data *data, Outlet *outlets)
static View * viewWithCharacters(const char *chars, Outlet *outlets)
static void initialize(Class *clazz)
const EnumName ViewAutoresizingNames[]
static bool acceptsTouchResponder(const View *self)
static void renderDeviceWillReset(View *self)
static bool _bind(View *self, const Inlet *inlets, const Dictionary *dictionary)
static bool clearWarnings_predicate(const ident obj, ident data)
Filter Predicate for clearWarnings.
static void _applyThemeIfNeeded(View *view, ident data)
ViewEnumerator adapter for applyThemeIfNeeded.
static void willMoveToWindow(View *self, SDL_Window *window)
Uint32 MVC_NOTIFICATION_EVENT
static void attachStylesheet(View *self, SDL_Window *window)
static bool isKeyResponder(const View *self)
static void renderDeviceDidReset(View *self)
static void awakeWithResource(View *self, const Resource *resource)
static void hasOverflow_enumerate(View *view, ident data)
ViewEnumerator for hasOverflow.
static void enumerateSuperview(const View *self, ViewEnumerator enumerator, ident data)
static void renderDeviceDidReset_enumerate(View *subview, ident data)
ViewEnumerator for renderDeviceDidReset recursion.
static void layoutSubviews(View *self)
static void enumerate(View *self, ViewEnumerator enumerator, ident data)
static void enumerateAdjacent(const View *self, ViewEnumerator enumerator, ident data)
static SDL_Rect viewport(const View *self)
static void layoutIfNeeded_enumerate(View *subview, ident data)
ViewEnumerator for layoutIfNeeded recursion.
static View * hitTest(const View *self, const SDL_Point *point)
static bool hasClassName(const View *self, const char *className)
static void applyThemeIfNeeded(View *self, const Theme *theme)
static bool containsPoint(const View *self, const SDL_Point *point)
static void sizeToFit(View *self)
static SDL_Rect clippingFrame(const View *self)
static void enumerateSiblings(const View *self, ViewEnumerator enumerator, ident data)
const EnumName ViewVisibilityNames[]
static View * viewWithDictionary(const Dictionary *dictionary, Outlet *outlets)
static void awakeWithData(View *self, const Data *data)
static void enumerateDescendants(const View *self, ViewEnumerator enumerator, ident data)
static SDL_Rect bounds(const View *self)
static View * ancestorWithIdentifier(const View *self, const char *identifier)
static void resolve(View *self, Outlet *outlets)
static void emitViewEvent(View *self, ViewEvent code, ident data)
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
#define ViewAlignmentMaskBottom
#define ViewAlignmentMaskTop
#define ViewAlignmentMaskMiddle
#define CornerCutIsEmpty(cut)
ViewVisibility
Visibility constants.
@ ViewVisibilityUnspecified
#define MakeConstraint(mode, value)
#define ViewAlignmentMaskHorizontal
#define ClampSize(size, min, max)
Clamps size to min and max, where a max of zero is unbounded.
ViewPosition
Relative positioning of subviews within their superview.
#define ViewAlignmentMaskVertical
#define ViewAlignmentMaskAny
@ ViewAutoresizingContain
@ ViewAlignmentBottomRight
@ ViewAlignmentBottomLeft
@ ViewAlignmentMiddleCenter
@ ViewAlignmentMiddleRight
@ ViewAlignmentMiddleLeft
@ ViewAlignmentBottomCenter
A ViewController manages a View and its descendants.
static Warning * initWithVaList(Warning *self, WarningType type, const char *fmt, va_list args)
WarningType
Warning types.
SDL_Rect MVC_TransformToWindow(SDL_Window *window, const SDL_Rect *rect)
Transforms the specified rectangle to normalized device coordinates in window.
static View * keyResponder(const WindowController *self)
static View * touchResponder(const WindowController *self)
A WindowController manages a ViewController and its descendants within an SDL_Window.
Inlets enable inbound data binding of View attributes through JSON.
Outlets enable outbound data binding of Views through JSON.
const char * identifier
The View identifier.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
Selectors are comprised of one or more SelectorSequences.
SimpleSelectorType type
The SimpleSelectorType.
char * pattern
The pattern, as provided by the user.
A constraint offered by an ancestor View to a descendant during View::sizeThatSatisfies.
int value
The constraint value; a size in pixels.
enum ViewConstraint::@3 mode
The horizontal inset of each of a View's corners.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Stylesheet * stylesheet
An optional Stylesheet.
bool clipsSubviews
If true, subviews will be clipped to this View's frame.
View * superview
The super View.
Array * subviews
The immediate subviews.
ViewController * viewController
The ViewController.
void invalidateStyle(View *self)
Invalidates the computed Style for this View and its descendants.
void setVisibility(View *self, ViewVisibility visibility)
Sets this View's visibility.
Style * style
The element-level Style of this View.
ViewAlignment alignment
The alignment.
SDL_Window * window
The window.
bool needsApplyTheme
If true, this View will apply the Theme before it is drawn.
View * viewWithResource(const Resource *resource, Outlet *outlets)
Instantiates a View initialized with the JSON data in resource.
ViewCornerCut cornerCut
The horizontal inset of each corner of the background and border.
Array * visibleSubviews(const View *self)
SDL_Color borderColor
The border color.
View * viewWithResourceName(const char *name, Outlet *outlets)
Instantiates a View initialized with the JSON Resource with the specified name.
void applyStyle(View *self, const Style *style)
Applies the given Style to this View.
int autoresizingMask
The ViewAutoresizing bitmask.
void detachStylesheet(View *self, SDL_Window *window)
Detaches this View's Stylesheet from the Theme associated with the given window.
View * nextResponder
The next responder, or event handler, in the chain.
ViewPointerEvents pointerEvents
Whether this View is the result of a hit test; its subviews always are.
bool needsLayout
If true, this View will layout its subviews before it is drawn.
char * identifier
An optional identifier.
Array * warnings
The Warnings this View generated.
ViewPadding padding
The padding.
int borderWidth
The border width.
SDL_Size minSize
The minimum size this View may be resized to during layout.
int backgroundGradientAngle
The angle of the background gradient, in degrees, clockwise from south: 0 (the default) fills downwar...
void updateBindings(View *self, ident data)
Updates data bindings, prompting the appropriate layout changes.
Style * computedStyle
The computed Style of this View.
Set * classNames
The class names.
ViewVisibility visibility
Whether this View is drawn, and contributes to its superview's size.
int borderRadius
The corner radius applied to the background, border and bevel.
SDL_Color backgroundGradientColor
The far color of the background gradient, which runs from View::backgroundColor.
View * viewWithData(const Data *data, Outlet *outlets)
Instantiates a View initialized with the contents of data.
SDL_Size maxSize
The maximum size this View may be resized to during layout.
View * init(View *self)
Initializes this View.
SDL_Color backgroundColor
The background color.
bool stretch
Whether this View takes a share of the space its StackView leaves along its axis.
SDL_Rect frame
The frame, relative to the superview.
View * initWithFrame(View *self, const SDL_Rect *frame)
Initializes this View with the specified frame.
View * viewWithDictionary(const Dictionary *dictionary, Outlet *outlets)
Instantiates a View initialized with the attributes described in dictionary.
String * message
The message.
WarningType type
The WarningType.