ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
View Struct Reference

Views are the fundamental building blocks of ObjectivelyMVC user interfaces. More...

#include <View.h>

Inheritance diagram for View:
Box CollectionItemView Control ImageView Label Option PageView ProgressBar ScrollBar ScrollView SlideShowView StackView TabView TableCellView Text

Public Member Functions

Class * _View (void)
 The View archetype.
 
bool acceptsKeyResponder (const View *self)
 
bool acceptsTouchResponder (const View *self)
 
void addClassName (View *self, const char *className)
 Adds the given class name to this View.
 
void addSubview (View *self, View *subview)
 Adds a subview to this view, to be drawn above its siblings.
 
void addSubviewRelativeTo (View *self, View *subview, View *other, ViewPosition position)
 Adds a subview to this view, positioned relatively to other.
 
 ancestorWithIdentifier (const View *self, const char *identifier)
 
void applyStyle (View *self, const Style *style)
 Applies the given Style to this View.
 
void applyTheme (View *self, const Theme *theme)
 Applies the given Theme to this View.
 
void applyThemeIfNeeded (View *self, const Theme *theme)
 Recursively applies the Theme to this View and its subviews.
 
void attachStylesheet (View *self, SDL_Window *window)
 Attaches this View's Stylesheet to the Theme associated with the given window.
 
void awakeWithCharacters (View *self, const char *chars)
 Wakes this View with the given null-terminated JSON C string.
 
void awakeWithData (View *self, const Data *data)
 Wakes this View with the specified JSON Data.
 
void awakeWithDictionary (View *, const Dictionary *)
 Wakes this View with the specified Dictionary.
 
void awakeWithResource (View *self, const Resource *resource)
 Wakes this View with the specified Resource.
 
void awakeWithResourceName (View *self, const char *name)
 Wakes this View with the Resource by the specified name.
 
void becomeKeyResponder (View *self)
 Become the key responder in the View hierarchy.
 
void becomeTouchResponder (View *self)
 Become the touch responder in the View hierarchy.
 
bool bind (View *self, const Inlet *inlets, const Dictionary *dictionary)
 Performs data binding for the Inlets described in dictionary.
 
SDL_Rect bounds (const View *self)
 
void bringSubviewToFront (View *self, View *subview)
 Brings the specified subview to the front.
 
void clearWarnings (const View *self, WarningType type)
 Clears this View's Warnings matching the given level.
 
SDL_Rect clippingFrame (const View *self)
 
bool containsPoint (const View *self, const SDL_Point *point)
 
int depth (const View *self)
 
 descendantWithIdentifier (const View *self, const char *identifier)
 
void detachStylesheet (View *self, SDL_Window *window)
 Detaches this View's Stylesheet from the Theme associated with the given window.
 
void didMoveToWindow (View *self, SDL_Window *window)
 Informs this View that it has been added to the View hierachy of the given window.
 
bool didReceiveEvent (const View *self, const SDL_Event *event)
 
void draw (View *self, Renderer *renderer)
 Draws this View.
 
void emitViewEvent (View *self, ViewEvent code, ident data)
 Emits a ViewEvent originating from this View.
 
void enumerate (const View *self, ViewEnumerator enumerator, ident data)
 
void enumerate (View *self, ViewEnumerator enumerator, ident data)
 Enumerates this View and its descendants, applying enumerator to each.
 
void enumerateAdjacent (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates adjacent siblings of this View, applying enumerator to each.
 
void enumerateAncestors (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all ancestors of this View, applying enumerator to each.
 
void enumerateDescendants (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all descendants of this View, applying enumerator to each.
 
void enumerateSelection (View *self, const char *rule, ViewEnumerator enumerator, ident data)
 Enumerates all Views in the selection matched by rule, applying enumerator to each.
 
void enumerateSiblings (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all siblings of this View, applying enumerator to each.
 
void enumerateSubviews (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all subviews of this View, applying enumerator to each.
 
void enumerateSuperview (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates the superview of this View, if any, applying enumerator to it.
 
void enumerateVisible (const View *self, ViewEnumerator enumerator, ident data)
 
void enumerateVisible (View *self, ViewEnumerator enumerator, ident data)
 Enumerates this View and its visible descendants, applying enumerator to each.
 
bool hasClassName (const View *self, cosnt char *className)
 
bool hasOverflow (const View *self)
 
ViewhitTest (const View *self, const SDL_Point *point)
 Performs a hit test against this View and its descendants for the given point.
 
Viewinit (View *self)
 Initializes this View.
 
ViewinitWithFrame (View *self, const SDL_Rect *frame)
 Initializes this View with the specified frame.
 
void invalidateStyle (View *self)
 Invalidates the computed Style for this View and its descendants.
 
bool isContainer (const View *self)
 
bool isDescendantOfView (const View *self, const View *view)
 
bool isKeyResponder (const View *self)
 
bool isTouchResponder (const View *self)
 
bool isVisible (const View *self)
 
void layoutIfNeeded (View *self)
 Recursively updates the layout of this View and its subviews.
 
 layoutSubviews (View *self)
 Performs layout for this View's immediate subviews.
 
bool matchesSelector (const View *self, const SimpleSelector *simpleSelector)
 
void moveToWindow (View *self, SDL_Window *window)
 Moves this View to the View hierarchy of the given window.
 
String * path (const View *self)
 
void removeAllClassNames (View *self)
 Removes all class names from this View.
 
void removeAllSubviews (View *self)
 Removes all subviews from this View.
 
void removeClassName (View *self, const char *className)
 Removes the given class name to this View.
 
void removeFromSuperview (View *self)
 Removes this View from its superview.
 
void removeSubview (View *self, View *subview)
 Removes the given subview from this View.
 
void render (View *self, Renderer *renderer)
 Renders this View using the given renderer.
 
void renderDeviceDidReset (View *self)
 Informs this View that the render device has reset.
 
void renderDeviceWillReset (View *self)
 Informs this View that the render device will reset.
 
SDL_Rect renderFrame (const View *self)
 
void replaceSubview (View *self, View *subview, View *replacement)
 Replaces the specified subview with the given replacement.
 
void resignKeyResponder (View *self)
 Resigns key responder priority.
 
void resignTouchResponder (View *self)
 Resigns touch responder priority.
 
void resize (View *self, const SDL_Size *size)
 Resizes this View to the specified size.
 
void resolve (View *self, Outlet *outlets)
 Resolves the given Outlets from this View's hierarchy.
 
void respondToEvent (View *self, const SDL_Event *event)
 Responds to the specified event.
 
Set * select (View *self, const char *rule)
 Resolves all descendants (including this View) that match the given Selector rule.
 
ViewselectFirst (View *self, const char *rule)
 Resolves the first descendant View that matches the given Selector rule.
 
SDL_Size size (const View *self)
 
SDL_Size sizeThastFills (const View *self)
 
SDL_Size sizeThatContains (const View *self)
 
SDL_Size sizeThatFills (const View *self)
 
void sizeThatFits (const View *self)
 
void sizeToContain (View *self)
 Resizes this View to contain its subviews.
 
void sizeToFill (View *self)
 Resizes this View to fill its superview.
 
void sizeToFit (View *self)
 Resizes this View to fit its subviews.
 
 subviewWithIdentifier (const View *self, const char *identifier)
 
void updateBindings (View *self)
 Updates data bindings, prompting the appropriate layout changes.
 
SDL_Rect viewport (const View *self)
 
ViewviewWithCharacters (const char *chars, Outlet *outlets)
 Instantiates a View initialized with the given null-terminated JSON C string.
 
ViewviewWithData (const Data *data, Outlet *outlets)
 Instantiates a View initialized with the contents of data.
 
ViewviewWithDictionary (const Dictionary *dictionary, Outlet *outlets)
 Instantiates a View initialized with the attributes described in dictionary.
 
ViewviewWithResource (const Resource *resource, Outlet *outlets)
 Instantiates a View initialized with the JSON data in resource.
 
ViewviewWithResourceName (const char *name, Outlet *outlets)
 Instantiates a View initialized with the JSON Resource with the specified name.
 
Array * visibleSubviews (const View *self)
 
void warn (View *self, ViewWarningType type, const char *fmt,...)
 
void warn (View *self, WarningType level, const char *fmt,...)
 Appends a warning for this View.
 
void willMoveToWindow (View *self, SDL_Window *window)
 Informs this View that it will be added to the View hierarchy for the given window.
 

Data Fields

ViewAlignment alignment
 The alignment.
 
int autoresizingMask
 The ViewAutoresizing bitmask.
 
SDL_Color backgroundColor
 The background color.
 
SDL_Color borderColor
 The border color.
 
int borderWidth
 The border width.
 
Set * classNames
 The class names.
 
bool clipsSubviews
 If true, subviews will be clipped to this View's frame.
 
StylecomputedStyle
 The computed Style of this View.
 
SDL_Rect frame
 The frame, relative to the superview.
 
bool hidden
 If true, this View is not drawn.
 
char * identifier
 An optional identifier.
 
SDL_Size maxSize
 The maximum size this View may be resized to during layout.
 
SDL_Size minSize
 The minimum size this View may be resized to during layout.
 
bool needsApplyTheme
 If true, this View will apply the Theme before it is drawn.
 
bool needsLayout
 If true, this View will layout its subviews before it is drawn.
 
ViewnextResponder
 The next responder, or event handler, in the chain.
 
Object object
 The superclass.
 
ViewPadding padding
 The padding.
 
Stylestyle
 The element-level Style of this View.
 
Stylesheetstylesheet
 An optional Stylesheet.
 
Array * subviews
 The immediate subviews.
 
Viewsuperview
 The super View.
 
ViewControllerviewController
 The ViewController.
 
Array * warnings
 The Warnings this View generated.
 
SDL_Window * window
 The window.
 

Protected Attributes

ViewInterface * interface
 The interface.
 

Detailed Description

Views are the fundamental building blocks of ObjectivelyMVC user interfaces.

Views provide organization and coordination of layout, drawing and event handling. Views maintain hierarchical relationships among other Views, whereby each View's parent, or superview, dictates where it will be drawn on the screen, which events it will be eligible to receive, etc.

Definition at line 134 of file View.h.

Member Function Documentation

◆ _View()

Class * _View ( void  )

The View archetype.

Returns
The View Class.

Definition at line 2056 of file View.c.

2056 {
2057 static Class *clazz;
2058 static Once once;
2059
2060 do_once(&once, {
2061 clazz = _initialize(&(const ClassDef) {
2062 .name = "View",
2063 .superclass = _Object(),
2064 .instanceSize = sizeof(View),
2065 .interfaceOffset = offsetof(View, interface),
2066 .interfaceSize = sizeof(ViewInterface),
2068 });
2069 });
2070
2071 return clazz;
2072}
static void initialize(Class *clazz)
Definition Box.c:123
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:134
ViewInterface * interface
The interface.
Definition View.h:145

◆ acceptsKeyResponder()

bool acceptsKeyResponder ( const View self)
Parameters
selfThe View.
Returns
True if this View can become the key responder, false otherwise.

Definition at line 69 of file Control.c.

69 {
70
71 Control *this = (Control *) self;
72
73 return (this->state & ControlStateDisabled) == 0;
74}
@ ControlStateDisabled
Definition Control.h:70
Controls are Views which capture and respond to events.
Definition Control.h:83

◆ acceptsTouchResponder()

bool acceptsTouchResponder ( const View self)
Parameters
selfThe View.
Returns
True if this View can become the touch responder, false otherwise.

Definition at line 79 of file Control.c.

79 {
80
81 Control *this = (Control *) self;
82
83 return (this->state & ControlStateDisabled) == 0;
84}

◆ addClassName()

void addClassName ( View self,
const char *  className 
)

Adds the given class name to this View.

Parameters
selfThe View.
classNameThe class name.

Definition at line 159 of file View.c.

159 {
160
161 if (className) {
162
163 String *string = $$(String, stringWithCharacters, className);
164 assert(string);
165
166 $(self->classNames, addObject, string);
167 release(string);
168
169 $(self, invalidateStyle);
170 }
171}
void invalidateStyle(View *self)
Invalidates the computed Style for this View and its descendants.
Definition View.c:1022
Set * classNames
The class names.
Definition View.h:176

◆ addSubview()

void addSubview ( View self,
View subview 
)

Adds a subview to this view, to be drawn above its siblings.

Parameters
selfThe View.
subviewThe subview to add.
Remarks
This method is equivalent to $(view, addSubviewRelativeTo, subview, NULL, OrderSame).

Definition at line 49 of file PageView.c.

49 {
50
51 super(View, self, addSubview, subview);
52
53 PageView *this = (PageView *) self;
54
55 subview->hidden = true;
56
57 if (this->currentPage == NULL) {
58 $(this, setCurrentPage, subview);
59 }
60}
static void setCurrentPage(PageView *self, View *currentPage)
Definition PageView.c:130
PageViews manage their subviews as pages in a book.
Definition PageView.h:60
void addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
Definition PageView.c:49
bool hidden
If true, this View is not drawn.
Definition View.h:196

◆ addSubviewRelativeTo()

void addSubviewRelativeTo ( View self,
View subview,
View other,
ViewPosition  position 
)

Adds a subview to this view, positioned relatively to other.

Parameters
selfThe View.
subviewThe subview to add.
otherAn optional View to position subview relative to.
positionThe relative position.

Definition at line 185 of file View.c.

185 {
186
187 assert(subview);
188 assert(subview != other);
189
190 retain(subview);
191
192 $(subview, removeFromSuperview);
193
194 if (other && other->superview == self) {
195
196 const Array *subviews = (Array *) self->subviews;
197 const ssize_t index = $(subviews, indexOfObject, other);
198
199 if (position == ViewPositionAfter) {
200 if (index == (ssize_t) (subviews->count - 1)) {
201 $(self->subviews, addObject, subview);
202 } else {
203 $(self->subviews, insertObjectAtIndex, subview, index + 1);
204 }
205 } else {
206 $(self->subviews, insertObjectAtIndex, subview, index);
207 }
208 } else {
209 $(self->subviews, addObject, subview);
210 }
211
212 release(subview);
213
214 subview->superview = self;
215
216 $(subview, moveToWindow, self->window);
217
218 $(subview, invalidateStyle);
219
220 self->needsLayout = true;
221}
@ ViewPositionAfter
Definition View.h:121
View * superview
The super View.
Definition View.h:259
Array * subviews
The immediate subviews.
Definition View.h:253
SDL_Window * window
The window.
Definition View.h:277
void removeFromSuperview(View *self)
Removes this View from its superview.
Definition View.c:1350
bool needsLayout
If true, this View will layout its subviews before it is drawn.
Definition View.h:222
void moveToWindow(View *self, SDL_Window *window)
Moves this View to the View hierarchy of the given window.
Definition View.c:1251

◆ ancestorWithIdentifier()

ancestorWithIdentifier ( const View self,
const char *  identifier 
)
Parameters
selfThe View.
identifierThe identifier.
Returns
The nearest ancestor View matching the given identifier.

Definition at line 227 of file View.c.

227 {
228
229 assert(identifier);
230
231 View *view = (View *) self;
232 while (view) {
233 if (view->identifier) {
234 if (strcmp(identifier, view->identifier) == 0) {
235 return view;
236 }
237 }
238 view = view->superview;
239 }
240
241 return NULL;
242}
char * identifier
An optional identifier.
Definition View.h:202

◆ applyStyle()

void applyStyle ( View self,
const Style style 
)

Applies the given Style to this View.

Parameters
selfThe View.
styleThe Style.

Definition at line 59 of file CollectionView.c.

59 {
60
61 super(View, self, applyStyle, style);
62
63 CollectionView *this = (CollectionView *) self;
64
65 const Inlet inlets[] = MakeInlets(
66 MakeInlet("axis", InletTypeEnum, &this->axis, (ident) CollectionViewAxisNames),
67 MakeInlet("item-size", InletTypeSize, &this->itemSize, NULL),
68 MakeInlet("item-spacing", InletTypeSize, &this->itemSpacing, NULL)
69 );
70
71 $(self, bind, inlets, (Dictionary *) style->attributes);
72}
const EnumName CollectionViewAxisNames[]
@ InletTypeEnum
Definition View+JSON.h:75
@ InletTypeSize
Definition View+JSON.h:110
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
Definition View+JSON.h:221
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
Definition View+JSON.h:216
CollectionViews display items in a grid.
Inlets enable inbound data binding of View attributes through JSON.
Definition View+JSON.h:155
Dictionary * attributes
Definition Style.h:59
Style * style
The element-level Style of this View.
Definition View.h:241
void applyStyle(View *self, const Style *style)
Applies the given Style to this View.
bool bind(View *self, const Inlet *inlets, const Dictionary *dictionary)
Performs data binding for the Inlets described in dictionary.

◆ applyTheme()

void applyTheme ( View self,
const Theme theme 
)

Applies the given Theme to this View.

Parameters
selfThe View.
themeThe Theme.

Definition at line 285 of file View.c.

285 {
286
287 assert(theme);
288
290 assert(computedStyle);
291
293
294 release(self->computedStyle);
295 self->computedStyle = retain(computedStyle);
296
298 $(self, applyStyle, self->computedStyle);
299 }
300
301 release(computedStyle);
302}
static bool isComputedEqual(const Style *self, const Style *other)
Definition Style.c:331
static void addAttributes(Style *self, const Dictionary *attributes)
Definition Style.c:119
static Theme * theme(SDL_Window *window)
Definition Theme.c:143
static Style * computeStyle(const Theme *self, const View *view)
Definition Theme.c:103
The Style type.
Definition Style.h:43
Style * computedStyle
The computed Style of this View.
Definition View.h:186

◆ applyThemeIfNeeded()

void applyThemeIfNeeded ( View self,
const Theme theme 
)

Recursively applies the Theme to this View and its subviews.

Parameters
selfThe View.
themeThe Theme.

Definition at line 317 of file View.c.

317 {
318
319 assert(theme);
320
322
323 if (self->needsApplyTheme) {
324
326
327 $(self, applyTheme, theme);
328
329 self->needsApplyTheme = false;
330 }
331}
static void _applyThemeIfNeeded(View *view, ident data)
ViewEnumerator adapter for applyThemeIfNeeded.
Definition View.c:313
@ WarningTypeStyle
Definition Warning.h:34
bool needsApplyTheme
If true, this View will apply the Theme before it is drawn.
Definition View.h:217
void clearWarnings(const View *self, WarningType type)
Clears this View's Warnings matching the given level.
Definition View.c:538
void applyTheme(View *self, const Theme *theme)
Applies the given Theme to this View.
Definition View.c:285
void enumerateSubviews(const View *self, ViewEnumerator enumerator, ident data)
Enumerates all subviews of this View, applying enumerator to each.
Definition View.c:835

◆ attachStylesheet()

void attachStylesheet ( View self,
SDL_Window *  window 
)

Attaches this View's Stylesheet to the Theme associated with the given window.

Parameters
selfThe View.
windowThe window.

Definition at line 337 of file View.c.

337 {
338
339 assert(window);
340
341 if (self->stylesheet) {
342 Theme *theme = $$(Theme, theme, window);
343 if (theme) {
344 $(theme, addStylesheet, self->stylesheet);
345 }
346 }
347}
static void addStylesheet(Theme *self, Stylesheet *stylesheet)
Definition Theme.c:55
The Theme type.
Definition Theme.h:51
Stylesheet * stylesheet
An optional Stylesheet.
Definition View.h:248

◆ awakeWithCharacters()

void awakeWithCharacters ( View self,
const char *  chars 
)

Wakes this View with the given null-terminated JSON C string.

Parameters
selfThe View.
charsA null-terminated JSON C string describing this View.
Remarks
This is a convenience method for View::awakeWithDictionary.

Definition at line 353 of file View.c.

353 {
354
355 Data *data = $$(Data, dataWithConstMemory, (uint8_t *) chars, strlen(chars));
356
357 $(self, awakeWithData, data);
358
359 release(data);
360}
void awakeWithData(View *self, const Data *data)
Wakes this View with the specified JSON Data.
Definition View.c:366

◆ awakeWithData()

void awakeWithData ( View self,
const Data *  data 
)

Wakes this View with the specified JSON Data.

Parameters
selfThe View.
dataThe JSON Data containing properties describing this View.
Remarks
This is a convenience method for View::awakeWithDictionary.

Definition at line 366 of file View.c.

366 {
367
368 JSONContext *ctx = $(alloc(JSONContext), init);
369 Dictionary *dictionary = $(ctx, objectFromData, data, 0);
370
371 if (dictionary) {
372 $(self, awakeWithDictionary, dictionary);
373 release(dictionary);
374 } else {
375 MVC_LogError("Failed to parse JSON for %s\n", classnameof(self));
376 }
377
378 release(ctx);
379}
#define MVC_LogError(fmt,...)
Definition Log.h:57
void awakeWithDictionary(View *, const Dictionary *)
Wakes this View with the specified Dictionary.
Definition Box.c:50
View * init(View *self)
Initializes this View.
Definition Box.c:67

◆ awakeWithDictionary()

void awakeWithDictionary ( View self,
const Dictionary *  dictionary 
)

Wakes this View with the specified Dictionary.

Parameters
selfThe View.
dictionaryA Dictionary of properties describing this View.
Remarks
This method is invoked when loading via JSON. Subclasses should override this method to perform any customization based on the contents of dictionary.

Definition at line 50 of file Box.c.

50 {
51
52 super(View, self, awakeWithDictionary, dictionary);
53
54 Box *this = (Box *) self;
55
56 const Inlet inlets[] = MakeInlets(
57 MakeInlet("contentView", InletTypeView, &this->contentView, NULL),
58 MakeInlet("label", InletTypeView, &this->label, NULL)
59 );
60
61 $(self, bind, inlets, dictionary);
62}
@ InletTypeView
Definition View+JSON.h:139
A container View with a positioned Label.
Definition Box.h:44

◆ awakeWithResource()

void awakeWithResource ( View self,
const Resource *  resource 
)

Wakes this View with the specified Resource.

Parameters
selfThe View.
resourceA Resource providing JSON data describing this View.

Definition at line 403 of file View.c.

403 {
404
405 assert(resource);
406
407 $(self, awakeWithData, resource->data);
408}

◆ awakeWithResourceName()

void awakeWithResourceName ( View self,
const char *  name 
)

Wakes this View with the Resource by the specified name.

Parameters
selfThe View.
nameThe name of a Resource providing JSON data describing this View.

Definition at line 414 of file View.c.

414 {
415
416 Resource *resource = $$(Resource, resourceWithName, name);
417
418 $(self, awakeWithResource, resource);
419
420 release(resource);
421}
void awakeWithResource(View *self, const Resource *resource)
Wakes this View with the specified Resource.
Definition View.c:403

◆ becomeKeyResponder()

void becomeKeyResponder ( View self)

Become the key responder in the View hierarchy.

Parameters
selfThe View.
Remarks
Becoming the key responder gives a View priority when handling key events.

Definition at line 130 of file Control.c.

130 {
131
132 Control *this = (Control *) self;
133
134 if (!$(this, isFocused)) {
135
136 this->state |= ControlStateFocused;
137
138 $(this, stateDidChange);
139 }
140
141 super(View, self, becomeKeyResponder);
142}
static void stateDidChange(Control *self)
Definition Control.c:343
static bool isFocused(const Control *self)
Definition Control.c:319
@ ControlStateFocused
Definition Control.h:69
void becomeKeyResponder(View *self)
Become the key responder in the View hierarchy.
Definition Control.c:130

◆ becomeTouchResponder()

void becomeTouchResponder ( View self)

Become the touch responder in the View hierarchy.

Parameters
selfThe View.
Remarks
Becoming the touch responder gives a View priority when handling touch events.

Definition at line 451 of file View.c.

451 {
452
453 assert(self->window);
454
455 if (!$(self, isTouchResponder)) {
456 SDL_PropertiesID props = SDL_GetWindowProperties(self->window);
457
458 View *touchResponder = SDL_GetPointerProperty(props, "touchResponder", NULL);
459 if (touchResponder) {
461 }
462
463 String *path = $(self, path);
464 MVC_LogDebug("%s\n", path->chars);
465 release(path);
466
467 SDL_SetPointerProperty(props, "touchResponder", self);
468 }
469}
#define MVC_LogDebug(fmt,...)
Definition Log.h:48
static View * touchResponder(const WindowController *self)
String * path(const View *self)
Definition View.c:1266
void resignTouchResponder(View *self)
Resigns touch responder priority.
Definition View.c:1500
bool isTouchResponder(const View *self)
Definition View.c:1069

◆ bind()

bool bind ( View self,
const Inlet inlets,
const Dictionary *  dictionary 
)

Performs data binding for the Inlets described in dictionary.

Parameters
selfThe View.
inletsThe Inlets to bind.
dictionaryA Dictionary describing this View.
Returns
True if one or more Inlet was bound, false otherwise.
Remarks
Subclasses will typically call this method from View::awakeWithDictionary.

◆ bounds()

SDL_Rect bounds ( const View self)
Parameters
selfThe View.
Returns
The bounds (frame minus padding) of this View.

Definition at line 492 of file View.c.

492 {
493
494 const SDL_Size size = $(self, size);
495
496 const SDL_Rect bounds = {
497 .x = self->padding.left,
498 .y = self->padding.top,
499 .w = max(0, size.w - (self->padding.left + self->padding.right)),
500 .h = max(0, size.h - (self->padding.top + self->padding.bottom)),
501 };
502
503 return bounds;
504}
SDL_Rect bounds(const View *self)
Definition View.c:492
SDL_Size size(const View *self)
Definition View.c:1640
ViewPadding padding
The padding.
Definition View.h:234
int top
Definition View.h:101
int bottom
Definition View.h:101
int right
Definition View.h:101
int left
Definition View.h:101

◆ bringSubviewToFront()

void bringSubviewToFront ( View self,
View subview 
)

Brings the specified subview to the front.

Parameters
selfThe View.
subviewThe subview.

Definition at line 510 of file View.c.

510 {
511
512 assert(subview);
513
514 if (subview->superview == self) {
515
516 View *last = $((Array *) self->subviews, lastObject);
517 if (last != subview) {
518 $(self, addSubviewRelativeTo, subview, last, ViewPositionAfter);
519 }
520 }
521}
void addSubviewRelativeTo(View *self, View *subview, View *other, ViewPosition position)
Adds a subview to this view, positioned relatively to other.
Definition View.c:185

◆ clearWarnings()

void clearWarnings ( const View self,
WarningType  level 
)

Clears this View's Warnings matching the given level.

Parameters
selfThe View.
typeThe bitmask of WarningTypes to clear.

Definition at line 538 of file View.c.

538 {
539 $(self->warnings, filter, clearWarnings_predicate, &type);
540}
static bool clearWarnings_predicate(const ident obj, ident data)
Filter Predicate for clearWarnings.
Definition View.c:526
Array * warnings
The Warnings this View generated.
Definition View.h:271

◆ clippingFrame()

SDL_Rect clippingFrame ( const View self)
Parameters
selfThe View.
Returns
The visible portion of this View's frame, in window coordinates.
Remarks
This is equivalent to the View's renderFrame, expanded for border width, and clipped to all ancestors.

Definition at line 546 of file View.c.

546 {
547
548 SDL_Rect frame = $(self, renderFrame);
549
550 if (self->borderWidth && self->borderColor.a) {
551 for (int i = 0; i < self->borderWidth; i++) {
552 frame.x -= 1;
553 frame.y -= 1;
554 frame.w += 2;
555 frame.h += 2;
556 }
557 }
558
559 const View *superview = self->superview;
560 while (superview) {
562 const SDL_Rect clippingFrame = $(superview, clippingFrame);
563 if (SDL_GetRectIntersection(&clippingFrame, &frame, &frame) == false) {
564 frame.w = frame.h = 0;
565 break;
566 }
567 }
569 }
570
571 return frame;
572}
bool clipsSubviews
If true, subviews will be clipped to this View's frame.
Definition View.h:181
SDL_Rect clippingFrame(const View *self)
Definition View.c:546
SDL_Color borderColor
The border color.
Definition View.h:165
int borderWidth
The border width.
Definition View.h:170
SDL_Rect renderFrame(const View *self)
Definition View.c:1444
SDL_Rect frame
The frame, relative to the superview.
Definition View.h:191

◆ containsPoint()

bool containsPoint ( const View self,
const SDL_Point *  point 
)
Parameters
selfThe View.
pointA point in object space.
Returns
True if the point falls within this View's clipped frame.

Definition at line 578 of file View.c.

578 {
579
580 const SDL_Rect frame = $(self, clippingFrame);
581
582 return (bool) SDL_PointInRect(point, &frame);
583}

◆ depth()

int depth ( const View self)
Parameters
selfThe View.
Returns
The depth of this View (ancestor depth + 1).

Definition at line 589 of file View.c.

589 {
590 return (self->superview ? $(self->superview, depth) + 1 : 0);
591}
int depth(const View *self)
Definition View.c:589

◆ descendantWithIdentifier()

descendantWithIdentifier ( const View self,
const char *  identifier 
)
Parameters
selfThe View.
identifierThe identifier.
Returns
The nearest descendant View matching the given identifier.

Definition at line 597 of file View.c.

597 {
598
599 assert(identifier);
600
601 if (self->identifier) {
602 if (strcmp(identifier, self->identifier) == 0) {
603 return (View *) self;
604 }
605 }
606
607 const Array *subviews = (Array *) self->subviews;
608 for (size_t i = 0; i < subviews->count; i++) {
609
610 const View *subview = subviews->elements[i];
611 View *descendant = $(subview, descendantWithIdentifier, identifier);
612 if (descendant) {
613 return descendant;
614 }
615 }
616
617 return NULL;
618}
descendantWithIdentifier(const View *self, const char *identifier)
Definition View.c:597

◆ detachStylesheet()

void detachStylesheet ( View self,
SDL_Window *  window 
)

Detaches this View's Stylesheet from the Theme associated with the given window.

Parameters
selfThe View.
windowThe window.

Definition at line 624 of file View.c.

624 {
625
626 assert(window);
627
628 if (self->stylesheet) {
629 Theme *theme = $$(Theme, theme, window);
630 if (theme) {
632 }
633 }
634}
static void removeStylesheet(Theme *self, Stylesheet *stylesheet)
Definition Theme.c:135

◆ didMoveToWindow()

void didMoveToWindow ( View self,
SDL_Window *  window 
)

Informs this View that it has been added to the View hierachy of the given window.

Parameters
selfThe View.
windowThe window, or NULL if this View has been removed from the window.

Definition at line 640 of file View.c.

640 {
641
642 if (window) {
643 $(self, attachStylesheet, window);
644
645 if (self->superview == NULL) {
646 $(self, sizeToFill);
647 }
648
649 self->needsLayout = true;
650 }
651}
void sizeToFill(View *self)
Resizes this View to fill its superview.
Definition View.c:1745
void attachStylesheet(View *self, SDL_Window *window)
Attaches this View's Stylesheet to the Theme associated with the given window.
Definition View.c:337

◆ didReceiveEvent()

bool didReceiveEvent ( const View self,
const SDL_Event *  event 
)
Parameters
selfThe View.
eventThe event.
Returns
True if this View received the event, false otherwise.

Definition at line 657 of file View.c.

657 {
658
659 if ($(self, isKeyResponder)) {
660 switch (event->type) {
661 case SDL_EVENT_KEY_DOWN:
662 case SDL_EVENT_KEY_UP:
663 case SDL_EVENT_TEXT_INPUT:
664 return true;
665 }
666 }
667
668 if ($(self, isVisible)) {
669
670 SDL_Point point;
671
672 switch (event->type) {
673 case SDL_EVENT_MOUSE_BUTTON_DOWN:
674 case SDL_EVENT_MOUSE_BUTTON_UP:
675 point = MakePoint(event->button.x, event->button.y);
676 break;
677 case SDL_EVENT_MOUSE_MOTION:
678 point = MakePoint(event->motion.x, event->motion.y);
679 break;
680 case SDL_EVENT_MOUSE_WHEEL: {
681 float mx, my;
682 SDL_GetMouseState(&mx, &my);
683 point = MakePoint(mx, my);
684 break;
685 }
686 default:
687 return false;
688 }
689
690 return $(self, containsPoint, &point);
691 }
692
693 return false;
694}
bool isKeyResponder(const View *self)
Definition View.c:1056
bool containsPoint(const View *self, const SDL_Point *point)
Definition View.c:578
bool isVisible(const View *self)
Definition View.c:1082

◆ draw()

void draw ( View self,
Renderer renderer 
)

Draws this View.

Parameters
selfThe View.
rendererThe Renderer.
Remarks
This method determines if the View is visible and dispatches Renderer::drawView before recursing down the View hierarchy. Rasterization is performed in View::render.
See also
View::render(View *, Renderer *)

Definition at line 709 of file View.c.

709 {
710
711 assert(self->window);
712
713 if (self->hidden == false) {
714
715 $(renderer, drawView, self);
716
717 $(self, enumerateSubviews, _draw, renderer);
718 }
719}
static void drawView(Renderer *self, View *view)
Definition Renderer.c:246
static void _draw(View *view, ident data)
ViewEnumerator adapter for draw.
Definition View.c:705

◆ emitViewEvent()

void emitViewEvent ( View self,
ViewEvent  code,
ident  data 
)

Emits a ViewEvent originating from this View.

Parameters
selfThe View.
codeThe ViewEvent code.
dataThe ViewEvent data.
Remarks
This method is used for emitting events from Views (as opposed to responding to user or system generated events). These events are propagated up the View hierarchy.

Definition at line 725 of file View.c.

725 {
726 SDL_PushEvent((SDL_Event *) &(const SDL_UserEvent) {
727 .type = MVC_VIEW_EVENT,
728 .code = code,
729 .data1 = self,
730 .data2 = data
731 });
732}
OBJECTIVELYMVC_EXPORT Uint32 MVC_VIEW_EVENT
The custom SDL_event type for View event relaying.
Definition Types.h:133

◆ enumerate() [1/2]

void enumerate ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

◆ enumerate() [2/2]

void enumerate ( View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates this View and its descendants, applying enumerator to each.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 738 of file View.c.

738 {
739
740 assert(enumerator);
741
742 enumerator(self, data);
743
744 $(self, enumerateDescendants, enumerator, data);
745}
void enumerateDescendants(const View *self, ViewEnumerator enumerator, ident data)
Enumerates all descendants of this View, applying enumerator to each.
Definition View.c:797

◆ enumerateAdjacent()

void enumerateAdjacent ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates adjacent siblings of this View, applying enumerator to each.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 751 of file View.c.

751 {
752
753 assert(enumerator);
754
755 if (self->superview) {
756 const Array *siblings = (Array *) self->superview->subviews;
757 const ssize_t index = $(siblings, indexOfObject, (const ident) self);
758 if (index > 0) {
759 enumerator($(siblings, objectAtIndex, index - 1), data);
760 }
761 if (index < (ssize_t) (siblings->count - 1)) {
762 enumerator($(siblings, objectAtIndex, index + 1), data);
763 }
764 }
765}

◆ enumerateAncestors()

void enumerateAncestors ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates all ancestors of this View, applying enumerator to each.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 771 of file View.c.

771 {
772
773 assert(enumerator);
774
775 for (View *view = self->superview; view; view = view->superview) {
776 enumerator(view, data);
777 }
778}

◆ enumerateDescendants()

void enumerateDescendants ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates all descendants of this View, applying enumerator to each.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 797 of file View.c.

797 {
798
799 assert(enumerator);
800
801 const Array *subviews = (Array *) self->subviews;
802 for (size_t i = 0; i < subviews->count; i++) {
803
804 View *subview = subviews->elements[i];
805 enumerator(subview, data);
806
807 $(subview, enumerateDescendants, enumerator, data);
808 }
809}

◆ enumerateSelection()

void enumerateSelection ( View self,
const char *  rule,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates all Views in the selection matched by rule, applying enumerator to each.

Parameters
selfThe View.
ruleThe Selector rule.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 784 of file View.c.

784 {
785
786 Selector *selector = $(alloc(Selector), initWithRule, rule);
787 assert(selector);
788
789 $(selector, enumerateSelection, self, enumerator, data);
790 release(selector);
791}
static Selector * initWithRule(Selector *self, const char *rule)
Definition Selector.c:190
Selectors are comprised of one or more SelectorSequences.
Definition Selector.h:49
void enumerateSelection(View *self, const char *rule, ViewEnumerator enumerator, ident data)
Enumerates all Views in the selection matched by rule, applying enumerator to each.
Definition View.c:784

◆ enumerateSiblings()

void enumerateSiblings ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates all siblings of this View, applying enumerator to each.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 815 of file View.c.

815 {
816
817 assert(enumerator);
818
819 if (self->superview) {
820
821 const Array *siblings = (Array *) self->superview->subviews;
822 for (size_t i = 0; i < siblings->count; i++) {
823 View *sibling = siblings->elements[i];
824 if (sibling != self) {
825 enumerator(sibling, data);
826 }
827 }
828 }
829}

◆ enumerateSubviews()

void enumerateSubviews ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates all subviews of this View, applying enumerator to each.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 835 of file View.c.

835 {
836
837 assert(enumerator);
838
839 const Array *subviews = (Array *) self->subviews;
840 for (size_t i = 0; i < subviews->count; i++) {
841 enumerator((View *) subviews->elements[i], data);
842 }
843}

◆ enumerateSuperview()

void enumerateSuperview ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates the superview of this View, if any, applying enumerator to it.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 849 of file View.c.

849 {
850
851 assert(enumerator);
852
853 if (self->superview) {
854 enumerator(self->superview, data);
855 }
856}

◆ enumerateVisible() [1/2]

void enumerateVisible ( const View self,
ViewEnumerator  enumerator,
ident  data 
)

◆ enumerateVisible() [2/2]

void enumerateVisible ( View self,
ViewEnumerator  enumerator,
ident  data 
)

Enumerates this View and its visible descendants, applying enumerator to each.

This is an optimized path for enumerating only visible subtrees.

Parameters
selfThe View.
enumeratorThe ViewEnumerator.
dataUser data.

Definition at line 862 of file View.c.

862 {
863
864 if ($(self, isVisible) == false) {
865 return;
866 }
867
868 enumerator(self, data);
869
870 const Array *subviews = (Array *) self->subviews;
871 for (size_t i = 0; i < subviews->count; i++) {
872
873 View *subview = subviews->elements[i];
874 $(subview, enumerateVisible, enumerator, data);
875 }
876}
void enumerateVisible(const View *self, ViewEnumerator enumerator, ident data)

◆ hasClassName()

bool hasClassName ( const View self,
cosnt char *  className 
)
Parameters
selfThe View
classNameThe class name.
Returns
True if this View has the given class name, false otherwise.

◆ hasOverflow()

bool hasOverflow ( const View self)
Parameters
selfThe View
Returns
True if this View's visible subviews exceed this View's bounds.

Definition at line 928 of file View.c.

928 {
929
930 Overflow overflow = {
931 .bounds = $(self, bounds)
932 };
933
934 $(self, enumerateSubviews, hasOverflow_enumerate, (ident) &overflow);
935
936 return overflow.hasOverflow;
937}
static void hasOverflow_enumerate(View *view, ident data)
ViewEnumerator for hasOverflow.
Definition View.c:906
SDL_Rect bounds
Definition View.c:899
bool hasOverflow
Definition View.c:900

◆ hitTest()

View * hitTest ( const View self,
const SDL_Point *  point 
)

Performs a hit test against this View and its descendants for the given point.

Parameters
selfThe View.
pointThe point to test.
Returns
The furthest descendant View that contains the given point.

Definition at line 943 of file View.c.

943 {
944
945 if (self->hidden == false) {
946
947 if ($(self, containsPoint, point)) {
948
949 const Array *subviews = (Array *) self->subviews;
950 for (size_t i = subviews->count; i; i--) {
951
952 const View *subview = subviews->elements[i - 1];
953 const View *view = $(subview, hitTest, point);
954 if (view) {
955 return (View *) view;
956 }
957 }
958
959 return (View *) self;
960 }
961 }
962
963 return NULL;
964}
View * hitTest(const View *self, const SDL_Point *point)
Performs a hit test against this View and its descendants for the given point.
Definition View.c:943

◆ init()

View * init ( View self)

Initializes this View.

Parameters
selfThe View.
Returns
The initialized View, or NULL on error.
Remarks
View::viewWithDictionary invokes this initializer when loading Views. Subclasses wishing to support JSON binding must override this method to call their designated initializer.

Definition at line 67 of file Box.c.

67 {
68 return (View *) $((Box *) self, initWithFrame, NULL);
69}
View * initWithFrame(View *self, const SDL_Rect *frame)
Initializes this View with the specified frame.
Definition View.c:978

◆ initWithFrame()

View * initWithFrame ( View self,
const SDL_Rect *  frame 
)

Initializes this View with the specified frame.

Parameters
selfThe View.
frameThe frame.
Returns
The initialized View, or NULL on error.
Remarks
Designated initializer.

Definition at line 978 of file View.c.

978 {
979
980 self = (View *) super(Object, self, init);
981 if (self) {
982
983 if (frame) {
984 self->frame = *frame;
985 }
986
987 self->classNames = $$(Set, setWithCapacity, 0);
988 assert(self->classNames);
989
990 self->computedStyle = $(alloc(Style), initWithAttributes, NULL);
991 assert(self->computedStyle);
992
993 self->subviews = $$(Array, arrayWithCapacity, 0);
994 assert(self->subviews);
995
996 self->style = $(alloc(Style), initWithAttributes, NULL);
997 assert(self->style);
998
999 self->warnings = $$(Array, arrayWithCapacity, 0);
1000 assert(self->warnings);
1001
1002 self->maxSize = MakeSize(INT32_MAX, INT32_MAX);
1003
1004 self->needsApplyTheme = true;
1005 self->needsLayout = true;
1006 }
1007
1008 return self;
1009}
static Style * initWithAttributes(Style *self, const Dictionary *attributes)
Definition Style.c:292
SDL_Size maxSize
The maximum size this View may be resized to during layout.
Definition View.h:207

◆ invalidateStyle()

void invalidateStyle ( View self)

Invalidates the computed Style for this View and its descendants.

Parameters
selfThe View.

Definition at line 1022 of file View.c.

1022 {
1023 $(self, enumerate, invalidateStyle_enumerate, NULL);
1024}
static void invalidateStyle_enumerate(View *view, ident data)
ViewEnumerator for invalidateStyle.
Definition View.c:1014
void enumerate(const View *self, ViewEnumerator enumerator, ident data)

◆ isContainer()

bool isContainer ( const View self)
Parameters
selfThe view.
Returns
True if this View's autoresizing mask includes Fit or Contain.

Definition at line 1030 of file View.c.

1030 {
1032}
@ ViewAutoresizingContain
Definition View.h:92
@ ViewAutoresizingFit
Definition View.h:91
int autoresizingMask
The ViewAutoresizing bitmask.
Definition View.h:155

◆ isDescendantOfView()

bool isDescendantOfView ( const View self,
const View view 
)
Parameters
selfThe View.
viewThe View to test against this View's hierarchy.
Returns
True if this View is a descendant of, or equal to, the given View.

Definition at line 1038 of file View.c.

1038 {
1039
1040 assert(view);
1041
1042 while (self) {
1043 if (self == view) {
1044 return true;
1045 }
1046 self = self->superview;
1047 }
1048
1049 return false;
1050}

◆ isKeyResponder()

bool isKeyResponder ( const View self)
Parameters
selfThe View.
Returns
True if this View is the first responder, false otherwise.

Definition at line 1056 of file View.c.

1056 {
1057
1058 if (self->window) {
1059 return SDL_GetPointerProperty(SDL_GetWindowProperties(self->window), "keyResponder", NULL) == self;
1060 } else {
1061 return false;
1062 }
1063}

◆ isTouchResponder()

bool isTouchResponder ( const View self)
Parameters
selfThe View.
Returns
True if this View is responding to mouse and touch events, false otherwise.

Definition at line 1069 of file View.c.

1069 {
1070
1071 if (self->window) {
1072 return SDL_GetPointerProperty(SDL_GetWindowProperties(self->window), "touchResponder", NULL) == self;
1073 } else {
1074 return false;
1075 }
1076}

◆ isVisible()

bool isVisible ( const View self)
Parameters
selfThe View.
Returns
True if this View is visible, false if it, or an ancestor, is hidden.

Definition at line 1082 of file View.c.

1082 {
1083
1084 for (const View *view = self; view; view = view->superview) {
1085 if (view->hidden) {
1086 return false;
1087 }
1088 }
1089
1090 return true;
1091}

◆ layoutIfNeeded()

void layoutIfNeeded ( View self)

Recursively updates the layout of this View and its subviews.

Parameters
selfThe View.

Definition at line 1104 of file View.c.

1104 {
1105
1107
1108 if (self->needsLayout) {
1109
1111
1112 $(self, layoutSubviews);
1113
1114 self->needsLayout = false;
1115 }
1116}
static void layoutIfNeeded_enumerate(View *subview, ident data)
ViewEnumerator for layoutIfNeeded recursion.
Definition View.c:1096
@ WarningTypeLayout
Definition Warning.h:35
layoutSubviews(View *self)
Performs layout for this View's immediate subviews.
Definition Box.c:74

◆ layoutSubviews()

layoutSubviews ( View self)

Performs layout for this View's immediate subviews.

Parameters
selfThe View.
Remarks
Subclasses may override this method to perform their own layout operations. This method is called recursively by View::layoutIfNeeded.

Definition at line 74 of file Box.c.

74 {
75
76 super(View, self, layoutSubviews);
77
78 View *label = (View *) ((Box *) self)->label;
79 if (label->hidden == false) {
80
81 const SDL_Size size = $(label, sizeThatContains);
82 label->frame.y = -size.h * 0.5;
83 }
84}
SDL_Size sizeThatContains(const View *self)
Definition View.c:1648

◆ matchesSelector()

bool matchesSelector ( const View self,
const SimpleSelector simpleSelector 
)
Parameters
selfThe View.
simpleSelectorThe SimpleSelector.
Returns
True if this View matches the SimpleSelector, false otherwise.

Definition at line 51 of file CollectionItemView.c.

51 {
52
53 assert(simpleSelector);
54
55 const CollectionItemView *this = (CollectionItemView *) self;
56 const char *pattern = simpleSelector->pattern;
57
58 switch (simpleSelector->type) {
60 if (strcmp("selected", pattern) == 0) {
61 return this->isSelected;
62 }
63 break;
64 default:
65 break;
66 }
67
68 return super(View, self, matchesSelector, simpleSelector);
69}
static bool isSelected(const Control *self)
Definition Control.c:335
@ SimpleSelectorTypePseudo
CollectionViewItems are a visual representation of an item within a CollectionView.
SimpleSelectorType type
The SimpleSelectorType.
char * pattern
The pattern, as provided by the user.
bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)

◆ moveToWindow()

void moveToWindow ( View self,
SDL_Window *  window 
)

Moves this View to the View hierarchy of the given window.

Parameters
selfThe View.
windowThe window, or NULL if this View is moving from its current window.

Definition at line 1251 of file View.c.

1251 {
1252
1253 $(self, willMoveToWindow, window);
1254
1255 self->window = window;
1256
1257 $(self, didMoveToWindow, window);
1258
1260}
static void moveToWindow_enumerate(View *subview, ident data)
ViewEnumerator for moveToWindow recursion.
Definition View.c:1243
void didMoveToWindow(View *self, SDL_Window *window)
Informs this View that it has been added to the View hierachy of the given window.
Definition View.c:640
void willMoveToWindow(View *self, SDL_Window *window)
Informs this View that it will be added to the View hierarchy for the given window.
Definition View.c:1935

◆ path()

String * path ( const View self)
Parameters
selfThe View.
Returns
A unique CSS selector matching this View.

Definition at line 1266 of file View.c.

1266 {
1267
1268 Array *parts = $$(Array, array);
1269
1270 const View *view = self;
1271 while (view) {
1272
1273 Array *classNames = $((Set *) view->classNames, allObjects);
1274
1275 String *part;
1276 if (view->identifier) {
1277 part = str("#%s", view->identifier);
1278 } else if (classNames->count) {
1279 part = str(".%s", ((String *) $(classNames, firstObject))->chars);
1280 } else {
1281 part = str("%s", classnameof(view));
1282 }
1283
1284 release(classNames);
1285
1286 $(parts, insertObjectAtIndex, part, 0);
1287 release(part);
1288
1289 if (view->viewController) {
1290 break;
1291 }
1292
1293 view = view->superview;
1294 }
1295
1296 String *path = $((Array *) parts, componentsJoinedByCharacters, " > ");
1297
1298 release(parts);
1299
1300 return path;
1301}
ViewController * viewController
The ViewController.
Definition View.h:265

◆ removeAllClassNames()

void removeAllClassNames ( View self)

Removes all class names from this View.

Parameters
selfThe View.

Definition at line 1307 of file View.c.

1307 {
1308
1309 $(self->classNames, removeAllObjects);
1310
1311 $(self, invalidateStyle);
1312}

◆ removeAllSubviews()

void removeAllSubviews ( View self)

Removes all subviews from this View.

Parameters
selfThe View.

Definition at line 1325 of file View.c.

1325 {
1326 $(self->subviews, removeAllObjectsWithEnumerator, removeAllSubviews_enumerate, self);
1327}
static void removeAllSubviews_enumerate(const Array *array, ident obj, ident data)
ArrayEnumerator for removeAllSubviews.
Definition View.c:1317

◆ removeClassName()

void removeClassName ( View self,
const char *  className 
)

Removes the given class name to this View.

Parameters
selfThe View.
classNameThe class name.

Definition at line 1333 of file View.c.

1333 {
1334
1335 if (className) {
1336 String *string = $$(String, stringWithCharacters, className);
1337 assert(string);
1338
1339 $(self->classNames, removeObject, string);
1340 release(string);
1341
1342 $(self, invalidateStyle);
1343 }
1344}

◆ removeFromSuperview()

void removeFromSuperview ( View self)

Removes this View from its superview.

Parameters
selfThe View.

Definition at line 1350 of file View.c.

1350 {
1351
1352 if (self->superview) {
1353 $(self->superview, removeSubview, self);
1354 }
1355}
void removeSubview(View *self, View *subview)
Removes the given subview from this View.
Definition PageView.c:72

◆ removeSubview()

void removeSubview ( View self,
View subview 
)

Removes the given subview from this View.

Parameters
selfThe View.
subviewThe subview.

Definition at line 72 of file PageView.c.

72 {
73
74 PageView *this = (PageView *) self;
75
76 retain(subview);
77
78 super(View, self, removeSubview, subview);
79
80 subview->hidden = false;
81
82 if (subview == this->currentPage) {
83 $(this, setCurrentPage, NULL);
84 }
85
86 release(subview);
87}

◆ render()

void render ( View self,
Renderer renderer 
)

Renders this View using the given renderer.

Parameters
selfThe View.
rendererThe Renderer.
Remarks
Subclasses should override this method to perform actual drawing operations. This method is called by draw as the View hierarchy is drawn.

Definition at line 179 of file Control.c.

179 {
180
181 super(View, self, render, renderer);
182
183 Control *this = (Control *) self;
184
185 const SDL_Rect frame = $(self, renderFrame);
186
187 if (this->bevel == ControlBevelInset) {
188
189 SDL_Point points[3];
190
191 points[0].x = frame.x;
192 points[0].y = frame.y + frame.h;
193
194 points[1].x = frame.x + frame.w;
195 points[1].y = frame.y + frame.h;
196
197 points[2].x = frame.x + frame.w;
198 points[2].y = frame.y;
199
200 $(renderer, drawLines, points, lengthof(points), &Colors.Silver);
201
202 points[0].x = frame.x;
203 points[0].y = frame.y + frame.h;
204
205 points[1].x = frame.x;
206 points[1].y = frame.y;
207
208 points[2].x = frame.x + frame.w;
209 points[2].y = frame.y;
210
211 $(renderer, drawLines, points, lengthof(points), &Colors.Black);
212
213 } else if (this->bevel == ControlBevelOutset) {
214
215 SDL_Point points[3];
216
217 points[0].x = frame.x;
218 points[0].y = frame.y + frame.h;
219
220 points[1].x = frame.x + frame.w;
221 points[1].y = frame.y + frame.h;
222
223 points[2].x = frame.x + frame.w;
224 points[2].y = frame.y;
225
226 $(renderer, drawLines, points, lengthof(points), &Colors.Black);
227
228 points[0].x = frame.x;
229 points[0].y = frame.y + frame.h;
230
231 points[1].x = frame.x;
232 points[1].y = frame.y;
233
234 points[2].x = frame.x + frame.w;
235 points[2].y = frame.y;
236
237 $(renderer, drawLines, points, lengthof(points), &Colors.Silver);
238 }
239
240 if (this->state & ControlStateFocused) {
241 $(renderer, drawRect, &frame, &Colors.Charcoal);
242 }
243}
@ ControlBevelInset
Definition Control.h:45
@ ControlBevelOutset
Definition Control.h:46
static void drawLines(const Renderer *self, const SDL_Point *points, size_t count, const SDL_Color *color)
Definition Renderer.c:137
static void drawRect(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color)
Definition Renderer.c:181
W3C Color constants.
Definition Colors.h:37
SDL_Color Charcoal
Definition Colors.h:53
SDL_Color Black
Definition Colors.h:46
SDL_Color Silver
Definition Colors.h:169
void render(View *self, Renderer *renderer)
Renders this View using the given renderer.
Definition Control.c:179

◆ renderDeviceDidReset()

void renderDeviceDidReset ( View self)

Informs this View that the render device has reset.

Parameters
selfThe View.
Remarks
Subclasses may override this method to allocate any OpenGL objects they require.

Definition at line 442 of file Text.c.

442 {
443
444 Text *this = (Text *) self;
445
446 this->font->scale = view_pixel_density(self->window);
447 $(this->font, renderDeviceDidReset);
448
449 super(View, self, renderDeviceDidReset);
450}
static float view_pixel_density(SDL_Window *window)
Definition Text.c:36
Text rendered with TrueType fonts.
Definition Text.h:69
void renderDeviceDidReset(View *self)
Informs this View that the render device has reset.
Definition Text.c:442

◆ renderDeviceWillReset()

void renderDeviceWillReset ( View self)

Informs this View that the render device will reset.

Parameters
selfThe View.
Remarks
Subclasses should override this method to free any OpenGL objects they own.

Definition at line 119 of file ImageView.c.

119 {
120
121 ImageView *this = (ImageView *) self;
122
123 this->texture = release(this->texture);
124
125 super(View, self, renderDeviceWillReset);
126}
ImageViews render an Image in the context of a View hierarchy.
Definition ImageView.h:45
void renderDeviceWillReset(View *self)
Informs this View that the render device will reset.
Definition ImageView.c:119

◆ renderFrame()

SDL_Frame renderFrame ( const View self)
Parameters
selfThe View.
Returns
This View's absolute frame in the View hierarchy, in object space.

Definition at line 1444 of file View.c.

1444 {
1445
1446 SDL_Rect frame = self->frame;
1447
1448 const View *view = self;
1449 const View *superview = view->superview;
1450 while (superview) {
1451
1452 frame.x += superview->frame.x;
1453 frame.y += superview->frame.y;
1454
1455 if (view->alignment != ViewAlignmentInternal) {
1457 frame.y += superview->padding.top;
1458 }
1459
1460 view = superview;
1461 superview = view->superview;
1462 }
1463
1464 return frame;
1465}
@ ViewAlignmentInternal
Definition View.h:78
ViewAlignment alignment
The alignment.
Definition View.h:150

◆ replaceSubview()

void replaceSubview ( View self,
View subview,
View replacement 
)

Replaces the specified subview with the given replacement.

Parameters
selfThe View.
subviewThe subview to replace.
replacementThe replacement subview.

Definition at line 1471 of file View.c.

1471 {
1472
1473 assert(subview);
1474 assert(replacement);
1475
1476 $(self, addSubviewRelativeTo, replacement, subview, ViewPositionAfter);
1477 $(self, removeSubview, subview);
1478}

◆ resignKeyResponder()

void resignKeyResponder ( View self)

Resigns key responder priority.

Parameters
selfThe View.

Definition at line 248 of file Control.c.

248 {
249
250 Control *this = (Control *) self;
251
252 if ($(this, isHighlighted) || $(this, isFocused)) {
253
254 this->state &= ~ControlStateHighlighted;
255 this->state &= ~ControlStateFocused;
256
257 $(this, stateDidChange);
258 }
259
260 super(View, self, resignKeyResponder);
261}
static bool isHighlighted(const Control *self)
Definition Control.c:327
void resignKeyResponder(View *self)
Resigns key responder priority.
Definition Control.c:248

◆ resignTouchResponder()

void resignTouchResponder ( View self)

Resigns touch responder priority.

Parameters
selfThe View.

Definition at line 1500 of file View.c.

1500 {
1501
1502 if (self->window && $(self, isTouchResponder)) {
1503
1504 String *path = $(self, path);
1505 MVC_LogDebug("%s\n", path->chars);
1506 release(path);
1507
1508 SDL_SetPointerProperty(SDL_GetWindowProperties(self->window), "touchResponder", NULL);
1509 }
1510}

◆ resize()

void resize ( View self,
const SDL_Size *  size 
)

Resizes this View to the specified size.

Parameters
selfThe View.
sizeThe size to set.

Definition at line 1516 of file View.c.

1516 {
1517
1518 const int w = clamp(size->w, self->minSize.w, self->maxSize.w);
1519 const int h = clamp(size->h, self->minSize.h, self->maxSize.h);
1520
1521 if (self->frame.w != w || self->frame.h != h) {
1522
1523 self->frame.w = w;
1524 self->frame.h = h;
1525
1526 self->needsLayout = true;
1527
1528 if (self->superview && $(self->superview, isContainer)) {
1529 self->superview->needsLayout = true;
1530 }
1531 }
1532}
bool isContainer(const View *self)
Definition View.c:1030
SDL_Size minSize
The minimum size this View may be resized to during layout.
Definition View.h:212

◆ resolve()

void resolve ( View self,
Outlet outlets 
)

Resolves the given Outlets from this View's hierarchy.

Parameters
selfThe View.
outletsThe Outlets to resolve.

Definition at line 1538 of file View.c.

1538 {
1539
1540 if (outlets) {
1541 for (Outlet *outlet = outlets; outlet->identifier; outlet++) {
1542 *outlet->view = $(self, descendantWithIdentifier, outlet->identifier);
1543 if (*outlet->view == NULL) {
1544 String *desc = $((Object *) self, description);
1545 MVC_LogError("Failed to resolve outlet '%s' for %s", outlet->identifier, desc->chars);
1546 release(desc);
1547 }
1548
1549 assert(*outlet->view);
1550 }
1551 }
1552}
static String * description(const Object *self)
Definition Label.c:47
Outlets enable outbound data binding of Views through JSON.
Definition View+JSON.h:200
const char * identifier
The View identifier.
Definition View+JSON.h:205

◆ respondToEvent()

void respondToEvent ( View self,
const SDL_Event *  event 
)

Responds to the specified event.

Parameters
selfThe View.
eventThe event.

Definition at line 266 of file Control.c.

266 {
267
268 Control *this = (Control *) self;
269
270 const ControlState state = (ControlState) this->state;
271 if (!(state & ControlStateDisabled)) {
272 if ($(this, captureEvent, event)) {
273 if (this->state != state) {
274 $(this, stateDidChange);
275 }
276 return;
277 }
278 }
279
280 super(View, self, respondToEvent, event);
281}
static bool captureEvent(Control *self, const SDL_Event *event)
Definition Button.c:78
ControlState
Control states, which are bit-masked.
Definition Control.h:65
void respondToEvent(View *self, const SDL_Event *event)
Responds to the specified event.
Definition Control.c:266

◆ select()

Set * select ( View self,
const char *  rule 
)

Resolves all descendants (including this View) that match the given Selector rule.

Parameters
selfThe View.
ruleThe Selector rule.
Returns
The Set of selected descendant Views.

◆ selectFirst()

View * selectFirst ( View self,
const char *  rule 
)

Resolves the first descendant View that matches the given Selector rule.

Parameters
selfThe View.
ruleThe Selector rule.
Returns
The matched View, or NULL.

Definition at line 1625 of file View.c.

1625 {
1626
1627 Selector *selector = $(alloc(Selector), initWithRule, rule);
1628 assert(selector);
1629
1630 View *first = $(selector, selectFirst, self);
1631
1632 release(selector);
1633 return first;
1634}
View * selectFirst(View *self, const char *rule)
Resolves the first descendant View that matches the given Selector rule.
Definition View.c:1625

◆ size()

SDL_Size size ( const View self)
Parameters
selfThe View.
Returns
The size of this View's frame.

Definition at line 1640 of file View.c.

1640 {
1641 return MakeSize(self->frame.w, self->frame.h);
1642}

◆ sizeThastFills()

SDL_Size sizeThastFills ( const View self)

◆ sizeThatContains()

SDL_Size sizeThatContains ( const View self)
Parameters
selfThe View.
Returns
An SDL_Size that contains this View's subviews.
Remarks
The returned size is greater than or equal to View::sizeThatFits.

Definition at line 1648 of file View.c.

1648 {
1649
1650 const SDL_Size size = $(self, size);
1651 const SDL_Size sizeThatFits = $(self, sizeThatFits);
1652
1653 return MakeSize(max(size.w, sizeThatFits.w), max(size.h, sizeThatFits.h));
1654}
void sizeThatFits(const View *self)
Definition Select.c:113

◆ sizeThatFills()

SDL_Size sizeThatFills ( const View self)
Parameters
selfThe View.
Returns
An SDL_Size that fills this View's superview.

Definition at line 1660 of file View.c.

1660 {
1661 SDL_Size size;
1662
1663 if (self->superview == NULL) {
1664 SDL_GetWindowSize(self->window, &size.w, &size.h);
1665 } else {
1666 size = $(self->superview, size);
1667 }
1668
1669 return size;
1670}

◆ sizeThatFits()

SDL_Size sizeThatFits ( const View self)
Parameters
selfThe View.
Returns
An SDL_Size that fits this View's subviews.
Remarks
The default implementation of this method returns the View's current size, or an appropriate value based on this View's autoresizingMask.

Definition at line 113 of file Select.c.

113 {
114
115 const Select *this = (Select *) self;
116
117 SDL_Size size = super(View, self, sizeThatFits);
118
119 const Array *options = (Array *) this->options;
120 for (size_t i = 0; i < options->count; i++) {
121
122 const View *option = $(options, objectAtIndex, i);
123 const SDL_Size optionSize = $(option, sizeThatFits);
124
125 size.w = max(size.w, optionSize.w + self->padding.left + self->padding.right);
126 size.h = max(size.h, optionSize.h + self->padding.top + self->padding.bottom);
127 }
128
129 return size;
130}
A Control allowing users to select one or more Options.
Definition Select.h:63

◆ sizeToContain()

void sizeToContain ( View self)

Resizes this View to contain its subviews.

Parameters
selfThe View.
See also
View::sizeThatContains(const View *)

Definition at line 1734 of file View.c.

1734 {
1735
1736 const SDL_Size size = $(self, sizeThatContains);
1737
1738 $(self, resize, &size);
1739}
void resize(View *self, const SDL_Size *size)
Resizes this View to the specified size.
Definition View.c:1516

◆ sizeToFill()

void sizeToFill ( View self)

Resizes this View to fill its superview.

Parameters
selfThe View.
See also
View::sizeThatFills(const View *)

Definition at line 1745 of file View.c.

1745 {
1746
1747 const SDL_Size size = $(self, sizeThatFills);
1748
1749 $(self, resize, &size);
1750}
SDL_Size sizeThatFills(const View *self)
Definition View.c:1660

◆ sizeToFit()

void sizeToFit ( View self)

Resizes this View to fit its subviews.

Parameters
selfThe View.
See also
View::sizeThatFits(const View *)

Definition at line 1756 of file View.c.

1756 {
1757
1758 const SDL_Size size = $(self, sizeThatFits);
1759
1760 $(self, resize, &size);
1761}

◆ subviewWithIdentifier()

View * subviewWithIdentifier ( const View self,
const char *  identifier 
)
Parameters
selfThe View.
identifierThe identifier.
Returns
The first subview matching the given identifier.

Definition at line 1767 of file View.c.

1767 {
1768
1769 assert(identifier);
1770
1771 const Array *subviews = (Array *) self->subviews;
1772 for (size_t i = 0; i < subviews->count; i++) {
1773
1774 View *subview = subviews->elements[i];
1775 if (subview->identifier) {
1776
1777 if (strcmp(identifier, subview->identifier) == 0) {
1778 return subview;
1779 }
1780 }
1781 }
1782
1783 return NULL;
1784}

◆ updateBindings()

void updateBindings ( View self)

Updates data bindings, prompting the appropriate layout changes.

Parameters
selfThe View.
Remarks
Subclasses should override this method to refresh any data sources they rely on.

Definition at line 117 of file HSVColorPicker.c.

117 {
118
119 super(View, self, updateBindings);
120
121 HSVColorPicker *this = (HSVColorPicker *) self;
122
123 $(this->hueSlider, setValue, this->hue);
124 $(this->saturationSlider, setValue, this->saturation);
125 $(this->valueSlider, setValue, this->value);
126
127 this->colorView->backgroundColor = $(this, rgbColor);
128}
static SDL_Color rgbColor(const HSVColorPicker *self)
static void setValue(ProgressBar *self, double value)
The HSVColorPicker type.
void updateBindings(View *self)
Updates data bindings, prompting the appropriate layout changes.

◆ viewport()

SDL_Rect viewport ( const View self)
Parameters
selfThe View.
Returns
The OpenGL viewport for this View.

Definition at line 1805 of file View.c.

1805 {
1806
1807 assert(self->window);
1808
1809 const SDL_Rect frame = $(self, renderFrame);
1810
1811 return MVC_TransformToWindow(self->window, &frame);
1812}
SDL_Rect MVC_TransformToWindow(SDL_Window *window, const SDL_Rect *rect)
Transforms the specified rectangle to normalized device coordinates in window.
Definition Window.c:29

◆ viewWithCharacters()

View * viewWithCharacters ( const char *  chars,
Outlet outlets 
)

Instantiates a View initialized with the given null-terminated JSON C string.

Parameters
charsA null-terminated JSON C string describing a View.
outletsAn optional array of Outlets to resolve.
Returns
The initialized View, or NULL on error.

Definition at line 1818 of file View.c.

1818 {
1819
1820 Data *data = $$(Data, dataWithConstMemory, (ident) chars, strlen(chars));
1821
1822 View *view = $$(View, viewWithData, data, outlets);
1823
1824 release(data);
1825
1826 return view;
1827}
View * viewWithData(const Data *data, Outlet *outlets)
Instantiates a View initialized with the contents of data.
Definition View.c:1833

◆ viewWithData()

View * viewWithData ( const Data *  data,
Outlet outlets 
)

Instantiates a View initialized with the contents of data.

Parameters
dataA Data containing JSON describing a View.
outletsAn optional array of Outlets to resolve.
Returns
The initialized View, or NULL on error.

Definition at line 1833 of file View.c.

1833 {
1834
1835 JSONContext *ctx = $(alloc(JSONContext), init);
1836 Dictionary *dictionary = $(ctx, objectFromData, data, 0);
1837
1838 View *view = NULL;
1839 if (dictionary) {
1840 view = $$(View, viewWithDictionary, dictionary, outlets);
1841 release(dictionary);
1842 } else {
1843 MVC_LogError("Failed to parse JSON\n");
1844 }
1845
1846 release(ctx);
1847 return view;
1848}
View * viewWithDictionary(const Dictionary *dictionary, Outlet *outlets)
Instantiates a View initialized with the attributes described in dictionary.
Definition View.c:1854

◆ viewWithDictionary()

View * viewWithDictionary ( const Dictionary *  dictionary,
Outlet outlets 
)

Instantiates a View initialized with the attributes described in dictionary.

Parameters
dictionaryA Dictionary describing a View.
outletsAn optional array of Outlets to resolve.
Returns
The initialized View, or NULL on error.
See also
View::initWithDictionary(View *, const Dictionary *, Outlet *outlets)

Definition at line 1854 of file View.c.

1854 {
1855
1856 View *view = NULL;
1857
1858 BindInlet(&MakeInlet(NULL, InletTypeView, &view, NULL), dictionary);
1859
1860 $(view, resolve, outlets);
1861
1862 return view;
1863}
#define BindInlet(inlet, obj)
Binds the Inlet to obj by invoking the appropriate InletBinding function.
Definition View+JSON.h:244
void resolve(View *self, Outlet *outlets)
Resolves the given Outlets from this View's hierarchy.
Definition View.c:1538

◆ viewWithResource()

View * viewWithResource ( const Resource *  resource,
Outlet outlets 
)

Instantiates a View initialized with the JSON data in resource.

Parameters
resourceA Resource containing JSON describing a View.
outletsAn optional array of Outlets to resolve.
Returns
The initialized View, or NULL on error.
See also
View::initWithData(View *, const Data *, Outlet *outlets)

Definition at line 1869 of file View.c.

1869 {
1870
1871 assert(resource);
1872
1873 return $$(View, viewWithData, resource->data, outlets);
1874}

◆ viewWithResourceName()

View * viewWithResourceName ( const char *  name,
Outlet outlets 
)

Instantiates a View initialized with the JSON Resource with the specified name.

Parameters
nameThe name of a JSON Resource describing a View.
outletsAn optional array of Outlets to resolve.
Returns
The initialized View, or NULL on error.
See also
View::initWithResource(View *, const Dictionary *, Outlet *outlets)

Definition at line 1880 of file View.c.

1880 {
1881
1882 Resource *resource = $$(Resource, resourceWithName, name);
1883
1884 View *view = $$(View, viewWithResource, resource, outlets);
1885
1886 release(resource);
1887
1888 return view;
1889}
View * viewWithResource(const Resource *resource, Outlet *outlets)
Instantiates a View initialized with the JSON data in resource.
Definition View.c:1869

◆ visibleSubviews()

Array * visibleSubviews ( const View self)
Parameters
selfThe View.
Returns
An Array of this View's visible subviews.
Remarks
The returned Array excludes that specify ViewAlignmentInternal.

Definition at line 92 of file PageView.c.

92 {
93 return $$(Array, arrayWithArray, (Array *) self->subviews);
94}

◆ warn() [1/2]

void warn ( View self,
ViewWarningType  type,
const char *  fmt,
  ... 
)

◆ warn() [2/2]

void warn ( View self,
WarningType  level,
const char *  fmt,
  ... 
)

Appends a warning for this View.

Parameters
selfThe View.
levelThe WarningType.
fmtThe format string.

Definition at line 1913 of file View.c.

1913 {
1914
1915 va_list args;
1916 va_start(args, fmt);
1917
1918 Warning *warning = $(alloc(Warning), initWithVaList, type, fmt, args);
1919
1920 va_end(args);
1921
1922 String *description = $((Object *) self, description);
1923 MVC_LogWarn("%s:: %s\n", description->chars, warning->message->chars);
1924 release(description);
1925
1926 $(self->warnings, addObject, warning);
1927
1928 release(warning);
1929}
#define MVC_LogWarn(fmt,...)
Definition Log.h:54
static Warning * initWithVaList(Warning *self, WarningType type, const char *fmt, va_list args)
Definition Warning.c:66
The Warning type.
Definition Warning.h:50
String * message
The message.
Definition Warning.h:71

◆ willMoveToWindow()

void willMoveToWindow ( View self,
SDL_Window *  window 
)

Informs this View that it will be added to the View hierarchy for the given window.

Parameters
selfThe View.
windowThe window, or NULL if this View will be removed from the window.

Definition at line 1935 of file View.c.

1935 {
1936
1937 if (self->window) {
1938 $(self, resignKeyResponder);
1939 $(self, resignTouchResponder);
1940 $(self, detachStylesheet, self->window);
1941 }
1942}
void detachStylesheet(View *self, SDL_Window *window)
Detaches this View's Stylesheet from the Theme associated with the given window.
Definition View.c:624

Field Documentation

◆ alignment

ViewAlignment View::alignment

The alignment.

Definition at line 150 of file View.h.

◆ autoresizingMask

int View::autoresizingMask

The ViewAutoresizing bitmask.

Definition at line 155 of file View.h.

◆ backgroundColor

SDL_Color View::backgroundColor

The background color.

Definition at line 160 of file View.h.

◆ borderColor

SDL_Color View::borderColor

The border color.

Definition at line 165 of file View.h.

◆ borderWidth

int View::borderWidth

The border width.

Definition at line 170 of file View.h.

◆ classNames

Set* View::classNames

The class names.

See also
Style

Definition at line 176 of file View.h.

◆ clipsSubviews

bool View::clipsSubviews

If true, subviews will be clipped to this View's frame.

Definition at line 181 of file View.h.

◆ computedStyle

Style* View::computedStyle

The computed Style of this View.

Definition at line 186 of file View.h.

◆ frame

SDL_Rect View::frame

The frame, relative to the superview.

Definition at line 191 of file View.h.

◆ hidden

bool View::hidden

If true, this View is not drawn.

Definition at line 196 of file View.h.

◆ identifier

char* View::identifier

An optional identifier.

Remarks
Identifiers are commonly used to resolve Outlets when loading Views via JSON.

Definition at line 202 of file View.h.

◆ interface

ViewInterface* View::interface
protected

The interface.

Definition at line 145 of file View.h.

◆ maxSize

SDL_Size View::maxSize

The maximum size this View may be resized to during layout.

Definition at line 207 of file View.h.

◆ minSize

SDL_Size View::minSize

The minimum size this View may be resized to during layout.

Definition at line 212 of file View.h.

◆ needsApplyTheme

bool View::needsApplyTheme

If true, this View will apply the Theme before it is drawn.

Definition at line 217 of file View.h.

◆ needsLayout

bool View::needsLayout

If true, this View will layout its subviews before it is drawn.

Definition at line 222 of file View.h.

◆ nextResponder

View* View::nextResponder

The next responder, or event handler, in the chain.

Remarks
By default, Views propagate events to their superview. If this member is not NULL, events will instead be propagated to this View.

Definition at line 229 of file View.h.

◆ object

Object View::object

The superclass.

Definition at line 139 of file View.h.

◆ padding

ViewPadding View::padding

The padding.

Definition at line 234 of file View.h.

◆ style

Style* View::style

The element-level Style of this View.

Remarks
Attributes in this Style are local to this View, and override any Attributes matched via Selector. That is, it is always the last Style added to the computed Style.

Definition at line 241 of file View.h.

◆ stylesheet

Stylesheet* View::stylesheet

An optional Stylesheet.

Remarks
If set, this Stylesheet is added to or removed from the current Theme when this View is added to or removed from a valid View hierarchy.

Definition at line 248 of file View.h.

◆ subviews

Array* View::subviews

The immediate subviews.

Definition at line 253 of file View.h.

◆ superview

View* View::superview

The super View.

Remarks
This reference is not retained.

Definition at line 259 of file View.h.

◆ viewController

ViewController* View::viewController

The ViewController.

Remarks
This is NULL unless the View is the immediate view of a ViewController.

Definition at line 265 of file View.h.

◆ warnings

Array* View::warnings

The Warnings this View generated.

Remarks
These are optionally displayed by the DebugViewController.

Definition at line 271 of file View.h.

◆ window

SDL_Window* View::window

The window.

Remarks
This is NULL until the View has been added to a WindowController.

Definition at line 277 of file View.h.


The documentation for this struct was generated from the following files: