-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrenderer.js
More file actions
116 lines (104 loc) · 3.15 KB
/
Copy pathrenderer.js
File metadata and controls
116 lines (104 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(function() {
let Signal = module.exports.Signal;
window.signals = {
saveChanges: new Signal(),
loadScript: new Signal(),
codeEditorResize: new Signal(),
saveScriptButtonClicked: new Signal()
};
let appLayout = null;
let initApp = function() {
let configDefault = {
settings: {
hasHeaders: true,
reorderEnabled: true,
selectionEnabled: false,
popoutWholeStack: false,
blockedPopoutsThrowError: true,
closePopoutsOnUnload: true,
showPopoutIcon: false,
showMaximiseIcon: true,
showCloseIcon: false
},
content: [{
type: 'row',
content: [{
width: 80,
type: 'row',
content: [{
title: 'Examples',
width: 20,
//header: { show: 'bottom' },
type: 'component',
isClosable: false,
componentName: 'ExamplesTreeView',
componentState: { }
},
{
type: 'stack',
content: [{
type: 'component',
title: 'Preview',
isClosable: false,
componentName: 'ExamplesMainView',
componentState: { }
},
{
type: 'component',
title: 'Code',
isClosable: false,
componentName: 'CodeEditorView',
componentState: { }
}]
}]
}]
}]
};
if (fs.existsSync(path.join(__dirname, "/layouts/custom.json"))) {
configDefault = JSON.parse(fs.readFileSync(path.join(__dirname, "/layouts/custom.json"), "utf8"));
}
appLayout = GoldenLayout ? new GoldenLayout(configDefault) : new window.GoldenLayout(configDefault);
appLayout.registerComponent('ExamplesMainView', ExamplesMainView);
appLayout.registerComponent('ExamplesTreeView', ExamplesTreeView);
appLayout.registerComponent('CodeEditorView', CodeEditorView);
appLayout.init();
window.changeLayout = function(type) {
let layoutCfg = JSON.parse(fs.readFileSync(path.join(__dirname, "/layouts/type" + type + ".json"), "utf8"));
document.body._codeEditor.style.display = "none";
document.body.append(document.body._codeEditor);
appLayout.destroy();
appLayout = GoldenLayout ? new GoldenLayout(layoutCfg) : new window.GoldenLayout(layoutCfg);
appLayout.registerComponent('ExamplesMainView', ExamplesMainView);
appLayout.registerComponent('ExamplesTreeView', ExamplesTreeView);
appLayout.registerComponent('CodeEditorView', CodeEditorView);
appLayout.init();
};
let codeEditor = new CodeEditor();
window.signals.loadScript.add(function(data) {
codeEditor.loadScript(data);
codeEditor.scriptLoaded = true;
});
window.signals.saveChanges.add(function(data) {
});
window.signals.codeEditorResize.add(function() {
codeEditor.resize();
});
};
let ipcr = require('electron').ipcRenderer;
ipcr.on('saveLayout', function(event, msg) {
let customLayout = null;
customLayout = appLayout.toConfig();
if (customLayout) {
fs.writeFileSync(path.join(__dirname, "/layouts/custom.json"), JSON.stringify(customLayout, null, 4), "utf-8");
}
});
ipcr.on('set-custom-script-active', function(event, msg) {
window.signals.saveChanges.dispatch(msg);
});
if (!fs.existsSync(process.cwd() + "/three.js-master")) {
new ThreeDownloader(initApp);
}
else {
initApp();
}
}());