120 {
121
123
124 if (event->type == SDL_MOUSEMOTION && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LMASK)) {
125
129 this->isResizing = true;
130 } else if (this->isDraggable) {
132 this->isDragging = true;
133 }
134 }
135
136 if (this->isResizing) {
138
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);
141
143 } else if (this->isDragging) {
144 self->
view.
frame.x +=
event->motion.xrel;
145 self->
view.
frame.y +=
event->motion.yrel;
146 }
147
148 return true;
149 }
150
151 if (event->type == SDL_MOUSEBUTTONUP && event->button.button == SDL_BUTTON_LEFT) {
152 self->
state &= ~ControlStateHighlighted;
153 this->isResizing = this->isDragging = false;
154 return true;
155 }
156
158}
@ ControlStateHighlighted
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.
unsigned int state
The bit mask of ControlState.
SDL_Size size(const Image *self)
void resize(View *self, const SDL_Size *size)
Resizes this View to the specified size.
_Bool didReceiveEvent(const View *self, const SDL_Event *event)
SDL_Rect frame
The frame, relative to the superview.