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.
60 // LEAK --- we should unref all the chilren...
61 this.filelayout.el.y = 0;
64 print("clutter files - load project: " + pr.name +"\n");
65 // should unref.. them hopefully.
67 this.project_title_name.el.text = pr.name;
68 this.project_title_path.el.text = pr.firstPath();
70 // file items contains a reference until we reload ...
71 this.fileitems = new Gee.ArrayList<Object>();
75 var fiter = pr.sortedFiles().list_iterator();
76 while (fiter.next()) {
77 var a = new Xcls_fileitem(this,fiter.get());
78 this.fileitems.add(a);
81 print("add to clutter file view: " + fiter.get().name + "\n");
82 this.filelayout.el.add_child(a.el);
87 if (!(pr is Project.Gtk)) {
88 print ("not gtk... skipping files");
91 var gpr = (Project.Gtk)pr;
92 var def = gpr.compilegroups.get("_default_");
93 var items = def.sources;
97 for(var i =0 ; i < items.size; i++) {
98 print ("cheking folder %s\n", items.get(i));
99 var files = gpr.filesForOpen(items.get(i));
100 if (files.size < 1) {
104 // add the directory... items.get(i);
105 var x = new Xcls_folderitem(this,items.get(i));
106 this.fileitems.add(x);
107 this.filelayout.el.add_child(x.el);
109 for(var j =0 ; j < files.size; j++) {
110 print ("adding file %s\n", files.get(j));
112 var y = new Xcls_folderfile(this, files.get(j));
113 this.fileitems.add(y);
114 x.el.add_child(y.el);
116 // add file to files.get(j);
121 //this.el.set_value(citer, 1, items.get(i) );
128 public void set_size (float w, float h)
131 // called by window resize... with is alreaddy -50 (for the buttons?)
136 if (this.el == null) {
137 print("object not ready yet?");
141 print("recv width %f, filelayoutw = %f", w, w-200);
143 w = GLib.Math.floorf ( w/120.0f) * 120.0f;
148 //_this.filelayout_manager.el.max_column_width = w - 200;
149 _this.filelayout.el.width = w - 200;
152 // this.el.get_stage().width-150,
154 h // this.el.get_stage().height
157 // 100 right for buttons ..
158 this.el.set_position(0,0);
161 this.scroller.el.set_size(
162 // this.el.get_stage().width-150,
164 h // this.el.get_stage().height
167 // 100 right for buttons ..
168 this.scroller.el.set_position(75,50);
170 _this.filelayout.el.y = 0.0f;
173 public class Xcls_project_title : Object
175 public Clutter.Actor el;
176 private Xcls_ClutterFiles _this;
182 public Xcls_project_title(Xcls_ClutterFiles _owner )
185 _this.project_title = this;
186 this.el = new Clutter.Actor();
190 // set gobject values
191 this.el.reactive = true;
192 var child_0 = new Xcls_project_title_manager( _this );
194 this.el.layout_manager = child_0.el;
195 var child_1 = new Xcls_FixedLayout4( _this );
197 this.el.layout_manager = child_1.el;
198 var child_2 = new Xcls_project_title_name( _this );
200 this.el.add_child ( child_2.el );
201 var child_3 = new Xcls_project_title_path( _this );
203 this.el.add_child ( child_3.el );
207 this.el.add_constraint(
208 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
210 this.el.set_position(75,0);
213 // user defined functions
215 public class Xcls_project_title_manager : Object
217 public Clutter.FlowLayout el;
218 private Xcls_ClutterFiles _this;
224 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
227 _this.project_title_manager = this;
228 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
232 // set gobject values
233 this.el.homogeneous = false;
234 this.el.row_spacing = 5f;
235 this.el.column_spacing = 20f;
238 // user defined functions
241 public class Xcls_FixedLayout4 : Object
243 public Clutter.FixedLayout el;
244 private Xcls_ClutterFiles _this;
250 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
253 this.el = new Clutter.FixedLayout();
257 // set gobject values
260 // user defined functions
263 public class Xcls_project_title_name : Object
265 public Clutter.Text el;
266 private Xcls_ClutterFiles _this;
272 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
275 _this.project_title_name = this;
276 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
280 // set gobject values
283 this.el.x_expand = false;
286 // user defined functions
289 public class Xcls_project_title_path : Object
291 public Clutter.Text el;
292 private Xcls_ClutterFiles _this;
298 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
301 _this.project_title_path = this;
302 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
306 // set gobject values
311 // user defined functions
315 public class Xcls_scroller : Object
317 public Clutter.ScrollActor el;
318 private Xcls_ClutterFiles _this;
322 public Gee.ArrayList<Xcls_fileitem> fileitems;
323 public Gdk.Pixbuf missing_thumb_pixbuf;
326 public Xcls_scroller(Xcls_ClutterFiles _owner )
329 _this.scroller = this;
330 this.el = new Clutter.ScrollActor();
333 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
334 this.missing_thumb_pixbuf = null;
336 // set gobject values
337 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
338 this.el.reactive = true;
339 var child_0 = new Xcls_filelayout( _this );
341 this.el.add_child ( child_0.el );
344 this.el.scroll_event.connect( ( event) => {
345 //Sprint("scroll event");
346 var y = _this.filelayout.el.y;
347 var dir = event.direction;
349 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
350 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
353 case Clutter.ScrollDirection.UP:
354 print("Scroll up by %f\n", event.y);
356 y = float.min(0, y); //
359 case Clutter.ScrollDirection.DOWN:
360 print("Scroll down by %f\n", event.y);
362 y = float.max(bottompos, y);
369 // range of scroll -- can go up -- eg.. -ve value.
373 // to work out the max -ve number
374 // height of filelayout
375 // height of scrollactor..
378 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
379 var nv = _this.filelayout.el.y ;
380 if (nv != -1 * ( last_child_bottom - this.el.height)) {
382 _this.filelayout.el.y = -1 * ( last_child_bottom - this.el.height);
392 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
393 // last_child_bottom - this.el.height,
395 // y = float.min(0, y); //??
396 // print("scroll event of %f - new y = %f ".printf(event.y, y));
397 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
399 _this.filelayout.el.y = y;
405 // user defined functions
407 public class Xcls_filelayout : Object
409 public Clutter.Actor el;
410 private Xcls_ClutterFiles _this;
416 public Xcls_filelayout(Xcls_ClutterFiles _owner )
419 _this.filelayout = this;
420 this.el = new Clutter.Actor();
424 // set gobject values
425 this.el.reactive = true;
426 var child_0 = new Xcls_filelayout_manager( _this );
428 this.el.layout_manager = child_0.el;
432 this.el.add_constraint(
433 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
437 // user defined functions
439 public class Xcls_filelayout_manager : Object
441 public Clutter.FlowLayout el;
442 private Xcls_ClutterFiles _this;
448 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
451 _this.filelayout_manager = this;
452 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
456 // set gobject values
457 this.el.homogeneous = false;
458 this.el.max_column_width = 100.0f;
459 this.el.row_spacing = 20f;
460 this.el.column_spacing = 20f;
463 // user defined functions
466 public class Xcls_fileitem : Object
468 public Clutter.Actor el;
469 private Xcls_ClutterFiles _this;
473 public JsRender.JsRender file;
474 public Xcls_image image;
475 public Xcls_typetitle typetitle;
476 public Xcls_title title;
479 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
482 this.el = new Clutter.Actor();
486 // set gobject values
487 this.el.reactive = true;
488 var child_0 = new Xcls_BoxLayout11( _this );
490 this.el.layout_manager = child_0.el;
491 var child_1 = new Xcls_image( _this ,file);
493 this.el.add_child ( child_1.el );
494 this.image = child_1;
495 var child_2 = new Xcls_typetitle( _this ,file);
497 this.el.add_child ( child_2.el );
498 this.typetitle = child_2;
499 var child_3 = new Xcls_title( _this ,file);
501 this.el.add_child ( child_3.el );
502 this.title = child_3;
507 this.el.set_size(100,100);
510 this.el.button_press_event.connect( ( event) => {
511 _this.open(this.file);
514 this.el.enter_event.connect( ( event) => {
515 this.el.background_color = Clutter.Color.from_string("#333");
518 this.el.leave_event.connect( ( event) => {
519 this.el.background_color = Clutter.Color.from_string("#000");
524 // user defined functions
526 public class Xcls_BoxLayout11 : Object
528 public Clutter.BoxLayout el;
529 private Xcls_ClutterFiles _this;
535 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
538 this.el = new Clutter.BoxLayout();
542 // set gobject values
544 this.el.orientation = Clutter.Orientation.VERTICAL;
547 // user defined functions
550 public class Xcls_image : Object
552 public Clutter.Actor el;
553 private Xcls_ClutterFiles _this;
559 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
562 this.el = new Clutter.Actor();
566 // set gobject values
567 this.el.margin_right = 5f;
568 this.el.margin_left = 5f;
569 this.el.x_align = Clutter.ActorAlign.START;
570 this.el.x_expand = false;
571 this.el.y_align = Clutter.ActorAlign.START;
572 this.el.margin_top = 5f;
573 this.el.y_expand = false;
578 Gdk.Pixbuf pixbuf= null;
580 var fname = file.getIconFileName(false);
583 if (FileUtils.test(fname, FileTest.EXISTS)) {
584 pixbuf = new Gdk.Pixbuf.from_file(fname);
590 if (pixbuf == null) {
593 if (_this.missing_thumb_pixbuf == null) {
594 var icon_theme = Gtk.IconTheme.get_default ();
595 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
596 _this.missing_thumb_pixbuf.ref();
598 pixbuf = _this.missing_thumb_pixbuf;
605 var img = new Clutter.Image();
606 img.set_data(pixbuf.get_pixels(),
608 ? Cogl.PixelFormat.RGBA_8888
609 : Cogl.PixelFormat.RGB_888,
611 pixbuf.get_height (),
612 pixbuf.get_rowstride ()
614 this.el.set_content(img);
618 // should probably do smarter scaling...
621 this.el.set_size(90, 70);
625 // user defined functions
628 public class Xcls_typetitle : Object
630 public Clutter.Text el;
631 private Xcls_ClutterFiles _this;
637 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
640 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
644 // set gobject values
645 this.el.x_align = Clutter.ActorAlign.START;
646 this.el.x_expand = false;
647 this.el.y_align = Clutter.ActorAlign.START;
648 this.el.y_expand = false;
651 // user defined functions
654 public class Xcls_title : Object
656 public Clutter.Text el;
657 private Xcls_ClutterFiles _this;
663 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
666 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
670 // set gobject values
671 this.el.x_align = Clutter.ActorAlign.START;
672 this.el.x_expand = false;
673 this.el.y_align = Clutter.ActorAlign.START;
674 this.el.y_expand = false;
677 // user defined functions
681 public class Xcls_folderitem : Object
683 public Clutter.Actor el;
684 private Xcls_ClutterFiles _this;
688 public Xcls_foldertitle foldertitle;
691 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
694 this.el = new Clutter.Actor();
698 // set gobject values
699 this.el.reactive = true;
700 var child_0 = new Xcls_BoxLayout16( _this );
702 this.el.layout_manager = child_0.el;
703 var child_1 = new Xcls_foldertitle( _this ,folderpath);
705 this.el.add_child ( child_1.el );
706 this.foldertitle = child_1;
710 //this.el.set_size(100,100);
713 // user defined functions
715 public class Xcls_BoxLayout16 : Object
717 public Clutter.BoxLayout el;
718 private Xcls_ClutterFiles _this;
724 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
727 this.el = new Clutter.BoxLayout();
731 // set gobject values
733 this.el.orientation = Clutter.Orientation.VERTICAL;
736 // user defined functions
739 public class Xcls_foldertitle : Object
741 public Clutter.Text el;
742 private Xcls_ClutterFiles _this;
748 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
751 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
755 // set gobject values
756 this.el.x_align = Clutter.ActorAlign.START;
757 this.el.x_expand = true;
758 this.el.y_align = Clutter.ActorAlign.START;
759 this.el.y_expand = false;
762 // user defined functions
765 public class Xcls_folderfile : Object
767 public Clutter.Text el;
768 private Xcls_ClutterFiles _this;
772 public string filepath;
775 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
778 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
782 // set gobject values
783 this.el.x_align = Clutter.ActorAlign.START;
784 this.el.x_expand = true;
785 this.el.y_align = Clutter.ActorAlign.START;
786 this.el.reactive = true;
787 this.el.y_expand = false;
792 this.filepath = filepath;
796 this.el.button_press_event.connect( ( event) => {
797 // _this.open(this.filepath);
800 this.el.enter_event.connect( ( event) => {
801 this.el.background_color = Clutter.Color.from_string("#fff");
802 this.el.fg_color = Clutter.Color.from_string("#000");
805 this.el.leave_event.connect( ( event) => {
806 this.el.background_color = Clutter.Color.from_string("#000");
811 // user defined functions