Marko Pintera před 11 roky
rodič
revize
abc644c627

+ 14 - 0
BansheeEditor/Source/BsEditorApplication.cpp

@@ -261,6 +261,20 @@ namespace BansheeEditor
 		gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
 		gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
 		gMainSyncedCA().submitToCoreThread(true);
 		gMainSyncedCA().submitToCoreThread(true);
 
 
+		RENDER_WINDOW_DESC modalWindowDesc;
+		modalWindowDesc.width = 200;
+		modalWindowDesc.height = 200;
+		modalWindowDesc.left = 0;
+		modalWindowDesc.top = 0;
+		modalWindowDesc.title = "ModalWindow";
+		modalWindowDesc.fullscreen = false;
+		modalWindowDesc.border = WindowBorder::None;
+		modalWindowDesc.toolWindow = true;
+		modalWindowDesc.modal = true;
+
+		RenderWindowPtr modalWindow = RenderWindow::create(modalWindowDesc, gApplication().getPrimaryWindow());
+
+
 		/************************************************************************/
 		/************************************************************************/
 		/* 							END DEBUG CODE                      		*/
 		/* 							END DEBUG CODE                      		*/
 		/************************************************************************/
 		/************************************************************************/

+ 9 - 3
CamelotCore/Include/CmRenderWindow.h

@@ -47,7 +47,7 @@ namespace CamelotFramework
 			, displayFrequency(60), colorDepth(32), depthBuffer(true)
 			, displayFrequency(60), colorDepth(32), depthBuffer(true)
 			, FSAA(0), FSAAHint(""), gamma(false), left(-1), top(-1)
 			, FSAA(0), FSAAHint(""), gamma(false), left(-1), top(-1)
 			, title(""), border(WindowBorder::Normal), outerDimensions(false), enableDoubleClick(true)
 			, title(""), border(WindowBorder::Normal), outerDimensions(false), enableDoubleClick(true)
-			, monitorIndex(-1), toolWindow(false)
+			, monitorIndex(-1), toolWindow(false), modal(false)
 		{ }
 		{ }
 
 
 		UINT32 width;
 		UINT32 width;
@@ -69,7 +69,8 @@ namespace CamelotFramework
 		bool outerDimensions;
 		bool outerDimensions;
 		bool enableDoubleClick;
 		bool enableDoubleClick;
 		bool toolWindow;
 		bool toolWindow;
-		UINT32 monitorIndex; // -1 == select based on coordinates
+		bool modal;
+		INT32 monitorIndex; // -1 == select based on coordinates
 
 
 		NameValuePairList platformSpecific;
 		NameValuePairList platformSpecific;
 	};
 	};
@@ -108,7 +109,7 @@ namespace CamelotFramework
         /**
         /**
          * @brief	Indicates whether the window is visible (not minimized or obscured).
          * @brief	Indicates whether the window is visible (not minimized or obscured).
          */
          */
-        virtual bool isVisible(void) const { return true; }
+        virtual bool isVisible() const { return true; }
 
 
         /** 
         /** 
         * @copydoc RenderTarget::isActive
         * @copydoc RenderTarget::isActive
@@ -125,6 +126,11 @@ namespace CamelotFramework
 		*/
 		*/
         virtual bool isFullScreen() const;
         virtual bool isFullScreen() const;
 
 
+		/**
+		 * @brief	Returns true if the window is modal.
+		 */
+		bool isModal() const { return mDesc.modal; }
+
 		INT32 getLeft() const { return mLeft; }
 		INT32 getLeft() const { return mLeft; }
 		INT32 getTop() const { return mTop; }
 		INT32 getTop() const { return mTop; }
 
 

+ 1 - 0
CamelotCore/Include/Win32/CmPlatformImpl.h

@@ -259,6 +259,7 @@ namespace CamelotFramework
 
 
 		static bool mIsTrackingMouse;
 		static bool mIsTrackingMouse;
 		static Vector<RenderWindow*>::type mMouseLeftWindows;
 		static Vector<RenderWindow*>::type mMouseLeftWindows;
+		static Stack<RenderWindow*>::type mModalWindowStack;
 
 
 		static NativeDropTargetData mDropTargets;
 		static NativeDropTargetData mDropTargets;
 
 

+ 82 - 0
CamelotCore/Source/CmPlatformWndProc.cpp

@@ -3,6 +3,7 @@
 #include "CmApplication.h"
 #include "CmApplication.h"
 #include "CmInput.h"
 #include "CmInput.h"
 #include "CmDebug.h"
 #include "CmDebug.h"
+#include "CmRenderWindowManager.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -14,6 +15,35 @@ namespace CamelotFramework
 		if (uMsg == WM_CREATE)
 		if (uMsg == WM_CREATE)
 		{	// Store pointer to Win32Window in user data area
 		{	// Store pointer to Win32Window in user data area
 			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
 			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
+
+			RenderWindow* newWindow = (RenderWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+			if(newWindow->isModal())
+			{
+				if(!mModalWindowStack.empty())
+				{
+					RenderWindow* curModalWindow = mModalWindowStack.top();
+
+					HWND curHwnd;
+					curModalWindow->getCustomAttribute("WINDOW", &curHwnd);
+					EnableWindow(curHwnd, FALSE);
+				}
+				else
+				{
+					Vector<RenderWindow*>::type renderWindows = RenderWindowManager::instance().getRenderWindows();
+					for(auto& renderWindow : renderWindows)
+					{
+						if(renderWindow == newWindow)
+							continue;
+
+						HWND curHwnd;
+						renderWindow->getCustomAttribute("WINDOW", &curHwnd);
+						EnableWindow(curHwnd, FALSE);
+					}
+				}
+
+				mModalWindowStack.push(newWindow);
+			}
+
 			return 0;
 			return 0;
 		}
 		}
 
 
@@ -31,6 +61,58 @@ namespace CamelotFramework
 				if( active )
 				if( active )
 					win->setActive(true);
 					win->setActive(true);
 
 
+				break;
+			}
+		case WM_DESTROY:
+			{
+				bool reenableWindows = false;
+				if(!mModalWindowStack.empty())
+				{
+					if(mModalWindowStack.top() == win) // This is the most common case, top-most modal was closed
+					{
+						mModalWindowStack.pop();
+					}
+					else // Possibly some other window was closed somehow, see if it was modal and remove from stack if it is
+					{
+						Stack<RenderWindow*>::type newStack;
+
+						while(!mModalWindowStack.empty())
+						{
+							RenderWindow* curWindow = mModalWindowStack.top();
+							mModalWindowStack.pop();
+
+							if(curWindow == win)
+								continue;
+
+							newStack.push(curWindow);
+						}
+
+						mModalWindowStack = newStack;
+					}
+
+					if(!mModalWindowStack.empty()) // Enable next modal window
+					{
+						RenderWindow* curModalWindow = mModalWindowStack.top();
+
+						HWND curHwnd;
+						curModalWindow->getCustomAttribute("WINDOW", &curHwnd);
+						EnableWindow(curHwnd, TRUE);
+					}
+					else
+						reenableWindows = true; // No more modal windows, re-enable any remaining window
+				}
+
+				if(reenableWindows)
+				{
+					Vector<RenderWindow*>::type renderWindows = RenderWindowManager::instance().getRenderWindows();
+					for(auto& renderWindow : renderWindows)
+					{
+						HWND curHwnd;
+						renderWindow->getCustomAttribute("WINDOW", &curHwnd);
+						EnableWindow(curHwnd, TRUE);
+					}
+				}
+
 				break;
 				break;
 			}
 			}
 		case WM_SETFOCUS:
 		case WM_SETFOCUS:

+ 2 - 0
CamelotCore/Source/Win32/CmPlatformImpl.cpp

@@ -27,6 +27,8 @@ namespace CamelotFramework
 	bool Platform::mIsTrackingMouse = false;
 	bool Platform::mIsTrackingMouse = false;
 	Vector<RenderWindow*>::type Platform::mMouseLeftWindows;
 	Vector<RenderWindow*>::type Platform::mMouseLeftWindows;
 
 
+	Stack<RenderWindow*>::type Platform::mModalWindowStack;
+
 	NativeDropTargetData Platform::mDropTargets;
 	NativeDropTargetData Platform::mDropTargets;
 
 
 	bool Platform::mRequiresStartUp = false;
 	bool Platform::mRequiresStartUp = false;

+ 0 - 2
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -89,8 +89,6 @@ namespace BansheeEditor
 					const String& className = curClass->getFullName();
 					const String& className = curClass->getFullName();
 					EditorWidgetManager::instance().registerWidget(className, 
 					EditorWidgetManager::instance().registerWidget(className, 
 						std::bind(&ScriptEditorWindow::openEditorWidgetCallback, curClass->getNamespace(), curClass->getTypeName(), std::placeholders::_1));
 						std::bind(&ScriptEditorWindow::openEditorWidgetCallback, curClass->getNamespace(), curClass->getTypeName(), std::placeholders::_1));
-
-					EditorWidgetManager::instance().open(className);
 				}
 				}
 			}
 			}
 		}
 		}