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_scoller scoller;
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_scoller( _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)) {
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++) {
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 var y = new Xcls_folderfile(this, files.get(j));
111 this.fileitems.add(y);
112 x.el.add_child(y.el);
114 // add file to files.get(j);
119 //this.el.set_value(citer, 1, items.get(i) );
126 public void set_size (float w, float h)
129 // called by window resize... with is alreaddy -50 (for the buttons?)
132 if (this.el == null) {
133 print("object not ready yet?");
136 _this.filelayout_manager.el.max_column_width = w - 75;
139 // this.el.get_stage().width-150,
141 h // this.el.get_stage().height
144 // 100 right for buttons ..
145 this.el.set_position(0,0);
148 this.scoller.el.set_size(
149 // this.el.get_stage().width-150,
151 h // this.el.get_stage().height
154 // 100 right for buttons ..
155 this.scoller.el.set_position(75,50);
157 public class Xcls_project_title : Object
159 public Clutter.Actor el;
160 private Xcls_ClutterFiles _this;
166 public Xcls_project_title(Xcls_ClutterFiles _owner )
169 _this.project_title = this;
170 this.el = new Clutter.Actor();
174 // set gobject values
175 this.el.reactive = true;
176 var child_0 = new Xcls_project_title_manager( _this );
178 this.el.layout_manager = child_0.el;
179 var child_1 = new Xcls_FixedLayout4( _this );
181 this.el.layout_manager = child_1.el;
182 var child_2 = new Xcls_project_title_name( _this );
184 this.el.add_child ( child_2.el );
185 var child_3 = new Xcls_project_title_path( _this );
187 this.el.add_child ( child_3.el );
191 this.el.add_constraint(
192 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
194 this.el.set_position(75,0);
197 // user defined functions
199 public class Xcls_project_title_manager : Object
201 public Clutter.FlowLayout el;
202 private Xcls_ClutterFiles _this;
208 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
211 _this.project_title_manager = this;
212 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
216 // set gobject values
217 this.el.homogeneous = false;
218 this.el.row_spacing = 5f;
219 this.el.column_spacing = 20f;
222 // user defined functions
225 public class Xcls_FixedLayout4 : Object
227 public Clutter.FixedLayout el;
228 private Xcls_ClutterFiles _this;
234 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
237 this.el = new Clutter.FixedLayout();
241 // set gobject values
244 // user defined functions
247 public class Xcls_project_title_name : Object
249 public Clutter.Text el;
250 private Xcls_ClutterFiles _this;
256 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
259 _this.project_title_name = this;
260 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
264 // set gobject values
267 this.el.x_expand = false;
270 // user defined functions
273 public class Xcls_project_title_path : Object
275 public Clutter.Text el;
276 private Xcls_ClutterFiles _this;
282 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
285 _this.project_title_path = this;
286 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
290 // set gobject values
295 // user defined functions
299 public class Xcls_scoller : Object
301 public Clutter.ScrollActor el;
302 private Xcls_ClutterFiles _this;
306 public Gee.ArrayList<Xcls_fileitem> fileitems;
307 public Gdk.Pixbuf missing_thumb_pixbuf;
310 public Xcls_scoller(Xcls_ClutterFiles _owner )
313 _this.scoller = this;
314 this.el = new Clutter.ScrollActor();
317 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
318 this.missing_thumb_pixbuf = null;
320 // set gobject values
321 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
322 this.el.reactive = true;
323 var child_0 = new Xcls_filelayout( _this );
325 this.el.add_child ( child_0.el );
328 this.el.scroll_event.connect( ( event) => {
329 //Sprint("scroll event");
330 var y = _this.filelayout.el.y;
331 var dir = event.direction;
333 case Clutter.ScrollDirection.UP:
336 case Clutter.ScrollDirection.DOWN:
342 // range of scroll -- can go up -- eg.. -ve value.
346 // to work out the max -ve number
347 // height of filelayout
348 // height of scrollactor..
350 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
351 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
358 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
359 // last_child_bottom - this.el.height,
361 // y = float.min(0, y); //??
362 // print("scroll event of %f - new y = %f ".printf(event.y, y));
363 _this.filelayout.el.y = y;
369 // user defined functions
371 public class Xcls_filelayout : Object
373 public Clutter.Actor el;
374 private Xcls_ClutterFiles _this;
380 public Xcls_filelayout(Xcls_ClutterFiles _owner )
383 _this.filelayout = this;
384 this.el = new Clutter.Actor();
388 // set gobject values
389 this.el.reactive = true;
390 var child_0 = new Xcls_filelayout_manager( _this );
392 this.el.layout_manager = child_0.el;
396 this.el.add_constraint(
397 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
401 // user defined functions
403 public class Xcls_filelayout_manager : Object
405 public Clutter.FlowLayout el;
406 private Xcls_ClutterFiles _this;
412 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
415 _this.filelayout_manager = this;
416 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
420 // set gobject values
421 this.el.homogeneous = true;
422 this.el.row_spacing = 20f;
423 this.el.column_spacing = 20f;
426 // user defined functions
429 public class Xcls_fileitem : Object
431 public Clutter.Actor el;
432 private Xcls_ClutterFiles _this;
436 public JsRender.JsRender file;
437 public Xcls_image image;
438 public Xcls_typetitle typetitle;
439 public Xcls_title title;
442 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
445 this.el = new Clutter.Actor();
449 // set gobject values
450 this.el.reactive = true;
451 var child_0 = new Xcls_BoxLayout11( _this );
453 this.el.layout_manager = child_0.el;
454 var child_1 = new Xcls_image( _this ,file);
456 this.el.add_child ( child_1.el );
457 this.image = child_1;
458 var child_2 = new Xcls_typetitle( _this ,file);
460 this.el.add_child ( child_2.el );
461 this.typetitle = child_2;
462 var child_3 = new Xcls_title( _this ,file);
464 this.el.add_child ( child_3.el );
465 this.title = child_3;
470 this.el.set_size(100,100);
473 this.el.button_press_event.connect( ( event) => {
474 _this.open(this.file);
477 this.el.enter_event.connect( ( event) => {
478 this.el.background_color = Clutter.Color.from_string("#333");
481 this.el.leave_event.connect( ( event) => {
482 this.el.background_color = Clutter.Color.from_string("#000");
487 // user defined functions
489 public class Xcls_BoxLayout11 : Object
491 public Clutter.BoxLayout el;
492 private Xcls_ClutterFiles _this;
498 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
501 this.el = new Clutter.BoxLayout();
505 // set gobject values
507 this.el.orientation = Clutter.Orientation.VERTICAL;
510 // user defined functions
513 public class Xcls_image : Object
515 public Clutter.Actor el;
516 private Xcls_ClutterFiles _this;
522 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
525 this.el = new Clutter.Actor();
529 // set gobject values
530 this.el.margin_right = 5f;
531 this.el.margin_left = 5f;
532 this.el.x_align = Clutter.ActorAlign.START;
533 this.el.x_expand = true;
534 this.el.y_align = Clutter.ActorAlign.START;
535 this.el.margin_top = 5f;
536 this.el.y_expand = true;
541 Gdk.Pixbuf pixbuf= null;
543 var fname = file.getIconFileName(false);
546 if (FileUtils.test(fname, FileTest.EXISTS)) {
547 pixbuf = new Gdk.Pixbuf.from_file(fname);
553 if (pixbuf == null) {
556 if (_this.missing_thumb_pixbuf == null) {
557 var icon_theme = Gtk.IconTheme.get_default ();
558 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
559 _this.missing_thumb_pixbuf.ref();
561 pixbuf = _this.missing_thumb_pixbuf;
568 var img = new Clutter.Image();
569 img.set_data(pixbuf.get_pixels(),
571 ? Cogl.PixelFormat.RGBA_8888
572 : Cogl.PixelFormat.RGB_888,
574 pixbuf.get_height (),
575 pixbuf.get_rowstride ()
577 this.el.set_content(img);
581 // should probably do smarter scaling...
584 this.el.set_size(90, 70);
588 // user defined functions
591 public class Xcls_typetitle : Object
593 public Clutter.Text el;
594 private Xcls_ClutterFiles _this;
600 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
603 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
607 // set gobject values
608 this.el.x_align = Clutter.ActorAlign.START;
609 this.el.x_expand = true;
610 this.el.y_align = Clutter.ActorAlign.START;
611 this.el.y_expand = true;
614 // user defined functions
617 public class Xcls_title : Object
619 public Clutter.Text el;
620 private Xcls_ClutterFiles _this;
626 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
629 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
633 // set gobject values
634 this.el.x_align = Clutter.ActorAlign.START;
635 this.el.x_expand = true;
636 this.el.y_align = Clutter.ActorAlign.START;
637 this.el.y_expand = true;
640 // user defined functions
644 public class Xcls_folderitem : Object
646 public Clutter.Actor el;
647 private Xcls_ClutterFiles _this;
651 public Xcls_foldertitle foldertitle;
654 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
657 this.el = new Clutter.Actor();
661 // set gobject values
662 this.el.reactive = true;
663 var child_0 = new Xcls_BoxLayout16( _this );
665 this.el.layout_manager = child_0.el;
666 var child_1 = new Xcls_foldertitle( _this ,folderpath);
668 this.el.add_child ( child_1.el );
669 this.foldertitle = child_1;
673 //this.el.set_size(100,100);
676 // user defined functions
678 public class Xcls_BoxLayout16 : Object
680 public Clutter.BoxLayout el;
681 private Xcls_ClutterFiles _this;
687 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
690 this.el = new Clutter.BoxLayout();
694 // set gobject values
696 this.el.orientation = Clutter.Orientation.VERTICAL;
699 // user defined functions
702 public class Xcls_foldertitle : Object
704 public Clutter.Text el;
705 private Xcls_ClutterFiles _this;
711 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
714 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
718 // set gobject values
719 this.el.x_align = Clutter.ActorAlign.START;
720 this.el.x_expand = true;
721 this.el.y_align = Clutter.ActorAlign.START;
722 this.el.y_expand = true;
725 // user defined functions
728 public class Xcls_folderfile : Object
730 public Clutter.Text el;
731 private Xcls_ClutterFiles _this;
735 public string filepath;
738 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
741 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
745 // set gobject values
746 this.el.x_align = Clutter.ActorAlign.START;
747 this.el.x_expand = true;
748 this.el.y_align = Clutter.ActorAlign.START;
749 this.el.y_expand = true;
754 this.filepath = filepath;
758 this.el.button_press_event.connect( ( event) => {
759 // _this.open(this.filepath);
762 this.el.enter_event.connect( ( event) => {
763 this.el.background_color = Clutter.Color.from_string("#333");
766 this.el.leave_event.connect( ( event) => {
767 this.el.background_color = Clutter.Color.from_string("#000");
772 // user defined functions