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;
19 PROJECT // project settings..
25 public Xcls_WindowLeftTree left_tree;
26 public Xcls_WindowAddProp add_props;
27 public Xcls_LeftProps left_props;
28 public Xcls_ProjectSettings projectsettings;
29 public ValaProjectSettings vala_projectsettings;
30 public Xcls_RightPalete rightpalete;
31 public Editor code_editor;
32 public Xcls_WindowRooView window_rooview;
33 public Xcls_GtkView window_gladeview;
34 public Xcls_DialogNewComponent new_file_dialog;
36 public Xcls_WindowLeftProjects left_projects; // can not see where this is initialized..
38 public WindowState(MainWindow win)
47 // on clutter space...
48 this.projectEditInit();
50 this.projectListInit();)
60 this.webkitViewInit();
70 public void leftTreeInit()
73 this.left_tree = new Xcls_WindowLeftTree();
75 this.left_tree.main_window = _this.win;
77 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
78 this.left_tree.el.show_all();
80 this.left_tree.before_node_change.connect(() => {
81 return this.leftTreeBeforeChange();
85 this.left_tree.node_selected.connect((sel) => {
86 this.leftTreeNodeSelected(sel);
89 this.left_tree.changed.connect(() => {
90 this.window_rooview.requestRedraw();
91 this.left_tree.model.file.save();
96 public bool leftTreeBeforeChange(JsRender.Node? sel)
98 if (this.state != "codeedit") {
99 this.left_props.finish_editing();
102 if (!this.code_editor.saveContents()) {
108 public void leftTreeNodeSelected(JsRender.Node? sel)
111 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
114 this.left_props.el.hide();
116 this.left_props.el.show();
117 this.left_props.load(this.left_tree.getActiveFile(), sel);
118 switch (this.state) {
123 this.rightpalete.clear();
126 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
132 this.add_props.clear();
135 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
141 this.add_props.clear();
144 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
162 public void propsListInit()
165 this.left_props =new Xcls_LeftProps();
166 this.left_props.ref();
167 this.left_props.main_window = _this;
168 this.win.props.el.pack_start(this.left_props.el,true, true,0);
169 this.left_props.el.show_all();
171 this.left_props.show_editor.connect( (file, node, type, key) => {
172 this.codeEditShow(file, node, type, key);
176 this.left_props.stop_editor.connect( () => {
177 if (this.state != "codeedit") {
181 var ret = this.code_editor.saveContents();
189 this.left_props.changed.connect(() => {
190 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
191 this.window_rooview.requestRedraw();
194 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
196 this.left_tree.model.updateSelected();
197 this.left_tree.model.file.save();
204 //------------- projects edit
206 public void projectEditInit()
208 this.projectsettings =new Xcls_ProjectSettings();
209 this.projectsettings.ref(); /// really?
211 this.vala_projectsettings =new ValaProjectSettings();
212 this.vala_projectsettings.ref();
213 this.vala_projectsettings.window = this;
215 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
216 //this.projectsettings.el.show_all();
218 var stage = this.win.projecteditview.el.get_stage();
219 stage.set_background_color( Clutter.Color.from_string("#000"));
221 this.projectsettings.buttonPressed.connect((btn) => {
222 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
224 this.window_rooview.view.renderJS(true);
226 if (btn == "apply") {
227 this.window_rooview.view.renderJS(true);
231 // do nothing for gtk..
233 if (btn == "save" || btn == "apply") {
234 this.win.project.save();
238 this.projectEditHide();
243 // ----------- object adding
244 public void objectAddInit()
247 this.rightpalete = new Xcls_RightPalete();
248 this.rightpalete.ref(); /// really?
249 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
250 //this.projectsettings.el.show_all();
252 stage = _this.win.objectview.el.get_stage();
253 stage.set_background_color( Clutter.Color.from_string("#000"));
257 // ----------- properties adding list...
258 // listener uses the properties
259 public void propsAddInit()
262 this.add_props = new Xcls_WindowAddProp();
263 this.add_props.ref(); /// really?
264 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
265 //this.projectsettings.el.show_all();
267 var stage = _this.win.addpropsview.el.get_stage();
268 stage.set_background_color( Clutter.Color.from_string("#000"));
271 this.add_props.select.connect( (key,type,skel, etype) => {
272 this.left_props.addProp(etype, key, skel, type);
276 public void propsAddShow()
280 public void propsAddHide()
288 // ----------- Add / Edit listener
289 // listener uses the properties
290 //public void listenerInit() { }
291 public void listenerShow()
295 public void listenerHide()
300 // -------------- codeEditor
302 public void codeEditInit()
304 this.code_editor = new Editor();
305 this.code_editor.ref(); /// really?
306 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
307 //this.projectsettings.el.show_all();
309 stage = _this.win.codeeditview.el.get_stage();
310 stage.set_background_color( Clutter.Color.from_string("#000"));
313 this.code_editor.save.connect( () => {
314 this.left_tree.model.file.save();
315 this.left_tree.model.updateSelected();
320 // ----------- list of projects on left
321 public void projectListInit()
324 this.left_projects = new Xcls_WindowLeftProjects();
325 this.left_projects.ref();
326 this.win.leftpane.el.pack_start(this.left_projects.el,true, true,0);
327 this.left_projects.el.show_all();
328 this.left_projects.project_selected.connect((proj) => {
330 this.clutterfiles.loadProject(proj);
335 // ----------- file view
337 public void fileViewInit()
339 stage = _this.rooview.el.get_stage(); \\ seems odd...
340 this.clutterfiles = new Xcls_ClutterFiles();
341 this.clutterfiles.ref();
342 stage.add_child(this.clutterfiles.el);
343 this.clutterfiles.el.show_all();
346 this.clutterfiles.open.connect((file) => {
347 this.fileViewOpen(file);
351 public void fileNewInit()
353 this.new_file_dialog = new Xcls_DialogNewComponent();
354 // force it modal to the main window..
355 this.new_file_dialog.el.set_transient_for(this.el);
356 this.new_file_dialog.el.set_modal(true);
358 this.new_file_dialog.success.connect((project,file) =>
360 this.fileViewOpen(file);
366 public void fileViewOpen(JsRender.JsRender file)
368 this.win.project = file.project;
370 this.left_tree.model.loadFile(file);
372 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
373 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
375 if (file.xtype == "Roo" ) {
376 ctr.foreach( (w) => { ctr.remove(w); });
377 ctr_p.foreach( (w) => { ctr_p.remove(w); });
378 ctr.add(this.window_rooview.el);
379 ctr_p.add(this.projectsettings.el);
380 this.window_rooview.loadFile(file);
381 this.window_rooview.el.show_all();
382 this.projectsettings.el.show_all();
385 ctr.foreach( (w) => { ctr.remove(w); });
386 ctr_p.foreach( (w) => { ctr_p.remove(w); });
387 ctr.add(this.window_gladeview.el);
388 ctr_p.add(this.vala_projectsettings.el);
389 this.window_gladeview.loadFile(file);
390 this.window_gladeview.el.show_all();
391 this.vala_projectsettings.el.show_all();
393 print("OPEN : " + file.name);
394 this.editpane.el.set_position(_this.editpane.el.max_position);
395 this.win.setTitle(file.project.name + " : " +file.name);
401 // --------- webkit view
402 public void webkitViewInit()
404 this.window_rooview =new Xcls_WindowRooView();
405 this.window_rooview.ref();
406 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
407 this.window_rooview.el.show_all();
409 stage = this.win.rooview.el.get_stage();
410 stage.set_background_color( Clutter.Color.from_string("#000"));
415 public void gtkViewInit()
417 this.window_gladeview =new Xcls_GtkView();
418 this.window_gladeview.ref();
421 public void switchState(State new_state)
423 if (this.state == State.PREVIEW) {
424 // try and do a snapshot..
433 switch (this.state) {
436 if (this.left_tree.getActiveFile() != null) {
437 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
438 this.window_rooview.createThumb();
440 this.window_gladeview.createThumb();
443 // normally we are going from preview to another state.
444 // and different windows hide the preview in differnt ways..
450 this.addpropsview.el.save_easing_state();
451 this.addpropsview.el.set_scale(0.0f,0.0f);
452 this.win.addpropsview.el.restore_easing_state();
456 this.win.codeeditview.el.save_easing_state();
457 this.win.codeeditview.el.set_scale(0.0f,0.0f);
458 this.win.codeeditview.el.restore_easing_state();
463 this.win.objectview.el.save_easing_state();
464 this.win.objectview.el.set_scale(0.0f,0.0f);
465 this.win.objectview.el.restore_easing_state();
469 this.win.projecteditview.el.save_easing_state();
470 this.win.projecteditview.el.set_scale(0.0f,0.0f);
471 this.win.projecteditview.el.restore_easing_state();
473 var oldstate =this.state;
474 this.state = new_state;
477 this.buttonShowHide();
479 switch (this.state) {
481 case State.PREVIEW: // this is the default state when working...
482 this.win.rooview.el.save_easing_state();
483 this.win.rooview.el.set_scale(1.0f,1.0f);
484 this.win.rooview.el.restore_easing_state();
490 var ae = this.left_tree.getActiveElement();
495 this.add_props.el.show_all();
497 Palete.factory(this.win.project.xtype),
503 this.addpropsview.el.save_easing_state();
504 this.addpropsview.el.set_scale(0.0f,0.0f);
505 this.win.addpropsview.el.restore_easing_state();
509 this.win.codeeditview.el.save_easing_state();
510 this.win.codeeditview.el.set_scale(0.0f,0.0f);
511 this.win.codeeditview.el.restore_easing_state();
516 this.win.objectview.el.save_easing_state();
517 this.win.objectview.el.set_scale(0.0f,0.0f);
518 this.win.objectview.el.restore_easing_state();
522 this.win.projecteditview.el.save_easing_state();
523 this.win.projecteditview.el.set_scale(0.0f,0.0f);
524 this.win.projecteditview.el.restore_easing_state();
527 case State.FILES: // can only get here from PREVIEW state.. in theory..
530 this.win.editpane.el.hide(); // holder for tree and properties..
532 this.left_projects.el.show();
534 var el = this.win.rooview.el;
535 el.save_easing_state();
536 el.set_easing_duration(1000);
538 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
539 el.set_scale(0.0f,0.0f);
542 if (this.win.project != null) {
543 this.left_projects.selectProject(_this.project);
546 el.restore_easing_state();
556 // -- buttons show hide.....
558 public void buttonsShowHide()
560 // basically hide everything, then show the relivant..
562 this.win.backbutton.el.hide();
564 this.win.projectbutton.el.hide(); // show file nav...
565 this.win.editfilebutton.el.hide();
566 this.win.projecteditbutton.el.hide();
569 this.win.objectshowbutton.el.hide(); // add objects
570 this.win.addpropbutton.el.hide();
571 this.win.addlistenerbutton.el.hide();
575 this.win.addprojectbutton.el.hide();
576 this.win.addfilebutton.el.hide();
577 this.win.delprojectbutton.el.hide();
578 this.win.new_window.el.hide();
581 switch (this.state) {
583 case State.PREVIEW: // this is the default state when working...
585 this.win.projectbutton.el.show(); // show file nav...
586 this.win.editfilebutton.el.show();
587 this.win.projecteditbutton.el.show();
590 this.win.objectshowbutton.el.show(); // add objects
591 this.win.addpropbutton.el.show();
592 this.win.addlistenerbutton.el.show();
601 this.win.backbutton.el.show();
602 this.win.objectshowbutton.el.show(); // add objects
603 this.win.addpropbutton.el.show();
604 this.win.addlistenerbutton.el.show();
608 this.win.backbutton.el.show();
610 this.win.addprojectbutton.el.show();
611 this.win.addfilebutton.el.show();
612 this.win.delprojectbutton.el.show();
613 this.win.new_window.el.show();