resources/Editors/Editor.Roo.grid.Grid.bjs
[app.Builder.js] / src / Builder4 / WindowState.vala
index cc413fd..359677b 100644 (file)
@@ -38,36 +38,44 @@ public class WindowState : Object
     public Xcls_ClutterFiles     clutterfiles;
 
     public Xcls_WindowLeftProjects left_projects; // can not see where this is initialized.. 
+    
+    public DialogTemplateSelect template_select; 
+    
+    // dialogs??
+    public Xcls_DialogPluginWebkit webkit_plugin;
+    
     // ctor 
     public WindowState(Xcls_MainWindow win)
     {
-        this.win = win;
-        // initialize
-
-        // left elements..
-        this.leftTreeInit();
-        this.propsListInit();
-
-        // on clutter space...
-        this.projectEditInit();
-        this.codeEditInit();
-        this.projectListInit();
-        this.fileViewInit();
-        
-        // adding stuff
-        this.objectAddInit();
-        this.propsAddInit();
-     
-        
-        // previews...
-        this.gtkViewInit();
-        this.webkitViewInit();
+               this.win = win;
+               // initialize
+
+               // left elements..
+               this.leftTreeInit();
+               this.propsListInit();
+
+               // on clutter space...
+               this.projectEditInit();
+               this.codeEditInit();
+               this.projectListInit();
+               this.fileViewInit();
 
-        // dialogs
+               // adding stuff
+               this.objectAddInit();
+               this.propsAddInit();
 
-        this.fileNewInit();
 
-        this.children_loaded = true;
+               // previews...
+               this.gtkViewInit();
+               this.webkitViewInit();
+
+               // dialogs
+
+               this.fileNewInit();
+
+               this.webkit_plugin = new Xcls_DialogPluginWebkit();
+               this.template_select = new DialogTemplateSelect();
+               this.children_loaded = true;
     }
 
 
@@ -439,11 +447,32 @@ public class WindowState : Object
         this.window_gladeview  =new Xcls_GtkView();
         this.window_gladeview.ref();
     }
-
+    
+    public void easingSaveAll()
+    {
+        this.win.addpropsview.el.save_easing_state();
+        this.win.codeeditview.el.save_easing_state();
+        this.win.objectview.el.save_easing_state();
+        this.win.projecteditview.el.save_easing_state();
+        this.win.rooview.el.save_easing_state();
+        this.clutterfiles.el.save_easing_state();
+         
+    }
+    public void easingRestoreAll()
+    {
+        this.win.addpropsview.el.restore_easing_state();
+        this.win.codeeditview.el.restore_easing_state();
+        this.win.objectview.el.restore_easing_state();
+        this.win.projecteditview.el.restore_easing_state();
+        this.win.rooview.el.restore_easing_state();
+        this.clutterfiles.el.restore_easing_state();
+        
+    }
     public void switchState(State new_state)
     {
         
-
+        // save the easing state of everything..
+        this.easingSaveAll();
         
         switch (this.state) {
 
@@ -462,52 +491,49 @@ public class WindowState : Object
             
            case State.LISTENER:
            case State.PROP:
-                this.win.addpropsview.el.save_easing_state();
+                
                 this.win.addpropsview.el.set_scale(0.0f,0.0f);
-                this.win.addpropsview.el.restore_easing_state();   
-                break;
+                 break;
                 
             case State.CODE:
 
 
                 this.code_editor.saveContents();
-                this.win.codeeditview.el.save_easing_state();
+              
                 this.win.codeeditview.el.set_scale(0.0f,0.0f);
-                this.win.codeeditview.el.restore_easing_state();    
-                break;
+                 break;
 
 
              case State.OBJECT:
-                this.win.objectview.el.save_easing_state();
+               
                 this.win.objectview.el.set_scale(0.0f,0.0f);
-                this.win.objectview.el.restore_easing_state();    
-                break;
+                 break;
 
            case State.PROJECT:
-                this.win.projecteditview.el.save_easing_state();
+                if (this.win.project.xtype == "Gtk") {
+                    this.vala_projectsettings.save();
+                } 
+                
                 this.win.projecteditview.el.set_scale(0.0f,0.0f);
-                this.win.projecteditview.el.restore_easing_state();    
-                break;
+                 break;
 
           case State.FILES:
                 // hide files...
-                this.win.rooview.el.save_easing_state();
-               this.win.rooview.el.show_all();
+                
+                this.win.rooview.el.show_all();
                 this.win.rooview.el.set_easing_duration(1000);
                 this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
                 this.win.rooview.el.set_scale(1.0f,1.0f);
                 this.win.rooview.el.set_pivot_point(0.5f,0.5f);
                 this.win.rooview.el.set_opacity(0xff);
-                this.win.rooview.el.restore_easing_state();  
+               
                 
                
-                this.clutterfiles.el.save_easing_state();
-                this.clutterfiles.el.set_easing_duration(1000);
+                 this.clutterfiles.el.set_easing_duration(1000);
                 this.clutterfiles.el.set_pivot_point(0.5f,0.5f);
                 this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, -180.0f);
                 this.clutterfiles.el.set_opacity(0);
-                this.clutterfiles.el.restore_easing_state();  
-
                 //this.clutterfiles.el.hide();
                  
 
@@ -515,13 +541,15 @@ public class WindowState : Object
 
                 
         }
-        this.resizeCanvasElements();
+       
         var oldstate  =this.state;
         this.state = new_state;
-
+        
+        
                 
         this.buttonsShowHide();
         
+        
         switch (this.state) {
             
             case State.PREVIEW:  // this is the default state when working...
@@ -531,12 +559,10 @@ public class WindowState : Object
                  this.left_projects.el.hide(); 
                  if (oldstate != State.FILES) {
                     // it's handled above..
-                   print ("changing state to preview from NOT files..");
-                    this.win.rooview.el.save_easing_state();
-                           this.resizeCanvasElements();
-
+                    print ("changing state to preview from NOT files..");
+                     
                     this.win.rooview.el.set_scale(1.0f,1.0f);
-                    this.win.rooview.el.restore_easing_state();
                  }
                
                 break;
@@ -549,6 +575,8 @@ public class WindowState : Object
                 if (ae == null) {
                     this.state = oldstate;
                     this.buttonsShowHide();
+                    this.resizeCanvasElements();
+                    this.easingRestoreAll();
                     return;
                 }
                 this.add_props.el.show_all();
@@ -560,66 +588,59 @@ public class WindowState : Object
  
                     
  
-                this.win.rooview.el.save_easing_state();
-                // -- FIXME? this needs to be State aware?
-               this.resizeCanvasElements();
-
-               this.win.rooview.el.set_pivot_point(1.0f,0.5f);
-                this.win.rooview.el.restore_easing_state();
                 
-              
-                this.win.addpropsview.el.save_easing_state();
+                // -- FIXME? this needs to be State aware?
+         
+                this.win.rooview.el.set_pivot_point(1.0f,0.5f);
+                  
                 this.win.addpropsview.el.set_scale(1.0f,1.0f);
-                this.win.addpropsview.el.restore_easing_state();
-                break;
-                
-            case State.CODE:
-
-                this.code_editor.el.show_all();
-                
-                // caller needs to call editor - show....
-                this.win.rooview.el.save_easing_state();
-                //this.resizeCanvasElements();
-                this.win.rooview.el.restore_easing_state();
-                
-                this.win.codeeditview.el.save_easing_state();
-                this.win.codeeditview.el.set_scale(1.0f,1.0f);
-                this.win.codeeditview.el.restore_easing_state();    
-                break;
-
-
-             case State.OBJECT:
+                 break;
+           
+            case State.OBJECT:
                  var n = this.left_tree.getActiveElement();
 
                 if (this.left_tree.model.file == null) {
                     this.state =oldstate;
                     this.buttonsShowHide();
+                    this.resizeCanvasElements();
+                    this.easingRestoreAll();
                     return;
                 }
                 
                 if (n == null && this.left_tree.model.file.tree != null) {
                     this.state = oldstate;
                     this.buttonsShowHide();
+                    this.resizeCanvasElements();
+                    this.easingRestoreAll();
                     return;
                 }
 
                 this.rightpalete.el.show_all();
                 this.rightpalete.load(this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn());
 
-                this.win.rooview.el.save_easing_state();
-               // this.resizeCanvasElements();
-                this.win.rooview.el.restore_easing_state();
-
                 
-                this.win.objectview.el.save_easing_state();
+              
+            
                 this.win.objectview.el.set_scale(1.0f,1.0f);
-                this.win.objectview.el.restore_easing_state();    
+                 
                 break;
+              
+              
+            case State.CODE:
+
+                this.code_editor.el.show_all();
+                
+                // caller needs to call editor - show....
+                  
+                 this.win.codeeditview.el.set_scale(1.0f,1.0f);
+                 break;
+
+
 
            case State.PROJECT:
 
-             if (this.win.project.xtype == "Roo") {
+               if (this.win.project.xtype == "Roo") {
                     this.projectsettings.el.show_all();
                     this.projectsettings.show(this.win.project);
                 } else {
@@ -627,13 +648,11 @@ public class WindowState : Object
                     this.vala_projectsettings.show((Project.Gtk)this.win.project);
                 }
 
-                this.win.rooview.el.save_easing_state();
-               // this.resizeCanvasElements();
-                this.win.rooview.el.restore_easing_state();
-
-                this.win.projecteditview.el.save_easing_state();
+                this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right..
+                
                 this.win.projecteditview.el.set_scale(1.0f,1.0f);
-                this.win.projecteditview.el.restore_easing_state();    
+                
+               
                 break;
                 
            case State.FILES:  // can only get here from PREVIEW state.. in theory..
@@ -643,12 +662,10 @@ public class WindowState : Object
              
                 this.left_projects.el.show(); 
             
-                var el = this.win.rooview.el;
-                el.save_easing_state();
-                el.set_easing_duration(1000);
-                el.set_pivot_point(0.5f,0.5f);
-                el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 180.0f);
-                el.set_opacity(0);
+                 this.win.rooview.el.set_easing_duration(1000);
+                this.win.rooview.el.set_pivot_point(0.5f,0.5f);
+                this.win.rooview.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 180.0f);
+                this.win.rooview.el.set_opacity(0);
                 //el.set_scale(0.0f,0.0f);
 
  
@@ -656,94 +673,26 @@ public class WindowState : Object
                     this.left_projects.selectProject(this.win.project);
                 }
              
-                el.restore_easing_state();
                 
                 this.clutterfiles.el.show_all();
-                this.clutterfiles.el.save_easing_state();
+                 
                 this.clutterfiles.el.set_easing_duration(1000);
                 this.clutterfiles.el.set_pivot_point(0.5f,0.5f);
                 this.clutterfiles.el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
                 this.clutterfiles.el.set_opacity(0xff);
-                this.clutterfiles.el.restore_easing_state();  
+                
                 
                 
                 break;
 
 
         }
-
-            
-    }
-    
-    // -- buttons show hide.....
-
-    public void buttonsShowHide()
-    {
-        // basically hide everything, then show the relivant..
-
-         this.win.backbutton.el.hide();
-    
-        this.win.projectbutton.el.hide(); // show file nav...
-        this.win.editfilebutton.el.hide();
-        this.win.projecteditbutton.el.hide();
-         
-        
-        this.win.objectshowbutton.el.hide(); // add objects
-        this.win.addpropbutton.el.hide();  
-        this.win.addlistenerbutton.el.hide(); 
-
-    
-    
-        this.win.addprojectbutton.el.hide();
-        this.win.addfilebutton.el.hide();
-        this.win.delprojectbutton.el.hide();
-        this.win.new_window.el.hide();
-
+        this.resizeCanvasElements();
+        this.easingRestoreAll();
         
-        switch (this.state) {
             
-            case State.PREVIEW:  // this is the default state when working...
-               
-                this.win.projectbutton.el.show(); // show file nav...
-                this.win.editfilebutton.el.show();
-                this.win.projecteditbutton.el.show();
-                 
-                
-                this.win.objectshowbutton.el.show(); // add objects
-                this.win.addpropbutton.el.show();  
-                this.win.addlistenerbutton.el.show(); 
-                break;
-            
-           
-            case State.CODE: 
-            case State.PROP:
-            case State.LISTENER:
-            case State.OBJECT:
-                
-                this.win.backbutton.el.show();
-                this.win.objectshowbutton.el.show(); // add objects
-                this.win.addpropbutton.el.show();  
-                this.win.addlistenerbutton.el.show(); 
-                break;
-            
-            case State.PROJECT: 
-                // anything else?
-                this.win.backbutton.el.show();
-                break;
-            
-    
-            case State.FILES:
-                this.win.backbutton.el.show();
-                     
-                this.win.addprojectbutton.el.show();
-                this.win.addfilebutton.el.show();
-                this.win.delprojectbutton.el.show();
-                this.win.new_window.el.show();
-                break;
-        }
-
     }
-
+    
     public int redraw_count = 0;
     public void resizeCanvas() // called by window resize .. delays redraw
     {
@@ -785,29 +734,19 @@ public class WindowState : Object
                print("WindowState.resizeCanvasElements = ingnore not loaded or no clutterfiles\n");
             return; 
         }
-           //print("WindowState.resizeCanvasElements = running");
-
-        
-        // ------- project view appears at top...
-
-               
-        // ------- add property/object left - max 300px, min 50... (or disapear..)     
-        
+           
         var avail = alloc.width < 50.0f ? 0 :  alloc.width - 50.0f;
         var palsize = avail < 300.0f ? avail : 300.0f;
-        //print("set palsize size %f\n", palsize);
-        // palate / props : fixed 300 pix
-                
+           
  
         // -------- code edit min 600
         
         var codesize = avail < 800.0f ? avail : 800.0f;
+        
+        
         //print("set code size %f\n", codesize);
 
-
             
-
-
         
         switch ( this.state) {
             case State.PREVIEW:
@@ -818,25 +757,110 @@ public class WindowState : Object
                 this.clutterfiles.set_size(alloc.width-50, alloc.height);
                 break;
 
-            case State.PROJECT: 
+            case State.PROJECT:
+            
                 this.win.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f);
+               
+               // this.win.rooview.el.save_easing_state();
+                //this.win.rooview.el.set_size(alloc.width / 2.0f, alloc.height / 2.0f);
+                this.win.rooview.el.set_scale(0.5f, 0.5f);
+                //this.win.rooview.el.restore_easing_state();
                 break;
 
             case State.CODE: 
                 this.win.codeeditview.el.set_size(codesize, alloc.height);
                 var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f;
-                   this.win.rooview.el.set_scale(scale,scale);
+                   //this.win.rooview.el.save_easing_state();
+                 
+                this.win.rooview.el.set_scale(scale,scale);
+               // this.win.rooview.el.restore_easing_state();
                 break;
                 
             case State.PROP:
-            case State.LISTENER:        
+            case State.LISTENER:
+                 this.win.addpropsview.el.set_size(palsize, alloc.height);
+                var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
+                this.win.rooview.el.set_scale(scale,scale);
+                break;
+                
             case State.OBJECT:  
                 this.win.objectview.el.set_size(palsize, alloc.height);    
-                this.win.addpropsview.el.set_size(palsize, alloc.height);
-                   var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
+                var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;
+                //this.win.rooview.el.save_easing_state();
                 this.win.rooview.el.set_scale(scale,scale);
+               // this.win.rooview.el.restore_easing_state();
+                break;
+        }
+    }
+
+    // -- buttons show hide.....
+
+    public void buttonsShowHide()
+    {
+        // basically hide everything, then show the relivant..
+
+         this.win.backbutton.el.hide();
+    
+        this.win.projectbutton.el.hide(); // show file nav...
+        this.win.editfilebutton.el.hide();
+        this.win.projecteditbutton.el.hide();
+         
+        
+        this.win.objectshowbutton.el.hide(); // add objects
+        this.win.addpropbutton.el.hide();  
+        this.win.addlistenerbutton.el.hide(); 
+
+    
+    
+        this.win.addprojectbutton.el.hide();
+        this.win.addfilebutton.el.hide();
+        this.win.delprojectbutton.el.hide();
+        this.win.new_window.el.hide();
+        this.win.reload_resources.el.hide();
+        
+        switch (this.state) {
+            
+            case State.PREVIEW:  // this is the default state when working...
+               
+                this.win.projectbutton.el.show(); // show file nav...
+                this.win.editfilebutton.el.show();
+                this.win.projecteditbutton.el.show();
+                 
+                
+                this.win.objectshowbutton.el.show(); // add objects
+                this.win.addpropbutton.el.show();  
+                this.win.addlistenerbutton.el.show(); 
+                break;
+            
+           
+            case State.CODE: 
+            case State.PROP:
+            case State.LISTENER:
+            case State.OBJECT:
+                
+                this.win.backbutton.el.show();
+                this.win.objectshowbutton.el.show(); // add objects
+                this.win.addpropbutton.el.show();  
+                this.win.addlistenerbutton.el.show(); 
+                break;
+            
+            case State.PROJECT: 
+                // anything else?
+                this.win.backbutton.el.show();
+                break;
+            
+    
+            case State.FILES:
+                this.win.backbutton.el.show();
+                     
+                this.win.addprojectbutton.el.show();
+                this.win.addfilebutton.el.show();
+                this.win.delprojectbutton.el.show();
+                this.win.new_window.el.show();
+                this.win.reload_resources.el.show();
                 break;
         }
+
     }