Browse Source

Better modal window test case

Marko Pintera 11 years ago
parent
commit
053df91815

+ 2 - 0
BansheeEditor/Include/BsEditorApplication.h

@@ -32,5 +32,7 @@ namespace BansheeEditor
 
 		EditorWidgetLayoutPtr loadWidgetLayout();
 		void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
+
+		static void closeModalWindow(CM::RenderWindowPtr window, CM::HSceneObject sceneObject);
 	};
 }

+ 30 - 0
BansheeEditor/Source/BsEditorApplication.cpp

@@ -30,6 +30,11 @@
 #include "BsVirtualInput.h"
 #include "CmWin32FolderMonitor.h"
 #include "BsProjectLibrary.h"
+#include "BsCamera.h"
+#include "BsGUIWidget.h"
+#include "BsGUIArea.h"
+#include "BsGUIButton.h"
+#include "BsGUILayout.h"
 
 using namespace CamelotFramework;
 using namespace BansheeEngine;
@@ -274,6 +279,25 @@ namespace BansheeEditor
 
 		RenderWindowPtr modalWindow = RenderWindow::create(modalWindowDesc, gApplication().getPrimaryWindow());
 
+		HSceneObject modalSceneObject = SceneObject::create("ModalWindow");
+
+		HCamera modalCamera = modalSceneObject->addComponent<Camera>();
+		modalCamera->initialize(modalWindow, 0.0f, 0.0f, 1.0f, 1.0f);
+		modalCamera->setNearClipDistance(5);
+		modalCamera->setAspectRatio(1.0f);
+		modalCamera->setIgnoreSceneRenderables(true);
+
+		HGUIWidget modalGUI = modalSceneObject->addComponent<GUIWidget>(modalCamera->getViewport().get());
+		modalGUI->setDepth(128);
+
+		modalGUI->setSkin(EditorGUI::instance().getSkin());
+
+		GUIArea* modalArea = GUIArea::createStretchedXY(*modalGUI, 0, 0, 0, 0, 500);
+		GUIButton* modalButton = GUIButton::create(*modalGUI, HString(L"Close"));
+		modalButton->onClick.connect(boost::bind(&EditorApplication::closeModalWindow, modalWindow, modalSceneObject));
+
+		modalArea->getLayout().addElement(modalButton);
+
 
 		/************************************************************************/
 		/* 							END DEBUG CODE                      		*/
@@ -332,6 +356,12 @@ namespace BansheeEditor
 
 	}
 
+	void EditorApplication::closeModalWindow(RenderWindowPtr window, CM::HSceneObject sceneObject)
+	{
+		sceneObject->destroy();
+		window->destroy();
+	}
+
 	EditorApplication::~EditorApplication()
 	{
 		// TODO - Move shutdown code from constructor to here. Right now I don't care because cleanup 

+ 2 - 1
CamelotCore/Include/CmCoreObject.h

@@ -23,7 +23,8 @@ namespace CamelotFramework
 			CGO_INITIALIZED = 0x01,
 			CGO_INIT_ON_RENDER_THREAD = 0x02,
 			CGO_SCHEDULED_FOR_INIT = 0x04,
-			CGO_SCHEDULED_FOR_DELETE = 0x08
+			CGO_SCHEDULED_FOR_DELETE = 0x08,
+			CGO_DESTROYED = 0x16
 		};
 
 	public:

+ 0 - 2
EditorWindowDock.txt

@@ -14,8 +14,6 @@ Polish TOOD:
 
 ------------------------
 
-Docked widgets are not shown anymore
-
 LATER:
  get rid of CmApplication gMainCA and similar methods. Users may access CoreThread singleton directly now
  get rid of CoreAccessor::submitToCoreThread and instead leave that functionally only available to CoreThread