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)
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;
546 View *(*ancestorWithIdentifier)(
const View *self,
const char *identifier);
661 bool (*bind)(
View *self,
const Inlet *inlets,
const Dictionary *dictionary);
723 View *(*descendantWithIdentifier)(
const View *self,
const char *identifier);
895 View *(*hitTest)(
const View *self,
const SDL_Point *point);
918 View *(*initWithFrame)(
View *self,
const SDL_Rect *frame);
1043 String *(*path)(
const View *self);
1190 Set *(*select)(
View *self,
const char *rule);
1200 View *(*selectFirst)(
View *self,
const char *rule);
1242 SDL_Size (*
size)(
const View *self);
1331 View *(*subviewWithIdentifier)(
const View *self,
const char *identifier);
1368 View *(*viewWithCharacters)(
const char *chars,
Outlet *outlets);
1379 View *(*viewWithData)(
const Data *data,
Outlet *outlets);
1391 View *(*viewWithDictionary)(
const Dictionary *dictionary,
Outlet *outlets);
1403 View *(*viewWithResource)(
const Resource *resource,
Outlet *outlets);
1415 View *(*viewWithResourceName)(
const char *
name,
Outlet *outlets);
1424 Array *(*visibleSubviews)(
const View *self);
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static void layoutSubviews(View *self)
static bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)
static void applyStyle(View *self, const Style *style)
static void becomeKeyResponder(View *self)
static bool acceptsKeyResponder(const View *self)
static bool respondToEvent(View *self, const SDL_Event *event)
static void render(View *self, Renderer *renderer)
static void resignKeyResponder(View *self)
static bool acceptsTouchResponder(const View *self)
static String * name(const Font *self)
static void updateBindings(View *self, ident data)
static SDL_Size size(const Image *self)
static void renderDeviceWillReset(ImageAtlas *self)
static void didMoveToWindow(View *self, SDL_Window *window)
static bool isVisible(const NavigationViewController *self)
True while the NavigationViewController is appearing or visible.
static void removeSubview(View *self, View *subview)
static void addSubview(View *self, View *subview)
static void renderDeviceDidReset(Renderer *self)
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
static SDL_Size sizeThatFits(const View *self)
static void enumerateSelection(const Selector *self, View *view, ViewEnumerator enumerator, ident data)
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.
const EnumName ViewAlignmentNames[]
static void removeClassName(View *self, const char *className)
static void addClassName(View *self, const char *className)
static bool isContainer(const View *self)
static void addSubviewRelativeTo(View *self, View *subview, View *other, ViewPosition position)
static bool isDescendantOfView(const View *self, const View *view)
static void resize(View *self, const SDL_Size *size)
static SDL_Size sizeThatSatisfies(View *self, ViewConstraint width, ViewConstraint height)
static void detachStylesheet(View *self, SDL_Window *window)
static bool isTouchResponder(const View *self)
const EnumName ViewPointerEventsNames[]
static void layoutIfNeeded(View *self)
static void sizeToContain(View *self)
static void enumerateAncestors(const View *self, ViewEnumerator enumerator, ident data)
static void clearWarnings(const View *self, WarningType type)
static int depth(const View *self)
static void enumerateVisible(View *self, ViewEnumerator enumerator, ident data)
static void draw(View *self, Renderer *renderer)
static SDL_Size sizeThatFills(const View *self)
static void removeAllClassNames(View *self)
static void enumerateSubviews(const View *self, ViewEnumerator enumerator, ident data)
static void layoutWithConstraint(View *self, ViewConstraint width, ViewConstraint height)
static void becomeTouchResponder(View *self)
static void resignTouchResponder(View *self)
static void replaceSubview(View *self, View *subview, View *replacement)
static void bringSubviewToFront(View *self, View *subview)
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static bool hasOverflow(const View *self)
static void invalidateStyle(View *self)
static void sizeToFill(View *self)
static void sizeToSatisfy(View *self, ViewConstraint width, ViewConstraint height)
static void warn(View *self, WarningType type, const char *fmt,...)
static void setNeedsLayout(View *self)
static void awakeWithCharacters(View *self, const char *chars)
static void moveToWindow(View *self, SDL_Window *window)
static void removeFromSuperview(View *self)
static void removeAllSubviews(View *self)
static SDL_Size sizeThatContains(const View *self)
static void applyTheme(View *self, const Theme *theme)
static void setVisibility(View *self, ViewVisibility visibility)
static void awakeWithResourceName(View *self, const char *name)
static void layoutWithSize(View *self, const SDL_Size *size)
static void setNeedsApplyTheme(View *self)
static SDL_Rect renderFrame(const View *self)
const EnumName ViewAutoresizingNames[]
static void willMoveToWindow(View *self, SDL_Window *window)
static void attachStylesheet(View *self, SDL_Window *window)
static bool isKeyResponder(const View *self)
static void awakeWithResource(View *self, const Resource *resource)
static void enumerateSuperview(const View *self, ViewEnumerator enumerator, ident data)
static void enumerate(View *self, ViewEnumerator enumerator, ident data)
static void enumerateAdjacent(const View *self, ViewEnumerator enumerator, ident data)
static SDL_Rect viewport(const View *self)
static bool hasClassName(const View *self, const char *className)
static void applyThemeIfNeeded(View *self, const Theme *theme)
static bool containsPoint(const View *self, const SDL_Point *point)
static void sizeToFit(View *self)
static SDL_Rect clippingFrame(const View *self)
static void enumerateSiblings(const View *self, ViewEnumerator enumerator, ident data)
const EnumName ViewVisibilityNames[]
static void awakeWithData(View *self, const Data *data)
static void enumerateDescendants(const View *self, ViewEnumerator enumerator, ident data)
static SDL_Rect bounds(const View *self)
static void resolve(View *self, Outlet *outlets)
static void emitViewEvent(View *self, ViewEvent code, ident data)
#define ViewAlignmentMaskInternal
#define ViewAlignmentMaskCenter
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.
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.
@ ViewConstraintMax
The offered value is an upper bound; the View may resolve to any size up to it.
@ ViewConstraintUnspecified
No bound is offered; the ancestor is itself unresolved for this axis.
@ ViewConstraintEqual
The offered value is final; the View must resolve to exactly this size.
int value
The constraint value; a size in pixels.
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.