1 static Xcls_ClutterFiles _ClutterFiles;
3 public class Xcls_ClutterFiles : Object
5 public Clutter.Actor el;
6 private Xcls_ClutterFiles _this;
8 public static Xcls_ClutterFiles singleton()
10 if (_ClutterFiles == null) {
11 _ClutterFiles= new Xcls_ClutterFiles();
15 public Xcls_project_title project_title;
16 public Xcls_project_title_manager project_title_manager;
17 public Xcls_project_title_name project_title_name;
18 public Xcls_project_title_path project_title_path;
19 public Xcls_scroller scroller;
20 public Xcls_filelayout filelayout;
21 public Xcls_filelayout_manager filelayout_manager;
22 public Xcls_folderfile folderfile;
25 public Clutter.ScrollMode scroll_mode;
26 public Gdk.Pixbuf missing_thumb_pixbuf;
27 public signal void open (JsRender.JsRender file);
28 public Project.Project project;
29 public Gee.ArrayList<Object> fileitems;
32 public Xcls_ClutterFiles()
35 this.el = new Clutter.Actor();
38 this.scroll_mode = Clutter.ScrollMode.VERTICALLY;
39 this.missing_thumb_pixbuf = null;
40 this.fileitems = new Gee.ArrayList<Object>();
43 this.el.reactive = true;
44 var child_0 = new Xcls_project_title( _this );
46 this.el.add_child ( child_0.el );
47 var child_1 = new Xcls_scroller( _this );
49 this.el.add_child ( child_1.el );
52 // user defined functions
53 public void clearFiles () {
55 this.filelayout.el.remove_all_children();
56 // we need to unref all the chidren that we loaded though...
59 public void loadProject (Project.Project pr) {
60 // list all the files, and create new Xcls_fileitem for each one.
65 // LEAK --- we should unref all the chilren...
66 this.filelayout.el.y = 0;
69 print("clutter files - load project: " + pr.name +"\n");
70 // should unref.. them hopefully.
72 this.project_title_name.el.text = pr.name;
73 this.project_title_path.el.text = pr.firstPath();
75 // file items contains a reference until we reload ...
76 this.fileitems = new Gee.ArrayList<Object>();
80 var fiter = pr.sortedFiles().list_iterator();
81 while (fiter.next()) {
82 var a = new Xcls_fileitem(this,fiter.get());
83 this.fileitems.add(a);
86 print("add to clutter file view: " + fiter.get().name + "\n");
87 this.filelayout.el.add_child(a.el);
92 if (!(pr is Project.Gtk)) {
93 print ("not gtk... skipping files");
96 var gpr = (Project.Gtk)pr;
97 var def = gpr.compilegroups.get("_default_");
98 var items = def.sources;
102 for(var i =0 ; i < items.size; i++) {
103 print ("cheking folder %s\n", items.get(i));
104 var files = gpr.filesForOpen(items.get(i));
105 if (files.size < 1) {
109 // add the directory... items.get(i);
110 var x = new Xcls_folderitem(this,items.get(i));
111 this.fileitems.add(x);
112 this.filelayout.el.add_child(x.el);
114 for(var j =0 ; j < files.size; j++) {
115 print ("adding file %s\n", files.get(j));
117 var y = new Xcls_folderfile(this, files.get(j));
118 this.fileitems.add(y);
119 x.el.add_child(y.el);
121 // add file to files.get(j);
126 //this.el.set_value(citer, 1, items.get(i) );
133 public void set_size (float w, float h)
136 // called by window resize... with is alreaddy -50 (for the buttons?)
141 if (this.el == null) {
142 print("object not ready yet?");
146 print("recv width %f, filelayoutw = %f", w, w-200);
148 w = GLib.Math.floorf ( w/120.0f) * 120.0f;
153 //_this.filelayout_manager.el.max_column_width = w - 200;
154 _this.filelayout.el.width = w ;
157 // this.el.get_stage().width-150,
159 h // this.el.get_stage().height
162 // 100 right for buttons ..
163 this.el.set_position(75,0);
166 this.scroller.el.set_size(
167 // this.el.get_stage().width-150,
169 h // this.el.get_stage().height
172 // 100 right for buttons ..
173 this.scroller.el.set_position(0,50);
175 _this.filelayout.el.y = 0.0f;
178 public class Xcls_project_title : Object
180 public Clutter.Actor el;
181 private Xcls_ClutterFiles _this;
187 public Xcls_project_title(Xcls_ClutterFiles _owner )
190 _this.project_title = this;
191 this.el = new Clutter.Actor();
195 // set gobject values
196 this.el.reactive = true;
197 var child_0 = new Xcls_project_title_manager( _this );
199 this.el.layout_manager = child_0.el;
200 var child_1 = new Xcls_FixedLayout4( _this );
202 this.el.layout_manager = child_1.el;
203 var child_2 = new Xcls_project_title_name( _this );
205 this.el.add_child ( child_2.el );
206 var child_3 = new Xcls_project_title_path( _this );
208 this.el.add_child ( child_3.el );
212 this.el.add_constraint(
213 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
215 this.el.set_position(0,0);
218 // user defined functions
220 public class Xcls_project_title_manager : Object
222 public Clutter.FlowLayout el;
223 private Xcls_ClutterFiles _this;
229 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
232 _this.project_title_manager = this;
233 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
237 // set gobject values
238 this.el.homogeneous = false;
239 this.el.row_spacing = 5f;
240 this.el.column_spacing = 20f;
243 // user defined functions
246 public class Xcls_FixedLayout4 : Object
248 public Clutter.FixedLayout el;
249 private Xcls_ClutterFiles _this;
255 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
258 this.el = new Clutter.FixedLayout();
262 // set gobject values
265 // user defined functions
268 public class Xcls_project_title_name : Object
270 public Clutter.Text el;
271 private Xcls_ClutterFiles _this;
277 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
280 _this.project_title_name = this;
281 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
285 // set gobject values
288 this.el.x_expand = false;
291 // user defined functions
294 public class Xcls_project_title_path : Object
296 public Clutter.Text el;
297 private Xcls_ClutterFiles _this;
303 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
306 _this.project_title_path = this;
307 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
311 // set gobject values
316 // user defined functions
320 public class Xcls_scroller : Object
322 public Clutter.ScrollActor el;
323 private Xcls_ClutterFiles _this;
327 public Gee.ArrayList<Xcls_fileitem> fileitems;
328 public Gdk.Pixbuf missing_thumb_pixbuf;
331 public Xcls_scroller(Xcls_ClutterFiles _owner )
334 _this.scroller = this;
335 this.el = new Clutter.ScrollActor();
338 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
339 this.missing_thumb_pixbuf = null;
341 // set gobject values
342 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
343 this.el.reactive = true;
344 var child_0 = new Xcls_filelayout( _this );
346 this.el.add_child ( child_0.el );
349 this.el.scroll_event.connect( ( event) => {
350 //Sprint("scroll event");
351 var y = _this.filelayout.el.y;
352 var dir = event.direction;
354 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
355 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
358 case Clutter.ScrollDirection.UP:
359 print("Scroll up by %f\n", event.y);
361 y = float.min(0, y); //
364 case Clutter.ScrollDirection.DOWN:
365 print("Scroll down by %f\n", event.y);
367 y = float.max(bottompos, y);
374 // range of scroll -- can go up -- eg.. -ve value.
378 // to work out the max -ve number
379 // height of filelayout
380 // height of scrollactor..
383 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
384 var nv = _this.filelayout.el.y ;
385 if (nv != -1 * ( last_child_bottom - this.el.height)) {
387 _this.filelayout.el.y = -1 * ( last_child_bottom - this.el.height);
397 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
398 // last_child_bottom - this.el.height,
400 // y = float.min(0, y); //??
401 // print("scroll event of %f - new y = %f ".printf(event.y, y));
402 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
404 _this.filelayout.el.y = y;
410 // user defined functions
412 public class Xcls_filelayout : Object
414 public Clutter.Actor el;
415 private Xcls_ClutterFiles _this;
421 public Xcls_filelayout(Xcls_ClutterFiles _owner )
424 _this.filelayout = this;
425 this.el = new Clutter.Actor();
429 // set gobject values
430 this.el.reactive = true;
431 var child_0 = new Xcls_filelayout_manager( _this );
433 this.el.layout_manager = child_0.el;
437 this.el.add_constraint(
438 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
442 // user defined functions
444 public class Xcls_filelayout_manager : Object
446 public Clutter.FlowLayout el;
447 private Xcls_ClutterFiles _this;
453 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
456 _this.filelayout_manager = this;
457 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
461 // set gobject values
462 this.el.homogeneous = false;
463 this.el.max_column_width = 100.0f;
464 this.el.row_spacing = 20f;
465 this.el.column_spacing = 20f;
468 // user defined functions
471 public class Xcls_fileitem : Object
473 public Clutter.Actor el;
474 private Xcls_ClutterFiles _this;
478 public JsRender.JsRender file;
479 public Xcls_image image;
480 public Xcls_typetitle typetitle;
481 public Xcls_title title;
484 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
487 this.el = new Clutter.Actor();
491 // set gobject values
492 this.el.reactive = true;
493 var child_0 = new Xcls_BoxLayout11( _this );
495 this.el.layout_manager = child_0.el;
496 var child_1 = new Xcls_image( _this ,file);
498 this.el.add_child ( child_1.el );
499 this.image = child_1;
500 var child_2 = new Xcls_typetitle( _this ,file);
502 this.el.add_child ( child_2.el );
503 this.typetitle = child_2;
504 var child_3 = new Xcls_title( _this ,file);
506 this.el.add_child ( child_3.el );
507 this.title = child_3;
512 this.el.set_size(100,100);
515 this.el.button_press_event.connect( ( event) => {
516 _this.open(this.file);
519 this.el.enter_event.connect( ( event) => {
520 this.el.background_color = Clutter.Color.from_string("#333");
521 this.title.el.background_color = Clutter.Color.from_string("#fff");
522 this.typetitle.el.background_color = Clutter.Color.from_string("#fff");
523 this.title.el.color = Clutter.Color.from_string("#000");
524 this.typetitle.el.color = Clutter.Color.from_string("#000");
528 this.el.leave_event.connect( ( event) => {
529 this.el.background_color = Clutter.Color.from_string("#000");
530 this.title.el.background_color = Clutter.Color.from_string("#000");
531 this.typetitle.el.background_color = Clutter.Color.from_string("#000");
532 this.title.el.color = Clutter.Color.from_string("#fff");
533 this.typetitle.el.color = Clutter.Color.from_string("#fff");
540 // user defined functions
542 public class Xcls_BoxLayout11 : Object
544 public Clutter.BoxLayout el;
545 private Xcls_ClutterFiles _this;
551 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
554 this.el = new Clutter.BoxLayout();
558 // set gobject values
560 this.el.orientation = Clutter.Orientation.VERTICAL;
563 // user defined functions
566 public class Xcls_image : Object
568 public Clutter.Actor el;
569 private Xcls_ClutterFiles _this;
575 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
578 this.el = new Clutter.Actor();
582 // set gobject values
583 this.el.margin_right = 5f;
584 this.el.margin_left = 5f;
585 this.el.x_align = Clutter.ActorAlign.START;
586 this.el.x_expand = false;
587 this.el.y_align = Clutter.ActorAlign.START;
588 this.el.margin_top = 5f;
589 this.el.y_expand = false;
594 Gdk.Pixbuf pixbuf= null;
596 var fname = file.getIconFileName(false);
599 if (FileUtils.test(fname, FileTest.EXISTS)) {
600 pixbuf = new Gdk.Pixbuf.from_file(fname);
606 if (pixbuf == null) {
609 if (_this.missing_thumb_pixbuf == null) {
610 var icon_theme = Gtk.IconTheme.get_default ();
611 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
612 _this.missing_thumb_pixbuf.ref();
614 pixbuf = _this.missing_thumb_pixbuf;
621 var img = new Clutter.Image();
622 img.set_data(pixbuf.get_pixels(),
624 ? Cogl.PixelFormat.RGBA_8888
625 : Cogl.PixelFormat.RGB_888,
627 pixbuf.get_height (),
628 pixbuf.get_rowstride ()
630 this.el.set_content(img);
634 // should probably do smarter scaling...
637 this.el.set_size(90, 70);
641 // user defined functions
644 public class Xcls_typetitle : Object
646 public Clutter.Text el;
647 private Xcls_ClutterFiles _this;
653 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
656 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
660 // set gobject values
661 this.el.x_align = Clutter.ActorAlign.START;
662 this.el.x_expand = false;
663 this.el.y_align = Clutter.ActorAlign.START;
664 this.el.y_expand = false;
667 // user defined functions
670 public class Xcls_title : Object
672 public Clutter.Text el;
673 private Xcls_ClutterFiles _this;
679 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
682 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
686 // set gobject values
687 this.el.x_align = Clutter.ActorAlign.START;
688 this.el.x_expand = false;
689 this.el.y_align = Clutter.ActorAlign.START;
690 this.el.y_expand = false;
693 // user defined functions
697 public class Xcls_folderitem : Object
699 public Clutter.Actor el;
700 private Xcls_ClutterFiles _this;
704 public Xcls_foldertitle foldertitle;
707 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
710 this.el = new Clutter.Actor();
714 // set gobject values
715 this.el.reactive = true;
716 var child_0 = new Xcls_BoxLayout16( _this );
718 this.el.layout_manager = child_0.el;
719 var child_1 = new Xcls_foldertitle( _this ,folderpath);
721 this.el.add_child ( child_1.el );
722 this.foldertitle = child_1;
723 var child_2 = new Xcls_folderfile( _this );
728 //this.el.set_size(100,100);
731 // user defined functions
733 public class Xcls_BoxLayout16 : Object
735 public Clutter.BoxLayout el;
736 private Xcls_ClutterFiles _this;
742 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
745 this.el = new Clutter.BoxLayout();
749 // set gobject values
751 this.el.orientation = Clutter.Orientation.VERTICAL;
754 // user defined functions
757 public class Xcls_foldertitle : Object
759 public Clutter.Text el;
760 private Xcls_ClutterFiles _this;
766 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
769 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
773 // set gobject values
774 this.el.x_align = Clutter.ActorAlign.START;
775 this.el.x_expand = true;
776 this.el.y_align = Clutter.ActorAlign.START;
777 this.el.y_expand = false;
780 // user defined functions
783 public class Xcls_folderfile : Object
785 public Clutter.Text el;
786 private Xcls_ClutterFiles _this;
790 public string filepath;
793 public Xcls_folderfile(Xcls_ClutterFiles _owner )
796 _this.folderfile = this;
797 this.el = new Clutter.Text();
801 // set gobject values
802 this.el.x_align = Clutter.ActorAlign.START;
803 this.el.x_expand = true;
804 this.el.y_align = Clutter.ActorAlign.START;
805 this.el.y_expand = true;
808 this.el.button_press_event.connect( ( event) => {
810 var f = JsRender.JsRender.factory("PlainFile", _this.project, this.filepath);
814 this.el.enter_event.connect( ( event) => {
815 this.el.background_color = Clutter.Color.from_string("#fff");
816 this.el.color = Clutter.Color.from_string("#000");
819 this.el.leave_event.connect( ( event) => {
820 this.el.background_color = Clutter.Color.from_string("#000");
821 this.el.color = Clutter.Color.from_string("#fff");
826 // user defined functions