131 {
132
134
135 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
137 if (this->isResizable && !this->isDragging) {
138 this->isResizing = true;
139 }
140 return true;
141 }
142 }
143
144 if (event->type == SDL_EVENT_MOUSE_MOTION) {
145
146 if (event->motion.state & SDL_BUTTON_LEFT) {
148
149 if (this->isResizing || this->isDraggable) {
150
151
152
153
154
155 this->gestureResidual.x += event->motion.xrel;
156 this->gestureResidual.y += event->motion.yrel;
157
158 const int dx = (int) this->gestureResidual.x;
159 const int dy = (int) this->gestureResidual.y;
160
161 this->gestureResidual.x -= dx;
162 this->gestureResidual.y -= dy;
163
164 if (this->isResizing) {
166
169
171
172 } else {
173 this->isDragging = true;
174
177
178
179
181 }
182
183 return true;
184 }
185 } else {
186 self->
state &= ~ControlStateHighlighted;
187 this->isResizing = this->isDragging = false;
188 this->gestureResidual.x = this->gestureResidual.y = 0.f;
189 }
190 }
191
193}
@ ControlStateHighlighted
static SDL_Size size(const Image *self)
static bool captureEvent(Control *self, const SDL_Event *event)
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)
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.
SDL_Rect frame
The frame, relative to the superview.