|
@@ -8,7 +8,7 @@ import Library from 'trapilib/dist/lib';
|
|
|
import SideBar from './SideBar';
|
|
|
import MainBar from './MainBar';
|
|
|
import ModuleBar from './ModuleBar';
|
|
|
-
|
|
|
+import { ViewNode } from 'trapilib/dist/lib/systems/ViewSystem';
|
|
|
|
|
|
let {
|
|
|
CoreSystem,
|
|
@@ -18,27 +18,26 @@ let {
|
|
|
|
|
|
export default class Gui {
|
|
|
constructor() {
|
|
|
- this.ModuleBar = new ModuleBar();
|
|
|
+ this.CoreSystem = new CoreSystem();
|
|
|
+
|
|
|
+ this.ModuleBar = new ModuleBar(this.CoreSystem); // Add CoreSystem deps
|
|
|
+
|
|
|
this.Keyboard = new Keyboard();
|
|
|
this.phoneRef = React.createRef();
|
|
|
this.phone = this.phoneRef;
|
|
|
this.toolboxRef = React.createRef();
|
|
|
this.toolbox = this.toolboxRef;
|
|
|
|
|
|
-
|
|
|
- this.CoreSystem = { render: () => null};
|
|
|
+
|
|
|
this.ToolBox = new ToolBox();
|
|
|
this.MainBar = new MainBar();
|
|
|
this.load();
|
|
|
this.__onUpdate = null;
|
|
|
- this.SideBar = new SideBar();
|
|
|
+ this.SideBar = new SideBar(this.CoreSystem);
|
|
|
this.ToolBox.onUpdate( () =>{
|
|
|
- let SideBarProps = {
|
|
|
- tool:this.ToolBox.activeTool
|
|
|
- }
|
|
|
- this.SideBar = new SideBar(SideBarProps)
|
|
|
- this.forceUpdate()
|
|
|
- })
|
|
|
+ this.SideBar.tool = this.ToolBox.activeTool;
|
|
|
+ this.forceUpdate();
|
|
|
+ });
|
|
|
|
|
|
this.MainBar.onSave( () => {
|
|
|
this.saveEnv();
|
|
@@ -52,7 +51,7 @@ export default class Gui {
|
|
|
if(this.phone){
|
|
|
// thats fine
|
|
|
this.ToolBoxMouse = new Mouse(this.toolbox.current);
|
|
|
- this.phoneMouse = new Mouse(this.phone.current);
|
|
|
+ this.phoneMouse = new Mouse(this.phone.current).droppable();
|
|
|
}
|
|
|
|
|
|
if(this.ToolBoxMouse !== undefined){
|
|
@@ -61,6 +60,7 @@ export default class Gui {
|
|
|
|
|
|
this.phoneMouse.listen()
|
|
|
.on('LeftDown',(e) => this.ToolManagement(e))
|
|
|
+ .on('Drop', (e) => this.dropContent(e))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -98,67 +98,75 @@ export default class Gui {
|
|
|
}
|
|
|
|
|
|
load() {
|
|
|
- this.CoreSystem = new CoreSystem();
|
|
|
- this.ToolBox = new ToolBox(this.CoreSystem);
|
|
|
- try{
|
|
|
- let env = localStorage.getItem('environment');
|
|
|
- if( env === null){
|
|
|
- this.CoreSystem.import(JSON.parse(jsLoad));
|
|
|
- }else{
|
|
|
- this.CoreSystem.import(JSON.parse(env));
|
|
|
- }
|
|
|
-
|
|
|
- this.forceUpdate();
|
|
|
- } catch(e) {
|
|
|
- console.log(e);
|
|
|
- }
|
|
|
- }
|
|
|
+ this.ToolBox = new ToolBox(this.CoreSystem);
|
|
|
+ try{
|
|
|
+ let env = localStorage.getItem('environment');
|
|
|
+ if( env === null){
|
|
|
+ this.CoreSystem.import(JSON.parse(jsLoad));
|
|
|
+ }else{
|
|
|
+ this.CoreSystem.import(JSON.parse(env));
|
|
|
+ }
|
|
|
+
|
|
|
+ this.forceUpdate();
|
|
|
+ } catch(e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
processElement(event){
|
|
|
- console.log(event)
|
|
|
- console.log('sdasdwd')
|
|
|
let Node = this.CoreSystem.ray({event});
|
|
|
let NewNode = this.ToolBox.editNode(Node);
|
|
|
this.forceUpdate();
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
+ dropContent({event, data}) {
|
|
|
+ data = JSON.parse(data);
|
|
|
+ let Node = this.CoreSystem.ray({event});
|
|
|
+ // Node.content
|
|
|
+ Node.props.selected = true;
|
|
|
+ console.log(Node, data);
|
|
|
+ let node = new ViewNode(Math.random(), data.ctor, {}, data.namespace);
|
|
|
+ Node.content = node;
|
|
|
+ console.log(node);
|
|
|
+
|
|
|
+ this.forceUpdate();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- mobileRender(){
|
|
|
- return (
|
|
|
- <div ref={this.phoneRef}>
|
|
|
- <View style={styles.mobileView}>
|
|
|
- {this.CoreSystem.render()}
|
|
|
- </View>
|
|
|
- </div>
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- renderSideBar(){
|
|
|
- return this.SideBar.render();
|
|
|
- }
|
|
|
-
|
|
|
- renderMainBar(){
|
|
|
- return this.MainBar.render();
|
|
|
- }
|
|
|
+ mobileRender(){
|
|
|
+ return (
|
|
|
+ <div ref={this.phoneRef}>
|
|
|
+ <View style={styles.mobileView}>
|
|
|
+ {this.CoreSystem.render()}
|
|
|
+ </View>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ renderSideBar(){
|
|
|
+ return this.SideBar.render();
|
|
|
+ }
|
|
|
+
|
|
|
+ renderMainBar(){
|
|
|
+ return this.MainBar.render();
|
|
|
+ }
|
|
|
|
|
|
- renderToolBox(){
|
|
|
- return (
|
|
|
- <div ref = {this.toolboxRef}>
|
|
|
+ renderToolBox(){
|
|
|
+ return (
|
|
|
+ <div ref = {this.toolboxRef}>
|
|
|
<View style={styles.toolbarView}>
|
|
|
{this.ToolBox.render()}
|
|
|
</View>
|
|
|
- </div>)
|
|
|
- }
|
|
|
-
|
|
|
- renderModuleBar(){
|
|
|
- return (
|
|
|
- <View>
|
|
|
- {this.ModuleBar.render()}
|
|
|
- </View>
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
+ </div>)
|
|
|
+ }
|
|
|
|
|
|
+ renderModuleBar(){
|
|
|
+ return (
|
|
|
+ <View>
|
|
|
+ {this.ModuleBar.render()}
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|