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 projectsettings
320 public void projectListInit() {
322 this.left_projects = new Xcls_WindowLeftProjects();
323 this.left_projects.ref();
324 this.leftpane.el.pack_start(this.left_projects.el,true, true,0);
325 this.left_projects.el.show_all();
326 this.left_projects.project_selected.connect((proj) => {
328 this.clutterfiles.loadProject(proj);
333 // ----------- file view
335 public void fileViewInit()
337 stage = _this.rooview.el.get_stage(); \\ seems odd...
338 this.clutterfiles = new Xcls_ClutterFiles();
339 this.clutterfiles.ref();
340 stage.add_child(this.clutterfiles.el);
341 this.clutterfiles.el.show_all();
344 this.clutterfiles.open.connect((file) => {
345 this.fileViewOpen(file);
349 public void fileNewInit()
351 this.new_file_dialog = new Xcls_DialogNewComponent();
352 // force it modal to the main window..
353 this.new_file_dialog.el.set_transient_for(this.el);
354 this.new_file_dialog.el.set_modal(true);
356 this.new_file_dialog.success.connect((project,file) =>
358 this.fileViewOpen(file);
364 public void fileViewOpen(JsRender.JsRender file)
366 this.win.project = file.project;
368 this.left_tree.model.loadFile(file);
370 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
371 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
373 if (file.xtype == "Roo" ) {
374 ctr.foreach( (w) => { ctr.remove(w); });
375 ctr_p.foreach( (w) => { ctr_p.remove(w); });
376 ctr.add(this.window_rooview.el);
377 ctr_p.add(this.projectsettings.el);
378 this.window_rooview.loadFile(file);
379 this.window_rooview.el.show_all();
380 this.projectsettings.el.show_all();
383 ctr.foreach( (w) => { ctr.remove(w); });
384 ctr_p.foreach( (w) => { ctr_p.remove(w); });
385 ctr.add(this.window_gladeview.el);
386 ctr_p.add(this.vala_projectsettings.el);
387 this.window_gladeview.loadFile(file);
388 this.window_gladeview.el.show_all();
389 this.vala_projectsettings.el.show_all();
391 print("OPEN : " + file.name);
392 this.editpane.el.set_position(_this.editpane.el.max_position);
393 this.win.setTitle(file.project.name + " : " +file.name);
399 // --------- webkit view
400 public void webkitViewInit()
402 this.window_rooview =new Xcls_WindowRooView();
403 this.window_rooview.ref();
404 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
405 this.window_rooview.el.show_all();
407 stage = this.win.rooview.el.get_stage();
408 stage.set_background_color( Clutter.Color.from_string("#000"));
413 public void gtkViewInit()
415 this.window_gladeview =new Xcls_GtkView();
416 this.window_gladeview.ref();
419 public void switchState(State new_state)
421 if (this.state == State.PREVIEW) {
422 // try and do a snapshot..
424 if (this.left_tree.getActiveFile() != null) {
425 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
426 this.window_rooview.createThumb();
428 this.window_gladeview.createThumb();
433 this.state = new_state;
435 this.buttonShowHide();
437 switch (this.state) {
439 case State.PREVIEW: // this is the default state when working...
442 case State.FILES: // can only get here from PREVIEW state.. in theory..
445 this.win.editpane.el.hide(); // holder for tree and properties..
447 this.left_projects.el.show();
449 var el = _this.rooview.el;
450 el.save_easing_state();
451 el.set_easing_duration(1000);
452 // show project / file view..
453 //_this.mainpane.lastWidth = _this.leftpane.el.get_position();
454 //_this.mainpane.el.set_position(0);
456 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
457 el.set_scale(0.0f,0.0f);
459 _this.state = "files";
460 if (_this.project != null) {
461 _this.left_projects.selectProject(_this.project);
463 //_this.clutterfiles.loadProject(_this.project);
465 el.restore_easing_state();
467 print("show view browsing");
470 // -- buttons show hide.....
472 public void buttonsShowHide()
474 // basically hide everything, then show the relivant..
476 this.win.backbutton.el.hide();
478 this.win.projectbutton.el.hide(); // show file nav...
479 this.win.editfilebutton.el.hide();
480 this.win.projecteditbutton.el.hide();
483 this.win.objectshowbutton.el.hide(); // add objects
484 this.win.addpropbutton.el.hide();
485 this.win.addlistenerbutton.el.hide();
489 this.win.addprojectbutton.el.hide();
490 this.win.addfilebutton.el.hide();
491 this.win.delprojectbutton.el.hide();
492 this.win.new_window.el.hide();
495 switch (this.state) {
497 case State.PREVIEW: // this is the default state when working...
499 this.win.projectbutton.el.show(); // show file nav...
500 this.win.editfilebutton.el.show();
501 this.win.projecteditbutton.el.show();
504 this.win.objectshowbutton.el.show(); // add objects
505 this.win.addpropbutton.el.show();
506 this.win.addlistenerbutton.el.show();
515 this.win.backbutton.el.show();
516 this.win.objectshowbutton.el.show(); // add objects
517 this.win.addpropbutton.el.show();
518 this.win.addlistenerbutton.el.show();
522 this.win.backbutton.el.show();
524 this.win.addprojectbutton.el.show();
525 this.win.addfilebutton.el.show();
526 this.win.delprojectbutton.el.show();
527 this.win.new_window.el.show();