diff Applications/Generic/GuiAdapter.cpp @ 879:12b591d5d63c am-dev

some Qt integration (wip)
author Alain Mazy <alain@mazy.be>
date Fri, 05 Jul 2019 14:52:43 +0200
parents e3c56d4f863f
children 9953f16c304d
line wrap: on
line diff
--- a/Applications/Generic/GuiAdapter.cpp	Wed Jul 03 10:26:51 2019 +0200
+++ b/Applications/Generic/GuiAdapter.cpp	Fri Jul 05 14:52:43 2019 +0200
@@ -41,14 +41,14 @@
     widgets_.push_back(widget);
   }
 
-  std::ostream& operator<<(
-    std::ostream& os, const GuiAdapterKeyboardEvent& event)
-  {
-    os << "ctrl: " << event.ctrlKey << ", " <<
-      "shift: " << event.shiftKey << ", " <<
-      "alt: " << event.altKey;
-    return os;
-  }
+  std::ostream& operator<<(
+    std::ostream& os, const GuiAdapterKeyboardEvent& event)
+  {
+    os << "ctrl: " << event.ctrlKey << ", " <<
+      "shift: " << event.shiftKey << ", " <<
+      "alt: " << event.altKey;
+    return os;
+  }
 
 #if ORTHANC_ENABLE_WASM == 1
   void GuiAdapter::Run()
@@ -434,15 +434,15 @@
   switch (source.button.button)
   {
   case SDL_BUTTON_MIDDLE:
-    dest.button = 1;
+    dest.button = GUIADAPTER_MOUSEBUTTON_MIDDLE;
     break;
 
   case SDL_BUTTON_RIGHT:
-    dest.button = 2;
+    dest.button = GUIADAPTER_MOUSEBUTTON_RIGHT;
     break;
 
   case SDL_BUTTON_LEFT:
-    dest.button = 0;
+    dest.button = GUIADAPTER_MOUSEBUTTON_LEFT;
     break;
 
   default:
@@ -544,14 +544,14 @@
 
     // the SDL window name IS the canvas name ("canvas" is used because this lib
     // is designed for Wasm
-    SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
-    ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!");
+    SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
+    ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!");
 
     const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
-    ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!");
+    ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!");
 
     std::string windowTitle(windowTitleSz);
-    ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!");
+    ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!");
 
     switch (event.mouse.type)
     {
@@ -573,14 +573,14 @@
   {
     // the SDL window name IS the canvas name ("canvas" is used because this lib
     // is designed for Wasm
-    SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
-    ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!");
+    SDL_Window* sdlWindow = SDL_GetWindowFromID(windowID);
+    ORTHANC_ASSERT(sdlWindow != NULL, "Window ID \"" << windowID << "\" is not a valid SDL window ID!");
      
     const char* windowTitleSz = SDL_GetWindowTitle(sdlWindow);
-    ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!");
+    ORTHANC_ASSERT(windowTitleSz != NULL, "Window ID \"" << windowID << "\" has a NULL window title!");
 
     std::string windowTitle(windowTitleSz);
-    ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!");
+    ORTHANC_ASSERT(windowTitle != "", "Window ID \"" << windowID << "\" has an empty window title!");
 
     switch (event.type)
     {
@@ -715,8 +715,8 @@
           }
 #endif
         }
-        else if (event.type == SDL_MOUSEWHEEL)
-        {
+        else if (event.type == SDL_MOUSEWHEEL)
+        {
 
           int scancodeCount = 0;
           const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
@@ -737,21 +737,21 @@
 
           GuiAdapterWheelEvent dest;
           ConvertFromPlatform(dest, ctrlPressed, shiftPressed, altPressed, event);
-          OnMouseWheelEvent(event.window.windowID, dest);
-
-          //KeyboardModifiers modifiers = GetKeyboardModifiers(keyboardState, scancodeCount);
-
-          //int x, y;
-          //SDL_GetMouseState(&x, &y);
-
-          //if (event.wheel.y > 0)
-          //{
-          //  locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Up, x, y, modifiers);
-          //}
-          //else if (event.wheel.y < 0)
-          //{
-          //  locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Down, x, y, modifiers);
-          //}
+          OnMouseWheelEvent(event.window.windowID, dest);
+
+          //KeyboardModifiers modifiers = GetKeyboardModifiers(keyboardState, scancodeCount);
+
+          //int x, y;
+          //SDL_GetMouseState(&x, &y);
+
+          //if (event.wheel.y > 0)
+          //{
+          //  locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Up, x, y, modifiers);
+          //}
+          //else if (event.wheel.y < 0)
+          //{
+          //  locker.GetCentralViewport().MouseWheel(MouseWheelDirection_Down, x, y, modifiers);
+          //}
         }
         else if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
         {