Mercurial > hg > orthanc-stone
comparison Samples/Sdl/TrackerSampleApp.cpp @ 750:284f37dc1c66
Wired undo redo to keys
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 21 May 2019 13:18:35 +0200 |
parents | 28b9e3a54200 |
children | a386bbc955dc |
comparison
equal
deleted
inserted
replaced
725:f8d582fc5731 | 750:284f37dc1c66 |
---|---|
164 { | 164 { |
165 int scancodeCount = 0; | 165 int scancodeCount = 0; |
166 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); | 166 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); |
167 | 167 |
168 if (activeTracker_.get() == NULL && | 168 if (activeTracker_.get() == NULL && |
169 SDL_SCANCODE_LCTRL < scancodeCount && | 169 SDL_SCANCODE_LALT < scancodeCount && |
170 keyboardState[SDL_SCANCODE_LCTRL]) | 170 keyboardState[SDL_SCANCODE_LALT]) |
171 { | 171 { |
172 // The "left-ctrl" key is down, while no tracker is present | 172 // The "left-ctrl" key is down, while no tracker is present |
173 // Let's display the info text | 173 // Let's display the info text |
174 PointerEvent e; | 174 PointerEvent e; |
175 e.AddPosition(compositor_->GetPixelCenterCoordinates( | 175 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
252 break; | 252 break; |
253 | 253 |
254 case SDLK_s: | 254 case SDLK_s: |
255 controller_->FitContent(compositor_->GetCanvasWidth(), | 255 controller_->FitContent(compositor_->GetCanvasWidth(), |
256 compositor_->GetCanvasHeight()); | 256 compositor_->GetCanvasHeight()); |
257 break; | |
258 | |
259 case SDLK_z: | |
260 LOG(INFO) << "SDLK_z has been pressed. event.key.keysym.mod == " << event.key.keysym.mod; | |
261 if (event.key.keysym.mod & KMOD_CTRL) | |
262 { | |
263 if (controller_->CanUndo()) | |
264 { | |
265 LOG(INFO) << "Undoing..."; | |
266 controller_->Undo(); | |
267 } | |
268 else | |
269 { | |
270 LOG(WARNING) << "Nothing to undo!!!"; | |
271 } | |
272 } | |
273 break; | |
274 | |
275 case SDLK_y: | |
276 LOG(INFO) << "SDLK_y has been pressed. event.key.keysym.mod == " << event.key.keysym.mod; | |
277 if (event.key.keysym.mod & KMOD_CTRL) | |
278 { | |
279 if (controller_->CanRedo()) | |
280 { | |
281 LOG(INFO) << "Redoing..."; | |
282 controller_->Redo(); | |
283 } | |
284 else | |
285 { | |
286 LOG(WARNING) << "Nothing to redo!!!"; | |
287 } | |
288 } | |
257 break; | 289 break; |
258 | 290 |
259 case SDLK_c: | 291 case SDLK_c: |
260 TakeScreenshot( | 292 TakeScreenshot( |
261 "screenshot.png", | 293 "screenshot.png", |