ecere/gui/3D Desktop; samples/orbitWithMouse: Fixes to run in window with native...
authorJerome St-Louis <jerome@ecere.com>
Thu, 7 Aug 2014 18:45:32 +0000 (14:45 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 7 Aug 2014 18:45:32 +0000 (14:45 -0400)
ecere/src/gui/Window.ec
samples/3D/orbitWithMouse/orbitWithMouse.ec

index aef3075..5fa4cf2 100644 (file)
@@ -767,13 +767,21 @@ private:
 
             if(rootWindow.is3D)
             {
-               x += rootWindow.parent.clientStart.x;
-               y += rootWindow.parent.clientStart.y;
+               int dx = rootWindow.parent.parent.clientStart.x;
+               int dy = rootWindow.parent.parent.clientStart.y;
+               if(!rootWindow.parent.nativeDecorations)
+               {
+                  dx += rootWindow.parent.clientStart.x;
+                  dy += rootWindow.parent.clientStart.y;
+               }
+               x += dx;
+               y += dy;
+
                /*
-               mox.left += rootWindow.parent.clientStart.x;
-               mox.top += rootWindow.parent.clientStart.y;
-               mox.right += rootWindow.parent.clientStart.x;
-               mox.bottom += rootWindow.parent.clientStart.y;
+               mox.left += dx;
+               mox.top += dy;
+               mox.right += dx;
+               mox.bottom += dy;
                */
             }
          }
@@ -814,13 +822,21 @@ private:
             y -= rootWindow.absPosition.y;
             if(rootWindow.is3D)
             {
-               x += rootWindow.parent.clientStart.x;
-               y += rootWindow.parent.clientStart.y;
+               int dx = rootWindow.parent.parent.clientStart.x;
+               int dy = rootWindow.parent.parent.clientStart.y;
+               if(!rootWindow.parent.nativeDecorations)
+               {
+                  dx += rootWindow.parent.clientStart.x;
+                  dy += rootWindow.parent.clientStart.y;
+               }
+               x += dx;
+               y += dy;
+
                /*
-               mox.left += rootWindow.parent.clientStart.x;
-               mox.top += rootWindow.parent.clientStart.y;
-               mox.right += rootWindow.parent.clientStart.x;
-               mox.bottom += rootWindow.parent.clientStart.y;
+               mox.left += dx;
+               mox.top += dy;
+               mox.right += dx;
+               mox.bottom += dy;
                */
             }
          }
index 6ba501a..e62c5f0 100644 (file)
@@ -6,7 +6,7 @@ import "ecere"
 
 #define SCALE ((float)virtualDesktop.clientSize.h / WINDOW_HEIGHT)
 
-//#define FULLSCREEN
+// #define FULLSCREEN
 
 class Window3D : struct
 {
@@ -287,7 +287,11 @@ class Desktop3D : Window
 #ifdef FULLSCREEN
    anchor = { 0, 0, 0, 0 };
 #else
-   size = Size { WINDOW_WIDTH, WINDOW_HEIGHT };
+   clientSize = { WINDOW_WIDTH, WINDOW_HEIGHT };
+   //nativeDecorations = false;
+   hasClose = true;
+   borderStyle = sizable;
+   hasMaximize = true;
 #endif
 
    Object lookAt {};
@@ -1122,8 +1126,8 @@ class Desktop3D : Window
                   {
                      EditBox
                      {
-                        this, multiLine = true, is3D = true, borderStyle = Fixed, hasClose = true, text = "Video",
-                        size = Size { WINDOW_WIDTH, WINDOW_HEIGHT }fileName = ":430.flc"
+                        this, multiLine = true, is3D = true, borderStyle = fixed, hasClose = true, //text = "EditBox",
+                        size = Size { WINDOW_WIDTH, WINDOW_HEIGHT } //fileName = ":430.flc"
                      }.Create();
                   }
                   else*/
@@ -1131,7 +1135,7 @@ class Desktop3D : Window
                      Picture
                      {
                         this, is3D = true, borderStyle = fixed, hasClose = true, text = "3D Window",
-                        size = Size { WINDOW_WIDTH, WINDOW_HEIGHT }, image = BitmapResource { fileName = shotFileNames[id] }, opacity = 1, inactive = false
+                        size = { WINDOW_WIDTH, WINDOW_HEIGHT }, image = BitmapResource { fileName = shotFileNames[id] }, opacity = 1, inactive = false
                      }.Create();
                   }
                   id++;
@@ -1295,6 +1299,9 @@ static void Update3DWindow(Window window, Box box)
    Window3D window3D = Desktop3DGetWindowHandle(window);
    int w = box.right - box.left + 1;
    int h = box.bottom - box.top + 1;
+   int offset = 0;
+   if(!virtualDesktop.nativeDecorations)
+      offset = (virtualDesktop.size.h - 1 - virtualDesktop.clientStart.y - virtualDesktop.clientSize.h);
 
    glBindTexture(GL_TEXTURE_2D, (int)(intptr)window3D.bitmap.driverData);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -1303,8 +1310,9 @@ static void Update3DWindow(Window window, Box box)
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
       box.left,
       window.size.h - h - box.top,
-      box.left + virtualDesktop.clientStart.x,
-      virtualDesktop.size.h - virtualDesktop.clientStart.y - h - box.top, w, h);
+      box.left + virtualDesktop.nativeDecorations ? 0 : virtualDesktop.clientStart.x,
+
+      virtualDesktop.clientSize.h - h - box.top + offset, w, h);
 }
 
 class Orbit : GuiApplication