28#include "../Assets/resize.png.h"
43 release(this->accessoryView);
44 release(this->contentView);
45 release(this->resizeHandle);
46 release(this->stackView);
74 $(self, bind, inlets, (Dictionary *) style->
attributes);
92 $(self, bind, inlets, dictionary);
116 View *resizeHandle = (
View *) this->resizeHandle;
121 resizeHandle->
hidden = !this->isResizable;
124#pragma mark - Control
133 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
135 if (this->isResizable && !this->isDragging) {
136 this->isResizing =
true;
142 if (event->type == SDL_EVENT_MOUSE_MOTION) {
144 if (event->motion.state & SDL_BUTTON_LEFT) {
147 if (this->isResizing || this->isDraggable) {
153 this->gestureResidual.x +=
event->motion.xrel;
154 this->gestureResidual.y +=
event->motion.yrel;
156 const int dx = (int) this->gestureResidual.x;
157 const int dy = (int) this->gestureResidual.y;
159 this->gestureResidual.x -= dx;
160 this->gestureResidual.y -= dy;
162 if (this->isResizing) {
171 this->isDragging =
true;
180 self->
state &= ~ControlStateHighlighted;
181 this->isResizing = this->isDragging =
false;
182 this->gestureResidual.x = this->gestureResidual.y = 0.f;
202 if (accessoryView->
hidden ==
false) {
204 size.h -= accessorySize.h + self->stackView->
spacing;
224 assert(self->stackView);
249 assert(self->resizeHandle);
262#pragma mark - Class lifecycle
269 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
272 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
274 ((ViewInterface *) clazz->interface)->init =
init;
277 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
279 ((PanelInterface *) clazz->interface)->contentSize =
contentSize;
280 ((PanelInterface *) clazz->interface)->initWithFrame =
initWithFrame;
301 clazz = _initialize(&(
const ClassDef) {
304 .instanceSize =
sizeof(
Panel),
305 .interfaceOffset = offsetof(
Panel, interface),
306 .interfaceSize =
sizeof(PanelInterface),
@ ControlStateHighlighted
static Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length)
static SDL_Size size(const Image *self)
static void addSubview(View *self, View *subview)
static void destroy(Class *clazz)
static SDL_Size contentSize(const Panel *self)
static bool acceptsKeyResponder(const View *self)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static void applyStyle(View *self, const Style *style)
static bool captureEvent(Control *self, const SDL_Event *event)
static Panel * initWithFrame(Panel *self, const SDL_Rect *frame)
static void dealloc(Object *self)
static void initialize(Class *clazz)
static void layoutSubviews(View *self)
#define DEFAULT_PANEL_RESIZE_HANDLE_SIZE
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static void addClassName(View *self, const char *className)
static void resize(View *self, const SDL_Size *size)
static void layoutIfNeeded(View *self)
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static SDL_Size sizeThatContains(const View *self)
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.
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.
bool isResizable
If true, this Panel may be resized by the user.
StackView * accessoryView
The optional accessories container.
bool isDraggable
If true, this Panel may be repositioned by the user.
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.
ViewAlignment alignment
The alignment.
int autoresizingMask
The ViewAutoresizing bitmask.
bool acceptsKeyResponder(const View *self)
layoutSubviews(View *self)
Performs layout for this View's immediate subviews.
SDL_Rect frame
The frame, relative to the superview.
bool hidden
If true, this View is not drawn.