Builder4/ClutterFiles.bjs
[app.Builder.js] / Builder4 / ClutterFiles.bjs
1 {
2     "id": "file-gtk-2",
3     "name": "ClutterFiles",
4     "parent": "",
5     "title": false,
6     "path": "/home/alan/gitlive/app.Builder.js/Builder4/ClutterFiles.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "scroll_event": "( event)  => {\n\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 ( last_child_bottom - this.el.height  > last_child_bottom);\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}"
11             },
12             "id": "ClutterFiles",
13             "scroll_mode": "Clutter.ScrollMode.VERTICAL",
14             "xtype": "ScrollActor",
15             "|reactive": "true",
16             "|void:set_size": "(float w, float h) {\n    _this.filelayout_manager.el.max_column_width = w - 150;\n   this.el.set_size(this.el.get_stage().width-150,\n                        this.el.get_stage().height);\n            this.el.set_position(100,50);\n}\n",
17             "|void:show": "(Project.Project pr) {\n    // list all the files, and create new Xcls_fileitem for each one.\n    \n    var fiter = pr.files.map_iterator();\n    while (fiter.next()) {\n        var a = new Xcls_fileitem(this,fiter.get_value());\n        a.ref();\n        print(\"add \" + fiter.get_value().name + \"\\n\");\n        this.filelayout.el.add_child(a.el);\n    }\n    this.el.show_all();\n}\n",
18             "|xns": "Clutter",
19             "items": [
20                 {
21                     "id": "filelayout",
22                     "pack": "add_child",
23                     "xtype": "Actor",
24                     "|init": "\nthis.el.add_constraint(\n    new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)\n);\n\n",
25                     "|reactive": "true",
26                     "|xns": "Clutter",
27                     "items": [
28                         {
29                             "*prop": "layout_manager",
30                             "column_spacing": 20,
31                             "id": "filelayout_manager",
32                             "row_spacing": 20,
33                             "xtype": "FlowLayout",
34                             "|homogeneous": "true",
35                             "|orientation": "Clutter.FlowOrientation.HORIZONTAL",
36                             "|xns": "Clutter"
37                         },
38                         {
39                             "*args": "JsRender.JsRender file",
40                             "id": "*fileitem",
41                             "pack": false,
42                             "xtype": "Actor",
43                             "|init": "this.el.set_size(100,100);",
44                             "|xns": "Clutter",
45                             "items": [
46                                 {
47                                     "*prop": "layout_manager",
48                                     "spacing": 4,
49                                     "xtype": "BoxLayout",
50                                     "|orientation": "Clutter.Orientation.VERTICAL",
51                                     "|xns": "Clutter"
52                                 },
53                                 {
54                                     "*args": "JsRender.JsRender file",
55                                     ".ctor": "new Clutter.Texture.from_file(file.getIconFile())",
56                                     "id": "+image",
57                                     "pack": "add_child",
58                                     "xtype": "Texture",
59                                     "|x_align": "Clutter.ActorAlign.START",
60                                     "|x_expand": "true",
61                                     "|xns": "Clutter",
62                                     "|y_align": "Clutter.ActorAlign.START",
63                                     "|y_expand": "false"
64                                 },
65                                 {
66                                     "*args": "JsRender.JsRender file",
67                                     ".ctor": "new Clutter.Text.full(\"Sans 10px\", file.nickName(),new Clutter.Color.from_string(\"#fff\"))",
68                                     "id": "+title",
69                                     "pack": "add_child",
70                                     "xtype": "Text",
71                                     "|x_align": "Clutter.ActorAlign.START",
72                                     "|x_expand": "true",
73                                     "|xns": "Clutter",
74                                     "|y_align": "Clutter.ActorAlign.START",
75                                     "|y_expand": "false"
76                                 }
77                             ]
78                         }
79                     ]
80                 }
81             ]
82         }
83     ],
84     "permname": "",
85     "modOrder": ""
86 }