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?)
134 if (this.el == null) {
135 print("object not ready yet?");
138 _this.filelayout_manager.el.max_column_width = w - 200;
141 // this.el.get_stage().width-150,
143 h // this.el.get_stage().height
146 // 100 right for buttons ..
147 this.el.set_position(0,0);
150 this.scroller.el.set_size(
151 // this.el.get_stage().width-150,
153 h // this.el.get_stage().height
156 // 100 right for buttons ..
157 this.scroller.el.set_position(75,50);
159 public class Xcls_project_title : Object
161 public Clutter.Actor el;
162 private Xcls_ClutterFiles _this;
168 public Xcls_project_title(Xcls_ClutterFiles _owner )
171 _this.project_title = this;
172 this.el = new Clutter.Actor();
176 // set gobject values
177 this.el.reactive = true;
178 var child_0 = new Xcls_project_title_manager( _this );
180 this.el.layout_manager = child_0.el;
181 var child_1 = new Xcls_FixedLayout4( _this );
183 this.el.layout_manager = child_1.el;
184 var child_2 = new Xcls_project_title_name( _this );
186 this.el.add_child ( child_2.el );
187 var child_3 = new Xcls_project_title_path( _this );
189 this.el.add_child ( child_3.el );
193 this.el.add_constraint(
194 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
196 this.el.set_position(75,0);
199 // user defined functions
201 public class Xcls_project_title_manager : Object
203 public Clutter.FlowLayout el;
204 private Xcls_ClutterFiles _this;
210 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
213 _this.project_title_manager = this;
214 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
218 // set gobject values
219 this.el.homogeneous = false;
220 this.el.row_spacing = 5f;
221 this.el.column_spacing = 20f;
224 // user defined functions
227 public class Xcls_FixedLayout4 : Object
229 public Clutter.FixedLayout el;
230 private Xcls_ClutterFiles _this;
236 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
239 this.el = new Clutter.FixedLayout();
243 // set gobject values
246 // user defined functions
249 public class Xcls_project_title_name : Object
251 public Clutter.Text el;
252 private Xcls_ClutterFiles _this;
258 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
261 _this.project_title_name = this;
262 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
266 // set gobject values
269 this.el.x_expand = false;
272 // user defined functions
275 public class Xcls_project_title_path : Object
277 public Clutter.Text el;
278 private Xcls_ClutterFiles _this;
284 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
287 _this.project_title_path = this;
288 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
292 // set gobject values
297 // user defined functions
301 public class Xcls_scroller : Object
303 public Clutter.ScrollActor el;
304 private Xcls_ClutterFiles _this;
308 public Gee.ArrayList<Xcls_fileitem> fileitems;
309 public Gdk.Pixbuf missing_thumb_pixbuf;
312 public Xcls_scroller(Xcls_ClutterFiles _owner )
315 _this.scroller = this;
316 this.el = new Clutter.ScrollActor();
319 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
320 this.missing_thumb_pixbuf = null;
322 // set gobject values
323 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
324 this.el.reactive = true;
325 var child_0 = new Xcls_filelayout( _this );
327 this.el.add_child ( child_0.el );
330 this.el.scroll_event.connect( ( event) => {
331 //Sprint("scroll event");
332 var y = _this.filelayout.el.y;
333 var dir = event.direction;
335 case Clutter.ScrollDirection.UP:
338 case Clutter.ScrollDirection.DOWN:
344 // range of scroll -- can go up -- eg.. -ve value.
348 // to work out the max -ve number
349 // height of filelayout
350 // height of scrollactor..
352 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
353 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
360 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
361 // last_child_bottom - this.el.height,
363 // y = float.min(0, y); //??
364 // print("scroll event of %f - new y = %f ".printf(event.y, y));
365 _this.filelayout.el.y = y;
371 // user defined functions
373 public class Xcls_filelayout : Object
375 public Clutter.Actor el;
376 private Xcls_ClutterFiles _this;
382 public Xcls_filelayout(Xcls_ClutterFiles _owner )
385 _this.filelayout = this;
386 this.el = new Clutter.Actor();
390 // set gobject values
391 this.el.reactive = true;
392 var child_0 = new Xcls_filelayout_manager( _this );
394 this.el.layout_manager = child_0.el;
398 this.el.add_constraint(
399 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
403 // user defined functions
405 public class Xcls_filelayout_manager : Object
407 public Clutter.FlowLayout el;
408 private Xcls_ClutterFiles _this;
414 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
417 _this.filelayout_manager = this;
418 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
422 // set gobject values
423 this.el.homogeneous = true;
424 this.el.max_column_width = 120f;
425 this.el.row_spacing = 20f;
426 this.el.column_spacing = 20f;
429 // user defined functions
432 public class Xcls_fileitem : Object
434 public Clutter.Actor el;
435 private Xcls_ClutterFiles _this;
439 public JsRender.JsRender file;
440 public Xcls_image image;
441 public Xcls_typetitle typetitle;
442 public Xcls_title title;
445 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
448 this.el = new Clutter.Actor();
452 // set gobject values
453 this.el.reactive = true;
454 var child_0 = new Xcls_BoxLayout11( _this );
456 this.el.layout_manager = child_0.el;
457 var child_1 = new Xcls_image( _this ,file);
459 this.el.add_child ( child_1.el );
460 this.image = child_1;
461 var child_2 = new Xcls_typetitle( _this ,file);
463 this.el.add_child ( child_2.el );
464 this.typetitle = child_2;
465 var child_3 = new Xcls_title( _this ,file);
467 this.el.add_child ( child_3.el );
468 this.title = child_3;
473 this.el.set_size(100,100);
476 this.el.button_press_event.connect( ( event) => {
477 _this.open(this.file);
480 this.el.enter_event.connect( ( event) => {
481 this.el.background_color = Clutter.Color.from_string("#333");
484 this.el.leave_event.connect( ( event) => {
485 this.el.background_color = Clutter.Color.from_string("#000");
490 // user defined functions
492 public class Xcls_BoxLayout11 : Object
494 public Clutter.BoxLayout el;
495 private Xcls_ClutterFiles _this;
501 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
504 this.el = new Clutter.BoxLayout();
508 // set gobject values
510 this.el.orientation = Clutter.Orientation.VERTICAL;
513 // user defined functions
516 public class Xcls_image : Object
518 public Clutter.Actor el;
519 private Xcls_ClutterFiles _this;
525 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
528 this.el = new Clutter.Actor();
532 // set gobject values
533 this.el.margin_right = 5f;
534 this.el.margin_left = 5f;
535 this.el.x_align = Clutter.ActorAlign.START;
536 this.el.x_expand = false;
537 this.el.y_align = Clutter.ActorAlign.START;
538 this.el.margin_top = 5f;
539 this.el.y_expand = false;
544 Gdk.Pixbuf pixbuf= null;
546 var fname = file.getIconFileName(false);
549 if (FileUtils.test(fname, FileTest.EXISTS)) {
550 pixbuf = new Gdk.Pixbuf.from_file(fname);
556 if (pixbuf == null) {
559 if (_this.missing_thumb_pixbuf == null) {
560 var icon_theme = Gtk.IconTheme.get_default ();
561 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
562 _this.missing_thumb_pixbuf.ref();
564 pixbuf = _this.missing_thumb_pixbuf;
571 var img = new Clutter.Image();
572 img.set_data(pixbuf.get_pixels(),
574 ? Cogl.PixelFormat.RGBA_8888
575 : Cogl.PixelFormat.RGB_888,
577 pixbuf.get_height (),
578 pixbuf.get_rowstride ()
580 this.el.set_content(img);
584 // should probably do smarter scaling...
587 this.el.set_size(90, 70);
591 // user defined functions
594 public class Xcls_typetitle : Object
596 public Clutter.Text el;
597 private Xcls_ClutterFiles _this;
603 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
606 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
610 // set gobject values
611 this.el.x_align = Clutter.ActorAlign.START;
612 this.el.x_expand = false;
613 this.el.y_align = Clutter.ActorAlign.START;
614 this.el.y_expand = false;
617 // user defined functions
620 public class Xcls_title : Object
622 public Clutter.Text el;
623 private Xcls_ClutterFiles _this;
629 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
632 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
636 // set gobject values
637 this.el.x_align = Clutter.ActorAlign.START;
638 this.el.x_expand = false;
639 this.el.y_align = Clutter.ActorAlign.START;
640 this.el.y_expand = false;
643 // user defined functions
647 public class Xcls_folderitem : Object
649 public Clutter.Actor el;
650 private Xcls_ClutterFiles _this;
654 public Xcls_foldertitle foldertitle;
657 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
660 this.el = new Clutter.Actor();
664 // set gobject values
665 this.el.reactive = true;
666 var child_0 = new Xcls_BoxLayout16( _this );
668 this.el.layout_manager = child_0.el;
669 var child_1 = new Xcls_foldertitle( _this ,folderpath);
671 this.el.add_child ( child_1.el );
672 this.foldertitle = child_1;
676 //this.el.set_size(100,100);
679 // user defined functions
681 public class Xcls_BoxLayout16 : Object
683 public Clutter.BoxLayout el;
684 private Xcls_ClutterFiles _this;
690 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
693 this.el = new Clutter.BoxLayout();
697 // set gobject values
699 this.el.orientation = Clutter.Orientation.VERTICAL;
702 // user defined functions
705 public class Xcls_foldertitle : Object
707 public Clutter.Text el;
708 private Xcls_ClutterFiles _this;
714 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
717 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
721 // set gobject values
722 this.el.x_align = Clutter.ActorAlign.START;
723 this.el.x_expand = true;
724 this.el.y_align = Clutter.ActorAlign.START;
725 this.el.y_expand = false;
728 // user defined functions
731 public class Xcls_folderfile : Object
733 public Clutter.Text el;
734 private Xcls_ClutterFiles _this;
738 public string filepath;
741 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
744 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
748 // set gobject values
749 this.el.x_align = Clutter.ActorAlign.START;
750 this.el.x_expand = true;
751 this.el.y_align = Clutter.ActorAlign.START;
752 this.el.reactive = true;
753 this.el.y_expand = false;
758 this.filepath = filepath;
762 this.el.button_press_event.connect( ( event) => {
763 // _this.open(this.filepath);
766 this.el.enter_event.connect( ( event) => {
767 this.el.background_color = Clutter.Color.from_string("#333");
770 this.el.leave_event.connect( ( event) => {
771 this.el.background_color = Clutter.Color.from_string("#000");
776 // user defined functions