resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / ClutterFiles.bjs
index 3cd37d7..03c89e8 100644 (file)
    "|  void clearFiles" : "() {\n    \n    this.filelayout.el.remove_all_children();\n    // we need to unref all the chidren that we loaded though...\n    \n}\n ",
    "Clutter.ScrollMode scroll_mode" : "Clutter.ScrollMode.VERTICALLY",
    "xtype" : "Actor",
-   "|  void loadProject" : "(Project.Project pr) {\n    // list all the files, and create new Xcls_fileitem for each one.\n    \n    // LEAK --- we should unref all the chilren...\n    this.filelayout.el.y = 0;\n    this.clearFiles();\n    \n    print(\"clutter files - load project: \" + pr.name +\"\\n\");\n    // should unref.. them hopefully.\n    \n    this.project_title_name.el.text = pr.name;\n    this.project_title_path.el.text = pr.firstPath();\n    \n    // file items contains a reference until we reload ...\n    this.fileitems = new Gee.ArrayList<Object>();\n\n    \n\n    var fiter = pr.sortedFiles().list_iterator();\n    while (fiter.next()) {\n        var a = new Xcls_fileitem(this,fiter.get());\n        this.fileitems.add(a);\n\n//        a.ref();\n        print(\"add to clutter file view: \" + fiter.get().name + \"\\n\");\n        this.filelayout.el.add_child(a.el);\n    }\n    \n    // folders...\n    \n    if (!(pr is Project.Gtk)) {\n        print (\"not gtk... skipping files\");\n        return;\n    }\n    var gpr = (Project.Gtk)pr;\n     var def = gpr.compilegroups.get(\"_default_\");\n     var items  = def.sources;\n     \n     \n     \n    for(var i =0 ; i < items.size; i++) {\n        print (\"cheking folder %s\\n\", items.get(i));\n         var files = gpr.files(items.get(i));\n         if (files.size < 1) {\n            continue;\n         }\n\n        // add the directory... items.get(i);\n        var x = new Xcls_folderitem(this,items.get(i));\n        this.fileitems.add(x);\n        this.filelayout.el.add_child(x.el);\n        \n        for(var j =0 ; j < files.size; j++) {\n            print (\"adding file %s\\n\", files.get(j));\n        \n            var y = new Xcls_folderfile(this, files.get(j));\n            this.fileitems.add(y);\n            x.el.add_child(y.el);\n\n            // add file to files.get(j);\n            \n        }\n        \n        \n        //this.el.set_value(citer, 1,   items.get(i) );\n    }\n    \n   \n    \n    this.el.show();\n}\n",
+   "|  void loadProject" : "(Project.Project pr) {\n    // list all the files, and create new Xcls_fileitem for each one.\n    \n    this.project = pr;\n    \n    \n    // LEAK --- we should unref all the chilren...\n    this.filelayout.el.y = 0;\n    this.clearFiles();\n    \n    print(\"clutter files - load project: \" + pr.name +\"\\n\");\n    // should unref.. them hopefully.\n    \n    this.project_title_name.el.text = pr.name;\n    this.project_title_path.el.text = pr.firstPath();\n    \n    // file items contains a reference until we reload ...\n    this.fileitems = new Gee.ArrayList<Object>();\n\n    \n\n    var fiter = pr.sortedFiles().list_iterator();\n    while (fiter.next()) {\n        var a = new Xcls_fileitem(this,fiter.get());\n        this.fileitems.add(a);\n\n//        a.ref();\n        print(\"add to clutter file view: \" + fiter.get().name + \"\\n\");\n        this.filelayout.el.add_child(a.el);\n    }\n    \n    // folders...\n    \n    if (!(pr is Project.Gtk)) {\n        print (\"not gtk... skipping files\");\n        return;\n    }\n    var gpr = (Project.Gtk)pr;\n     var def = gpr.compilegroups.get(\"_default_\");\n     var items  = def.sources;\n     \n     \n     \n    for(var i =0 ; i < items.size; i++) {\n        print (\"cheking folder %s\\n\", items.get(i));\n         var files = gpr.filesForOpen(items.get(i));\n         if (files.size < 1) {\n            continue;\n         }\n\n        // add the directory... items.get(i);\n        var x = new Xcls_folderitem(this,items.get(i));\n        this.fileitems.add(x);\n        this.filelayout.el.add_child(x.el);\n        \n        for(var j =0 ; j < files.size; j++) {\n            print (\"adding file %s\\n\", files.get(j));\n        \n            var y = new Xcls_folderfile(this, files.get(j));\n            this.fileitems.add(y);\n            x.el.add_child(y.el);\n\n            // add file to files.get(j);\n            \n        }\n        \n        \n        //this.el.set_value(citer, 1,   items.get(i) );\n    }\n    \n   \n    \n    this.el.show();\n}\n",
    "# Gdk.Pixbuf missing_thumb_pixbuf" : "null",
    "@ void open" : "(JsRender.JsRender file)",
    "$ xns" : "Clutter",
    "bool reactive" : true,
-   "|  void set_size" : "(float w, float h) \n{\n    \n     // called by window resize... with is alreaddy -50 (for the buttons?)\n     \n\n     if (this.el == null) {\n        print(\"object not ready yet?\");\n        return;\n    }\n   _this.filelayout_manager.el.max_column_width = w - 75;\n   \n    this.el.set_size(\n           // this.el.get_stage().width-150,\n           w,\n           h  // this.el.get_stage().height\n    );\n    \n    // 100 right for buttons ..\n    this.el.set_position(0,0);\n   \n   \n   this.scoller.el.set_size(\n           // this.el.get_stage().width-150,\n           w-150,\n           h  // this.el.get_stage().height\n    );\n    \n    // 100 right for buttons ..\n    this.scoller.el.set_position(75,50);\n}\n",
+   "Project.Project project" : "",
+   "|  void set_size" : "(float w, float h) \n{\n    \n     // called by window resize... with is alreaddy -50 (for the buttons?)\n     \n\n\n\n     if (this.el == null) {\n        print(\"object not ready yet?\");\n        return;\n    }\n    \n    print(\"recv width %f, filelayoutw = %f\", w, w-200);\n    \n    w = GLib.Math.floorf ( w/120.0f) * 120.0f;\n    \n    \n    \n    \n   //_this.filelayout_manager.el.max_column_width = w - 200;\n   _this.filelayout.el.width = w ;\n   \n    this.el.set_size(\n           // this.el.get_stage().width-150,\n           w,\n           h  // this.el.get_stage().height\n    );\n    \n    // 100 right for buttons ..\n    this.el.set_position(75,0);\n   \n   \n   this.scroller.el.set_size(\n           // this.el.get_stage().width-150,\n           w,\n           h  // this.el.get_stage().height\n    );\n    \n    // 100 right for buttons ..\n    this.scroller.el.set_position(0,50);\n    // scroll...\n    _this.filelayout.el.y = 0.0f;\n    \n}\n",
    "# Gee.ArrayList<Object> fileitems" : "new Gee.ArrayList<Object>()",
    "items" : [
     {
      "id" : "project_title",
-     "* init" : "\nthis.el.add_constraint(\n    new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)\n);\nthis.el.set_position(75,0);\n ",
+     "* init" : "\nthis.el.add_constraint(\n    new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)\n);\nthis.el.set_position(0,0);\n ",
      "xtype" : "Actor",
      "* pack" : "add_child",
      "$ reactive" : true,
     },
     {
      "listeners" : {
-      "scroll_event" : "( event) => {\n   //Sprint(\"scroll event\");\n            var y = _this.filelayout.el.y;\n            var dir = event.direction;\n            switch (dir) {\n                case Clutter.ScrollDirection.UP:\n                    y += event.y /2;\n                    break;\n                case Clutter.ScrollDirection.DOWN:\n                    y -= event.y /2 ;\n                    break;\n                default:\n                    return false;\n            }\n            // range of scroll -- can go up -- eg.. -ve value.\n            \n            y = float.min(0, y);\n            \n            // to work out the max -ve number\n            // height of filelayout\n            // height of scrollactor..\n            \n            var last_child_bottom = _this.filelayout.el.last_child.y +  _this.filelayout.el.last_child.height;\n             if ( (-1 * (y+200)) > (  last_child_bottom - this.el.height)) {\n                return  false;\n            }\n        \n        \n            \n            \n        //    print(\"\\nlast child - this height = %f  ==== new y %f\\n \".printf( \n          //          last_child_bottom - this.el.height,\n           //         y));    \n           // y = float.min(0, y);    //??\n           // print(\"scroll event of %f  - new y = %f \".printf(event.y, y));\n            _this.filelayout.el.y = y;\n            return true;\n          \n}"
+      "scroll_event" : "( event) => {\n    print(\"scroll event\\n\");\n    var y = _this.filelayout.el.y;\n    var dir = event.direction;\n    \n    var last_child_bottom = _this.filelayout.el.last_child.y +  _this.filelayout.el.last_child.height;\n    var bottompos = -1 * (  last_child_bottom - (0.5f * this.el.height));\n    \n    switch (dir) {\n        case Clutter.ScrollDirection.UP:\n            print(\"Scroll up by %f\\n\", event.y);\n            y += event.y /2;\n            y = float.min(0, y); // \n            break;\n            \n        case Clutter.ScrollDirection.DOWN:\n            print(\"Scroll down by %f\\n\", event.y);\n            y -= event.y /2 ;\n            y = float.max(bottompos, y);\n            \n            \n            break;\n     \t  case Clutter.ScrollDirection.SMOOTH:\n     \t    double delta_x, delta_y;\n     \t    event.get_scroll_delta(out delta_x, out delta_y);\n            //print(\"Scroll SMOOTH? by %f\\n\",  delta_y * event.y);\n            y += ((float)delta_y * event.y * -1.0f) /2 ;\n            y = float.max(bottompos, y);\n            y = float.min(0, y); // \n                       \n            break;\n        default:\n\t        print(\"scroll event = bad direction %s\\n\", dir.to_string());\n            return false;\n    }\n    // range of scroll -- can go up -- eg.. -ve value.\n    \n\n    \n   print(\"Set scroll to %f (lcb=%f / height = %f)\\n\", y, last_child_bottom, this.el.height);\n   \n    _this.filelayout.el.y = y;\n    return true;\n          \n}"
      },
      "# Gee.ArrayList<Xcls_fileitem> fileitems" : "new Gee.ArrayList<Xcls_fileitem>()",
-     "id" : "scoller",
+     "id" : "scroller",
      "Clutter.ScrollMode scroll_mode" : "Clutter.ScrollMode.VERTICALLY",
      "xtype" : "ScrollActor",
      "* pack" : "add_child",
        "items" : [
         {
          "id" : "filelayout_manager",
+         "bool homogeneous" : false,
          "$ orientation" : "Clutter.FlowOrientation.HORIZONTAL",
          "xtype" : "FlowLayout",
+         "float max_column_width" : "100.0f",
          "$ xns" : "Clutter",
          "row_spacing" : 20,
          "* prop" : "layout_manager",
-         "column_spacing" : 20,
-         "$ homogeneous" : true
+         "column_spacing" : 20
         },
         {
          "listeners" : {
           "button_press_event" : "  (  event) => {\n    _this.open(this.file);\n    return false;\n} ",
-          "enter_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#333\");\n        return false;\n}",
-          "leave_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#000\");\n    return false;\n}"
+          "enter_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#333\");\n    this.title.el.background_color =   Clutter.Color.from_string(\"#fff\");\n    this.typetitle.el.background_color =   Clutter.Color.from_string(\"#fff\");\n    this.title.el.color =   Clutter.Color.from_string(\"#000\");\n    this.typetitle.el.color =   Clutter.Color.from_string(\"#000\");\n    \n        return false;\n}",
+          "leave_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#000\");\n     this.title.el.background_color =   Clutter.Color.from_string(\"#000\");\n    this.typetitle.el.background_color =   Clutter.Color.from_string(\"#000\");\n    this.title.el.color =   Clutter.Color.from_string(\"#fff\");\n    this.typetitle.el.color =   Clutter.Color.from_string(\"#fff\");\n   \n    \n    return false;\n}"
          },
          "id" : "*fileitem",
          "* args" : "JsRender.JsRender file",
            "id" : "+image",
            "* args" : "JsRender.JsRender file",
            "* init" : "{\n    Gdk.Pixbuf pixbuf= null;\n    \n    var fname = file.getIconFileName(false);\n\n    try {\n        if (FileUtils.test(fname, FileTest.EXISTS)) {\n            pixbuf = new Gdk.Pixbuf.from_file(fname);\n        } \n    } catch (Error e) {\n        // noop\n    \n    }\n    if (pixbuf == null) {\n        \n        try {\n            if (_this.missing_thumb_pixbuf == null) {\n                    var icon_theme = Gtk.IconTheme.get_default ();\n                    _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);\n                    _this.missing_thumb_pixbuf.ref();\n                }\n                pixbuf = _this.missing_thumb_pixbuf;\n\n        } catch (Error e) {\n            // noop?\n        }\n    }\n    try {\n        var img = new Clutter.Image();\n        img.set_data(pixbuf.get_pixels(),   \n                            pixbuf.has_alpha \n                              ? Cogl.PixelFormat.RGBA_8888\n                              : Cogl.PixelFormat.RGB_888,\n                            pixbuf.get_width (),\n                pixbuf.get_height (),\n                            pixbuf.get_rowstride ()\n        );\n        this.el.set_content(img);\n    } catch (Error e) {\n        // noop?\n    }\n     // should probably do smarter scaling...\n    \n    \n    this.el.set_size(90, 70);\n}\n",
-           "$ x_expand" : true,
            "* pack" : "add_child",
            "xtype" : "Actor",
+           "bool x_expand" : false,
            "$ y_align" : "Clutter.ActorAlign.START",
            "$ margin_left" : 5,
            "$ xns" : "Clutter",
           },
           {
            "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickType(),  Clutter.Color.from_string(\"#fff\"))",
-           "id" : "+typetitle",
            "* args" : "JsRender.JsRender file",
-           "$ x_expand" : true,
+           "id" : "+typetitle",
            "* pack" : "add_child",
            "xtype" : "Text",
+           "bool x_expand" : false,
            "$ y_align" : "Clutter.ActorAlign.START",
            "$ xns" : "Clutter",
            "bool y_expand" : false,
           },
           {
            "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickName(),  Clutter.Color.from_string(\"#fff\"))",
-           "id" : "+title",
            "* args" : "JsRender.JsRender file",
-           "$ x_expand" : true,
+           "id" : "+title",
            "* pack" : "add_child",
            "xtype" : "Text",
+           "bool x_expand" : false,
            "$ y_align" : "Clutter.ActorAlign.START",
            "$ xns" : "Clutter",
            "bool y_expand" : false,
            "* prop" : "layout_manager"
           },
           {
-           "* ctor" : "new Clutter.Text.full(\"Sans 14px\", GLib.Path.get_basename(folderpath),  Clutter.Color.from_string(\"#fff\"))",
-           "* args" : "string folderpath",
+           "* ctor" : "new Clutter.Text.full(\"Sans bold 14px\", GLib.Path.get_basename(folderpath),  Clutter.Color.from_string(\"#fff\"))",
            "id" : "+foldertitle",
+           "* args" : "string folderpath",
            "$ x_expand" : true,
            "* pack" : "add_child",
            "xtype" : "Text",
            "$ y_align" : "Clutter.ActorAlign.START",
            "$ xns" : "Clutter",
-           "$ y_expand" : true,
+           "bool y_expand" : false,
            "$ x_align" : "Clutter.ActorAlign.START"
           },
           {
            "listeners" : {
-            "button_press_event" : "  (  event) => {\n   // _this.open(this.filepath);\n    return false;\n} ",
-            "enter_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#333\");\n        return false;\n}",
-            "leave_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#000\");\n    return false;\n}"
+            "button_press_event" : "  (  event) => {\n    \n   var f = JsRender.JsRender.factory(\"PlainFile\", _this.project, this.filepath);\n    _this.open(f);\n    return false;\n} ",
+            "enter_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#fff\");\n    this.el.color =  Clutter.Color.from_string(\"#000\");\n        return false;\n}",
+            "leave_event" : "(  event)  => {\n    this.el.background_color =   Clutter.Color.from_string(\"#000\");\n     this.el.color =   Clutter.Color.from_string(\"#fff\");\n    return false;\n}"
            },
            "* ctor" : "new Clutter.Text.full(\"Sans 10px\", GLib.Path.get_basename(filepath),  Clutter.Color.from_string(\"#fff\"))",
            "* args" : "string filepath",
            "id" : "*folderfile",
-           "* init" : "{\n    this.filepath = filepath;\n}\n",
-           "$ x_expand" : true,
-           "* pack" : "add_child",
+           "* init" : "{\n\tthis.filepath = filepath;\n}\n",
            "xtype" : "Text",
-           "$ y_align" : "Clutter.ActorAlign.START",
+           "bool x_expand" : true,
+           "Clutter.ActorAlign y_align" : "Clutter.ActorAlign.START",
            "string filepath" : "",
            "$ xns" : "Clutter",
            "bool reactive" : true,
-           "bool y_expand" : false,
-           "$ x_align" : "Clutter.ActorAlign.START"
+           "Clutter.ActorAlign x_align" : "Clutter.ActorAlign.START",
+           "bool y_expand" : true
           }
          ]
         }