Przeglądaj źródła

IDE editors will disable virtual scene rendering when hidden

Ivan Safrin 11 lat temu
rodzic
commit
47148ce4e0

+ 2 - 1
IDE/Contents/Include/PolycodeEditor.h

@@ -69,7 +69,8 @@ public:
 	
 	virtual void handleEvent(Event *event);
 
-	virtual void Activate() {};	
+	virtual void Activate() {};
+   	virtual void Deactivate() {};
 	virtual void saveFile(){};
 	
 	void didAction(String actionName, PolycodeEditorActionData *beforeData, PolycodeEditorActionData *afterData, bool setFileChanged = true);

+ 4 - 0
IDE/Contents/Include/PolycodeEntityEditor.h

@@ -194,6 +194,8 @@ class EntityEditorMainView : public UIElement {
             void selectNone(bool doAction);
             void selectAll(bool doAction);
     
+            SceneRenderTexture *getRenderTexture();
+    
             void onGainFocus();
             void onLoseFocus();
             void deleteSelected(bool doAction);
@@ -312,6 +314,8 @@ class PolycodeEntityEditor : public PolycodeEditor {
 		void Resize(int x, int y);
     
         void Activate();
+        void Deactivate();
+    
         void saveFile();
         void saveCurveToObject(ObjectEntry *entry, BezierCurve *curve);
         void saveShaderOptionsToEntry(ObjectEntry *entry, Material *material, ShaderBinding *binding);

+ 2 - 0
IDE/Contents/Include/PolycodeFrame.h

@@ -146,6 +146,8 @@ class EditorHolder : public UIElement {
 		ObjectEntry *getEditorHolderConfig();
 		void applyConfig(ObjectEntry *entry);
 		
+        void activateEditor(bool val);
+    
 		void handleEvent(Event *event);
 		void Resize(Number width, Number height);		
 		

+ 16 - 1
IDE/Contents/Include/PolycodeMaterialEditor.h

@@ -155,6 +155,9 @@ class CubemapEditorPane : public UIElement {
 		void handleEvent(Event *event);
 		Cubemap *currentCubemap;		
 		
+        void Activate();
+        void Deactivate();
+    
 	protected:
 	
 		PropList *propList;
@@ -181,6 +184,9 @@ class PostEditorPane : public UIElement {
 		void handleEvent(Event *event);
 		Material *currentMaterial;	
 		
+        void Activate();
+        void Deactivate();
+    
 		void adjustPreview();
 		
 		protected:
@@ -249,6 +255,10 @@ class MaterialEditorPane : public UIElement {
 	public:
 		MaterialEditorPane();
 		~MaterialEditorPane();
+    
+        void Activate();
+        void Deactivate();
+    
 		
 		void setMaterial(Material *material);
 		void handleEvent(Event *event);
@@ -279,6 +289,9 @@ class MaterialMainWindow : public UIElement {
 	MaterialMainWindow(ResourcePool *resourcePool);
 	~MaterialMainWindow();
 	
+    void Activate();
+    void Deactivate();
+    
 	void Resize(Number width, Number height);
 	
 	MaterialEditorPane *materialPane;
@@ -297,8 +310,10 @@ class PolycodeMaterialEditor : public PolycodeEditor {
 	bool openFile(OSFileEntry filePath);
 	void Resize(int x, int y);
 	
+    void Activate();
+    void Deactivate();
 	
-	void handleEvent(Event *event);	
+	void handleEvent(Event *event);
 	void saveFile();
 	void saveMaterials(ObjectEntry *materialsEntry, std::vector<Material*> materials);
 	

+ 3 - 0
IDE/Contents/Include/PolycodeMeshEditor.h

@@ -39,6 +39,9 @@ class PolycodeMeshEditor : public PolycodeEditor {
 		void handleEvent(Event *event);
 	
 		void reloadMaterials();
+    
+        void Activate();
+        void Deactivate();
 	
 		bool openFile(OSFileEntry filePath);
 		void Resize(int x, int y);

+ 11 - 0
IDE/Contents/Source/PolycodeEntityEditor.cpp

@@ -581,6 +581,10 @@ void EntityEditorMainView::doAction(String actionName, PolycodeEditorActionData
     }
 }
 
+SceneRenderTexture *EntityEditorMainView::getRenderTexture() {
+    return renderTexture;
+}
+
 void EntityEditorMainView::setEditorMode(int newMode) {
     editorMode = newMode;
     if(editorMode == EDITOR_MODE_3D) {
@@ -1680,6 +1684,13 @@ bool PolycodeEntityEditor::openFile(OSFileEntry filePath) {
 
 void PolycodeEntityEditor::Activate() {
     Resize(getWidth(), getHeight());
+    mainView->getMainScene()->enabled = true;
+    mainView->getRenderTexture()->enabled = true;
+}
+
+void PolycodeEntityEditor::Deactivate() {
+    mainView->getMainScene()->enabled = false;
+    mainView->getRenderTexture()->enabled = false;
 }
 
 void PolycodeEntityEditor::saveCurveToObject(ObjectEntry *entry, BezierCurve *curve) {

+ 21 - 2
IDE/Contents/Source/PolycodeFrame.cpp

@@ -538,6 +538,21 @@ EditorHolder::EditorHolder(PolycodeProject *project, PolycodeEditorManager *edit
     setOwnsChildrenRecursive(true);
 }
 
+void EditorHolder::activateEditor(bool val) {
+	if(firstChildHolder) {
+		firstChildHolder->activateEditor(val);
+		secondChildHolder->activateEditor(val);
+		return;
+	}
+    if(currentEditor) {
+        if(val) {
+            currentEditor->Activate();
+        } else {
+            currentEditor->Deactivate();
+        }
+    }
+}
+
 ObjectEntry *EditorHolder::getEditorHolderConfig() {
 	ObjectEntry *configEntry = new ObjectEntry();
 	configEntry->name = "editor_holder";
@@ -686,10 +701,12 @@ void EditorHolder::setEditor(PolycodeEditor *newEditor) {
 
 	if(currentEditor) {
 		removeChild(currentEditor);
+        currentEditor->Deactivate();
 		currentEditor->setEditorHolder(NULL);
 	}
 	currentEditor = newEditor;
-	if(currentEditor) {	
+	if(currentEditor) {
+        currentEditor->Activate();
 		EditorHolder *currentEditorHolder = currentEditor->getEditorHolder();
 		if(currentEditorHolder) {
 			currentEditorHolder->setEditor(NULL);
@@ -937,9 +954,11 @@ PolycodeProjectTab::PolycodeProjectTab(String caption, PolycodeProject *project,
 
 void PolycodeProjectTab::setActive(bool val) {
 	active = val;
+    editorHolder->activateEditor(val);
+    
 	if(!active) {
 		projectBrowser->removeAllHandlers();
-	}
+    }
 }
 
 bool PolycodeProjectTab::isActive() {

+ 53 - 0
IDE/Contents/Source/PolycodeMaterialEditor.cpp

@@ -94,6 +94,17 @@ PostEditorPane::PostEditorPane(ResourcePool *resourcePool) : UIElement() {
 		
 }
 
+void PostEditorPane::Activate() {
+    postPreview->previewScene->enabled = true;
+    postPreview->renderTexture->enabled = true;
+}
+
+void PostEditorPane::Deactivate() {
+    postPreview->previewScene->enabled = false;
+    postPreview->renderTexture->enabled = false;
+}
+
+
 PostEditorPane::~PostEditorPane() {
 
 }
@@ -247,6 +258,18 @@ CubemapEditorPane::CubemapEditorPane(ResourcePool *resourcePool) : UIElement() {
 	
 }
 
+
+void CubemapEditorPane::Activate() {
+    cubemapPreview->previewScene->enabled = true;
+    cubemapPreview->renderTexture->enabled = true;
+}
+
+void CubemapEditorPane::Deactivate() {
+    cubemapPreview->previewScene->enabled = false;
+    cubemapPreview->renderTexture->enabled = false;
+}
+
+
 void CubemapEditorPane::setCubemap(Cubemap *cubemap) {
 	enabled = true;
 	currentCubemap = cubemap;
@@ -941,6 +964,16 @@ void MaterialEditorPane::handleEvent(Event *event) {
 	}
 }
 
+void MaterialEditorPane::Activate() {
+    materialPreview->previewScene->enabled = true;
+    materialPreview->renderTexture->enabled = true;
+}
+
+void MaterialEditorPane::Deactivate() {
+    materialPreview->previewScene->enabled = false;
+    materialPreview->renderTexture->enabled = false;
+}
+
 void MaterialEditorPane::setMaterial(Material *material) {
 	changingMaterial = true;
 	
@@ -1002,6 +1035,18 @@ MaterialMainWindow::MaterialMainWindow(ResourcePool *resourcePool) : UIElement()
 	addChild(postPane);
 }
 
+void MaterialMainWindow::Activate() {
+    materialPane->Activate();
+    cubemapPane->Activate();
+    cubemapPane->Activate();
+}
+
+void MaterialMainWindow::Deactivate() {
+    materialPane->Deactivate();
+    cubemapPane->Deactivate();
+    cubemapPane->Deactivate();
+}
+
 MaterialMainWindow::~MaterialMainWindow() {
 }
 	
@@ -1116,6 +1161,14 @@ PolycodeMaterialEditor::PolycodeMaterialEditor() : PolycodeEditor(true){
 	selectedMaterialNode = NULL;
 }
 
+void PolycodeMaterialEditor::Activate() {
+    mainWindow->Activate();
+}
+
+void PolycodeMaterialEditor::Deactivate() {
+    mainWindow->Deactivate();
+}
+
 PolycodeMaterialEditor::~PolycodeMaterialEditor() {
     CoreServices::getInstance()->getResourceManager()->unsubscibeFromResourcePool(resourcePool);
     

+ 11 - 0
IDE/Contents/Source/PolycodeMeshEditor.cpp

@@ -79,6 +79,17 @@ PolycodeMeshEditor::PolycodeMeshEditor() : PolycodeEditor(true){
 	
 }
 
+void PolycodeMeshEditor::Activate() {
+    previewScene->enabled = true;
+    renderTexture->enabled = true;
+}
+
+void PolycodeMeshEditor::Deactivate() {
+    previewScene->enabled = false;
+    renderTexture->enabled = false;
+    
+}
+
 void PolycodeMeshEditor::reloadMaterials() {
 
 	Resource *selectedMaterial = NULL;