X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FBuilder4%2FWindowState.vala;h=08dd43b2dc4b8bf73a75238d7be2d4a031d64088;hb=071e6176bacac9fcc0f47eab7c4b6af448d0a654;hp=1cea3a42970d518e312f04ffbca89a40ece69448;hpb=50be78f795d4b8f81246178bbc3c32ea1a98adcd;p=app.Builder.js diff --git a/src/Builder4/WindowState.vala b/src/Builder4/WindowState.vala index 1cea3a429..08dd43b2d 100644 --- a/src/Builder4/WindowState.vala +++ b/src/Builder4/WindowState.vala @@ -8,7 +8,7 @@ public class WindowState : Object { public Xcls_MainWindow win; - + public enum State { NONE, PREVIEW, @@ -30,8 +30,7 @@ public class WindowState : Object public Project.Project project; public JsRender.JsRender file; - - + public Xcls_WindowLeftTree left_tree; public Xcls_WindowAddProp add_props; @@ -94,15 +93,9 @@ public class WindowState : Object this.template_select = new DialogTemplateSelect(); this.children_loaded = true; - this.left_tree.node_selected.connect((sel) => { - if (this.file.xtype == "Roo") { - this.window_rooview.sourceview.nodeSelected(sel); - } else { - this.window_gladeview.sourceview.nodeSelected(sel); - } - }); + this.valasource = new Palete.ValaSource(); - this.valasource.compiled.connect(this.valaCompiled); + this.valasource.compiled.connect(this.showCompileResult); this.compile_results = new Xcls_ValaCompileResults(); this.compile_results.window = this.win; @@ -127,16 +120,31 @@ public class WindowState : Object this.left_tree.el.show_all(); this.left_tree.before_node_change.connect(() => { + // if the node change is caused by the editor (code preview) + if (this.left_tree.view.lastEventSource == "editor") { + return true; + } return this.leftTreeBeforeChange(); }); - - this.left_tree.node_selected.connect((sel) => { - this.leftTreeNodeSelected(sel); + + this.left_tree.node_selected.connect((sel, source) => { + if (source == "editor") { + return; + } + if (this.file.xtype == "Roo") { + this.window_rooview.sourceview.nodeSelected(sel,true); // foce scroll. + } else { + this.window_gladeview.sourceview.nodeSelected(sel); + } + }); + + this.left_tree.node_selected.connect((sel, source) => { + this.leftTreeNodeSelected(sel, source); }); this.left_tree.changed.connect(() => { - + print("LEFT TREE: Changed fired\n"); this.file.save(); if (this.left_tree.getActiveFile().xtype == "Roo" ) { this.window_rooview.requestRedraw(); @@ -160,7 +168,7 @@ public class WindowState : Object return false; } - public void leftTreeNodeSelected(JsRender.Node? sel) + public void leftTreeNodeSelected(JsRender.Node? sel, string source) { print("node_selected called %s\n", (sel == null) ? "NULL" : "a value"); @@ -504,8 +512,33 @@ public class WindowState : Object } - + + // our project properties is different for Roo and Gtk + // it would be better to change the above code to use this, + public void attachProjectSettings() { + var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget())); + + if (this.win.project.xtype == "Roo" ) { + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr_p.add(this.projectsettings.el); + this.projectsettings.el.show_all(); + + } else { + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr_p.add(this.vala_projectsettings.el); + this.vala_projectsettings.el.show_all(); + } + } + /* + public void fileViewOpenPlain(string fname) + { + + this.switchState (State.CODEONLY); + this.code_editor.showPlainFile(fname); + } + */ + // --------- webkit view public void webkitViewInit() { @@ -557,6 +590,13 @@ public class WindowState : Object return; } + // stop werid stuff happening + + if (this.state == State.FILES + && new_state == State.FILEPROJECT + && this.left_projects.getSelectedProject() == null) { + return; + } // save the easing state of everything.. this.easingSaveAll(); @@ -590,16 +630,23 @@ public class WindowState : Object case State.CODEONLY: // going from codeonly.. - this.win.leftpane.el.show(); + // enable re-calc of canvas.. - while (Gtk.events_pending()) { - Gtk.main_iteration(); - } + //this.code_editor.saveContents(); << not yet... if (new_state != State.PROJECTCODEONLY) { this.win.rooview.el.show(); + this.win.leftpane.el.show(); + this.win.codeeditview.el.set_scale(0.0f,0.0f); + } else { + this.win.codeeditview.el.set_pivot_point(0.0f,1.0f); // bottom left + this.win.codeeditview.el.set_scale(0.5f,0.5f); + } + while (Gtk.events_pending()) { + Gtk.main_iteration(); } - this.win.codeeditview.el.set_scale(0.0f,0.0f); // hides it completely... + + // hides it completely... break; @@ -614,13 +661,25 @@ public class WindowState : Object if (this.win.project.xtype == "Gtk") { this.vala_projectsettings.save(); } + if (this.state == State.FILEPROJECT) { + this.clutterfiles.el.set_scale(1.0f,1.0f); + } this.win.projecteditview.el.set_scale(0.0f,0.0f); - break; + break; case State.FILES: // goes to preview or codeonly... // hide files... + + if (new_state == State.FILEPROJECT) { + + this.clutterfiles.el.set_easing_duration(1000); + this.clutterfiles.el.set_pivot_point(0.5f,1.0f); + this.clutterfiles.el.set_scale(0.5f,0.5f); + break; + } + if (new_state == State.CODEONLY) { this.win.rooview.el.hide(); } else { @@ -633,13 +692,12 @@ public class WindowState : Object this.win.rooview.el.set_pivot_point(0.5f,0.5f); this.win.rooview.el.set_opacity(0xff); - - this.clutterfiles.el.set_easing_duration(1000); this.clutterfiles.el.set_pivot_point(0.5f,0.5f); this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, -180.0f); this.clutterfiles.el.set_opacity(0); + //this.clutterfiles.el.hide(); @@ -763,8 +821,10 @@ public class WindowState : Object break; case State.PROJECTCODEONLY: - this.win.codeeditview.el.set_pivot_point(1.0f,1.0f); // bottom right.. + // going to project edit (when in code only) + + if (this.win.project.xtype == "Roo") { this.projectsettings.el.show_all(); this.projectsettings.show(this.win.project); @@ -795,6 +855,12 @@ public class WindowState : Object case State.FILEPROJECT: var pr = this.left_projects.getSelectedProject(); + + this.win.project = pr; + + this.attachProjectSettings(); + print("FIlE PROJECT - show %s\n", pr.xtype); + if (pr.xtype == "Roo") { this.projectsettings.el.show_all(); this.projectsettings.show(this.win.project); @@ -1035,6 +1101,8 @@ public class WindowState : Object break; case State.PROJECT: + case State.FILEPROJECT: + case State.PROJECTCODEONLY: // anything else? this.win.backbutton.el.show(); @@ -1067,7 +1135,7 @@ public class WindowState : Object } - public void valaCompiled(Json.Object obj) + public void showCompileResult(Json.Object obj) { // vala has finished compiling... print("vala compiled"); @@ -1106,12 +1174,12 @@ public class WindowState : Object this.win.statusbar_compilestatus_label.el.hide(); this.win.statusbar_run.el.hide(); - - if (this.file.xtype == "Gtk") { + if (!has_errors) { this.win.statusbar_compilestatus_label.el.show(); - if (!has_errors) { - this.win.statusbar_run.el.show(); - } + this.win.statusbar_run.el.show(); + } + if (this.file.xtype == "Gtk") { + // not sure how this is working ok? - as highlighting is happening on the vala files at present.. var gbuf = this.window_gladeview.sourceview; gbuf.highlightErrorsJson("ERR", obj); gbuf.highlightErrorsJson("WARN", obj);