28#include "resize.png.h"
43 release(this->accessoryView);
44 release(this->contentView);
45 release(this->resizeHandle);
84 $(self,
bind, inlets, dictionary);
107 View *resizeHandle = (
View *) this->resizeHandle;
112 resizeHandle->
hidden = !this->isResizable;
115#pragma mark - Control
124 if (event->type == SDL_MOUSEMOTION && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LMASK)) {
129 this->isResizing =
true;
130 }
else if (this->isDraggable) {
132 this->isDragging =
true;
136 if (this->isResizing) {
139 size.
w = clamp(
size.
w + event->motion.xrel, this->minSize.w, this->maxSize.w);
140 size.
h = clamp(
size.
h + event->motion.yrel, this->minSize.h, this->maxSize.h);
143 }
else if (this->isDragging) {
144 self->
view.
frame.x +=
event->motion.xrel;
145 self->
view.
frame.y +=
event->motion.yrel;
151 if (event->type == SDL_MOUSEBUTTONUP && event->button.button == SDL_BUTTON_LEFT) {
152 self->
state &= ~ControlStateHighlighted;
153 this->isResizing = this->isDragging =
false;
173 if (accessoryView->
hidden ==
false) {
197 assert(self->stackView);
222 assert(self->resizeHandle);
235#pragma mark - Class lifecycle
242 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
244 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
246 ((ViewInterface *) clazz->interface)->init =
init;
249 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
251 ((PanelInterface *) clazz->interface)->contentSize =
contentSize;
252 ((PanelInterface *) clazz->interface)->initWithFrame =
initWithFrame;
273 clazz = _initialize(&(
const ClassDef) {
276 .instanceSize =
sizeof(
Panel),
277 .interfaceOffset = offsetof(
Panel, interface),
278 .interfaceSize =
sizeof(PanelInterface),
@ ControlStateHighlighted
static void destroy(Class *clazz)
static void dealloc(Object *self)
static void initialize(Class *clazz)
#define DEFAULT_PANEL_RESIZE_HANDLE_SIZE
#define MakeSize(w, h)
Creates an SDL_Size with the given dimensions.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
Box * initWithFrame(Box *self, const SDL_Rect *frame)
Initializes this Box with the given frame.
CollectionView * init(CollectionView *self, const SDL_Rect *frame)
Initializes this CollectionView with the specified frame and style.
Controls are Views which capture events and dispatch Actions.
_Bool captureEvent(Control *self, const SDL_Event *event)
Captures a given event, potentially altering the state of this Control.
Class * _Control(void)
The Control archetype.
unsigned int state
The bit mask of ControlState.
SDL_Size size(const Image *self)
Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length)
Initializes this Image with the specified bytes.
ImageViews render an Image in the context of a View hierarchy.
Inlets enable inbound data binding of View attributes through JSON.
Draggable and resizable container Views.
SDL_Size maxSize
The maximum size to which this Panel's frame can be resized.
_Bool isResizable
If true, this Panel may be resized by the user.
_Bool isDraggable
If true, this Panel may be repositioned by the user.
SDL_Size contentSize(const Panel *self)
StackView * accessoryView
The optional accessories container.
Class * _Panel(void)
The Panel archetype.
StackView * contentView
The internal container.
StackViews are containers that manage the arrangement of their subviews.
int spacing
The subview spacing.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
_Bool bind(View *self, const Inlet *inlets, const Dictionary *dictionary)
Performs data binding for the Inlets described in dictionary.
ViewAlignment alignment
The alignment.
_Bool hidden
If true, this View is not drawn.
void addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
void addClassName(View *self, const char *className)
Adds the given class name to this View.
void applyStyle(View *self, const Style *style)
Applies the given Style to this View.
void resize(View *self, const SDL_Size *size)
Resizes this View to the specified size.
_Bool didReceiveEvent(const View *self, const SDL_Event *event)
int autoresizingMask
The ViewAutoresizing bitmask.
void awakeWithDictionary(View *self, const Dictionary *dictionary)
Wakes this View with the specified Dictionary.
layoutSubviews(View *self)
Performs layout for this View's immediate subviews.
SDL_Size sizeThatContains(const View *self)
SDL_Rect frame
The frame, relative to the superview.