changeset 750:284f37dc1c66

Wired undo redo to keys
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 21 May 2019 13:18:35 +0200
parents f8d582fc5731
children 712ff6ff3c19
files Samples/Sdl/TrackerSampleApp.cpp
diffstat 1 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/Sdl/TrackerSampleApp.cpp	Tue May 21 10:39:51 2019 +0200
+++ b/Samples/Sdl/TrackerSampleApp.cpp	Tue May 21 13:18:35 2019 +0200
@@ -166,8 +166,8 @@
       const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
 
       if (activeTracker_.get() == NULL &&
-        SDL_SCANCODE_LCTRL < scancodeCount &&
-        keyboardState[SDL_SCANCODE_LCTRL])
+        SDL_SCANCODE_LALT < scancodeCount &&
+        keyboardState[SDL_SCANCODE_LALT])
       {
         // The "left-ctrl" key is down, while no tracker is present
         // Let's display the info text
@@ -256,6 +256,38 @@
           compositor_->GetCanvasHeight());
         break;
 
+      case SDLK_z:
+        LOG(INFO) << "SDLK_z has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
+        if (event.key.keysym.mod & KMOD_CTRL)
+        {
+          if (controller_->CanUndo())
+          {
+            LOG(INFO) << "Undoing...";
+            controller_->Undo();
+          }
+          else
+          {
+            LOG(WARNING) << "Nothing to undo!!!";
+          }
+        }
+        break;
+
+      case SDLK_y:
+        LOG(INFO) << "SDLK_y has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
+        if (event.key.keysym.mod & KMOD_CTRL)
+        {
+          if (controller_->CanRedo())
+          {
+            LOG(INFO) << "Redoing...";
+            controller_->Redo();
+          }
+          else
+          {
+            LOG(WARNING) << "Nothing to redo!!!";
+          }
+        }
+        break;
+
       case SDLK_c:
         TakeScreenshot(
           "screenshot.png",