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 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 2067 of file View.c.

2067 {
2068 static Class *clazz;
2069 static Once once;
2070
2071 do_once(&once, {
2072 clazz = _initialize(&(const ClassDef) {
2073 .name = "View",
2074 .superclass = _Object(),
2075 .instanceSize = sizeof(View),
2076 .interfaceOffset = offsetof(View, interface),
2077 .interfaceSize = sizeof(ViewInterface),
2079 });
2080 });
2081
2082 return clazz;
2083}
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:1033
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:1361
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:1262

◆ 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:846

◆ 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:1277
void resignTouchResponder(View *self)
Resigns touch responder priority.
Definition View.c:1511
bool isTouchResponder(const View *self)
Definition View.c:1080

◆ 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:1651
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
565 if (MVC_LogEnabled(SDL_LOG_PRIORITY_VERBOSE)) {
566 String *desc = $((Object *) self, description);
567 String *superdesc = $((Object *) superview, description);
568
569 MVC_LogVerbose("%s is clipped by %s\n", desc->chars, superdesc->chars);
570
571 release(desc);
572 release(superdesc);
573 }
574
575 frame.w = frame.h = 0;
576 break;
577 }
578 }
580 }
581
582 return frame;
583}
static String * description(const Object *self)
Definition Label.c:47
#define MVC_LogVerbose(fmt,...)
Definition Log.h:45
#define MVC_LogEnabled(priority)
Definition Log.h:39
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:1455
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 589 of file View.c.

589 {
590
591 const SDL_Rect frame = $(self, clippingFrame);
592
593 return (bool) SDL_PointInRect(point, &frame);
594}

◆ depth()

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

Definition at line 600 of file View.c.

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

◆ 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 608 of file View.c.

608 {
609
610 assert(identifier);
611
612 if (self->identifier) {
613 if (strcmp(identifier, self->identifier) == 0) {
614 return (View *) self;
615 }
616 }
617
618 const Array *subviews = (Array *) self->subviews;
619 for (size_t i = 0; i < subviews->count; i++) {
620
621 const View *subview = subviews->elements[i];
622 View *descendant = $(subview, descendantWithIdentifier, identifier);
623 if (descendant) {
624 return descendant;
625 }
626 }
627
628 return NULL;
629}
descendantWithIdentifier(const View *self, const char *identifier)
Definition View.c:608

◆ 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 635 of file View.c.

635 {
636
637 assert(window);
638
639 if (self->stylesheet) {
640 Theme *theme = $$(Theme, theme, window);
641 if (theme) {
643 }
644 }
645}
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 651 of file View.c.

651 {
652
653 if (window) {
654 $(self, attachStylesheet, window);
655
656 if (self->superview == NULL) {
657 $(self, sizeToFill);
658 }
659
660 self->needsLayout = true;
661 }
662}
void sizeToFill(View *self)
Resizes this View to fill its superview.
Definition View.c:1756
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 668 of file View.c.

668 {
669
670 if ($(self, isKeyResponder)) {
671 switch (event->type) {
672 case SDL_EVENT_KEY_DOWN:
673 case SDL_EVENT_KEY_UP:
674 case SDL_EVENT_TEXT_INPUT:
675 return true;
676 }
677 }
678
679 if ($(self, isVisible)) {
680
681 SDL_Point point;
682
683 switch (event->type) {
684 case SDL_EVENT_MOUSE_BUTTON_DOWN:
685 case SDL_EVENT_MOUSE_BUTTON_UP:
686 point = MakePoint(event->button.x, event->button.y);
687 break;
688 case SDL_EVENT_MOUSE_MOTION:
689 point = MakePoint(event->motion.x, event->motion.y);
690 break;
691 case SDL_EVENT_MOUSE_WHEEL: {
692 float mx, my;
693 SDL_GetMouseState(&mx, &my);
694 point = MakePoint(mx, my);
695 break;
696 }
697 default:
698 return false;
699 }
700
701 return $(self, containsPoint, &point);
702 }
703
704 return false;
705}
bool isKeyResponder(const View *self)
Definition View.c:1067
bool containsPoint(const View *self, const SDL_Point *point)
Definition View.c:589
bool isVisible(const View *self)
Definition View.c:1093

◆ 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 720 of file View.c.

720 {
721
722 assert(self->window);
723
724 if (self->hidden == false) {
725
726 $(renderer, drawView, self);
727
728 $(self, enumerateSubviews, _draw, renderer);
729 }
730}
static void drawView(Renderer *self, View *view)
Definition Renderer.c:234
static void _draw(View *view, ident data)
ViewEnumerator adapter for draw.
Definition View.c:716

◆ 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 736 of file View.c.

736 {
737 SDL_PushEvent((SDL_Event *) &(const SDL_UserEvent) {
738 .type = MVC_VIEW_EVENT,
739 .code = code,
740 .data1 = self,
741 .data2 = data
742 });
743}
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 749 of file View.c.

749 {
750
751 assert(enumerator);
752
753 enumerator(self, data);
754
755 $(self, enumerateDescendants, enumerator, data);
756}
void enumerateDescendants(const View *self, ViewEnumerator enumerator, ident data)
Enumerates all descendants of this View, applying enumerator to each.
Definition View.c:808

◆ 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 762 of file View.c.

762 {
763
764 assert(enumerator);
765
766 if (self->superview) {
767 const Array *siblings = (Array *) self->superview->subviews;
768 const ssize_t index = $(siblings, indexOfObject, (const ident) self);
769 if (index > 0) {
770 enumerator($(siblings, objectAtIndex, index - 1), data);
771 }
772 if (index < (ssize_t) (siblings->count - 1)) {
773 enumerator($(siblings, objectAtIndex, index + 1), data);
774 }
775 }
776}

◆ 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 782 of file View.c.

782 {
783
784 assert(enumerator);
785
786 for (View *view = self->superview; view; view = view->superview) {
787 enumerator(view, data);
788 }
789}

◆ 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 808 of file View.c.

808 {
809
810 assert(enumerator);
811
812 const Array *subviews = (Array *) self->subviews;
813 for (size_t i = 0; i < subviews->count; i++) {
814
815 View *subview = subviews->elements[i];
816 enumerator(subview, data);
817
818 $(subview, enumerateDescendants, enumerator, data);
819 }
820}

◆ 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 795 of file View.c.

795 {
796
797 Selector *selector = $(alloc(Selector), initWithRule, rule);
798 assert(selector);
799
800 $(selector, enumerateSelection, self, enumerator, data);
801 release(selector);
802}
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:795

◆ 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 826 of file View.c.

826 {
827
828 assert(enumerator);
829
830 if (self->superview) {
831
832 const Array *siblings = (Array *) self->superview->subviews;
833 for (size_t i = 0; i < siblings->count; i++) {
834 View *sibling = siblings->elements[i];
835 if (sibling != self) {
836 enumerator(sibling, data);
837 }
838 }
839 }
840}

◆ 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 846 of file View.c.

846 {
847
848 assert(enumerator);
849
850 const Array *subviews = (Array *) self->subviews;
851 for (size_t i = 0; i < subviews->count; i++) {
852 enumerator((View *) subviews->elements[i], data);
853 }
854}

◆ 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 860 of file View.c.

860 {
861
862 assert(enumerator);
863
864 if (self->superview) {
865 enumerator(self->superview, data);
866 }
867}

◆ 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 873 of file View.c.

873 {
874
875 if ($(self, isVisible) == false) {
876 return;
877 }
878
879 enumerator(self, data);
880
881 const Array *subviews = (Array *) self->subviews;
882 for (size_t i = 0; i < subviews->count; i++) {
883
884 View *subview = subviews->elements[i];
885 $(subview, enumerateVisible, enumerator, data);
886 }
887}
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 939 of file View.c.

939 {
940
941 Overflow overflow = {
942 .bounds = $(self, bounds)
943 };
944
945 $(self, enumerateSubviews, hasOverflow_enumerate, (ident) &overflow);
946
947 return overflow.hasOverflow;
948}
static void hasOverflow_enumerate(View *view, ident data)
ViewEnumerator for hasOverflow.
Definition View.c:917
SDL_Rect bounds
Definition View.c:910
bool hasOverflow
Definition View.c:911

◆ 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 954 of file View.c.

954 {
955
956 if (self->hidden == false) {
957
958 if ($(self, containsPoint, point)) {
959
960 const Array *subviews = (Array *) self->subviews;
961 for (size_t i = subviews->count; i; i--) {
962
963 const View *subview = subviews->elements[i - 1];
964 const View *view = $(subview, hitTest, point);
965 if (view) {
966 return (View *) view;
967 }
968 }
969
970 return (View *) self;
971 }
972 }
973
974 return NULL;
975}
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:954

◆ 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:989

◆ 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 989 of file View.c.

989 {
990
991 self = (View *) super(Object, self, init);
992 if (self) {
993
994 if (frame) {
995 self->frame = *frame;
996 }
997
998 self->classNames = $$(Set, setWithCapacity, 0);
999 assert(self->classNames);
1000
1001 self->computedStyle = $(alloc(Style), initWithAttributes, NULL);
1002 assert(self->computedStyle);
1003
1004 self->subviews = $$(Array, arrayWithCapacity, 0);
1005 assert(self->subviews);
1006
1007 self->style = $(alloc(Style), initWithAttributes, NULL);
1008 assert(self->style);
1009
1010 self->warnings = $$(Array, arrayWithCapacity, 0);
1011 assert(self->warnings);
1012
1013 self->maxSize = MakeSize(INT32_MAX, INT32_MAX);
1014
1015 self->needsApplyTheme = true;
1016 self->needsLayout = true;
1017 }
1018
1019 return self;
1020}
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 1033 of file View.c.

1033 {
1034 $(self, enumerate, invalidateStyle_enumerate, NULL);
1035}
static void invalidateStyle_enumerate(View *view, ident data)
ViewEnumerator for invalidateStyle.
Definition View.c:1025
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 1041 of file View.c.

1041 {
1043}
@ 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 1049 of file View.c.

1049 {
1050
1051 assert(view);
1052
1053 while (self) {
1054 if (self == view) {
1055 return true;
1056 }
1057 self = self->superview;
1058 }
1059
1060 return false;
1061}

◆ isKeyResponder()

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

Definition at line 1067 of file View.c.

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

◆ 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 1080 of file View.c.

1080 {
1081
1082 if (self->window) {
1083 return SDL_GetPointerProperty(SDL_GetWindowProperties(self->window), "touchResponder", NULL) == self;
1084 } else {
1085 return false;
1086 }
1087}

◆ 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 1093 of file View.c.

1093 {
1094
1095 for (const View *view = self; view; view = view->superview) {
1096 if (view->hidden) {
1097 return false;
1098 }
1099 }
1100
1101 return true;
1102}

◆ layoutIfNeeded()

void layoutIfNeeded ( View self)

Recursively updates the layout of this View and its subviews.

Parameters
selfThe View.

Definition at line 1115 of file View.c.

1115 {
1116
1118
1119 if (self->needsLayout) {
1120
1122
1123 $(self, layoutSubviews);
1124
1125 self->needsLayout = false;
1126 }
1127}
static void layoutIfNeeded_enumerate(View *subview, ident data)
ViewEnumerator for layoutIfNeeded recursion.
Definition View.c:1107
@ 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:1659

◆ 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 1262 of file View.c.

1262 {
1263
1264 $(self, willMoveToWindow, window);
1265
1266 self->window = window;
1267
1268 $(self, didMoveToWindow, window);
1269
1271}
static void moveToWindow_enumerate(View *subview, ident data)
ViewEnumerator for moveToWindow recursion.
Definition View.c:1254
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:651
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:1946

◆ path()

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

Definition at line 1277 of file View.c.

1277 {
1278
1279 Array *parts = $$(Array, array);
1280
1281 const View *view = self;
1282 while (view) {
1283
1284 Array *classNames = $((Set *) view->classNames, allObjects);
1285
1286 String *part;
1287 if (view->identifier) {
1288 part = str("#%s", view->identifier);
1289 } else if (classNames->count) {
1290 part = str(".%s", ((String *) $(classNames, firstObject))->chars);
1291 } else {
1292 part = str("%s", classnameof(view));
1293 }
1294
1295 release(classNames);
1296
1297 $(parts, insertObjectAtIndex, part, 0);
1298 release(part);
1299
1300 if (view->viewController) {
1301 break;
1302 }
1303
1304 view = view->superview;
1305 }
1306
1307 String *path = $((Array *) parts, componentsJoinedByCharacters, " > ");
1308
1309 release(parts);
1310
1311 return path;
1312}
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 1318 of file View.c.

1318 {
1319
1320 $(self->classNames, removeAllObjects);
1321
1322 $(self, invalidateStyle);
1323}

◆ removeAllSubviews()

void removeAllSubviews ( View self)

Removes all subviews from this View.

Parameters
selfThe View.

Definition at line 1336 of file View.c.

1336 {
1337 $(self->subviews, removeAllObjectsWithEnumerator, removeAllSubviews_enumerate, self);
1338}
static void removeAllSubviews_enumerate(const Array *array, ident obj, ident data)
ArrayEnumerator for removeAllSubviews.
Definition View.c:1328

◆ 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 1344 of file View.c.

1344 {
1345
1346 if (className) {
1347 String *string = $$(String, stringWithCharacters, className);
1348 assert(string);
1349
1350 $(self->classNames, removeObject, string);
1351 release(string);
1352
1353 $(self, invalidateStyle);
1354 }
1355}

◆ removeFromSuperview()

void removeFromSuperview ( View self)

Removes this View from its superview.

Parameters
selfThe View.

Definition at line 1361 of file View.c.

1361 {
1362
1363 if (self->superview) {
1364 $(self->superview, removeSubview, self);
1365 }
1366}
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:125
static void drawRect(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color)
Definition Renderer.c:169
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 440 of file Text.c.

440 {
441
442 Text *this = (Text *) self;
443
444 this->font->scale = view_pixel_density(self->window);
445 $(this->font, renderDeviceDidReset);
446
447 super(View, self, renderDeviceDidReset);
448}
static float view_pixel_density(SDL_Window *window)
Definition Text.c:34
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:440

◆ 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 1455 of file View.c.

1455 {
1456
1457 SDL_Rect frame = self->frame;
1458
1459 const View *view = self;
1460 const View *superview = view->superview;
1461 while (superview) {
1462
1463 frame.x += superview->frame.x;
1464 frame.y += superview->frame.y;
1465
1466 if (view->alignment != ViewAlignmentInternal) {
1468 frame.y += superview->padding.top;
1469 }
1470
1471 view = superview;
1472 superview = view->superview;
1473 }
1474
1475 return frame;
1476}
@ 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 1482 of file View.c.

1482 {
1483
1484 assert(subview);
1485 assert(replacement);
1486
1487 $(self, addSubviewRelativeTo, replacement, subview, ViewPositionAfter);
1488 $(self, removeSubview, subview);
1489}

◆ 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 1511 of file View.c.

1511 {
1512
1513 if (self->window && $(self, isTouchResponder)) {
1514
1515 String *path = $(self, path);
1516 MVC_LogDebug("%s\n", path->chars);
1517 release(path);
1518
1519 SDL_SetPointerProperty(SDL_GetWindowProperties(self->window), "touchResponder", NULL);
1520 }
1521}

◆ 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 1527 of file View.c.

1527 {
1528
1529 const int w = clamp(size->w, self->minSize.w, self->maxSize.w);
1530 const int h = clamp(size->h, self->minSize.h, self->maxSize.h);
1531
1532 if (self->frame.w != w || self->frame.h != h) {
1533
1534 self->frame.w = w;
1535 self->frame.h = h;
1536
1537 self->needsLayout = true;
1538
1539 if (self->superview && $(self->superview, isContainer)) {
1540 self->superview->needsLayout = true;
1541 }
1542 }
1543}
bool isContainer(const View *self)
Definition View.c:1041
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 1549 of file View.c.

1549 {
1550
1551 if (outlets) {
1552 for (Outlet *outlet = outlets; outlet->identifier; outlet++) {
1553 *outlet->view = $(self, descendantWithIdentifier, outlet->identifier);
1554 if (*outlet->view == NULL) {
1555 String *desc = $((Object *) self, description);
1556 MVC_LogError("Failed to resolve outlet '%s' for %s", outlet->identifier, desc->chars);
1557 release(desc);
1558 }
1559
1560 assert(*outlet->view);
1561 }
1562 }
1563}
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:77
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 1636 of file View.c.

1636 {
1637
1638 Selector *selector = $(alloc(Selector), initWithRule, rule);
1639 assert(selector);
1640
1641 View *first = $(selector, selectFirst, self);
1642
1643 release(selector);
1644 return first;
1645}
View * selectFirst(View *self, const char *rule)
Resolves the first descendant View that matches the given Selector rule.
Definition View.c:1636

◆ size()

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

Definition at line 1651 of file View.c.

1651 {
1652 return MakeSize(self->frame.w, self->frame.h);
1653}

◆ 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 1659 of file View.c.

1659 {
1660
1661 const SDL_Size size = $(self, size);
1662 const SDL_Size sizeThatFits = $(self, sizeThatFits);
1663
1664 return MakeSize(max(size.w, sizeThatFits.w), max(size.h, sizeThatFits.h));
1665}
void sizeThatFits(const View *self)
Definition Select.c:92

◆ sizeThatFills()

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

Definition at line 1671 of file View.c.

1671 {
1672 SDL_Size size;
1673
1674 if (self->superview == NULL) {
1675 SDL_GetWindowSize(self->window, &size.w, &size.h);
1676 } else {
1677 size = $(self->superview, size);
1678 }
1679
1680 return size;
1681}

◆ 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 92 of file Select.c.

92 {
93
94 const Select *this = (Select *) self;
95
96 SDL_Size size = super(View, self, sizeThatFits);
97
98 const Array *options = (Array *) this->options;
99 for (size_t i = 0; i < options->count; i++) {
100
101 const View *option = $(options, objectAtIndex, i);
102 const SDL_Size optionSize = $(option, sizeThatFits);
103
104 size.w = max(size.w, optionSize.w + self->padding.left + self->padding.right);
105 size.h = max(size.h, optionSize.h + self->padding.top + self->padding.bottom);
106 }
107
108 return size;
109}
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 1745 of file View.c.

1745 {
1746
1747 const SDL_Size size = $(self, sizeThatContains);
1748
1749 $(self, resize, &size);
1750}
void resize(View *self, const SDL_Size *size)
Resizes this View to the specified size.
Definition View.c:1527

◆ sizeToFill()

void sizeToFill ( View self)

Resizes this View to fill its superview.

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

Definition at line 1756 of file View.c.

1756 {
1757
1758 const SDL_Size size = $(self, sizeThatFills);
1759
1760 $(self, resize, &size);
1761}
SDL_Size sizeThatFills(const View *self)
Definition View.c:1671

◆ sizeToFit()

void sizeToFit ( View self)

Resizes this View to fit its subviews.

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

Definition at line 1767 of file View.c.

1767 {
1768
1769 const SDL_Size size = $(self, sizeThatFits);
1770
1771 $(self, resize, &size);
1772}

◆ 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 1778 of file View.c.

1778 {
1779
1780 assert(identifier);
1781
1782 const Array *subviews = (Array *) self->subviews;
1783 for (size_t i = 0; i < subviews->count; i++) {
1784
1785 View *subview = subviews->elements[i];
1786 if (subview->identifier) {
1787
1788 if (strcmp(identifier, subview->identifier) == 0) {
1789 return subview;
1790 }
1791 }
1792 }
1793
1794 return NULL;
1795}

◆ 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 1816 of file View.c.

1816 {
1817
1818 assert(self->window);
1819
1820 const SDL_Rect frame = $(self, renderFrame);
1821
1822 return MVC_TransformToWindow(self->window, &frame);
1823}
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 1829 of file View.c.

1829 {
1830
1831 Data *data = $$(Data, dataWithConstMemory, (ident) chars, strlen(chars));
1832
1833 View *view = $$(View, viewWithData, data, outlets);
1834
1835 release(data);
1836
1837 return view;
1838}
View * viewWithData(const Data *data, Outlet *outlets)
Instantiates a View initialized with the contents of data.
Definition View.c:1844

◆ 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 1844 of file View.c.

1844 {
1845
1846 JSONContext *ctx = $(alloc(JSONContext), init);
1847 Dictionary *dictionary = $(ctx, objectFromData, data, 0);
1848
1849 View *view = NULL;
1850 if (dictionary) {
1851 view = $$(View, viewWithDictionary, dictionary, outlets);
1852 release(dictionary);
1853 } else {
1854 MVC_LogError("Failed to parse JSON\n");
1855 }
1856
1857 release(ctx);
1858 return view;
1859}
View * viewWithDictionary(const Dictionary *dictionary, Outlet *outlets)
Instantiates a View initialized with the attributes described in dictionary.
Definition View.c:1865

◆ 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 1865 of file View.c.

1865 {
1866
1867 View *view = NULL;
1868
1869 BindInlet(&MakeInlet(NULL, InletTypeView, &view, NULL), dictionary);
1870
1871 $(view, resolve, outlets);
1872
1873 return view;
1874}
#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:1549

◆ 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 1880 of file View.c.

1880 {
1881
1882 assert(resource);
1883
1884 return $$(View, viewWithData, resource->data, outlets);
1885}

◆ 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 1891 of file View.c.

1891 {
1892
1893 Resource *resource = $$(Resource, resourceWithName, name);
1894
1895 View *view = $$(View, viewWithResource, resource, outlets);
1896
1897 release(resource);
1898
1899 return view;
1900}
View * viewWithResource(const Resource *resource, Outlet *outlets)
Instantiates a View initialized with the JSON data in resource.
Definition View.c:1880

◆ 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 1924 of file View.c.

1924 {
1925
1926 va_list args;
1927 va_start(args, fmt);
1928
1929 Warning *warning = $(alloc(Warning), initWithVaList, type, fmt, args);
1930
1931 va_end(args);
1932
1933 String *description = $((Object *) self, description);
1934 MVC_LogWarn("%s:: %s\n", description->chars, warning->message->chars);
1935 release(description);
1936
1937 $(self->warnings, addObject, warning);
1938
1939 release(warning);
1940}
#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 1946 of file View.c.

1946 {
1947
1948 if (self->window) {
1949 $(self, resignKeyResponder);
1950 $(self, resignTouchResponder);
1951 $(self, detachStylesheet, self->window);
1952 }
1953}
void detachStylesheet(View *self, SDL_Window *window)
Detaches this View's Stylesheet from the Theme associated with the given window.
Definition View.c:635

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: