src/Builder4/WindowState.vala
[app.Builder.js] / src / Builder4 / WindowState.vala
1 /**
2  * as state management is a bit too complicated inside the builder
3  * it's better to seperate this into this class
4  * 
5  * This class has references to all the Class instances that make up the window..
6  * 
7  */
8 public class WindowState : Object 
9 {
10         public Xcls_MainWindow win;
11
12         public enum State {
13                 NONE,
14                 PREVIEW,
15                 OBJECT,
16                 PROP,
17                 LISTENER,
18                 CODE,
19                 FILES,
20                 PROJECT // project settings..
21         }
22
23         public State state = State.NONE;
24
25         public bool children_loaded = false;
26
27         
28         public Xcls_WindowLeftTree  left_tree;
29         public Xcls_WindowAddProp   add_props;
30         public Xcls_LeftProps       left_props;
31         public Xcls_ProjectSettings projectsettings;
32         public ValaProjectSettings  vala_projectsettings;
33         public Xcls_RightPalete     rightpalete;
34         public Editor               code_editor;    
35         public Xcls_WindowRooView   window_rooview;
36         public Xcls_GtkView         window_gladeview;
37         public Xcls_ValaCompileErrors valacompileerrors;
38         
39         public Xcls_ClutterFiles     clutterfiles;
40
41         public Xcls_WindowLeftProjects left_projects; // can not see where this is initialized.. 
42         
43         public DialogTemplateSelect template_select; 
44         
45         public Xcls_PopoverFileDetails file_details;
46         
47         
48         // dialogs??
49         public Xcls_DialogPluginWebkit webkit_plugin;
50         
51         // ctor 
52         public WindowState(Xcls_MainWindow win)
53         {
54                 this.win = win;
55                 // initialize
56
57                 // left elements..
58                 this.leftTreeInit();
59                 this.propsListInit();
60
61                 // on clutter space...
62                 this.projectEditInit();
63                 this.codeEditInit();
64                 this.projectListInit();
65                 this.fileViewInit();
66
67                 // adding stuff
68                 this.objectAddInit();
69                 this.propsAddInit();
70
71
72                 // previews...
73                 this.gtkViewInit();
74                 this.webkitViewInit();
75
76                 // dialogs
77
78                 this.fileDetailsInit();
79
80                 this.webkit_plugin = new Xcls_DialogPluginWebkit();
81                 this.template_select = new DialogTemplateSelect();
82                 this.children_loaded = true;
83         }
84
85
86         // left tree
87
88         public void leftTreeInit()
89         {
90          
91                 this.left_tree = new Xcls_WindowLeftTree();
92                 this.left_tree.ref();
93                 this.left_tree.main_window = this.win;
94         
95                 this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
96                 this.left_tree.el.show_all();
97                    
98                 this.left_tree.before_node_change.connect(() => {
99                         return this.leftTreeBeforeChange();
100
101                 });
102
103                 this.left_tree.node_selected.connect((sel) => {
104                         this.leftTreeNodeSelected(sel);
105                 });
106          
107                 this.left_tree.changed.connect(() => {
108                         this.window_rooview.requestRedraw();
109                         this.left_tree.model.file.save();
110                 });
111                  
112         }
113
114         public bool leftTreeBeforeChange()
115         {
116                 if (this.state != State.CODE) {
117                         this.left_props.finish_editing();
118                         return true;
119                 }
120                 if (!this.code_editor.saveContents()) {
121                         return false;
122                 }
123                 return false;
124         }
125         
126         public void leftTreeNodeSelected(JsRender.Node? sel)
127         {
128
129                 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
130
131                 if (sel == null) {
132                         this.left_props.el.hide();
133                 } 
134                 this.left_props.el.show();
135                 this.left_props.load(this.left_tree.getActiveFile(), sel);
136                 switch (this.state) {
137                         
138                         case State.OBJECT: 
139                                   
140                                  if (sel == null) {
141                                         this.rightpalete.clear();
142                                         break;
143                                 }
144                                 this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
145                                 break;
146                                  
147                 
148                    case State.PROP:
149                                 if (sel == null) {
150                                         this.add_props.clear();
151                                         break;
152                                 }
153                                 this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
154                                 break;
155
156                         case State.LISTENER:
157                            
158                                 if (sel == null) {
159                                         this.add_props.clear();
160                                         break;
161                                 }
162                                 this.add_props.show(this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
163                                 break;
164                                 
165                         case State.CODE:
166                                  this.switchState(State.PREVIEW);
167                          
168                                 break;
169                            
170                                                         
171                 }
172                  
173
174         }
175
176
177
178
179         public void propsListInit()
180         {
181         
182                 this.left_props =new Xcls_LeftProps();
183                 this.left_props.ref();
184                 this.left_props.main_window = this.win;
185                 this.win.props.el.pack_start(this.left_props.el,true, true,0);
186                 this.left_props.el.show_all();
187         
188                 this.left_props.show_editor.connect( (file, node, type,  key) => {
189                         this.switchState(State.CODE);
190                         this.code_editor.show(
191                                 file,
192                                 node,
193                                 type,
194                                 key
195                         );
196                         
197                         
198                 });
199
200    
201                 this.left_props.stop_editor.connect( () => {
202                         if (this.state != State.CODE) {
203                                 return true;
204                         }
205         
206                         var ret =  this.code_editor.saveContents();
207                         if (!ret) {
208                                 return false;
209                         }
210                         this.switchState(State.PREVIEW);
211                         return ret;
212                 });
213         
214                 this.left_props.changed.connect(() => {
215                           if (this.left_tree.getActiveFile().xtype == "Roo" ) {
216                                    this.window_rooview.requestRedraw();
217                                    
218                            } else {
219                                   this.window_gladeview.loadFile(this.left_tree.getActiveFile());
220                           }
221                           this.left_tree.model.updateSelected();
222                           this.left_tree.model.file.save();
223                 });
224         
225
226
227         }
228
229         //-------------  projects edit
230
231         public void projectEditInit()
232         {
233                 this.projectsettings  =new Xcls_ProjectSettings();
234                 this.projectsettings.ref();  /// really?
235         
236                 this.vala_projectsettings  =new ValaProjectSettings();
237                 this.vala_projectsettings.ref();
238                 this.vala_projectsettings.window = this.win;
239         
240                 ((Gtk.Container)(this.win.projecteditview.el.get_widget())).add(this.projectsettings.el);
241                 //this.projectsettings.el.show_all();
242
243                 var stage = this.win.projecteditview.el.get_stage();
244                 stage.set_background_color(  Clutter.Color.from_string("#000"));
245         
246                 this.projectsettings.buttonPressed.connect((btn) => {
247                          if (this.left_tree.getActiveFile().xtype == "Roo" ) {
248                                 if (btn == "save") {
249                                         this.window_rooview.view.renderJS(true);
250                                 }
251                                 if (btn == "apply") {
252                                         this.window_rooview.view.renderJS(true);
253                                         return;
254                                 }
255                         } else {
256                                 // do nothing for gtk..
257                         }
258                         if (btn == "save" || btn == "apply") {
259                                 this.win.project.save();
260                  
261                         }
262                         this.switchState (State.PREVIEW); 
263                          
264                  });
265
266         }
267         // ----------- object adding
268         public void objectAddInit()
269         {
270
271                 this.rightpalete  = new Xcls_RightPalete();
272                 this.rightpalete.ref();  /// really?
273                 ((Gtk.Container)(this.win.objectview.el.get_widget())).add(this.rightpalete.el);
274                 //this.projectsettings.el.show_all();
275
276                 var stage = this.win.objectview.el.get_stage();
277                 stage.set_background_color(  Clutter.Color.from_string("#000"));
278                    
279         }
280         
281         // -----------  properties adding list...
282         // listener uses the properties 
283         public void propsAddInit()
284         {
285         // Add properties
286                 this.add_props  = new Xcls_WindowAddProp();
287                 this.add_props.ref();  /// really?
288                 ((Gtk.Container)(this.win.addpropsview.el.get_widget())).add(this.add_props.el);
289                 //this.projectsettings.el.show_all();
290
291                 var  stage = this.win.addpropsview.el.get_stage();
292                 stage.set_background_color(  Clutter.Color.from_string("#000"));
293
294
295                 this.add_props.select.connect( (key,type,skel, etype) => {
296                         this.left_props.addProp(etype, key, skel, type);
297                 });
298
299         }
300         public void propsAddShow()
301         {
302
303         }
304         public void propsAddHide()
305         {
306         
307         }
308
309
310
311         
312         // ----------- Add / Edit listener
313         // listener uses the properties 
314         //public void listenerInit()     { }
315         public void listenerShow()
316         {
317
318         }
319         public void listenerHide()
320         {
321         
322         }
323
324         // -------------- codeEditor
325
326         public void codeEditInit()
327         {
328                 this.code_editor  = new  Editor();
329                 //this.code_editor.ref();  /// really?
330                 ((Gtk.Container)(this.win.codeeditview.el.get_widget())).add(this.code_editor.el);
331                 
332                 this.code_editor.window = this.win;
333                 //this.projectsettings.el.show_all();
334
335                 var stage = this.win.codeeditview.el.get_stage();
336                 stage.set_background_color(  Clutter.Color.from_string("#000"));
337                 // editor.save...
338
339                 this.code_editor.save.connect( () => {
340                          this.left_tree.model.file.save();
341                          this.left_tree.model.updateSelected();
342                 });
343                 
344         }
345
346         // ----------- list of projects on left
347         public void  projectListInit() 
348         {
349
350                 this.left_projects = new Xcls_WindowLeftProjects();
351                  this.left_projects.ref();
352                  this.win.leftpane.el.pack_start(this.left_projects.el,true, true,0);
353                  this.left_projects.el.show_all();
354                  this.left_projects.project_selected.connect((proj) => {
355                         this.buttonsShowHide();
356                         proj.scanDirs();
357                         this.clutterfiles.loadProject(proj);
358                 
359                  });
360
361         }
362         // ----------- file view
363
364         public void fileViewInit()
365         {
366                 var stage = this.win.rooview.el.get_stage(); // seems odd... 
367                 this.clutterfiles = new Xcls_ClutterFiles();
368                 this.clutterfiles.ref();
369                 stage.add_child(this.clutterfiles.el);
370                 this.clutterfiles.el.show_all();
371
372
373                 this.clutterfiles.open.connect((file) => { 
374                         this.fileViewOpen(file);
375                 });
376                 this.clutterfiles.el.transitions_completed.connect(() => {
377                         if (this.state == State.FILES) {
378                                 this.win.rooview.el.hide();
379                         } else {
380                                 this.clutterfiles.el.hide();
381                         }
382                         
383                         
384                 });
385
386         }
387  
388         public void fileDetailsInit()
389         {
390                 this.file_details = new Xcls_PopoverFileDetails();
391                 this.file_details.mainwindow = this.win;
392                 // force it modal to the main window..
393                 
394                 this.file_details.success.connect((project,file) =>
395                 {
396                         this.fileViewOpen(file);
397                 });
398
399         }
400         
401         public void fileViewOpen(JsRender.JsRender file)
402         {
403                 this.win.project = file.project;
404                 this.switchState (State.PREVIEW); 
405         
406                 this.left_tree.model.loadFile(file);
407         
408                 var ctr= ((Gtk.Container)(this.win.rooview.el.get_widget()));
409                 var ctr_p= ((Gtk.Container)(this.win.projecteditview.el.get_widget()));
410         
411                 if (file.xtype == "Roo" ) { 
412                         ctr.foreach( (w) => { ctr.remove(w); });
413                         ctr_p.foreach( (w) => { ctr_p.remove(w); });
414                         ctr.add(this.window_rooview.el);
415                         ctr_p.add(this.projectsettings.el);            
416                         this.window_rooview.loadFile(file);
417                         this.window_rooview.el.show_all();
418                         this.projectsettings.el.show_all();            
419
420                 } else {
421                         ctr.foreach( (w) => { ctr.remove(w); });
422                         ctr_p.foreach( (w) => { ctr_p.remove(w); });            
423                         ctr.add(this.window_gladeview.el);
424                         ctr_p.add(this.vala_projectsettings.el);
425                         this.window_gladeview.loadFile(file);
426                         this.window_gladeview.el.show_all();
427                         this.vala_projectsettings.el.show_all();
428                 }
429                 print("OPEN : " + file.name);
430                 this.win.editpane.el.set_position(this.win.editpane.el.max_position);
431                 this.win.setTitle(file.project.name + " : " +file.name);
432                          
433
434                 }
435
436         
437         // ---------  webkit view
438         public void webkitViewInit()
439         {
440                 this.window_rooview  =new Xcls_WindowRooView();
441                 this.window_rooview.ref();
442                 ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
443                 this.window_rooview.el.show_all();
444
445                 var stage = this.win.rooview.el.get_stage();
446                 stage.set_background_color(  Clutter.Color.from_string("#000"));
447         }
448
449         // ------ Gtk  - view
450
451         public void gtkViewInit()
452         {
453                 this.window_gladeview  =new Xcls_GtkView();
454                 this.window_gladeview.ref();
455                 this.window_gladeview.main_window = this.win;
456         }
457         
458         public void easingSaveAll()
459         {
460                 this.win.addpropsview.el.save_easing_state();
461                 this.win.codeeditview.el.save_easing_state();
462                 this.win.objectview.el.save_easing_state();
463                 this.win.projecteditview.el.save_easing_state();
464                 this.win.rooview.el.save_easing_state();
465                 this.clutterfiles.el.save_easing_state();
466                  
467         }
468         public void easingRestoreAll()
469         {
470                 this.win.addpropsview.el.restore_easing_state();
471                 this.win.codeeditview.el.restore_easing_state();
472                 this.win.objectview.el.restore_easing_state();
473                 this.win.projecteditview.el.restore_easing_state();
474                 this.win.rooview.el.restore_easing_state();
475                 this.clutterfiles.el.restore_easing_state();
476                 
477         }
478         public void switchState(State new_state)
479         {
480                 
481                 // save the easing state of everything..
482                 this.easingSaveAll();
483                 
484                 switch (this.state) {
485
486                         case State.PREVIEW:
487                                 if (this.left_tree.getActiveFile() != null) {
488                                          if (this.left_tree.getActiveFile().xtype == "Roo" ) {
489                                                  this.window_rooview.createThumb();
490                                          } else {
491                                                   this.window_gladeview.createThumb();
492                                           }
493                                 }
494                                 // normally we are going from preview to another state.
495                                 // and different windows hide the preview in differnt ways..
496                                 
497                                 break;
498                         
499                    case State.LISTENER:
500                    case State.PROP:
501                                 
502                                 this.win.addpropsview.el.set_scale(0.0f,0.0f);
503                                  break;
504                                 
505                         case State.CODE:
506
507
508                                 this.code_editor.saveContents();
509                           
510                                 this.win.codeeditview.el.set_scale(0.0f,0.0f);
511                                  break;
512
513
514                          case State.OBJECT:
515                            
516                                 this.win.objectview.el.set_scale(0.0f,0.0f);
517                                  break;
518
519                    case State.PROJECT:
520                                 if (this.win.project.xtype == "Gtk") {
521                                         this.vala_projectsettings.save();
522                                 } 
523                                 
524                                 this.win.projecteditview.el.set_scale(0.0f,0.0f);
525                                  break;
526
527                   case State.FILES:
528                                 // hide files...
529                                 
530                                 this.win.rooview.el.show_all();
531                                 this.win.rooview.el.set_easing_duration(1000);
532                                 this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
533                                 this.win.rooview.el.set_scale(1.0f,1.0f);
534                                 this.win.rooview.el.set_pivot_point(0.5f,0.5f);
535                                 this.win.rooview.el.set_opacity(0xff);
536                            
537                                 
538                            
539                                  this.clutterfiles.el.set_easing_duration(1000);
540                                 this.clutterfiles.el.set_pivot_point(0.5f,0.5f);
541                                 this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, -180.0f);
542                                 this.clutterfiles.el.set_opacity(0);
543  
544                                 //this.clutterfiles.el.hide();
545                                  
546
547                                 break;
548
549                                 
550                 }
551            
552                 var oldstate  =this.state;
553                 this.state = new_state;
554                 
555                 
556                                 
557                 this.buttonsShowHide();
558                 
559                 
560                 switch (this.state) {
561                         
562                         case State.PREVIEW:  // this is the default state when working...
563                                  this.win.editpane.el.show(); // holder for tree and properties..
564                                  
565                          
566                                  this.left_projects.el.hide(); 
567                                  if (oldstate != State.FILES) {
568                                         // it's handled above..
569                                         print ("changing state to preview from NOT files..");
570                                          
571  
572                                         this.win.rooview.el.set_scale(1.0f,1.0f);
573                                  }
574                            
575                                 break;
576
577
578                         case State.LISTENER:
579                 // same as prop?
580                         case State.PROP:
581                                 var ae =      this.left_tree.getActiveElement();
582                                 if (ae == null) {
583                                         this.state = oldstate;
584                                         this.buttonsShowHide();
585                                         this.resizeCanvasElements();
586                                         this.easingRestoreAll();
587                                         return;
588                                 }
589                                 this.add_props.el.show_all();
590                                 this.add_props.show(
591                                         Palete.factory(this.win.project.xtype), 
592                                         this.state == State.LISTENER ? "signals" : "props",
593                                         ae.fqn()
594                                 );
595  
596                                         
597  
598                                 
599                                 // -- FIXME? this needs to be State aware?
600                  
601                                 this.win.rooview.el.set_pivot_point(1.0f,0.5f);
602                                   
603                                 this.win.addpropsview.el.set_scale(1.0f,1.0f);
604                                  break;
605                    
606                         case State.OBJECT:
607                                  var n = this.left_tree.getActiveElement();
608
609                                 if (this.left_tree.model.file == null) {
610                                         this.state =oldstate;
611                                         this.buttonsShowHide();
612                                         this.resizeCanvasElements();
613                                         this.easingRestoreAll();
614                                         return;
615                                 }
616                                 
617                                 if (n == null && this.left_tree.model.file.tree != null) {
618                                         this.state = oldstate;
619                                         this.buttonsShowHide();
620                                         this.resizeCanvasElements();
621                                         this.easingRestoreAll();
622                                         return;
623                                 }
624
625                                 this.rightpalete.el.show_all();
626                                 this.rightpalete.load(this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn());
627
628                                 
629                           
630                         
631                                 this.win.objectview.el.set_scale(1.0f,1.0f);
632                                  
633                                 break;
634                    
635                    
636                         case State.CODE:
637
638                                 this.code_editor.el.show_all();
639                                 
640                                 // caller needs to call editor - show....
641                                   
642  
643                                  this.win.codeeditview.el.set_scale(1.0f,1.0f);
644                                  break;
645
646
647
648                    case State.PROJECT:
649
650                            if (this.win.project.xtype == "Roo") {
651                                         this.projectsettings.el.show_all();
652                                         this.projectsettings.show(this.win.project);
653                                 } else {
654                                         this.vala_projectsettings.el.show_all();
655                                         this.vala_projectsettings.show((Project.Gtk)this.win.project);
656                                 }
657
658                                 this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right..
659                                 
660                                 this.win.projecteditview.el.set_scale(1.0f,1.0f);
661                                 
662                            
663                                 break;
664                                 
665                    case State.FILES:  // can only get here from PREVIEW state.. in theory..
666                                 
667    
668                                 this.win.editpane.el.hide(); // holder for tree and properties..
669                          
670                                 this.left_projects.el.show(); 
671                         
672                                  this.win.rooview.el.set_easing_duration(1000);
673                                 this.win.rooview.el.set_pivot_point(0.5f,0.5f);
674                                 this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 180.0f);
675                                 this.win.rooview.el.set_opacity(0);
676                                 //el.set_scale(0.0f,0.0f);
677
678  
679                                 if (this.win.project != null) {
680                                         this.left_projects.selectProject(this.win.project);
681                                 }
682                          
683                                 
684                                 this.clutterfiles.el.show_all();
685                                  
686                                 this.clutterfiles.el.set_easing_duration(1000);
687                                 this.clutterfiles.el.set_pivot_point(0.5f,0.5f);
688                                 this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
689                                 this.clutterfiles.el.set_opacity(0xff);
690                                 
691                                 
692                                 
693                                 break;
694
695
696                 }
697                 this.resizeCanvasElements();
698                 this.easingRestoreAll();
699                 
700                         
701         }
702         
703         public int redraw_count = 0;
704         public void resizeCanvas() // called by window resize .. delays redraw
705         {
706                 var rc = this.redraw_count;        
707                 this.redraw_count = 2;
708                 if (rc == 0) {
709                         GLib.Timeout.add(100,  ()  =>{
710                                  return this.resizeCanvasQueue();
711                         });
712                 }
713         }
714         public bool  resizeCanvasQueue()
715         {
716                 //print("WindowState.resizeCanvasQueue %d\n", this.redraw_count);        
717
718                 if (this.redraw_count < 1) {
719                         return false; // should not really happen...
720                 }
721
722
723                 this.redraw_count--;
724
725                 if (this.redraw_count > 0) {
726                         return true; // do it again in 1 second...
727                 }
728                 // got down to 0 or -1....
729                 this.redraw_count = 0;
730                 this.resizeCanvasElements();
731                 return false;
732
733         }
734         public void resizeCanvasElements()
735         {
736                 Gtk.Allocation alloc;
737                 this.win.clutterembed.el.get_allocation(out alloc);
738
739            // print("WindowState.resizeCanvasElements\n");
740                 if (!this.children_loaded || this.win.clutterembed == null) {
741                         print("WindowState.resizeCanvasElements = ingnore not loaded or no clutterfiles\n");
742                         return; 
743                 }
744                 
745                 var avail = alloc.width < 50.0f ? 0 :  alloc.width - 50.0f;
746                 var palsize = avail < 300.0f ? avail : 300.0f;
747                    
748  
749                 // -------- code edit min 600
750                 
751                 var codesize = avail < 800.0f ? avail : 800.0f;
752                 
753                 
754                 //print("set code size %f\n", codesize);
755
756                         
757                 
758                 switch ( this.state) {
759                         case State.PREVIEW:
760                                 this.win.rooview.el.set_size(alloc.width-50, alloc.height);
761                                 break;
762         
763                         case State.FILES: 
764                                 this.clutterfiles.set_size(alloc.width-50, alloc.height);
765                                 break;
766
767                         case State.PROJECT:
768                  
769                                 this.win.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f);
770                 
771                            // this.win.rooview.el.save_easing_state();
772                                 //this.win.rooview.el.set_size(alloc.width / 2.0f, alloc.height / 2.0f);
773                                 this.win.rooview.el.set_scale(0.5f, 0.5f);
774                                 //this.win.rooview.el.restore_easing_state();
775                                 break;
776
777                         case State.CODE: 
778                                 this.win.codeeditview.el.set_size(codesize, alloc.height);
779                                 var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f;
780                                 //this.win.rooview.el.save_easing_state();
781                                  
782                                 this.win.rooview.el.set_scale(scale,scale);
783                            // this.win.rooview.el.restore_easing_state();
784                                 break;
785                                 
786                         case State.PROP:
787                         case State.LISTENER:
788                                  this.win.addpropsview.el.set_size(palsize, alloc.height);
789                                 var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
790                                 this.win.rooview.el.set_scale(scale,scale);
791                                 break;
792                                 
793                         case State.OBJECT:  
794                                 this.win.objectview.el.set_size(palsize, alloc.height);    
795                                 var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
796                                 //this.win.rooview.el.save_easing_state();
797                                 this.win.rooview.el.set_scale(scale,scale);
798                            // this.win.rooview.el.restore_easing_state();
799                                 break;
800                 }
801         }
802
803         // -- buttons show hide.....
804
805         public void buttonsShowHide()
806         {
807                 // basically hide everything, then show the relivant..
808
809                  this.win.backbutton.el.hide();
810         
811                 this.win.projectbutton.el.hide(); // show file nav...
812                 this.win.editfilebutton.el.hide();
813                 this.win.projecteditbutton.el.hide();
814                  
815                 
816                 this.win.objectshowbutton.el.hide(); // add objects
817                 this.win.addpropbutton.el.hide();  
818                 this.win.addlistenerbutton.el.hide(); 
819
820         
821         
822                 this.win.addprojectbutton.el.hide();
823                 this.win.addfilebutton.el.hide();
824                 this.win.delprojectbutton.el.hide();
825                   
826                 
827                 switch (this.state) {
828                         
829                         case State.PREVIEW:  // this is the default state when working...
830                            
831                                 this.win.projectbutton.el.show(); // show file nav...
832                                 this.win.editfilebutton.el.show();
833                                 this.win.projecteditbutton.el.show();
834                                  
835                                 
836                                 this.win.objectshowbutton.el.show(); // add objects
837                                 this.win.addpropbutton.el.show();  
838                                 this.win.addlistenerbutton.el.show(); 
839                                 break;
840                         
841                    
842                         case State.CODE: 
843                         case State.PROP:
844                         case State.LISTENER:
845                         case State.OBJECT:
846                                 
847                                 this.win.backbutton.el.show();
848                                 this.win.objectshowbutton.el.show(); // add objects
849                                 this.win.addpropbutton.el.show();  
850                                 this.win.addlistenerbutton.el.show(); 
851                                 break;
852                         
853                         case State.PROJECT: 
854                                 // anything else?
855                                 this.win.backbutton.el.show();
856                                 break;
857                         
858         
859                         case State.FILES:
860                                 if (this.left_projects.getSelectedProject() != null ) {
861                                         if (this.left_tree.getActiveFile() != null) {
862                                                 this.win.backbutton.el.show();
863                                         }
864                                         this.win.addfilebutton.el.show();
865                                 }
866                                          
867                                 this.win.addprojectbutton.el.show();
868                                 this.win.delprojectbutton.el.show();
869                                 
870                                 break;
871                 }
872
873         }
874
875         
876 }
877
878