2 * as state management is a bit too complicated inside the builder
3 * it's better to seperate this into this class
5 * This class has references to all the Class instances that make up the window..
8 public class WindowState : Object
10 public MainWindow win;
24 public Xcls_WindowLeftTree left_tree;
25 public Xcls_WindowAddProp add_props;
26 public Xcls_LeftProps left_props;
27 public Xcls_ProjectSettings projectsettings;
28 public ValaProjectSettings vala_projectsettings;
29 public Xcls_RightPalete rightpalete;
30 public Editor code_editor;
31 public Xcls_WindowRooView window_rooview;
32 public Xcls_GtkView window_gladeview;
33 public Xcls_DialogNewComponent new_file_dialog;
35 public Xcls_WindowLeftProjects left_projects; // can not see where this is initialized..
37 public WindowState(MainWindow win)
46 // on clutter space...
47 this.projectEditInit();
49 this.projectListInit();)
59 this.webkitViewInit();
69 public void leftTreeInit()
72 this.left_tree = new Xcls_WindowLeftTree();
74 this.left_tree.main_window = _this.win;
76 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
77 this.left_tree.el.show_all();
79 this.left_tree.before_node_change.connect(() => {
80 return this.leftTreeBeforeChange();
84 this.left_tree.node_selected.connect((sel) => {
85 this.leftTreeNodeSelected(sel);
88 this.left_tree.changed.connect(() => {
89 this.window_rooview.requestRedraw();
90 this.left_tree.model.file.save();
95 public bool leftTreeBeforeChange(JsRender.Node? sel)
97 if (this.state != "codeedit") {
98 this.left_props.finish_editing();
101 if (!this.code_editor.saveContents()) {
107 public void leftTreeNodeSelected(JsRender.Node? sel)
110 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
113 this.left_props.el.hide();
115 this.left_props.el.show();
116 this.left_props.load(this.left_tree.getActiveFile(), sel);
117 switch (this.state) {
122 this.rightpalete.clear();
125 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
131 this.add_props.clear();
134 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
140 this.add_props.clear();
143 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
161 public void propsListInit()
164 this.left_props =new Xcls_LeftProps();
165 this.left_props.ref();
166 this.left_props.main_window = _this;
167 this.win.props.el.pack_start(this.left_props.el,true, true,0);
168 this.left_props.el.show_all();
170 this.left_props.show_editor.connect( (file, node, type, key) => {
171 this.codeEditShow(file, node, type, key);
175 this.left_props.stop_editor.connect( () => {
176 if (this.state != "codeedit") {
180 var ret = this.code_editor.saveContents();
188 this.left_props.changed.connect(() => {
189 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
190 this.window_rooview.requestRedraw();
193 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
195 this.left_tree.model.updateSelected();
196 this.left_tree.model.file.save();
203 //------------- projects edit
205 public void projectEditInit()
207 this.projectsettings =new Xcls_ProjectSettings();
208 this.projectsettings.ref(); /// really?
210 this.vala_projectsettings =new ValaProjectSettings();
211 this.vala_projectsettings.ref();
212 this.vala_projectsettings.window = this;
214 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
215 //this.projectsettings.el.show_all();
217 var stage = this.win.projecteditview.el.get_stage();
218 stage.set_background_color( Clutter.Color.from_string("#000"));
220 this.projectsettings.buttonPressed.connect((btn) => {
221 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
223 this.window_rooview.view.renderJS(true);
225 if (btn == "apply") {
226 this.window_rooview.view.renderJS(true);
230 // do nothing for gtk..
232 if (btn == "save" || btn == "apply") {
233 this.win.project.save();
237 this.projectEditHide();
242 // ----------- object adding
243 public void objectAddInit()
246 this.rightpalete = new Xcls_RightPalete();
247 this.rightpalete.ref(); /// really?
248 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
249 //this.projectsettings.el.show_all();
251 stage = _this.win.objectview.el.get_stage();
252 stage.set_background_color( Clutter.Color.from_string("#000"));
256 // ----------- properties adding list...
257 // listener uses the properties
258 public void propsAddInit()
261 this.add_props = new Xcls_WindowAddProp();
262 this.add_props.ref(); /// really?
263 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
264 //this.projectsettings.el.show_all();
266 var stage = _this.win.addpropsview.el.get_stage();
267 stage.set_background_color( Clutter.Color.from_string("#000"));
270 this.add_props.select.connect( (key,type,skel, etype) => {
271 this.left_props.addProp(etype, key, skel, type);
275 public void propsAddShow()
279 public void propsAddHide()
287 // ----------- Add / Edit listener
288 // listener uses the properties
289 //public void listenerInit() { }
290 public void listenerShow()
294 public void listenerHide()
299 // -------------- codeEditor
301 public void codeEditInit()
303 this.code_editor = new Editor();
304 this.code_editor.ref(); /// really?
305 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
306 //this.projectsettings.el.show_all();
308 stage = _this.win.codeeditview.el.get_stage();
309 stage.set_background_color( Clutter.Color.from_string("#000"));
312 this.code_editor.save.connect( () => {
313 this.left_tree.model.file.save();
314 this.left_tree.model.updateSelected();
319 // ----------- list of projects on left
320 public void projectListInit()
323 this.left_projects = new Xcls_WindowLeftProjects();
324 this.left_projects.ref();
325 this.win.leftpane.el.pack_start(this.left_projects.el,true, true,0);
326 this.left_projects.el.show_all();
327 this.left_projects.project_selected.connect((proj) => {
329 this.clutterfiles.loadProject(proj);
334 // ----------- file view
336 public void fileViewInit()
338 stage = _this.rooview.el.get_stage(); \\ seems odd...
339 this.clutterfiles = new Xcls_ClutterFiles();
340 this.clutterfiles.ref();
341 stage.add_child(this.clutterfiles.el);
342 this.clutterfiles.el.show_all();
345 this.clutterfiles.open.connect((file) => {
346 this.fileViewOpen(file);
350 public void fileNewInit()
352 this.new_file_dialog = new Xcls_DialogNewComponent();
353 // force it modal to the main window..
354 this.new_file_dialog.el.set_transient_for(this.el);
355 this.new_file_dialog.el.set_modal(true);
357 this.new_file_dialog.success.connect((project,file) =>
359 this.fileViewOpen(file);
365 public void fileViewOpen(JsRender.JsRender file)
367 this.win.project = file.project;
369 this.left_tree.model.loadFile(file);
371 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
372 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
374 if (file.xtype == "Roo" ) {
375 ctr.foreach( (w) => { ctr.remove(w); });
376 ctr_p.foreach( (w) => { ctr_p.remove(w); });
377 ctr.add(this.window_rooview.el);
378 ctr_p.add(this.projectsettings.el);
379 this.window_rooview.loadFile(file);
380 this.window_rooview.el.show_all();
381 this.projectsettings.el.show_all();
384 ctr.foreach( (w) => { ctr.remove(w); });
385 ctr_p.foreach( (w) => { ctr_p.remove(w); });
386 ctr.add(this.window_gladeview.el);
387 ctr_p.add(this.vala_projectsettings.el);
388 this.window_gladeview.loadFile(file);
389 this.window_gladeview.el.show_all();
390 this.vala_projectsettings.el.show_all();
392 print("OPEN : " + file.name);
393 this.editpane.el.set_position(_this.editpane.el.max_position);
394 this.win.setTitle(file.project.name + " : " +file.name);
400 // --------- webkit view
401 public void webkitViewInit()
403 this.window_rooview =new Xcls_WindowRooView();
404 this.window_rooview.ref();
405 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
406 this.window_rooview.el.show_all();
408 stage = this.win.rooview.el.get_stage();
409 stage.set_background_color( Clutter.Color.from_string("#000"));
414 public void gtkViewInit()
416 this.window_gladeview =new Xcls_GtkView();
417 this.window_gladeview.ref();
420 public void switchState(State new_state)
422 if (this.state == State.PREVIEW) {
423 // try and do a snapshot..
425 if (this.left_tree.getActiveFile() != null) {
426 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
427 this.window_rooview.createThumb();
429 this.window_gladeview.createThumb();
434 switch (this.state) {
437 this.win.rooview.el.save_easing_state();
438 this.addpropsview.el.save_easing_state();
440 this.win.rooview.el.set_scale(1.0f,1.0f);
441 this.addpropsview.el.set_scale(0.0f,0.0f);
444 this.win.rooview.el.restore_easing_state();
445 this.win.addpropsview.el.restore_easing_state();
452 this.state = new_state;
454 this.buttonShowHide();
456 switch (this.state) {
458 case State.PREVIEW: // this is the default state when working...
461 case State.FILES: // can only get here from PREVIEW state.. in theory..
464 this.win.editpane.el.hide(); // holder for tree and properties..
466 this.left_projects.el.show();
468 var el = this.win.rooview.el;
469 el.save_easing_state();
470 el.set_easing_duration(1000);
472 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
473 el.set_scale(0.0f,0.0f);
476 if (this.win.project != null) {
477 this.left_projects.selectProject(_this.project);
480 el.restore_easing_state();
490 // -- buttons show hide.....
492 public void buttonsShowHide()
494 // basically hide everything, then show the relivant..
496 this.win.backbutton.el.hide();
498 this.win.projectbutton.el.hide(); // show file nav...
499 this.win.editfilebutton.el.hide();
500 this.win.projecteditbutton.el.hide();
503 this.win.objectshowbutton.el.hide(); // add objects
504 this.win.addpropbutton.el.hide();
505 this.win.addlistenerbutton.el.hide();
509 this.win.addprojectbutton.el.hide();
510 this.win.addfilebutton.el.hide();
511 this.win.delprojectbutton.el.hide();
512 this.win.new_window.el.hide();
515 switch (this.state) {
517 case State.PREVIEW: // this is the default state when working...
519 this.win.projectbutton.el.show(); // show file nav...
520 this.win.editfilebutton.el.show();
521 this.win.projecteditbutton.el.show();
524 this.win.objectshowbutton.el.show(); // add objects
525 this.win.addpropbutton.el.show();
526 this.win.addlistenerbutton.el.show();
535 this.win.backbutton.el.show();
536 this.win.objectshowbutton.el.show(); // add objects
537 this.win.addpropbutton.el.show();
538 this.win.addlistenerbutton.el.show();
542 this.win.backbutton.el.show();
544 this.win.addprojectbutton.el.show();
545 this.win.addfilebutton.el.show();
546 this.win.delprojectbutton.el.show();
547 this.win.new_window.el.show();