26#include <Objectively/Data.h>
27#include <Objectively/Enum.h>
28#include <Objectively/Dictionary.h>
29#include <Objectively/Array.h>
30#include <Objectively/Set.h>
31#include <Objectively/Resource.h>
44#define ViewAlignmentMaskTop 0x1
45#define ViewAlignmentMaskMiddle 0x2
46#define ViewAlignmentMaskBottom 0x4
47#define ViewAlignmentMaskLeft 0x8
48#define ViewAlignmentMaskCenter 0x10
49#define ViewAlignmentMaskRight 0x20
50#define ViewAlignmentMaskInternal 0x100
52#define ViewAlignmentMaskVertical \
53 (ViewAlignmentMaskTop | ViewAlignmentMaskMiddle | ViewAlignmentMaskBottom)
55#define ViewAlignmentMaskHorizontal \
56 (ViewAlignmentMaskLeft | ViewAlignmentMaskCenter | ViewAlignmentMaskRight)
58#define ViewAlignmentMaskAny \
59 (ViewAlignmentMaskHorizontal | ViewAlignmentMaskVertical)
103#define ClampSize(size, min, max) \
104 clamp((size), (min), (max) ? (max) : INT32_MAX)
151 ViewConstraintUnspecified
163#define MakeConstraint(mode, value) \
164 (ViewConstraint) { (mode), (value) }
176#define MakePadding(top, right, bottom, left) \
177 (ViewPadding) { (top), (right), (bottom), (left) }
182#define AddPadding(a, b) \
183 MakePadding(a.top + b.top, a.right + b.right, a.bottom + b.bottom, a.left + b.left)
198#define MakeCornerCut(topLeft, topRight, bottomRight, bottomLeft) \
199 (ViewCornerCut) { (topLeft), (topRight), (bottomRight), (bottomLeft) }
204#define CornerCutIsEmpty(cut) \
205 ((cut).topLeft == 0 && (cut).topRight == 0 && (cut).bottomRight == 0 && (cut).bottomLeft == 0)
215typedef struct ViewInterface ViewInterface;
303 } clippingFrameCache;
362 bool needsApplyStyle;
370 bool needsApplyThemeSubviews;
385 bool needsLayoutSubviews;
486struct ViewInterface {
491 ObjectInterface parentInterface;
499 bool (*acceptsKeyResponder)(
const View *self);
507 bool (*acceptsTouchResponder)(
const View *self);
516 void (*addClassName)(
View *self,
const char *className);
526 void (*addSubview)(
View *self,
View *subview);
546 View *(*ancestorWithIdentifier)(
const View *self,
const char *identifier);
555 void (*applyStyle)(
View *self,
const Style *style);
582 void (*attachStylesheet)(
View *self, SDL_Window *window);
592 void (*awakeWithCharacters)(
View *self,
const char *chars);
602 void (*awakeWithData)(
View *self,
const Data *data);
613 void (*awakeWithDictionary)(
View *self,
const Dictionary *dictionary);
622 void (*awakeWithResource)(
View *self,
const Resource *resource);
631 void (*awakeWithResourceName)(
View *self,
const char *
name);
640 void (*becomeKeyResponder)(
View *self);
649 void (*becomeTouchResponder)(
View *self);
661 bool (*bind)(
View *self,
const Inlet *inlets,
const Dictionary *dictionary);
669 SDL_Rect (*bounds)(
const View *self);
678 void (*bringSubviewToFront)(
View *self,
View *subview);
697 SDL_Rect (*clippingFrame)(
const View *self);
706 bool (*containsPoint)(
const View *self,
const SDL_Point *point);
714 int (*depth)(
const View *self);
723 View *(*descendantWithIdentifier)(
const View *self,
const char *identifier);
732 void (*detachStylesheet)(
View *self, SDL_Window *window);
741 void (*didMoveToWindow)(
View *self, SDL_Window *window);
750 bool (*didReceiveEvent)(
const View *self,
const SDL_Event *event);
774 void (*emitViewEvent)(
View *self,
ViewEvent code, ident data);
814 void (*enumerateDescendants)(
const View *self,
ViewEnumerator enumerator, ident data);
825 void (*enumerateSelection)(
View *self,
const char *rule,
ViewEnumerator enumerator, ident data);
875 bool (*hasClassName)(
const View *self,
const char *className);
883 bool (*hasOverflow)(
const View *self);
895 View *(*hitTest)(
const View *self,
const SDL_Point *point);
918 View *(*initWithFrame)(
View *self,
const SDL_Rect *frame);
926 void (*invalidateStyle)(
View *self);
934 bool (*isContainer)(
const View *self);
943 bool (*isDescendantOfView)(
const View *self,
const View *view);
951 bool (*isKeyResponder)(
const View *self);
959 bool (*isTouchResponder)(
const View *self);
967 bool (*isVisible)(
const View *self);
979 void (*layoutIfNeeded)(
View *self);
991 void (*layoutSubviews)(
View *self);
1017 void (*layoutWithSize)(
View *self,
const SDL_Size *size);
1035 void (*moveToWindow)(
View *self, SDL_Window *window);
1043 String *(*path)(
const View *self);
1051 void (*removeAllClassNames)(
View *self);
1059 void (*removeAllSubviews)(
View *self);
1068 void (*removeClassName)(
View *self,
const char *className);
1076 void (*removeFromSuperview)(
View *self);
1085 void (*removeSubview)(
View *self,
View *subview);
1105 void (*renderDeviceDidReset)(
View *self);
1114 void (*renderDeviceWillReset)(
View *self);
1122 SDL_Rect (*renderFrame)(
const View *self);
1132 void (*replaceSubview)(
View *self,
View *subview,
View *replacement);
1140 void (*resignKeyResponder)(
View *self);
1148 void (*resignTouchResponder)(
View *self);
1159 void (*resize)(
View *self,
const SDL_Size *size);
1168 void (*resolve)(
View *self,
Outlet *outlets);
1177 void (*respondToEvent)(
View *self,
const SDL_Event *event);
1187 Set *(*select)(
View *self,
const char *rule);
1197 View *(*selectFirst)(
View *self,
const char *rule);
1220 void (*setNeedsApplyTheme)(
View *self);
1231 void (*setNeedsLayout)(
View *self);
1239 SDL_Size (*size)(
const View *self);
1248 SDL_Size (*sizeThatContains)(
const View *self);
1260 SDL_Size (*sizeThatFits)(
const View *self);
1268 SDL_Size (*sizeThatFills)(
const View *self);
1290 void (*sizeToContain)(
View *self);
1299 void (*sizeToFill)(
View *self);
1308 void (*sizeToFit)(
View *self);
1328 View *(*subviewWithIdentifier)(
const View *self,
const char *identifier);
1346 void (*updateBindings)(
View *self, ident data);
1354 SDL_Rect (*viewport)(
const View *self);
1365 View *(*viewWithCharacters)(
const char *chars,
Outlet *outlets);
1376 View *(*viewWithData)(
const Data *data,
Outlet *outlets);
1388 View *(*viewWithDictionary)(
const Dictionary *dictionary,
Outlet *outlets);
1400 View *(*viewWithResource)(
const Resource *resource,
Outlet *outlets);
1412 View *(*viewWithResourceName)(
const char *
name,
Outlet *outlets);
1421 Array *(*visibleSubviews)(
const View *self);
1440 void (*willMoveToWindow)(
View *self, SDL_Window *window);
static String * name(const Font *self)
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
static Theme * theme(SDL_Window *window)
ViewEvent
View event relay codes.
void(* ViewEnumerator)(View *view, ident data)
A function type for View enumeration.
#define OBJECTIVELYMVC_EXPORT
JSON data binding for Views.
#define ViewAlignmentMaskInternal
#define ViewAlignmentMaskCenter
OBJECTIVELYMVC_EXPORT const EnumName ViewPointerEventsNames[]
ViewPointerEvents
Whether a View is the result of a hit test.
OBJECTIVELYMVC_EXPORT Class * _View(void)
OBJECTIVELYMVC_EXPORT void MVC_InvalidateRenderFrames(void)
Invalidates every View's cached View::renderFrame and View::clippingFrame.
#define ViewAlignmentMaskLeft
#define ViewAlignmentMaskBottom
#define ViewAlignmentMaskTop
#define ViewAlignmentMaskRight
#define ViewAlignmentMaskMiddle
ViewVisibility
Visibility constants.
@ ViewVisibilityUnspecified
ViewPosition
Relative positioning of subviews within their superview.
OBJECTIVELYMVC_EXPORT const EnumName ViewVisibilityNames[]
OBJECTIVELYMVC_EXPORT const EnumName ViewAlignmentNames[]
OBJECTIVELYMVC_EXPORT const EnumName ViewAutoresizingNames[]
ViewAutoresizing
Auto-resizing constants, which are bitmasked.
@ ViewAutoresizingContain
ViewAlignment
Alignment constants, used to align a View within its superview.
@ ViewAlignmentBottomRight
@ ViewAlignmentBottomLeft
@ ViewAlignmentMiddleCenter
@ ViewAlignmentMiddleRight
@ ViewAlignmentMiddleLeft
@ ViewAlignmentBottomCenter
Warnings are accumulated on Views so that they may be reported by the DebugViewController.
WarningType
Warning types.
Inlets enable inbound data binding of View attributes through JSON.
Outlets enable outbound data binding of Views through JSON.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
Stylesheets are comprised of Selectors and Styles.
A constraint offered by an ancestor View to a descendant during View::sizeThatSatisfies.
int value
The constraint value; a size in pixels.
@ ViewConstraintMax
The offered value is an upper bound; the View may resolve to any size up to it.
@ ViewConstraintEqual
The offered value is final; the View must resolve to exactly this size.
A ViewController manages a View and its descendants.
The horizontal inset of each of a View's corners.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Stylesheet * stylesheet
An optional Stylesheet.
bool clipsSubviews
If true, subviews will be clipped to this View's frame.
View * superview
The super View.
Array * subviews
The immediate subviews.
ViewController * viewController
The ViewController.
Style * style
The element-level Style of this View.
ViewAlignment alignment
The alignment.
SDL_Window * window
The window.
bool needsApplyTheme
If true, this View will apply the Theme before it is drawn.
ViewCornerCut cornerCut
The horizontal inset of each corner of the background and border.
SDL_Color borderColor
The border color.
int autoresizingMask
The ViewAutoresizing bitmask.
View * nextResponder
The next responder, or event handler, in the chain.
ViewPointerEvents pointerEvents
Whether this View is the result of a hit test; its subviews always are.
bool needsLayout
If true, this View will layout its subviews before it is drawn.
char * identifier
An optional identifier.
Array * warnings
The Warnings this View generated.
ViewPadding padding
The padding.
int borderWidth
The border width.
SDL_Size minSize
The minimum size this View may be resized to during layout.
int backgroundGradientAngle
The angle of the background gradient, in degrees, clockwise from south: 0 (the default) fills downwar...
Object object
The superclass.
Style * computedStyle
The computed Style of this View.
Set * classNames
The class names.
ViewVisibility visibility
Whether this View is drawn, and contributes to its superview's size.
int borderRadius
The corner radius applied to the background, border and bevel.
SDL_Color backgroundGradientColor
The far color of the background gradient, which runs from View::backgroundColor.
SDL_Size maxSize
The maximum size this View may be resized to during layout.
SDL_Color backgroundColor
The background color.
bool stretch
Whether this View takes a share of the space its StackView leaves along its axis.
SDL_Rect frame
The frame, relative to the superview.
ViewInterface * interface[0]
The interface type.
Spacing applied to the inside of a View's frame.