-{
- "build_module" : "builder",
- "items" : [
- {
- "# Gdk.Pixbuf missing_thumb_pixbuf" : "null",
- "# Gee.ArrayList<Object> fileitems" : "new Gee.ArrayList<Object>()",
- "$ xns" : "Clutter",
- "@ void open" : "(JsRender.JsRender file)",
- "Clutter.ScrollMode scroll_mode" : "Clutter.ScrollMode.VERTICALLY",
- "Project.Project project" : "",
- "bool reactive" : true,
- "id" : "ClutterFiles",
- "items" : [
- {
- "$ reactive" : true,
- "$ xns" : "Clutter",
- "* init" : [
- "",
- "this.el.add_constraint(",
- " new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)",
- ");",
- "this.el.set_position(0,0);",
- " "
- ],
- "* pack" : "add_child",
- "id" : "project_title",
- "items" : [
- {
- "$ orientation" : "Clutter.FlowOrientation.HORIZONTAL",
- "$ xns" : "Clutter",
- "* prop" : "layout_manager",
- "boolean homogeneous" : false,
- "column_spacing" : 20,
- "id" : "project_title_manager",
- "row_spacing" : 5,
- "xtype" : "FlowLayout"
- },
- {
- "$ xns" : "Clutter",
- "* prop" : "layout_manager",
- "xtype" : "FixedLayout"
- },
- {
- "$ xns" : "Clutter",
- "* ctor" : "new Clutter.Text.full(\"Sans 20px\", \"\", Clutter.Color.from_string(\"#eee\"))",
- "* pack" : "add_child",
- "boolean x_expand" : false,
- "float x" : "0.0f",
- "float y" : "10.0f",
- "id" : "project_title_name",
- "xtype" : "Text"
- },
- {
- "$ xns" : "Clutter",
- "* ctor" : "new Clutter.Text.full(\"Sans 10px\", \"\", Clutter.Color.from_string(\"#ccc\"))",
- "* pack" : "add_child",
- "float x" : "0.0f",
- "float y" : "35.0f",
- "id" : "project_title_path",
- "xtype" : "Text"
- }
- ],
- "xtype" : "Actor"
- },
- {
- "# Gdk.Pixbuf missing_thumb_pixbuf" : "null",
- "# Gee.ArrayList<Xcls_fileitem> fileitems" : "new Gee.ArrayList<Xcls_fileitem>()",
- "$ xns" : "Clutter",
- "* pack" : "add_child",
- "Clutter.ScrollMode scroll_mode" : "Clutter.ScrollMode.VERTICALLY",
- "bool reactive" : true,
- "id" : "scroller",
- "items" : [
- {
- "$ reactive" : true,
- "$ xns" : "Clutter",
- "* init" : [
- "",
- "this.el.add_constraint(",
- " new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)",
- ");",
- "",
- " "
- ],
- "* pack" : "add_child",
- "id" : "filelayout",
- "items" : [
- {
- "$ orientation" : "Clutter.FlowOrientation.HORIZONTAL",
- "$ xns" : "Clutter",
- "* prop" : "layout_manager",
- "bool homogeneous" : false,
- "column_spacing" : 20,
- "float max_column_width" : "100.0f",
- "id" : "filelayout_manager",
- "row_spacing" : 20,
- "xtype" : "FlowLayout"
- },
- {
- "# JsRender.JsRender file" : "",
- "$ reactive" : true,
- "$ xns" : "Clutter",
- "* args" : "JsRender.JsRender file",
- "* init" : [
- "this.file = file;",
- "this.el.set_size(100,100);"
- ],
- "* pack" : true,
- "id" : "*fileitem",
- "items" : [
- {
- "$ xns" : "Clutter",
- "* prop" : "layout_manager",
- "orientation" : "Clutter.Orientation.VERTICAL",
- "spacing" : 4,
- "xtype" : "BoxLayout"
- },
- {
- "$ margin_left" : 5,
- "$ margin_right" : 5,
- "$ margin_top" : 5,
- "$ x_align" : "Clutter.ActorAlign.START",
- "$ xns" : "Clutter",
- "$ y_align" : "Clutter.ActorAlign.START",
- "* args" : "JsRender.JsRender file",
- "* init" : [
- "{",
- " Gdk.Pixbuf pixbuf= null;",
- " ",
- " var fname = file.getIconFileName(false);",
- "",
- " try {",
- " if (FileUtils.test(fname, FileTest.EXISTS)) {",
- " pixbuf = new Gdk.Pixbuf.from_file(fname);",
- " } ",
- " } catch (Error e) {",
- " // noop",
- " ",
- " }",
- " if (pixbuf == null) {",
- " ",
- " try {",
- " if (_this.missing_thumb_pixbuf == null) {",
- " var icon_theme = Gtk.IconTheme.get_default ();",
- " _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
- " _this.missing_thumb_pixbuf.ref();",
- " }",
- " pixbuf = _this.missing_thumb_pixbuf;",
- "",
- " } catch (Error e) {",
- " // noop?",
- " }",
- " }",
- " try {",
- " var img = new Clutter.Image();",
- " img.set_data(pixbuf.get_pixels(), ",
- " pixbuf.has_alpha ",
- " ? Cogl.PixelFormat.RGBA_8888",
- " : Cogl.PixelFormat.RGB_888,",
- " pixbuf.get_width (),",
- " pixbuf.get_height (),",
- " pixbuf.get_rowstride ()",
- " );",
- " this.el.set_content(img);",
- " } catch (Error e) {",
- " // noop?",
- " }",
- " // should probably do smarter scaling...",
- " ",
- " ",
- " this.el.set_size(90, 70);",
- "}",
- ""
- ],
- "* pack" : "add_child",
- "bool x_expand" : false,
- "bool y_expand" : false,
- "id" : "+image",
- "xtype" : "Actor"
- },
- {
- "$ x_align" : "Clutter.ActorAlign.START",
- "$ xns" : "Clutter",
- "$ y_align" : "Clutter.ActorAlign.START",
- "* args" : "JsRender.JsRender file",
- "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickType(), Clutter.Color.from_string(\"#fff\"))",
- "* pack" : "add_child",
- "bool x_expand" : false,
- "bool y_expand" : false,
- "id" : "+typetitle",
- "xtype" : "Text"
- },
- {
- "$ x_align" : "Clutter.ActorAlign.START",
- "$ xns" : "Clutter",
- "$ y_align" : "Clutter.ActorAlign.START",
- "* args" : "JsRender.JsRender file",
- "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickNameSplit(), Clutter.Color.from_string(\"#fff\"))",
- "* pack" : "add_child",
- "bool x_expand" : false,
- "bool y_expand" : false,
- "id" : "+title",
- "xtype" : "Text"
- }
- ],
- "listeners" : {
- "button_press_event" : [
- " ( event ) => {",
- " _this.open(this.file);",
- " return false;",
- "} "
- ],
- "enter_event" : [
- "( 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;",
- "}"
- ],
- "leave_event" : [
- "( 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;",
- "}"
- ]
- },
- "xtype" : "Actor"
- },
- {
- "$ reactive" : true,
- "$ xns" : "Clutter",
- "* args" : "string folderpath",
- "* init" : [
- " ",
- "//this.el.set_size(100,100);"
- ],
- "* pack" : true,
- "id" : "*folderitem",
- "items" : [
- {
- "$ xns" : "Clutter",
- "* prop" : "layout_manager",
- "orientation" : "Clutter.Orientation.VERTICAL",
- "spacing" : 2,
- "xtype" : "BoxLayout"
- },
- {
- "$ x_align" : "Clutter.ActorAlign.START",
- "$ x_expand" : true,
- "$ xns" : "Clutter",
- "$ y_align" : "Clutter.ActorAlign.START",
- "* args" : "string folderpath",
- "* ctor" : "new Clutter.Text.full(\"Sans bold 14px\", GLib.Path.get_basename(folderpath), Clutter.Color.from_string(\"#fff\"))",
- "* pack" : "add_child",
- "bool y_expand" : false,
- "id" : "+foldertitle",
- "xtype" : "Text"
- },
- {
- "$ xns" : "Clutter",
- "* args" : "string filepath",
- "* ctor" : "new Clutter.Text.full(\"Sans 10px\", GLib.Path.get_basename(filepath), Clutter.Color.from_string(\"#fff\"))",
- "* init" : [
- "{",
- "\tthis.filepath = filepath;",
- "}",
- ""
- ],
- "Clutter.ActorAlign x_align" : "Clutter.ActorAlign.START",
- "Clutter.ActorAlign y_align" : "Clutter.ActorAlign.START",
- "bool reactive" : true,
- "bool x_expand" : true,
- "bool y_expand" : true,
- "id" : "*folderfile",
- "listeners" : {
- "button_press_event" : [
- " ( event) => {",
- " ",
- " var f = JsRender.JsRender.factory(\"PlainFile\", _this.project, this.filepath);",
- " _this.open(f);",
- " return false;",
- "} "
- ],
- "enter_event" : [
- "( event) => {",
- " this.el.background_color = Clutter.Color.from_string(\"#fff\");",
- " this.el.color = Clutter.Color.from_string(\"#000\");",
- " return false;",
- "}"
- ],
- "leave_event" : [
- "( event) => {",
- " this.el.background_color = Clutter.Color.from_string(\"#000\");",
- " this.el.color = Clutter.Color.from_string(\"#fff\");",
- " return false;",
- "}"
- ]
- },
- "string filepath" : "",
- "xtype" : "Text"
- }
- ],
- "xtype" : "Actor"
- }
- ],
- "xtype" : "Actor"
- }
- ],
- "listeners" : {
- "scroll_event" : [
- "( event) => {",
- " 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;",
- " ",
- " case Clutter.ScrollDirection.DOWN:",
- " print(\"Scroll down by %f\\n\", event.y);",
- " y -= event.y /2 ;",
- " y = float.max(bottompos, y);",
- " ",
- " ",
- " break;",
- " \t case Clutter.ScrollDirection.SMOOTH:",
- " \t double delta_x, delta_y;",
- " \t 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:",
- "\t 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;",
- " ",
- "}"
- ]
- },
- "xtype" : "ScrollActor"
- }
- ],
- "xtype" : "Actor",
- "| void clearFiles" : [
- "() {",
- " ",
- " this.filelayout.el.remove_all_children();",
- " // we need to unref all the chidren that we loaded though...",
- " ",
- "}",
- " "
- ],
- "| 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();",
- " ",
- " print(\"clutter files - load project: \" + pr.name +\"\\n\");",
- " // should unref.. them hopefully.",
- " ",
- " this.project_title_name.el.text = pr.name;",
- " this.project_title_path.el.text = pr.firstPath();",
- " ",
- " // file items contains a reference until we reload ...",
- " this.fileitems = new Gee.ArrayList<Object>();",
- "",
- " ",
- "",
- " var fiter = pr.sortedFiles().list_iterator();",
- " while (fiter.next()) {",
- " var a = new Xcls_fileitem(this,fiter.get());",
- " this.fileitems.add(a);",
- "",
- "// a.ref();",
- " print(\"add to clutter file view: \" + fiter.get().name + \"\\n\");",
- " this.filelayout.el.add_child(a.el);",
- " }",
- " ",
- " // folders...",
- " ",
- " if (!(pr is Project.Gtk)) {",
- " print (\"not gtk... skipping files\");",
- " return;",
- " }",
- " var gpr = (Project.Gtk)pr;",
- " var def = gpr.compilegroups.get(\"_default_\");",
- " // not sure why the above is returng null!??",
- " if (def == null) {",
- " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
- " \t\tgpr.compilegroups.set(\"_default_\", def);",
- " }",
- "\t var items = def.sources;",
- "\t\t ",
- "\t\t ",
- "\t ",
- "\tfor(var i =0 ; i < items.size; i++) {",
- "\t print (\"cheking folder %s\\n\", items.get(i));",
- "\t var files = gpr.filesForOpen(items.get(i));",
- "\t if (files.size < 1) {",
- "\t continue;",
- "\t }",
- "",
- "\t // add the directory... items.get(i);",
- "\t var x = new Xcls_folderitem(this,items.get(i));",
- "\t this.fileitems.add(x);",
- "\t this.filelayout.el.add_child(x.el);",
- "\t ",
- "\t for(var j =0 ; j < files.size; j++) {",
- "\t print (\"adding file %s\\n\", files.get(j));",
- "\t ",
- "\t var y = new Xcls_folderfile(this, files.get(j));",
- "\t this.fileitems.add(y);",
- "\t x.el.add_child(y.el);",
- "",
- "\t // add file to files.get(j);",
- "\t ",
- "\t }",
- "\t ",
- "\t ",
- "\t //this.el.set_value(citer, 1, items.get(i) );",
- "\t}",
- " ",
- " ",
- " ",
- " this.el.show();",
- "}",
- ""
- ],
- "| void set_size" : [
- "(float w, float h) ",
- "{",
- " ",
- " // called by window resize... with is alreaddy -50 (for the buttons?)",
- " ",
- "",
- "",
- "",
- " if (this.el == null) {",
- " print(\"object not ready yet?\");",
- " return;",
- " }",
- " ",
- " 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,",
- " w,",
- " h // this.el.get_stage().height",
- " );",
- " ",
- " // 100 right for buttons ..",
- " this.el.set_position(75,0);",
- " ",
- " ",
- " this.scroller.el.set_size(",
- " // this.el.get_stage().width-150,",
- " w,",
- " h // this.el.get_stage().height",
- " );",
- " ",
- " // 100 right for buttons ..",
- " this.scroller.el.set_position(0,50);",
- " // scroll...",
- " _this.filelayout.el.y = 0.0f;",
- " ",
- "}",
- ""
- ]
- }
- ],
- "modOrder" : "",
- "name" : "ClutterFiles",
- "parent" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ClutterFiles.bjs",
- "permname" : "",
- "title" : ""
-}
\ No newline at end of file