Skip to content

Commit 47148ce

Browse files
committed
IDE editors will disable virtual scene rendering when hidden
1 parent f3a8991 commit 47148ce

File tree

9 files changed

+123
-4
lines changed

9 files changed

+123
-4
lines changed

IDE/Contents/Include/PolycodeEditor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class PolycodeEditor : public UIElement, public ClipboardProvider {
6969

7070
virtual void handleEvent(Event *event);
7171

72-
virtual void Activate() {};
72+
virtual void Activate() {};
73+
virtual void Deactivate() {};
7374
virtual void saveFile(){};
7475

7576
void didAction(String actionName, PolycodeEditorActionData *beforeData, PolycodeEditorActionData *afterData, bool setFileChanged = true);

IDE/Contents/Include/PolycodeEntityEditor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class EntityEditorMainView : public UIElement {
194194
void selectNone(bool doAction);
195195
void selectAll(bool doAction);
196196

197+
SceneRenderTexture *getRenderTexture();
198+
197199
void onGainFocus();
198200
void onLoseFocus();
199201
void deleteSelected(bool doAction);
@@ -312,6 +314,8 @@ class PolycodeEntityEditor : public PolycodeEditor {
312314
void Resize(int x, int y);
313315

314316
void Activate();
317+
void Deactivate();
318+
315319
void saveFile();
316320
void saveCurveToObject(ObjectEntry *entry, BezierCurve *curve);
317321
void saveShaderOptionsToEntry(ObjectEntry *entry, Material *material, ShaderBinding *binding);

IDE/Contents/Include/PolycodeFrame.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class EditorHolder : public UIElement {
146146
ObjectEntry *getEditorHolderConfig();
147147
void applyConfig(ObjectEntry *entry);
148148

149+
void activateEditor(bool val);
150+
149151
void handleEvent(Event *event);
150152
void Resize(Number width, Number height);
151153

IDE/Contents/Include/PolycodeMaterialEditor.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class CubemapEditorPane : public UIElement {
155155
void handleEvent(Event *event);
156156
Cubemap *currentCubemap;
157157

158+
void Activate();
159+
void Deactivate();
160+
158161
protected:
159162

160163
PropList *propList;
@@ -181,6 +184,9 @@ class PostEditorPane : public UIElement {
181184
void handleEvent(Event *event);
182185
Material *currentMaterial;
183186

187+
void Activate();
188+
void Deactivate();
189+
184190
void adjustPreview();
185191

186192
protected:
@@ -249,6 +255,10 @@ class MaterialEditorPane : public UIElement {
249255
public:
250256
MaterialEditorPane();
251257
~MaterialEditorPane();
258+
259+
void Activate();
260+
void Deactivate();
261+
252262

253263
void setMaterial(Material *material);
254264
void handleEvent(Event *event);
@@ -279,6 +289,9 @@ class MaterialMainWindow : public UIElement {
279289
MaterialMainWindow(ResourcePool *resourcePool);
280290
~MaterialMainWindow();
281291

292+
void Activate();
293+
void Deactivate();
294+
282295
void Resize(Number width, Number height);
283296

284297
MaterialEditorPane *materialPane;
@@ -297,8 +310,10 @@ class PolycodeMaterialEditor : public PolycodeEditor {
297310
bool openFile(OSFileEntry filePath);
298311
void Resize(int x, int y);
299312

313+
void Activate();
314+
void Deactivate();
300315

301-
void handleEvent(Event *event);
316+
void handleEvent(Event *event);
302317
void saveFile();
303318
void saveMaterials(ObjectEntry *materialsEntry, std::vector<Material*> materials);
304319

IDE/Contents/Include/PolycodeMeshEditor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class PolycodeMeshEditor : public PolycodeEditor {
3939
void handleEvent(Event *event);
4040

4141
void reloadMaterials();
42+
43+
void Activate();
44+
void Deactivate();
4245

4346
bool openFile(OSFileEntry filePath);
4447
void Resize(int x, int y);

IDE/Contents/Source/PolycodeEntityEditor.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ void EntityEditorMainView::doAction(String actionName, PolycodeEditorActionData
581581
}
582582
}
583583

584+
SceneRenderTexture *EntityEditorMainView::getRenderTexture() {
585+
return renderTexture;
586+
}
587+
584588
void EntityEditorMainView::setEditorMode(int newMode) {
585589
editorMode = newMode;
586590
if(editorMode == EDITOR_MODE_3D) {
@@ -1680,6 +1684,13 @@ bool PolycodeEntityEditor::openFile(OSFileEntry filePath) {
16801684

16811685
void PolycodeEntityEditor::Activate() {
16821686
Resize(getWidth(), getHeight());
1687+
mainView->getMainScene()->enabled = true;
1688+
mainView->getRenderTexture()->enabled = true;
1689+
}
1690+
1691+
void PolycodeEntityEditor::Deactivate() {
1692+
mainView->getMainScene()->enabled = false;
1693+
mainView->getRenderTexture()->enabled = false;
16831694
}
16841695

16851696
void PolycodeEntityEditor::saveCurveToObject(ObjectEntry *entry, BezierCurve *curve) {

IDE/Contents/Source/PolycodeFrame.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,21 @@ EditorHolder::EditorHolder(PolycodeProject *project, PolycodeEditorManager *edit
538538
setOwnsChildrenRecursive(true);
539539
}
540540

541+
void EditorHolder::activateEditor(bool val) {
542+
if(firstChildHolder) {
543+
firstChildHolder->activateEditor(val);
544+
secondChildHolder->activateEditor(val);
545+
return;
546+
}
547+
if(currentEditor) {
548+
if(val) {
549+
currentEditor->Activate();
550+
} else {
551+
currentEditor->Deactivate();
552+
}
553+
}
554+
}
555+
541556
ObjectEntry *EditorHolder::getEditorHolderConfig() {
542557
ObjectEntry *configEntry = new ObjectEntry();
543558
configEntry->name = "editor_holder";
@@ -686,10 +701,12 @@ void EditorHolder::setEditor(PolycodeEditor *newEditor) {
686701

687702
if(currentEditor) {
688703
removeChild(currentEditor);
704+
currentEditor->Deactivate();
689705
currentEditor->setEditorHolder(NULL);
690706
}
691707
currentEditor = newEditor;
692-
if(currentEditor) {
708+
if(currentEditor) {
709+
currentEditor->Activate();
693710
EditorHolder *currentEditorHolder = currentEditor->getEditorHolder();
694711
if(currentEditorHolder) {
695712
currentEditorHolder->setEditor(NULL);
@@ -937,9 +954,11 @@ PolycodeProjectTab::PolycodeProjectTab(String caption, PolycodeProject *project,
937954

938955
void PolycodeProjectTab::setActive(bool val) {
939956
active = val;
957+
editorHolder->activateEditor(val);
958+
940959
if(!active) {
941960
projectBrowser->removeAllHandlers();
942-
}
961+
}
943962
}
944963

945964
bool PolycodeProjectTab::isActive() {

IDE/Contents/Source/PolycodeMaterialEditor.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ PostEditorPane::PostEditorPane(ResourcePool *resourcePool) : UIElement() {
9494

9595
}
9696

97+
void PostEditorPane::Activate() {
98+
postPreview->previewScene->enabled = true;
99+
postPreview->renderTexture->enabled = true;
100+
}
101+
102+
void PostEditorPane::Deactivate() {
103+
postPreview->previewScene->enabled = false;
104+
postPreview->renderTexture->enabled = false;
105+
}
106+
107+
97108
PostEditorPane::~PostEditorPane() {
98109

99110
}
@@ -247,6 +258,18 @@ CubemapEditorPane::CubemapEditorPane(ResourcePool *resourcePool) : UIElement() {
247258

248259
}
249260

261+
262+
void CubemapEditorPane::Activate() {
263+
cubemapPreview->previewScene->enabled = true;
264+
cubemapPreview->renderTexture->enabled = true;
265+
}
266+
267+
void CubemapEditorPane::Deactivate() {
268+
cubemapPreview->previewScene->enabled = false;
269+
cubemapPreview->renderTexture->enabled = false;
270+
}
271+
272+
250273
void CubemapEditorPane::setCubemap(Cubemap *cubemap) {
251274
enabled = true;
252275
currentCubemap = cubemap;
@@ -941,6 +964,16 @@ void MaterialEditorPane::handleEvent(Event *event) {
941964
}
942965
}
943966

967+
void MaterialEditorPane::Activate() {
968+
materialPreview->previewScene->enabled = true;
969+
materialPreview->renderTexture->enabled = true;
970+
}
971+
972+
void MaterialEditorPane::Deactivate() {
973+
materialPreview->previewScene->enabled = false;
974+
materialPreview->renderTexture->enabled = false;
975+
}
976+
944977
void MaterialEditorPane::setMaterial(Material *material) {
945978
changingMaterial = true;
946979

@@ -1002,6 +1035,18 @@ MaterialMainWindow::MaterialMainWindow(ResourcePool *resourcePool) : UIElement()
10021035
addChild(postPane);
10031036
}
10041037

1038+
void MaterialMainWindow::Activate() {
1039+
materialPane->Activate();
1040+
cubemapPane->Activate();
1041+
cubemapPane->Activate();
1042+
}
1043+
1044+
void MaterialMainWindow::Deactivate() {
1045+
materialPane->Deactivate();
1046+
cubemapPane->Deactivate();
1047+
cubemapPane->Deactivate();
1048+
}
1049+
10051050
MaterialMainWindow::~MaterialMainWindow() {
10061051
}
10071052

@@ -1116,6 +1161,14 @@ PolycodeMaterialEditor::PolycodeMaterialEditor() : PolycodeEditor(true){
11161161
selectedMaterialNode = NULL;
11171162
}
11181163

1164+
void PolycodeMaterialEditor::Activate() {
1165+
mainWindow->Activate();
1166+
}
1167+
1168+
void PolycodeMaterialEditor::Deactivate() {
1169+
mainWindow->Deactivate();
1170+
}
1171+
11191172
PolycodeMaterialEditor::~PolycodeMaterialEditor() {
11201173
CoreServices::getInstance()->getResourceManager()->unsubscibeFromResourcePool(resourcePool);
11211174

IDE/Contents/Source/PolycodeMeshEditor.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ PolycodeMeshEditor::PolycodeMeshEditor() : PolycodeEditor(true){
7979

8080
}
8181

82+
void PolycodeMeshEditor::Activate() {
83+
previewScene->enabled = true;
84+
renderTexture->enabled = true;
85+
}
86+
87+
void PolycodeMeshEditor::Deactivate() {
88+
previewScene->enabled = false;
89+
renderTexture->enabled = false;
90+
91+
}
92+
8293
void PolycodeMeshEditor::reloadMaterials() {
8394

8495
Resource *selectedMaterial = NULL;

0 commit comments

Comments
 (0)