From 1e1811ff48c1376657d844f08bd301ce0f37a73e Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Thu, 7 Aug 2014 14:45:32 -0400 Subject: [PATCH 1/1] ecere/gui/3D Desktop; samples/orbitWithMouse: Fixes to run in window with native decorations --- ecere/src/gui/Window.ec | 40 ++++++++++++++++++++--------- samples/3D/orbitWithMouse/orbitWithMouse.ec | 22 +++++++++++----- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/ecere/src/gui/Window.ec b/ecere/src/gui/Window.ec index aef3075..5fa4cf2 100644 --- a/ecere/src/gui/Window.ec +++ b/ecere/src/gui/Window.ec @@ -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; */ } } diff --git a/samples/3D/orbitWithMouse/orbitWithMouse.ec b/samples/3D/orbitWithMouse/orbitWithMouse.ec index 6ba501a..e62c5f0 100644 --- a/samples/3D/orbitWithMouse/orbitWithMouse.ec +++ b/samples/3D/orbitWithMouse/orbitWithMouse.ec @@ -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 -- 1.8.3.1