resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / ClutterFiles.vala
index 782d44c..f10613d 100644 (file)
@@ -16,7 +16,7 @@ public class Xcls_ClutterFiles : Object
     public Xcls_project_title_manager project_title_manager;
     public Xcls_project_title_name project_title_name;
     public Xcls_project_title_path project_title_path;
-    public Xcls_scoller scoller;
+    public Xcls_scroller scroller;
     public Xcls_filelayout filelayout;
     public Xcls_filelayout_manager filelayout_manager;
 
@@ -24,6 +24,7 @@ public class Xcls_ClutterFiles : Object
     public Clutter.ScrollMode scroll_mode;
     public Gdk.Pixbuf missing_thumb_pixbuf;
     public signal void open (JsRender.JsRender file);
+    public Project.Project project;
     public Gee.ArrayList<Object> fileitems;
 
     // ctor
@@ -42,7 +43,7 @@ public class Xcls_ClutterFiles : Object
         var child_0 = new Xcls_project_title( _this );
         child_0.ref();
         this.el.add_child (  child_0.el  );
-        var child_1 = new Xcls_scoller( _this );
+        var child_1 = new Xcls_scroller( _this );
         child_1.ref();
         this.el.add_child (  child_1.el  );
     }
@@ -57,6 +58,9 @@ public class Xcls_ClutterFiles : Object
     public  void loadProject (Project.Project pr) {
         // list all the files, and create new Xcls_fileitem for each one.
         
+        this.project = pr;
+        
+        
         // LEAK --- we should unref all the chilren...
         this.filelayout.el.y = 0;
         this.clearFiles();
@@ -96,7 +100,7 @@ public class Xcls_ClutterFiles : Object
          
         for(var i =0 ; i < items.size; i++) {
             print ("cheking folder %s\n", items.get(i));
-             var files = gpr.files(items.get(i));
+             var files = gpr.filesForOpen(items.get(i));
              if (files.size < 1) {
                 continue;
              }
@@ -131,11 +135,22 @@ public class Xcls_ClutterFiles : Object
          // called by window resize... with is alreaddy -50 (for the buttons?)
          
     
+    
+    
          if (this.el == null) {
             print("object not ready yet?");
             return;
         }
-       _this.filelayout_manager.el.max_column_width = w - 75;
+        
+        print("recv width %f, filelayoutw = %f", w, w-200);
+        
+        w = GLib.Math.floorf ( w/120.0f) * 120.0f;
+        
+        
+        
+        
+       //_this.filelayout_manager.el.max_column_width = w - 200;
+       _this.filelayout.el.width = w ;
        
         this.el.set_size(
                // this.el.get_stage().width-150,
@@ -144,17 +159,20 @@ public class Xcls_ClutterFiles : Object
         );
         
         // 100 right for buttons ..
-        this.el.set_position(0,0);
+        this.el.set_position(75,0);
        
        
-       this.scoller.el.set_size(
+       this.scroller.el.set_size(
                // this.el.get_stage().width-150,
-               w-150,
+               w,
                h  // this.el.get_stage().height
         );
         
         // 100 right for buttons ..
-        this.scoller.el.set_position(75,50);
+        this.scroller.el.set_position(0,50);
+        // scroll...
+        _this.filelayout.el.y = 0.0f;
+        
     }
     public class Xcls_project_title : Object
     {
@@ -193,7 +211,7 @@ public class Xcls_ClutterFiles : Object
             this.el.add_constraint(
                 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
             );
-            this.el.set_position(75,0);
+            this.el.set_position(0,0);
         }
 
         // user defined functions
@@ -298,7 +316,7 @@ public class Xcls_ClutterFiles : Object
     }
 
 
-    public class Xcls_scoller : Object
+    public class Xcls_scroller : Object
     {
         public Clutter.ScrollActor el;
         private Xcls_ClutterFiles  _this;
@@ -309,10 +327,10 @@ public class Xcls_ClutterFiles : Object
         public Gdk.Pixbuf missing_thumb_pixbuf;
 
         // ctor
-        public Xcls_scoller(Xcls_ClutterFiles _owner )
+        public Xcls_scroller(Xcls_ClutterFiles _owner )
         {
             _this = _owner;
-            _this.scoller = this;
+            _this.scroller = this;
             this.el = new Clutter.ScrollActor();
 
             // my vars (dec)
@@ -328,42 +346,48 @@ public class Xcls_ClutterFiles : Object
 
             //listeners
             this.el.scroll_event.connect( ( event) => {
-               //Sprint("scroll event");
-                        var y = _this.filelayout.el.y;
-                        var dir = event.direction;
-                        switch (dir) {
-                            case Clutter.ScrollDirection.UP:
-                                y += event.y /2;
-                                break;
-                            case Clutter.ScrollDirection.DOWN:
-                                y -= event.y /2 ;
-                                break;
-                            default:
-                                return false;
-                        }
-                        // range of scroll -- can go up -- eg.. -ve value.
-                        
-                        y = float.min(0, y);
-                        
-                        // to work out the max -ve number
-                        // height of filelayout
-                        // height of scrollactor..
+                print("scroll event\n");
+                var y = _this.filelayout.el.y;
+                var dir = event.direction;
+                
+                var last_child_bottom = _this.filelayout.el.last_child.y +  _this.filelayout.el.last_child.height;
+                var bottompos = -1 * (  last_child_bottom - (0.5f * this.el.height));
+                
+                switch (dir) {
+                    case Clutter.ScrollDirection.UP:
+                        print("Scroll up by %f\n", event.y);
+                        y += event.y /2;
+                        y = float.min(0, y); // 
+                        break;
                         
-                        var last_child_bottom = _this.filelayout.el.last_child.y +  _this.filelayout.el.last_child.height;
-                         if ( (-1 * (y+200)) > (  last_child_bottom - this.el.height)) {
-                            return  false;
-                        }
-                    
-                    
+                    case Clutter.ScrollDirection.DOWN:
+                        print("Scroll down by %f\n", event.y);
+                        y -= event.y /2 ;
+                        y = float.max(bottompos, y);
                         
                         
-                    //    print("\nlast child - this height = %f  ==== new y %f\n ".printf( 
-                      //          last_child_bottom - this.el.height,
-                       //         y));    
-                       // y = float.min(0, y);    //??
-                       // print("scroll event of %f  - new y = %f ".printf(event.y, y));
-                        _this.filelayout.el.y = y;
-                        return true;
+                        break;
+                         case Clutter.ScrollDirection.SMOOTH:
+                           double delta_x, delta_y;
+                           event.get_scroll_delta(out delta_x, out delta_y);
+                        //print("Scroll SMOOTH? by %f\n",  delta_y * event.y);
+                        y += ((float)delta_y * event.y * -1.0f) /2 ;
+                        y = float.max(bottompos, y);
+                        y = float.min(0, y); // 
+                                   
+                        break;
+                    default:
+                       print("scroll event = bad direction %s\n", dir.to_string());
+                        return false;
+                }
+                // range of scroll -- can go up -- eg.. -ve value.
+                
+            
+                
+               print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
+               
+                _this.filelayout.el.y = y;
+                return true;
                       
             });
         }
@@ -420,7 +444,8 @@ public class Xcls_ClutterFiles : Object
             // my vars (dec)
 
             // set gobject values
-            this.el.homogeneous = true;
+            this.el.homogeneous = false;
+            this.el.max_column_width = 100.0f;
             this.el.row_spacing = 20f;
             this.el.column_spacing = 20f;
         }
@@ -478,10 +503,21 @@ public class Xcls_ClutterFiles : Object
             });
             this.el.enter_event.connect( (  event)  => {
                 this.el.background_color =   Clutter.Color.from_string("#333");
+                this.title.el.background_color =   Clutter.Color.from_string("#fff");
+                this.typetitle.el.background_color =   Clutter.Color.from_string("#fff");
+                this.title.el.color =   Clutter.Color.from_string("#000");
+                this.typetitle.el.color =   Clutter.Color.from_string("#000");
+                
                     return false;
             });
             this.el.leave_event.connect( (  event)  => {
                 this.el.background_color =   Clutter.Color.from_string("#000");
+                 this.title.el.background_color =   Clutter.Color.from_string("#000");
+                this.typetitle.el.background_color =   Clutter.Color.from_string("#000");
+                this.title.el.color =   Clutter.Color.from_string("#fff");
+                this.typetitle.el.color =   Clutter.Color.from_string("#fff");
+               
+                
                 return false;
             });
         }
@@ -532,10 +568,10 @@ public class Xcls_ClutterFiles : Object
             this.el.margin_right = 5f;
             this.el.margin_left = 5f;
             this.el.x_align = Clutter.ActorAlign.START;
-            this.el.x_expand = true;
+            this.el.x_expand = false;
             this.el.y_align = Clutter.ActorAlign.START;
             this.el.margin_top = 5f;
-            this.el.y_expand = true;
+            this.el.y_expand = false;
 
             // init method
 
@@ -608,9 +644,9 @@ public class Xcls_ClutterFiles : Object
 
             // set gobject values
             this.el.x_align = Clutter.ActorAlign.START;
-            this.el.x_expand = true;
+            this.el.x_expand = false;
             this.el.y_align = Clutter.ActorAlign.START;
-            this.el.y_expand = true;
+            this.el.y_expand = false;
         }
 
         // user defined functions
@@ -634,7 +670,7 @@ public class Xcls_ClutterFiles : Object
 
             // set gobject values
             this.el.x_align = Clutter.ActorAlign.START;
-            this.el.x_expand = true;
+            this.el.x_expand = false;
             this.el.y_align = Clutter.ActorAlign.START;
             this.el.y_expand = false;
         }
@@ -713,7 +749,7 @@ public class Xcls_ClutterFiles : Object
         public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
         {
             _this = _owner;
-            this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath),  Clutter.Color.from_string("#fff"));
+            this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath),  Clutter.Color.from_string("#fff"));
 
             // my vars (dec)
 
@@ -721,7 +757,7 @@ public class Xcls_ClutterFiles : Object
             this.el.x_align = Clutter.ActorAlign.START;
             this.el.x_expand = true;
             this.el.y_align = Clutter.ActorAlign.START;
-            this.el.y_expand = true;
+            this.el.y_expand = false;
         }
 
         // user defined functions
@@ -754,20 +790,24 @@ public class Xcls_ClutterFiles : Object
             // init method
 
             {
-                this.filepath = filepath;
+               this.filepath = filepath;
             }
 
             //listeners
             this.el.button_press_event.connect( (  event) => {
-               // _this.open(this.filepath);
+                
+               var f = JsRender.JsRender.factory("PlainFile", _this.project, this.filepath);
+                _this.open(f);
                 return false;
             });
             this.el.enter_event.connect( (  event)  => {
-                this.el.background_color =   Clutter.Color.from_string("#333");
+                this.el.background_color =   Clutter.Color.from_string("#fff");
+                this.el.color =  Clutter.Color.from_string("#000");
                     return false;
             });
             this.el.leave_event.connect( (  event)  => {
                 this.el.background_color =   Clutter.Color.from_string("#000");
+                 this.el.color =   Clutter.Color.from_string("#fff");
                 return false;
             });
         }