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