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;
135 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
137 if (this->isResizable && !this->isDragging) {
138 this->isResizing =
true;
145 if (event->type == SDL_EVENT_MOUSE_MOTION) {
147 if (event->motion.state & SDL_BUTTON_LEFT) {
148 if (this->isResizing || this->isDraggable) {
154 this->gestureResidual.x +=
event->motion.xrel;
155 this->gestureResidual.y +=
event->motion.yrel;
157 const int dx = (int) this->gestureResidual.x;
158 const int dy = (int) this->gestureResidual.y;
160 this->gestureResidual.x -= dx;
161 this->gestureResidual.y -= dy;
163 if (this->isResizing) {
172 this->isDragging =
true;
180 self->needsApplyStyle =
true;
192 this->isResizing = this->isDragging =
false;
193 this->gestureResidual.x = this->gestureResidual.y = 0.f;
197 bool consumed =
false;
198 if (event->type == SDL_EVENT_MOUSE_BUTTON_UP && event->button.button == SDL_BUTTON_LEFT) {
199 consumed = this->isDragging || this->isResizing;
200 this->isResizing = this->isDragging =
false;
201 this->gestureResidual.x = this->gestureResidual.y = 0.f;
206 return consumed || bubbled;
224 size.h -= accessorySize.h + self->stackView->
spacing;
244 assert(self->stackView);
268 assert(self->resizeHandle);
281#pragma mark - Class lifecycle
288 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
291 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
293 ((ViewInterface *) clazz->interface)->init =
init;
294 ((ViewInterface *) clazz->interface)->layoutSubviews =
layoutSubviews;
296 ((ViewInterface *) clazz->interface)->respondToEvent =
respondToEvent;
298 ((PanelInterface *) clazz->interface)->contentSize =
contentSize;
299 ((PanelInterface *) clazz->interface)->initWithFrame =
initWithFrame;
320 clazz = _initialize(&(
const ClassDef) {
322 .superclass =
_View(),
323 .instanceSize =
sizeof(
Panel),
324 .interfaceSize =
sizeof(PanelInterface),
static AtlasImage * initWithImage(AtlasImage *self, ImageAtlas *atlas, Image *image)
static void initialize(Class *clazz)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static void dealloc(Object *self)
static Box * initWithFrame(Box *self, const SDL_Rect *frame)
static void layoutSubviews(View *self)
static void destroy(Class *clazz)
static void applyStyle(View *self, const Style *style)
static bool acceptsKeyResponder(const View *self)
static bool respondToEvent(View *self, const SDL_Event *event)
static Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length, float pixelDensity)
static SDL_Size size(const Image *self)
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 bool respondToEvent(View *self, const SDL_Event *event)
static void applyStyle(View *self, const Style *style)
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
static void addIntegerAttribute(Style *self, const char *attr, int value)
static void addEnumAttribute(Style *self, const char *attr, const EnumName *names, int value)
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
const EnumName ViewAlignmentNames[]
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 void setVisibility(View *self, ViewVisibility visibility)
static void layoutWithSize(View *self, const SDL_Size *size)
static void setNeedsApplyTheme(View *self)
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.
Panel * initWithFrame(Panel *self, const SDL_Rect *frame)
Initializes this Panel with the specified frame and style.
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.
Style * style
The element-level Style of this View.
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.
int autoresizingMask
The ViewAutoresizing bitmask.
SDL_Size size(const View *self)
SDL_Size sizeThatContains(const View *self)
SDL_Rect frame
The frame, relative to the superview.