129 {
130
132
133 if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
135 if (this->isResizable && !this->isDragging) {
136 this->isResizing = true;
137 }
138 return true;
139 }
140 }
141
142 if (event->type == SDL_EVENT_MOUSE_MOTION) {
143
144 if (event->motion.state & SDL_BUTTON_LEFT) {
146
147 if (this->isResizing || this->isDraggable) {
148
149
150
151
152
153 this->gestureResidual.x += event->motion.xrel;
154 this->gestureResidual.y += event->motion.yrel;
155
156 const int dx = (int) this->gestureResidual.x;
157 const int dy = (int) this->gestureResidual.y;
158
159 this->gestureResidual.x -= dx;
160 this->gestureResidual.y -= dy;
161
162 if (this->isResizing) {
164
167
169
170 } else {
171 this->isDragging = true;
172
175 }
176
177 return true;
178 }
179 } else {
180 self->
state &= ~ControlStateHighlighted;
181 this->isResizing = this->isDragging = false;
182 this->gestureResidual.x = this->gestureResidual.y = 0.f;
183 }
184 }
185
187}
@ 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)
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.