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