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 // floor ( w/120) * 120...
145 //_this.filelayout_manager.el.max_column_width = w - 200;
146 _this.filelayout.el.width = w - 200;
149 // this.el.get_stage().width-150,
151 h // this.el.get_stage().height
154 // 100 right for buttons ..
155 this.el.set_position(0,0);
158 this.scroller.el.set_size(
159 // this.el.get_stage().width-150,
161 h // this.el.get_stage().height
164 // 100 right for buttons ..
165 this.scroller.el.set_position(75,50);
167 _this.filelayout.el.y = 0.0f;
170 public class Xcls_project_title : Object
172 public Clutter.Actor el;
173 private Xcls_ClutterFiles _this;
179 public Xcls_project_title(Xcls_ClutterFiles _owner )
182 _this.project_title = this;
183 this.el = new Clutter.Actor();
187 // set gobject values
188 this.el.reactive = true;
189 var child_0 = new Xcls_project_title_manager( _this );
191 this.el.layout_manager = child_0.el;
192 var child_1 = new Xcls_FixedLayout4( _this );
194 this.el.layout_manager = child_1.el;
195 var child_2 = new Xcls_project_title_name( _this );
197 this.el.add_child ( child_2.el );
198 var child_3 = new Xcls_project_title_path( _this );
200 this.el.add_child ( child_3.el );
204 this.el.add_constraint(
205 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
207 this.el.set_position(75,0);
210 // user defined functions
212 public class Xcls_project_title_manager : Object
214 public Clutter.FlowLayout el;
215 private Xcls_ClutterFiles _this;
221 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
224 _this.project_title_manager = this;
225 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
229 // set gobject values
230 this.el.homogeneous = false;
231 this.el.row_spacing = 5f;
232 this.el.column_spacing = 20f;
235 // user defined functions
238 public class Xcls_FixedLayout4 : Object
240 public Clutter.FixedLayout el;
241 private Xcls_ClutterFiles _this;
247 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
250 this.el = new Clutter.FixedLayout();
254 // set gobject values
257 // user defined functions
260 public class Xcls_project_title_name : Object
262 public Clutter.Text el;
263 private Xcls_ClutterFiles _this;
269 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
272 _this.project_title_name = this;
273 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
277 // set gobject values
280 this.el.x_expand = false;
283 // user defined functions
286 public class Xcls_project_title_path : Object
288 public Clutter.Text el;
289 private Xcls_ClutterFiles _this;
295 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
298 _this.project_title_path = this;
299 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
303 // set gobject values
308 // user defined functions
312 public class Xcls_scroller : Object
314 public Clutter.ScrollActor el;
315 private Xcls_ClutterFiles _this;
319 public Gee.ArrayList<Xcls_fileitem> fileitems;
320 public Gdk.Pixbuf missing_thumb_pixbuf;
323 public Xcls_scroller(Xcls_ClutterFiles _owner )
326 _this.scroller = this;
327 this.el = new Clutter.ScrollActor();
330 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
331 this.missing_thumb_pixbuf = null;
333 // set gobject values
334 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
335 this.el.reactive = true;
336 var child_0 = new Xcls_filelayout( _this );
338 this.el.add_child ( child_0.el );
341 this.el.scroll_event.connect( ( event) => {
342 //Sprint("scroll event");
343 var y = _this.filelayout.el.y;
344 var dir = event.direction;
346 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
347 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
350 case Clutter.ScrollDirection.UP:
351 print("Scroll up by %f\n", event.y);
353 y = float.min(0, y); //
356 case Clutter.ScrollDirection.DOWN:
357 print("Scroll down by %f\n", event.y);
359 y = float.max(bottompos, y);
366 // range of scroll -- can go up -- eg.. -ve value.
370 // to work out the max -ve number
371 // height of filelayout
372 // height of scrollactor..
375 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
376 var nv = _this.filelayout.el.y ;
377 if (nv != -1 * ( last_child_bottom - this.el.height)) {
379 _this.filelayout.el.y = -1 * ( last_child_bottom - this.el.height);
389 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
390 // last_child_bottom - this.el.height,
392 // y = float.min(0, y); //??
393 // print("scroll event of %f - new y = %f ".printf(event.y, y));
394 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
396 _this.filelayout.el.y = y;
402 // user defined functions
404 public class Xcls_filelayout : Object
406 public Clutter.Actor el;
407 private Xcls_ClutterFiles _this;
413 public Xcls_filelayout(Xcls_ClutterFiles _owner )
416 _this.filelayout = this;
417 this.el = new Clutter.Actor();
421 // set gobject values
422 this.el.reactive = true;
423 var child_0 = new Xcls_filelayout_manager( _this );
425 this.el.layout_manager = child_0.el;
429 this.el.add_constraint(
430 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
434 // user defined functions
436 public class Xcls_filelayout_manager : Object
438 public Clutter.FlowLayout el;
439 private Xcls_ClutterFiles _this;
445 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
448 _this.filelayout_manager = this;
449 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
453 // set gobject values
454 this.el.homogeneous = false;
455 this.el.max_column_width = 100.0f;
456 this.el.row_spacing = 20f;
457 this.el.column_spacing = 20f;
460 // user defined functions
463 public class Xcls_fileitem : Object
465 public Clutter.Actor el;
466 private Xcls_ClutterFiles _this;
470 public JsRender.JsRender file;
471 public Xcls_image image;
472 public Xcls_typetitle typetitle;
473 public Xcls_title title;
476 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
479 this.el = new Clutter.Actor();
483 // set gobject values
484 this.el.reactive = true;
485 var child_0 = new Xcls_BoxLayout11( _this );
487 this.el.layout_manager = child_0.el;
488 var child_1 = new Xcls_image( _this ,file);
490 this.el.add_child ( child_1.el );
491 this.image = child_1;
492 var child_2 = new Xcls_typetitle( _this ,file);
494 this.el.add_child ( child_2.el );
495 this.typetitle = child_2;
496 var child_3 = new Xcls_title( _this ,file);
498 this.el.add_child ( child_3.el );
499 this.title = child_3;
504 this.el.set_size(100,100);
507 this.el.button_press_event.connect( ( event) => {
508 _this.open(this.file);
511 this.el.enter_event.connect( ( event) => {
512 this.el.background_color = Clutter.Color.from_string("#333");
515 this.el.leave_event.connect( ( event) => {
516 this.el.background_color = Clutter.Color.from_string("#000");
521 // user defined functions
523 public class Xcls_BoxLayout11 : Object
525 public Clutter.BoxLayout el;
526 private Xcls_ClutterFiles _this;
532 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
535 this.el = new Clutter.BoxLayout();
539 // set gobject values
541 this.el.orientation = Clutter.Orientation.VERTICAL;
544 // user defined functions
547 public class Xcls_image : Object
549 public Clutter.Actor el;
550 private Xcls_ClutterFiles _this;
556 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
559 this.el = new Clutter.Actor();
563 // set gobject values
564 this.el.margin_right = 5f;
565 this.el.margin_left = 5f;
566 this.el.x_align = Clutter.ActorAlign.START;
567 this.el.x_expand = false;
568 this.el.y_align = Clutter.ActorAlign.START;
569 this.el.margin_top = 5f;
570 this.el.y_expand = false;
575 Gdk.Pixbuf pixbuf= null;
577 var fname = file.getIconFileName(false);
580 if (FileUtils.test(fname, FileTest.EXISTS)) {
581 pixbuf = new Gdk.Pixbuf.from_file(fname);
587 if (pixbuf == null) {
590 if (_this.missing_thumb_pixbuf == null) {
591 var icon_theme = Gtk.IconTheme.get_default ();
592 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
593 _this.missing_thumb_pixbuf.ref();
595 pixbuf = _this.missing_thumb_pixbuf;
602 var img = new Clutter.Image();
603 img.set_data(pixbuf.get_pixels(),
605 ? Cogl.PixelFormat.RGBA_8888
606 : Cogl.PixelFormat.RGB_888,
608 pixbuf.get_height (),
609 pixbuf.get_rowstride ()
611 this.el.set_content(img);
615 // should probably do smarter scaling...
618 this.el.set_size(90, 70);
622 // user defined functions
625 public class Xcls_typetitle : Object
627 public Clutter.Text el;
628 private Xcls_ClutterFiles _this;
634 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
637 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
641 // set gobject values
642 this.el.x_align = Clutter.ActorAlign.START;
643 this.el.x_expand = false;
644 this.el.y_align = Clutter.ActorAlign.START;
645 this.el.y_expand = false;
648 // user defined functions
651 public class Xcls_title : Object
653 public Clutter.Text el;
654 private Xcls_ClutterFiles _this;
660 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
663 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
667 // set gobject values
668 this.el.x_align = Clutter.ActorAlign.START;
669 this.el.x_expand = false;
670 this.el.y_align = Clutter.ActorAlign.START;
671 this.el.y_expand = false;
674 // user defined functions
678 public class Xcls_folderitem : Object
680 public Clutter.Actor el;
681 private Xcls_ClutterFiles _this;
685 public Xcls_foldertitle foldertitle;
688 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
691 this.el = new Clutter.Actor();
695 // set gobject values
696 this.el.reactive = true;
697 var child_0 = new Xcls_BoxLayout16( _this );
699 this.el.layout_manager = child_0.el;
700 var child_1 = new Xcls_foldertitle( _this ,folderpath);
702 this.el.add_child ( child_1.el );
703 this.foldertitle = child_1;
707 //this.el.set_size(100,100);
710 // user defined functions
712 public class Xcls_BoxLayout16 : Object
714 public Clutter.BoxLayout el;
715 private Xcls_ClutterFiles _this;
721 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
724 this.el = new Clutter.BoxLayout();
728 // set gobject values
730 this.el.orientation = Clutter.Orientation.VERTICAL;
733 // user defined functions
736 public class Xcls_foldertitle : Object
738 public Clutter.Text el;
739 private Xcls_ClutterFiles _this;
745 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
748 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
752 // set gobject values
753 this.el.x_align = Clutter.ActorAlign.START;
754 this.el.x_expand = true;
755 this.el.y_align = Clutter.ActorAlign.START;
756 this.el.y_expand = false;
759 // user defined functions
762 public class Xcls_folderfile : Object
764 public Clutter.Text el;
765 private Xcls_ClutterFiles _this;
769 public string filepath;
772 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
775 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
779 // set gobject values
780 this.el.x_align = Clutter.ActorAlign.START;
781 this.el.x_expand = true;
782 this.el.y_align = Clutter.ActorAlign.START;
783 this.el.reactive = true;
784 this.el.y_expand = false;
789 this.filepath = filepath;
793 this.el.button_press_event.connect( ( event) => {
794 // _this.open(this.filepath);
797 this.el.enter_event.connect( ( event) => {
798 this.el.background_color = Clutter.Color.from_string("#333");
801 this.el.leave_event.connect( ( event) => {
802 this.el.background_color = Clutter.Color.from_string("#000");
807 // user defined functions