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;
24 public Clutter.ScrollMode scroll_mode;
25 public Gdk.Pixbuf missing_thumb_pixbuf;
26 public signal void open (JsRender.JsRender file);
27 public Gee.ArrayList<Object> fileitems;
30 public Xcls_ClutterFiles()
33 this.el = new Clutter.Actor();
36 this.scroll_mode = Clutter.ScrollMode.VERTICALLY;
37 this.missing_thumb_pixbuf = null;
38 this.fileitems = new Gee.ArrayList<Object>();
41 this.el.reactive = true;
42 var child_0 = new Xcls_project_title( _this );
44 this.el.add_child ( child_0.el );
45 var child_1 = new Xcls_scroller( _this );
47 this.el.add_child ( child_1.el );
50 // user defined functions
51 public void clearFiles () {
53 this.filelayout.el.remove_all_children();
54 // we need to unref all the chidren that we loaded though...
57 public void loadProject (Project.Project pr) {
58 // list all the files, and create new Xcls_fileitem for each one.
63 // LEAK --- we should unref all the chilren...
64 this.filelayout.el.y = 0;
67 print("clutter files - load project: " + pr.name +"\n");
68 // should unref.. them hopefully.
70 this.project_title_name.el.text = pr.name;
71 this.project_title_path.el.text = pr.firstPath();
73 // file items contains a reference until we reload ...
74 this.fileitems = new Gee.ArrayList<Object>();
78 var fiter = pr.sortedFiles().list_iterator();
79 while (fiter.next()) {
80 var a = new Xcls_fileitem(this,fiter.get());
81 this.fileitems.add(a);
84 print("add to clutter file view: " + fiter.get().name + "\n");
85 this.filelayout.el.add_child(a.el);
90 if (!(pr is Project.Gtk)) {
91 print ("not gtk... skipping files");
94 var gpr = (Project.Gtk)pr;
95 var def = gpr.compilegroups.get("_default_");
96 var items = def.sources;
100 for(var i =0 ; i < items.size; i++) {
101 print ("cheking folder %s\n", items.get(i));
102 var files = gpr.filesForOpen(items.get(i));
103 if (files.size < 1) {
107 // add the directory... items.get(i);
108 var x = new Xcls_folderitem(this,items.get(i));
109 this.fileitems.add(x);
110 this.filelayout.el.add_child(x.el);
112 for(var j =0 ; j < files.size; j++) {
113 print ("adding file %s\n", files.get(j));
115 var y = new Xcls_folderfile(this, files.get(j));
116 this.fileitems.add(y);
117 x.el.add_child(y.el);
119 // add file to files.get(j);
124 //this.el.set_value(citer, 1, items.get(i) );
131 public void set_size (float w, float h)
134 // called by window resize... with is alreaddy -50 (for the buttons?)
139 if (this.el == null) {
140 print("object not ready yet?");
144 print("recv width %f, filelayoutw = %f", w, w-200);
146 w = GLib.Math.floorf ( w/120.0f) * 120.0f;
151 //_this.filelayout_manager.el.max_column_width = w - 200;
152 _this.filelayout.el.width = w ;
155 // this.el.get_stage().width-150,
157 h // this.el.get_stage().height
160 // 100 right for buttons ..
161 this.el.set_position(75,0);
164 this.scroller.el.set_size(
165 // this.el.get_stage().width-150,
167 h // this.el.get_stage().height
170 // 100 right for buttons ..
171 this.scroller.el.set_position(0,50);
173 _this.filelayout.el.y = 0.0f;
176 public class Xcls_project_title : Object
178 public Clutter.Actor el;
179 private Xcls_ClutterFiles _this;
185 public Xcls_project_title(Xcls_ClutterFiles _owner )
188 _this.project_title = this;
189 this.el = new Clutter.Actor();
193 // set gobject values
194 this.el.reactive = true;
195 var child_0 = new Xcls_project_title_manager( _this );
197 this.el.layout_manager = child_0.el;
198 var child_1 = new Xcls_FixedLayout4( _this );
200 this.el.layout_manager = child_1.el;
201 var child_2 = new Xcls_project_title_name( _this );
203 this.el.add_child ( child_2.el );
204 var child_3 = new Xcls_project_title_path( _this );
206 this.el.add_child ( child_3.el );
210 this.el.add_constraint(
211 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
213 this.el.set_position(0,0);
216 // user defined functions
218 public class Xcls_project_title_manager : Object
220 public Clutter.FlowLayout el;
221 private Xcls_ClutterFiles _this;
227 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
230 _this.project_title_manager = this;
231 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
235 // set gobject values
236 this.el.homogeneous = false;
237 this.el.row_spacing = 5f;
238 this.el.column_spacing = 20f;
241 // user defined functions
244 public class Xcls_FixedLayout4 : Object
246 public Clutter.FixedLayout el;
247 private Xcls_ClutterFiles _this;
253 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
256 this.el = new Clutter.FixedLayout();
260 // set gobject values
263 // user defined functions
266 public class Xcls_project_title_name : Object
268 public Clutter.Text el;
269 private Xcls_ClutterFiles _this;
275 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
278 _this.project_title_name = this;
279 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
283 // set gobject values
286 this.el.x_expand = false;
289 // user defined functions
292 public class Xcls_project_title_path : Object
294 public Clutter.Text el;
295 private Xcls_ClutterFiles _this;
301 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
304 _this.project_title_path = this;
305 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
309 // set gobject values
314 // user defined functions
318 public class Xcls_scroller : Object
320 public Clutter.ScrollActor el;
321 private Xcls_ClutterFiles _this;
325 public Gee.ArrayList<Xcls_fileitem> fileitems;
326 public Gdk.Pixbuf missing_thumb_pixbuf;
329 public Xcls_scroller(Xcls_ClutterFiles _owner )
332 _this.scroller = this;
333 this.el = new Clutter.ScrollActor();
336 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
337 this.missing_thumb_pixbuf = null;
339 // set gobject values
340 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
341 this.el.reactive = true;
342 var child_0 = new Xcls_filelayout( _this );
344 this.el.add_child ( child_0.el );
347 this.el.scroll_event.connect( ( event) => {
348 //Sprint("scroll event");
349 var y = _this.filelayout.el.y;
350 var dir = event.direction;
352 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
353 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
356 case Clutter.ScrollDirection.UP:
357 print("Scroll up by %f\n", event.y);
359 y = float.min(0, y); //
362 case Clutter.ScrollDirection.DOWN:
363 print("Scroll down by %f\n", event.y);
365 y = float.max(bottompos, y);
372 // range of scroll -- can go up -- eg.. -ve value.
376 // to work out the max -ve number
377 // height of filelayout
378 // height of scrollactor..
381 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
382 var nv = _this.filelayout.el.y ;
383 if (nv != -1 * ( last_child_bottom - this.el.height)) {
385 _this.filelayout.el.y = -1 * ( last_child_bottom - this.el.height);
395 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
396 // last_child_bottom - this.el.height,
398 // y = float.min(0, y); //??
399 // print("scroll event of %f - new y = %f ".printf(event.y, y));
400 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
402 _this.filelayout.el.y = y;
408 // user defined functions
410 public class Xcls_filelayout : Object
412 public Clutter.Actor el;
413 private Xcls_ClutterFiles _this;
419 public Xcls_filelayout(Xcls_ClutterFiles _owner )
422 _this.filelayout = this;
423 this.el = new Clutter.Actor();
427 // set gobject values
428 this.el.reactive = true;
429 var child_0 = new Xcls_filelayout_manager( _this );
431 this.el.layout_manager = child_0.el;
435 this.el.add_constraint(
436 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
440 // user defined functions
442 public class Xcls_filelayout_manager : Object
444 public Clutter.FlowLayout el;
445 private Xcls_ClutterFiles _this;
451 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
454 _this.filelayout_manager = this;
455 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
459 // set gobject values
460 this.el.homogeneous = false;
461 this.el.max_column_width = 100.0f;
462 this.el.row_spacing = 20f;
463 this.el.column_spacing = 20f;
466 // user defined functions
469 public class Xcls_fileitem : Object
471 public Clutter.Actor el;
472 private Xcls_ClutterFiles _this;
476 public JsRender.JsRender file;
477 public Xcls_image image;
478 public Xcls_typetitle typetitle;
479 public Xcls_title title;
482 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
485 this.el = new Clutter.Actor();
489 // set gobject values
490 this.el.reactive = true;
491 var child_0 = new Xcls_BoxLayout11( _this );
493 this.el.layout_manager = child_0.el;
494 var child_1 = new Xcls_image( _this ,file);
496 this.el.add_child ( child_1.el );
497 this.image = child_1;
498 var child_2 = new Xcls_typetitle( _this ,file);
500 this.el.add_child ( child_2.el );
501 this.typetitle = child_2;
502 var child_3 = new Xcls_title( _this ,file);
504 this.el.add_child ( child_3.el );
505 this.title = child_3;
510 this.el.set_size(100,100);
513 this.el.button_press_event.connect( ( event) => {
514 _this.open(this.file);
517 this.el.enter_event.connect( ( event) => {
518 this.el.background_color = Clutter.Color.from_string("#333");
519 this.title.el.background_color = Clutter.Color.from_string("#fff");
520 this.typetitle.el.background_color = Clutter.Color.from_string("#fff");
521 this.title.el.color = Clutter.Color.from_string("#000");
522 this.typetitle.el.color = Clutter.Color.from_string("#000");
526 this.el.leave_event.connect( ( event) => {
527 this.el.background_color = Clutter.Color.from_string("#000");
528 this.title.el.background_color = Clutter.Color.from_string("#000");
529 this.typetitle.el.background_color = Clutter.Color.from_string("#000");
530 this.title.el.color = Clutter.Color.from_string("#fff");
531 this.typetitle.el.color = Clutter.Color.from_string("#fff");
538 // user defined functions
540 public class Xcls_BoxLayout11 : Object
542 public Clutter.BoxLayout el;
543 private Xcls_ClutterFiles _this;
549 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
552 this.el = new Clutter.BoxLayout();
556 // set gobject values
558 this.el.orientation = Clutter.Orientation.VERTICAL;
561 // user defined functions
564 public class Xcls_image : Object
566 public Clutter.Actor el;
567 private Xcls_ClutterFiles _this;
573 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
576 this.el = new Clutter.Actor();
580 // set gobject values
581 this.el.margin_right = 5f;
582 this.el.margin_left = 5f;
583 this.el.x_align = Clutter.ActorAlign.START;
584 this.el.x_expand = false;
585 this.el.y_align = Clutter.ActorAlign.START;
586 this.el.margin_top = 5f;
587 this.el.y_expand = false;
592 Gdk.Pixbuf pixbuf= null;
594 var fname = file.getIconFileName(false);
597 if (FileUtils.test(fname, FileTest.EXISTS)) {
598 pixbuf = new Gdk.Pixbuf.from_file(fname);
604 if (pixbuf == null) {
607 if (_this.missing_thumb_pixbuf == null) {
608 var icon_theme = Gtk.IconTheme.get_default ();
609 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
610 _this.missing_thumb_pixbuf.ref();
612 pixbuf = _this.missing_thumb_pixbuf;
619 var img = new Clutter.Image();
620 img.set_data(pixbuf.get_pixels(),
622 ? Cogl.PixelFormat.RGBA_8888
623 : Cogl.PixelFormat.RGB_888,
625 pixbuf.get_height (),
626 pixbuf.get_rowstride ()
628 this.el.set_content(img);
632 // should probably do smarter scaling...
635 this.el.set_size(90, 70);
639 // user defined functions
642 public class Xcls_typetitle : Object
644 public Clutter.Text el;
645 private Xcls_ClutterFiles _this;
651 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
654 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
658 // set gobject values
659 this.el.x_align = Clutter.ActorAlign.START;
660 this.el.x_expand = false;
661 this.el.y_align = Clutter.ActorAlign.START;
662 this.el.y_expand = false;
665 // user defined functions
668 public class Xcls_title : Object
670 public Clutter.Text el;
671 private Xcls_ClutterFiles _this;
677 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
680 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
684 // set gobject values
685 this.el.x_align = Clutter.ActorAlign.START;
686 this.el.x_expand = false;
687 this.el.y_align = Clutter.ActorAlign.START;
688 this.el.y_expand = false;
691 // user defined functions
695 public class Xcls_folderitem : Object
697 public Clutter.Actor el;
698 private Xcls_ClutterFiles _this;
702 public Xcls_foldertitle foldertitle;
705 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
708 this.el = new Clutter.Actor();
712 // set gobject values
713 this.el.reactive = true;
714 var child_0 = new Xcls_BoxLayout16( _this );
716 this.el.layout_manager = child_0.el;
717 var child_1 = new Xcls_foldertitle( _this ,folderpath);
719 this.el.add_child ( child_1.el );
720 this.foldertitle = child_1;
724 //this.el.set_size(100,100);
727 // user defined functions
729 public class Xcls_BoxLayout16 : Object
731 public Clutter.BoxLayout el;
732 private Xcls_ClutterFiles _this;
738 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
741 this.el = new Clutter.BoxLayout();
745 // set gobject values
747 this.el.orientation = Clutter.Orientation.VERTICAL;
750 // user defined functions
753 public class Xcls_foldertitle : Object
755 public Clutter.Text el;
756 private Xcls_ClutterFiles _this;
762 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
765 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
769 // set gobject values
770 this.el.x_align = Clutter.ActorAlign.START;
771 this.el.x_expand = true;
772 this.el.y_align = Clutter.ActorAlign.START;
773 this.el.y_expand = false;
776 // user defined functions
779 public class Xcls_folderfile : Object
781 public Clutter.Text el;
782 private Xcls_ClutterFiles _this;
786 public string filepath;
789 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
792 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
796 // set gobject values
797 this.el.x_align = Clutter.ActorAlign.START;
798 this.el.x_expand = true;
799 this.el.y_align = Clutter.ActorAlign.START;
800 this.el.reactive = true;
801 this.el.y_expand = true;
806 this.filepath = filepath;
810 this.el.button_press_event.connect( ( event) => {
812 var f = JsRender.JsRender.factory("PlainFile", _this.project, this.filepath);
816 this.el.enter_event.connect( ( event) => {
817 this.el.background_color = Clutter.Color.from_string("#fff");
818 this.el.color = Clutter.Color.from_string("#000");
821 this.el.leave_event.connect( ( event) => {
822 this.el.background_color = Clutter.Color.from_string("#000");
823 this.el.color = Clutter.Color.from_string("#fff");
828 // user defined functions