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.files(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 //_this.filelayout_manager.el.max_column_width = w - 200;
144 _this.filelayout.el.width = w - 200;
147 // this.el.get_stage().width-150,
149 h // this.el.get_stage().height
152 // 100 right for buttons ..
153 this.el.set_position(0,0);
156 this.scroller.el.set_size(
157 // this.el.get_stage().width-150,
159 h // this.el.get_stage().height
162 // 100 right for buttons ..
163 this.scroller.el.set_position(75,50);
165 public class Xcls_project_title : Object
167 public Clutter.Actor el;
168 private Xcls_ClutterFiles _this;
174 public Xcls_project_title(Xcls_ClutterFiles _owner )
177 _this.project_title = this;
178 this.el = new Clutter.Actor();
182 // set gobject values
183 this.el.reactive = true;
184 var child_0 = new Xcls_project_title_manager( _this );
186 this.el.layout_manager = child_0.el;
187 var child_1 = new Xcls_FixedLayout4( _this );
189 this.el.layout_manager = child_1.el;
190 var child_2 = new Xcls_project_title_name( _this );
192 this.el.add_child ( child_2.el );
193 var child_3 = new Xcls_project_title_path( _this );
195 this.el.add_child ( child_3.el );
199 this.el.add_constraint(
200 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
202 this.el.set_position(75,0);
205 // user defined functions
207 public class Xcls_project_title_manager : Object
209 public Clutter.FlowLayout el;
210 private Xcls_ClutterFiles _this;
216 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
219 _this.project_title_manager = this;
220 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
224 // set gobject values
225 this.el.homogeneous = false;
226 this.el.row_spacing = 5f;
227 this.el.column_spacing = 20f;
230 // user defined functions
233 public class Xcls_FixedLayout4 : Object
235 public Clutter.FixedLayout el;
236 private Xcls_ClutterFiles _this;
242 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
245 this.el = new Clutter.FixedLayout();
249 // set gobject values
252 // user defined functions
255 public class Xcls_project_title_name : Object
257 public Clutter.Text el;
258 private Xcls_ClutterFiles _this;
264 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
267 _this.project_title_name = this;
268 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
272 // set gobject values
275 this.el.x_expand = false;
278 // user defined functions
281 public class Xcls_project_title_path : Object
283 public Clutter.Text el;
284 private Xcls_ClutterFiles _this;
290 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
293 _this.project_title_path = this;
294 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
298 // set gobject values
303 // user defined functions
307 public class Xcls_scroller : Object
309 public Clutter.ScrollActor el;
310 private Xcls_ClutterFiles _this;
314 public Gee.ArrayList<Xcls_fileitem> fileitems;
315 public Gdk.Pixbuf missing_thumb_pixbuf;
318 public Xcls_scroller(Xcls_ClutterFiles _owner )
321 _this.scroller = this;
322 this.el = new Clutter.ScrollActor();
325 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
326 this.missing_thumb_pixbuf = null;
328 // set gobject values
329 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
330 this.el.reactive = true;
331 var child_0 = new Xcls_filelayout( _this );
333 this.el.add_child ( child_0.el );
336 this.el.scroll_event.connect( ( event) => {
337 //Sprint("scroll event");
338 var y = _this.filelayout.el.y;
339 var dir = event.direction;
341 case Clutter.ScrollDirection.UP:
342 print("Scroll up by %f\n", event.y);
347 case Clutter.ScrollDirection.DOWN:
348 print("Scroll down by %f\n", event.y);
354 // range of scroll -- can go up -- eg.. -ve value.
358 // to work out the max -ve number
359 // height of filelayout
360 // height of scrollactor..
362 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
363 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
364 var nv = _this.filelayout.el.y ;
365 if (nv != -1 * ( last_child_bottom - this.el.height)) {
367 _this.filelayout.el.y = -1 * ( last_child_bottom - this.el.height);
377 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
378 // last_child_bottom - this.el.height,
380 // y = float.min(0, y); //??
381 // print("scroll event of %f - new y = %f ".printf(event.y, y));
382 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
384 _this.filelayout.el.y = y;
390 // user defined functions
392 public class Xcls_filelayout : Object
394 public Clutter.Actor el;
395 private Xcls_ClutterFiles _this;
401 public Xcls_filelayout(Xcls_ClutterFiles _owner )
404 _this.filelayout = this;
405 this.el = new Clutter.Actor();
409 // set gobject values
410 this.el.reactive = true;
411 var child_0 = new Xcls_filelayout_manager( _this );
413 this.el.layout_manager = child_0.el;
417 this.el.add_constraint(
418 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
422 // user defined functions
424 public class Xcls_filelayout_manager : Object
426 public Clutter.FlowLayout el;
427 private Xcls_ClutterFiles _this;
433 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
436 _this.filelayout_manager = this;
437 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
441 // set gobject values
442 this.el.homogeneous = false;
443 this.el.max_column_width = 100.0f;
444 this.el.row_spacing = 20f;
445 this.el.column_spacing = 20f;
448 // user defined functions
451 public class Xcls_fileitem : Object
453 public Clutter.Actor el;
454 private Xcls_ClutterFiles _this;
458 public JsRender.JsRender file;
459 public Xcls_image image;
460 public Xcls_typetitle typetitle;
461 public Xcls_title title;
464 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
467 this.el = new Clutter.Actor();
471 // set gobject values
472 this.el.reactive = true;
473 var child_0 = new Xcls_BoxLayout11( _this );
475 this.el.layout_manager = child_0.el;
476 var child_1 = new Xcls_image( _this ,file);
478 this.el.add_child ( child_1.el );
479 this.image = child_1;
480 var child_2 = new Xcls_typetitle( _this ,file);
482 this.el.add_child ( child_2.el );
483 this.typetitle = child_2;
484 var child_3 = new Xcls_title( _this ,file);
486 this.el.add_child ( child_3.el );
487 this.title = child_3;
492 this.el.set_size(100,100);
495 this.el.button_press_event.connect( ( event) => {
496 _this.open(this.file);
499 this.el.enter_event.connect( ( event) => {
500 this.el.background_color = Clutter.Color.from_string("#333");
503 this.el.leave_event.connect( ( event) => {
504 this.el.background_color = Clutter.Color.from_string("#000");
509 // user defined functions
511 public class Xcls_BoxLayout11 : Object
513 public Clutter.BoxLayout el;
514 private Xcls_ClutterFiles _this;
520 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
523 this.el = new Clutter.BoxLayout();
527 // set gobject values
529 this.el.orientation = Clutter.Orientation.VERTICAL;
532 // user defined functions
535 public class Xcls_image : Object
537 public Clutter.Actor el;
538 private Xcls_ClutterFiles _this;
544 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
547 this.el = new Clutter.Actor();
551 // set gobject values
552 this.el.margin_right = 5f;
553 this.el.margin_left = 5f;
554 this.el.x_align = Clutter.ActorAlign.START;
555 this.el.x_expand = false;
556 this.el.y_align = Clutter.ActorAlign.START;
557 this.el.margin_top = 5f;
558 this.el.y_expand = false;
563 Gdk.Pixbuf pixbuf= null;
565 var fname = file.getIconFileName(false);
568 if (FileUtils.test(fname, FileTest.EXISTS)) {
569 pixbuf = new Gdk.Pixbuf.from_file(fname);
575 if (pixbuf == null) {
578 if (_this.missing_thumb_pixbuf == null) {
579 var icon_theme = Gtk.IconTheme.get_default ();
580 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
581 _this.missing_thumb_pixbuf.ref();
583 pixbuf = _this.missing_thumb_pixbuf;
590 var img = new Clutter.Image();
591 img.set_data(pixbuf.get_pixels(),
593 ? Cogl.PixelFormat.RGBA_8888
594 : Cogl.PixelFormat.RGB_888,
596 pixbuf.get_height (),
597 pixbuf.get_rowstride ()
599 this.el.set_content(img);
603 // should probably do smarter scaling...
606 this.el.set_size(90, 70);
610 // user defined functions
613 public class Xcls_typetitle : Object
615 public Clutter.Text el;
616 private Xcls_ClutterFiles _this;
622 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
625 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
629 // set gobject values
630 this.el.x_align = Clutter.ActorAlign.START;
631 this.el.x_expand = false;
632 this.el.y_align = Clutter.ActorAlign.START;
633 this.el.y_expand = false;
636 // user defined functions
639 public class Xcls_title : Object
641 public Clutter.Text el;
642 private Xcls_ClutterFiles _this;
648 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
651 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
655 // set gobject values
656 this.el.x_align = Clutter.ActorAlign.START;
657 this.el.x_expand = false;
658 this.el.y_align = Clutter.ActorAlign.START;
659 this.el.y_expand = false;
662 // user defined functions
666 public class Xcls_folderitem : Object
668 public Clutter.Actor el;
669 private Xcls_ClutterFiles _this;
673 public Xcls_foldertitle foldertitle;
676 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
679 this.el = new Clutter.Actor();
683 // set gobject values
684 this.el.reactive = true;
685 var child_0 = new Xcls_BoxLayout16( _this );
687 this.el.layout_manager = child_0.el;
688 var child_1 = new Xcls_foldertitle( _this ,folderpath);
690 this.el.add_child ( child_1.el );
691 this.foldertitle = child_1;
695 //this.el.set_size(100,100);
698 // user defined functions
700 public class Xcls_BoxLayout16 : Object
702 public Clutter.BoxLayout el;
703 private Xcls_ClutterFiles _this;
709 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
712 this.el = new Clutter.BoxLayout();
716 // set gobject values
718 this.el.orientation = Clutter.Orientation.VERTICAL;
721 // user defined functions
724 public class Xcls_foldertitle : Object
726 public Clutter.Text el;
727 private Xcls_ClutterFiles _this;
733 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
736 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
740 // set gobject values
741 this.el.x_align = Clutter.ActorAlign.START;
742 this.el.x_expand = true;
743 this.el.y_align = Clutter.ActorAlign.START;
744 this.el.y_expand = false;
747 // user defined functions
750 public class Xcls_folderfile : Object
752 public Clutter.Text el;
753 private Xcls_ClutterFiles _this;
757 public string filepath;
760 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
763 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
767 // set gobject values
768 this.el.x_align = Clutter.ActorAlign.START;
769 this.el.x_expand = true;
770 this.el.y_align = Clutter.ActorAlign.START;
771 this.el.reactive = true;
772 this.el.y_expand = false;
777 this.filepath = filepath;
781 this.el.button_press_event.connect( ( event) => {
782 // _this.open(this.filepath);
785 this.el.enter_event.connect( ( event) => {
786 this.el.background_color = Clutter.Color.from_string("#333");
789 this.el.leave_event.connect( ( event) => {
790 this.el.background_color = Clutter.Color.from_string("#000");
795 // user defined functions