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);
111 View *contentView = (
View *) this->contentView;
117 View *resizeHandle = (
View *) this->resizeHandle;
126#pragma mark - Control
135 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
137 if (this->isResizable && !this->isDragging) {
138 this->isResizing =
true;
144 if (event->type == SDL_EVENT_MOUSE_MOTION) {
146 if (event->motion.state & SDL_BUTTON_LEFT) {
149 if (this->isResizing || this->isDraggable) {
155 this->gestureResidual.x +=
event->motion.xrel;
156 this->gestureResidual.y +=
event->motion.yrel;
158 const int dx = (int) this->gestureResidual.x;
159 const int dy = (int) this->gestureResidual.y;
161 this->gestureResidual.x -= dx;
162 this->gestureResidual.y -= dy;
164 if (this->isResizing) {
173 this->isDragging =
true;
186 self->
state &= ~ControlStateHighlighted;
187 this->isResizing = this->isDragging =
false;
188 this->gestureResidual.x = this->gestureResidual.y = 0.f;
210 size.h -= accessorySize.h + self->stackView->
spacing;
230 assert(self->stackView);
254 assert(self->resizeHandle);
267#pragma mark - Class lifecycle
274 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
277 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
279 ((ViewInterface *) clazz->interface)->init =
init;
282 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
284 ((PanelInterface *) clazz->interface)->contentSize =
contentSize;
285 ((PanelInterface *) clazz->interface)->initWithFrame =
initWithFrame;
306 clazz = _initialize(&(
const ClassDef) {
309 .instanceSize =
sizeof(
Panel),
310 .interfaceSize =
sizeof(PanelInterface),
static AtlasImage * initWithImage(AtlasImage *self, ImageAtlas *atlas, Image *image)
@ ControlStateHighlighted
static Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length, float pixelDensity)
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)
void MVC_InvalidateRenderFrames(void)
Invalidates every View's cached View::renderFrame and View::clippingFrame.
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static SDL_Size sizeThatContains(const View *self)
static void setVisibility(View *self, ViewVisibility visibility)
static void layoutWithSize(View *self, const SDL_Size *size)
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.
int autoresizingMask
The ViewAutoresizing bitmask.
bool acceptsKeyResponder(const View *self)
layoutSubviews(View *self)
Arranges this View's immediate subviews within its (already final) frame.
ViewVisibility visibility
Whether this View is drawn, and contributes to its superview's size.
SDL_Rect frame
The frame, relative to the superview.