resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / ClutterFiles.bjs
1 {
2  "name" : "ClutterFiles",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ClutterFiles.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "id" : "ClutterFiles",
12    "|  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 ",
13    "Clutter.ScrollMode scroll_mode" : "Clutter.ScrollMode.VERTICALLY",
14    "xtype" : "Actor",
15    "|  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",
16    "# Gdk.Pixbuf missing_thumb_pixbuf" : "null",
17    "@ void open" : "(JsRender.JsRender file)",
18    "$ xns" : "Clutter",
19    "bool reactive" : true,
20    "Project.Project project" : "",
21    "|  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",
22    "# Gee.ArrayList<Object> fileitems" : "new Gee.ArrayList<Object>()",
23    "items" : [
24     {
25      "id" : "project_title",
26      "* init" : "\nthis.el.add_constraint(\n    new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)\n);\nthis.el.set_position(0,0);\n ",
27      "xtype" : "Actor",
28      "* pack" : "add_child",
29      "$ reactive" : true,
30      "$ xns" : "Clutter",
31      "items" : [
32       {
33        "id" : "project_title_manager",
34        "$ orientation" : "Clutter.FlowOrientation.HORIZONTAL",
35        "xtype" : "FlowLayout",
36        "boolean homogeneous" : false,
37        "$ xns" : "Clutter",
38        "row_spacing" : 5,
39        "* prop" : "layout_manager",
40        "column_spacing" : 20
41       },
42       {
43        "xtype" : "FixedLayout",
44        "$ xns" : "Clutter",
45        "* prop" : "layout_manager"
46       },
47       {
48        "* ctor" : "new Clutter.Text.full(\"Sans 20px\", \"\",  Clutter.Color.from_string(\"#eee\"))",
49        "id" : "project_title_name",
50        "float x" : "0.0f",
51        "* pack" : "add_child",
52        "xtype" : "Text",
53        "float y" : "10.0f",
54        "boolean x_expand" : false,
55        "$ xns" : "Clutter"
56       },
57       {
58        "* ctor" : "new Clutter.Text.full(\"Sans 10px\", \"\",  Clutter.Color.from_string(\"#ccc\"))",
59        "id" : "project_title_path",
60        "float x" : "0.0f",
61        "* pack" : "add_child",
62        "xtype" : "Text",
63        "float y" : "35.0f",
64        "$ xns" : "Clutter"
65       }
66      ]
67     },
68     {
69      "listeners" : {
70       "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}"
71      },
72      "# Gee.ArrayList<Xcls_fileitem> fileitems" : "new Gee.ArrayList<Xcls_fileitem>()",
73      "id" : "scroller",
74      "Clutter.ScrollMode scroll_mode" : "Clutter.ScrollMode.VERTICALLY",
75      "xtype" : "ScrollActor",
76      "* pack" : "add_child",
77      "# Gdk.Pixbuf missing_thumb_pixbuf" : "null",
78      "$ xns" : "Clutter",
79      "bool reactive" : true,
80      "items" : [
81       {
82        "id" : "filelayout",
83        "* init" : "\nthis.el.add_constraint(\n    new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)\n);\n\n ",
84        "xtype" : "Actor",
85        "* pack" : "add_child",
86        "$ reactive" : true,
87        "$ xns" : "Clutter",
88        "items" : [
89         {
90          "id" : "filelayout_manager",
91          "bool homogeneous" : false,
92          "$ orientation" : "Clutter.FlowOrientation.HORIZONTAL",
93          "xtype" : "FlowLayout",
94          "float max_column_width" : "100.0f",
95          "$ xns" : "Clutter",
96          "row_spacing" : 20,
97          "* prop" : "layout_manager",
98          "column_spacing" : 20
99         },
100         {
101          "listeners" : {
102           "button_press_event" : "  (  event) => {\n    _this.open(this.file);\n    return false;\n} ",
103           "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}",
104           "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}"
105          },
106          "id" : "*fileitem",
107          "* args" : "JsRender.JsRender file",
108          "* init" : "this.file = file;\nthis.el.set_size(100,100);",
109          "* pack" : true,
110          "xtype" : "Actor",
111          "# JsRender.JsRender file" : "",
112          "$ reactive" : true,
113          "$ xns" : "Clutter",
114          "items" : [
115           {
116            "spacing" : 4,
117            "xtype" : "BoxLayout",
118            "orientation" : "Clutter.Orientation.VERTICAL",
119            "$ xns" : "Clutter",
120            "* prop" : "layout_manager"
121           },
122           {
123            "$ margin_right" : 5,
124            "$ margin_top" : 5,
125            "id" : "+image",
126            "* args" : "JsRender.JsRender file",
127            "* 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",
128            "* pack" : "add_child",
129            "xtype" : "Actor",
130            "bool x_expand" : false,
131            "$ y_align" : "Clutter.ActorAlign.START",
132            "$ margin_left" : 5,
133            "$ xns" : "Clutter",
134            "bool y_expand" : false,
135            "$ x_align" : "Clutter.ActorAlign.START"
136           },
137           {
138            "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickType(),  Clutter.Color.from_string(\"#fff\"))",
139            "* args" : "JsRender.JsRender file",
140            "id" : "+typetitle",
141            "* pack" : "add_child",
142            "xtype" : "Text",
143            "bool x_expand" : false,
144            "$ y_align" : "Clutter.ActorAlign.START",
145            "$ xns" : "Clutter",
146            "bool y_expand" : false,
147            "$ x_align" : "Clutter.ActorAlign.START"
148           },
149           {
150            "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickName(),  Clutter.Color.from_string(\"#fff\"))",
151            "* args" : "JsRender.JsRender file",
152            "id" : "+title",
153            "* pack" : "add_child",
154            "xtype" : "Text",
155            "bool x_expand" : false,
156            "$ y_align" : "Clutter.ActorAlign.START",
157            "$ xns" : "Clutter",
158            "bool y_expand" : false,
159            "$ x_align" : "Clutter.ActorAlign.START"
160           }
161          ]
162         },
163         {
164          "id" : "*folderitem",
165          "* args" : "string folderpath",
166          "* init" : " \n//this.el.set_size(100,100);",
167          "* pack" : true,
168          "xtype" : "Actor",
169          "$ reactive" : true,
170          "$ xns" : "Clutter",
171          "items" : [
172           {
173            "spacing" : 2,
174            "xtype" : "BoxLayout",
175            "orientation" : "Clutter.Orientation.VERTICAL",
176            "$ xns" : "Clutter",
177            "* prop" : "layout_manager"
178           },
179           {
180            "* ctor" : "new Clutter.Text.full(\"Sans bold 14px\", GLib.Path.get_basename(folderpath),  Clutter.Color.from_string(\"#fff\"))",
181            "id" : "+foldertitle",
182            "* args" : "string folderpath",
183            "$ x_expand" : true,
184            "* pack" : "add_child",
185            "xtype" : "Text",
186            "$ y_align" : "Clutter.ActorAlign.START",
187            "$ xns" : "Clutter",
188            "bool y_expand" : false,
189            "$ x_align" : "Clutter.ActorAlign.START"
190           },
191           {
192            "listeners" : {
193             "button_press_event" : "  (  event) => {\n    \n   var f = JsRender.JsRender.factory(\"PlainFile\", _this.project, this.filepath);\n    _this.open(f);\n    return false;\n} ",
194             "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}",
195             "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}"
196            },
197            "* ctor" : "new Clutter.Text.full(\"Sans 10px\", GLib.Path.get_basename(filepath),  Clutter.Color.from_string(\"#fff\"))",
198            "* args" : "string filepath",
199            "id" : "*folderfile",
200            "* init" : "{\n\tthis.filepath = filepath;\n}\n",
201            "xtype" : "Text",
202            "bool x_expand" : true,
203            "Clutter.ActorAlign y_align" : "Clutter.ActorAlign.START",
204            "string filepath" : "",
205            "$ xns" : "Clutter",
206            "bool reactive" : true,
207            "Clutter.ActorAlign x_align" : "Clutter.ActorAlign.START",
208            "bool y_expand" : true
209           }
210          ]
211         }
212        ]
213       }
214      ]
215     }
216    ]
217   }
218  ]
219 }