public class WindowState : Object
{
public Xcls_MainWindow win;
-
+
public enum State {
NONE,
PREVIEW,
OBJECT,
PROP,
LISTENER,
- CODE,
+ CODE, // code editor.
CODEONLY,
FILES,
- PROJECT // project settings..
+ PROJECT, // project settings..
+ FILEPROJECT, // project when in file mode
+ PROJECTCODEONLY // when editing code...
}
public State state = State.NONE;
public bool children_loaded = false;
-
-
+
public Project.Project project;
public JsRender.JsRender file;
-
-
+
public Xcls_WindowLeftTree left_tree;
public Xcls_WindowAddProp add_props;
this.template_select = new DialogTemplateSelect();
this.children_loaded = true;
- this.left_tree.node_selected.connect((sel) => {
- 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;
+ this.valasource.compile_output.connect(this.compile_results.addLine);
+ this.win.statusbar_compilestatus_label.el.hide();
+ this.win.statusbar_run.el.hide();
+ this.win.search_results.el.hide();
}
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();
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");
}
- public void fileViewOpen(JsRender.JsRender file)
+ public void fileViewOpen(JsRender.JsRender file, int line = -1)
{
this.win.project = file.project;
- this.project = project;
+ this.project = file.project;
this.file = file;
this.switchState (State.CODEONLY);
file.loadItems();
this.code_editor.show(file, null, "", "");
+ if (line> -1) {
+ this.code_editor.scroll_to_line(line);
+ }
} else {
this.switchState (State.PREVIEW);
// this triggers loadItems..
this.left_tree.model.loadFile(file);
+ if (file.project.xtype == "Gtk" && line> -1 ) {
+ this.window_gladeview.scroll_to_line(line);
+ }
}
}
-
+
+ // 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()
{
this.window_rooview =new Xcls_WindowRooView();
+ this.window_rooview.main_window = this.win;
this.window_rooview.ref();
((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
this.window_rooview.el.show_all();
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();
// and different windows hide the preview in differnt ways..
break;
+
case State.LISTENER:
case State.PROP:
case State.CODEONLY:
// going from codeonly..
- this.win.leftpane.el.show();
+
// enable re-calc of canvas..
+
+ //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.code_editor.saveContents(); << not yet...
-
- this.win.rooview.el.show();
- this.win.codeeditview.el.set_scale(0.0f,0.0f);
+
+ // hides it completely...
break;
this.win.objectview.el.set_scale(0.0f,0.0f);
break;
- case State.PROJECT:
+ case State.FILEPROJECT:
+ case State.PROJECT:
+ case State.PROJECTCODEONLY:
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 {
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();
this.win.rooview.el.set_pivot_point(1.0f,0.5f);
break;
- case State.PROJECT:
+ case State.PROJECTCODEONLY:
+ // going to project edit (when in code only)
- if (this.win.project.xtype == "Roo") {
+
+
+ if (this.win.project.xtype == "Roo") {
this.projectsettings.el.show_all();
this.projectsettings.show(this.win.project);
} else {
this.vala_projectsettings.el.show_all();
this.vala_projectsettings.show((Project.Gtk)this.win.project);
}
+
+ this.win.projecteditview.el.set_scale(1.0f,1.0f);
+
+ break;
+
+ case State.PROJECT:
this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right..
+ if (this.win.project.xtype == "Roo") {
+ this.projectsettings.el.show_all();
+ this.projectsettings.show(this.win.project);
+ } else {
+ this.vala_projectsettings.el.show_all();
+ this.vala_projectsettings.show((Project.Gtk)this.win.project);
+ }
+
this.win.projecteditview.el.set_scale(1.0f,1.0f);
+
+ break;
-
+ 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);
+ } else {
+ this.vala_projectsettings.el.show_all();
+ this.vala_projectsettings.show((Project.Gtk)this.win.project);
+ }
+
+ this.win.projecteditview.el.set_scale(1.0f,1.0f);
+
break;
case State.FILES: // can only get here from PREVIEW (or code-only) state.. in theory..
this.easingRestoreAll();
// run the animation.. - then load files...
-
+ GLib.Timeout.add(500, () =>{
+ this.resizeCanvasElements();
+ return false;
+ });
}
{
// basically hide everything, then show the relivant..
- this.win.backbutton.el.hide();
-
- this.win.projectbutton.el.hide(); // show file nav...
+ // top bar btns
+ this.win.openbtn.el.hide();
+ this.win.openbackbtn.el.hide();
+
+ this.win.backbutton.el.hide();
+
+
this.win.editfilebutton.el.hide();
this.win.projecteditbutton.el.hide();
this.win.addprojectbutton.el.hide();
this.win.addfilebutton.el.hide();
this.win.delprojectbutton.el.hide();
-
+ this.win.search_entry.el.hide();
+ this.win.search_results.el.hide();
switch (this.state) {
case State.PREVIEW: // this is the default state when working...
- this.win.projectbutton.el.show(); // show file nav...
+
this.win.editfilebutton.el.show();
this.win.projecteditbutton.el.show();
+
this.win.objectshowbutton.el.show(); // add objects
this.win.addpropbutton.el.show();
this.win.addlistenerbutton.el.show();
+ this.win.search_entry.el.show();
+
+ this.win.openbtn.el.show();
+
break;
case State.CODEONLY:
- this.win.projectbutton.el.show();
+ this.win.openbtn.el.show();
+ this.win.projecteditbutton.el.show();
+ this.win.search_entry.el.show();
break;
case State.CODE:
+ this.win.search_entry.el.show();
+ this.win.backbutton.el.show();
+ this.win.objectshowbutton.el.show(); // add objects ?? can you do this from here?
+ this.win.addpropbutton.el.show();
+ this.win.addlistenerbutton.el.show();
+ break;
+ // continue thru..
case State.PROP:
case State.LISTENER:
case State.OBJECT:
break;
case State.PROJECT:
+ case State.FILEPROJECT:
+ case State.PROJECTCODEONLY:
// anything else?
this.win.backbutton.el.show();
+
break;
case State.FILES:
if (this.left_projects.getSelectedProject() != null ) {
if (this.left_tree.getActiveFile() != null) {
- this.win.backbutton.el.show();
+
+ this.win.openbackbtn.el.show();
}
this.win.addfilebutton.el.show();
- }
+ this.win.search_entry.el.show();
+ this.win.projecteditbutton.el.show();
+ }
+
this.win.addprojectbutton.el.show();
this.win.delprojectbutton.el.show();
+
+
+
break;
}
}
- public void valaCompiled(Json.Object obj)
+ public void showCompileResult(Json.Object obj)
{
// vala has finished compiling...
print("vala compiled");
var buf = this.code_editor.buffer;
buf.check_running = false;
+ var has_errors = false;
if (obj.has_member("ERR-TOTAL")) {
+ if (obj.get_int_member("ERR-TOTAL")> 0) {
+ has_errors = true;
+ }
this.win.statusbar_errors.setNotices( obj.get_object_member("ERR") , (int) obj.get_int_member("ERR-TOTAL"));
} else {
this.win.statusbar_errors.setNotices( new Json.Object() , 0);
} else {
this.win.statusbar_depricated.setNotices( new Json.Object(),0);
}
+ if (this.state = State.CODE:) {
+ buf.highlightErrorsJson("ERR", obj);
+ buf.highlightErrorsJson("WARN", obj);
+ buf.highlightErrorsJson("DEPR", obj);
+ }
- buf.highlightErrorsJson("ERR", obj);
- buf.highlightErrorsJson("WARN", obj);
- buf.highlightErrorsJson("DEPR", obj);
-
+ this.win.statusbar_compilestatus_label.el.hide();
+ this.win.statusbar_run.el.hide();
+ if (!has_errors) {
+ this.win.statusbar_compilestatus_label.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);
gbuf.highlightErrorsJson("DEPR", obj);
}
+
+ 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_rooview.sourceview;
+ gbuf.highlightErrorsJson("ERR", obj);
+ gbuf.highlightErrorsJson("WARN", obj);
+ gbuf.highlightErrorsJson("DEPR", obj);
+
+ }
+
this.last_compile_result = obj;