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