MCPcopy Create free account
hub / github.com/arrayfire/forge / pollEvents

Method pollEvents

src/backend/opengl/sdl/window.cpp:245–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245void Widget::pollEvents()
246{
247 static const float SPEED = 0.005f;
248 SDL_Event evnt;
249
250 while (SDL_PollEvent(&evnt)) {
251 /* handle window events that are triggered
252 when the window with window id 'mWindowId' is in focus
253 */
254 if (evnt.key.windowID == mWindowId) {
255 if (evnt.type == SDL_WINDOWEVENT) {
256 switch(evnt.window.event) {
257 case SDL_WINDOWEVENT_CLOSE:
258 mClose = true;
259 break;
260 case SDL_WINDOWEVENT_RESIZED:
261 mWidth = evnt.window.data1;
262 mHeight = evnt.window.data2;
263 resizePixelBuffers();
264 break;
265 }
266 }
267
268 if (evnt.type == SDL_KEYDOWN) {
269 switch(evnt.key.keysym.sym) {
270 case SDLK_ESCAPE:
271 mClose = true; break;
272 default:
273 mMod = evnt.key.keysym.sym;
274 break;
275 }
276 } else if (evnt.type == SDL_KEYUP) {
277 mMod = -1;
278 }
279
280 int x, y;
281 SDL_GetMouseState(&x, &y);
282 // reset UI transforms upon mouse middle click
283 if(evnt.type == SDL_MOUSEBUTTONUP) {
284 if(evnt.button.button == SDL_BUTTON_MIDDLE &&
285 (mMod == SDLK_LCTRL || mMod==SDLK_RCTRL)) {
286 setCellViewMatrix(x, y, IDENTITY);
287 setCellOrientationMatrix(x, y, IDENTITY);
288 }
289 }
290
291 const glm::mat4 viewMat = getCellViewMatrix(x, y);
292
293 if(evnt.type == SDL_MOUSEMOTION) {
294 if(evnt.motion.state == SDL_BUTTON_LMASK) {
295 double deltaX = -evnt.motion.xrel;
296 double deltaY = -evnt.motion.yrel;
297
298 glm::mat4 vMat(1);
299
300 if (mMod==SDLK_LALT || mMod==SDLK_RALT || mMod==SDLK_LCTRL || mMod==SDLK_RCTRL) {
301 // Zoom
302 if(deltaY != 0) {

Callers 2

drawMethod · 0.45
swapBuffersMethod · 0.45

Calls 1

trackballPointFunction · 0.85

Tested by

no test coverage detected