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)) {
90 var gpr = (Project.Gtk)pr;
91 var def = gpr.compilegroups.get("_default_");
92 var items = def.sources;
96 for(var i =0 ; i < items.size; i++) {
98 var files = gpr.files(items.get(i));
103 // add the directory... items.get(i);
104 var x = new Xcls_folderitem(this,items.get(i));
105 this.fileitems.add(x);
106 this.filelayout.el.add_child(x.el);
108 for(var j =0 ; j < files.size; j++) {
109 var y = new Xcls_folderfile(this, files.get(j));
110 this.fileitems.add(y);
111 y.el.add_child(y.el);
113 // add file to files.get(j);
118 //this.el.set_value(citer, 1, items.get(i) );
125 public void set_size (float w, float h)
128 // called by window resize... with is alreaddy -50 (for the buttons?)
131 if (this.el == null) {
132 print("object not ready yet?");
135 _this.filelayout_manager.el.max_column_width = w - 75;
138 // this.el.get_stage().width-150,
140 h // this.el.get_stage().height
143 // 100 right for buttons ..
144 this.el.set_position(0,0);
147 this.scoller.el.set_size(
148 // this.el.get_stage().width-150,
150 h // this.el.get_stage().height
153 // 100 right for buttons ..
154 this.scoller.el.set_position(75,50);
156 public class Xcls_project_title : Object
158 public Clutter.Actor el;
159 private Xcls_ClutterFiles _this;
165 public Xcls_project_title(Xcls_ClutterFiles _owner )
168 _this.project_title = this;
169 this.el = new Clutter.Actor();
173 // set gobject values
174 this.el.reactive = true;
175 var child_0 = new Xcls_project_title_manager( _this );
177 this.el.layout_manager = child_0.el;
178 var child_1 = new Xcls_FixedLayout4( _this );
180 this.el.layout_manager = child_1.el;
181 var child_2 = new Xcls_project_title_name( _this );
183 this.el.add_child ( child_2.el );
184 var child_3 = new Xcls_project_title_path( _this );
186 this.el.add_child ( child_3.el );
190 this.el.add_constraint(
191 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
193 this.el.set_position(75,0);
196 // user defined functions
198 public class Xcls_project_title_manager : Object
200 public Clutter.FlowLayout el;
201 private Xcls_ClutterFiles _this;
207 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
210 _this.project_title_manager = this;
211 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
215 // set gobject values
216 this.el.homogeneous = false;
217 this.el.row_spacing = 5f;
218 this.el.column_spacing = 20f;
221 // user defined functions
224 public class Xcls_FixedLayout4 : Object
226 public Clutter.FixedLayout el;
227 private Xcls_ClutterFiles _this;
233 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
236 this.el = new Clutter.FixedLayout();
240 // set gobject values
243 // user defined functions
246 public class Xcls_project_title_name : Object
248 public Clutter.Text el;
249 private Xcls_ClutterFiles _this;
255 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
258 _this.project_title_name = this;
259 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
263 // set gobject values
266 this.el.x_expand = false;
269 // user defined functions
272 public class Xcls_project_title_path : Object
274 public Clutter.Text el;
275 private Xcls_ClutterFiles _this;
281 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
284 _this.project_title_path = this;
285 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
289 // set gobject values
294 // user defined functions
298 public class Xcls_scoller : Object
300 public Clutter.ScrollActor el;
301 private Xcls_ClutterFiles _this;
305 public Gee.ArrayList<Xcls_fileitem> fileitems;
306 public Gdk.Pixbuf missing_thumb_pixbuf;
309 public Xcls_scoller(Xcls_ClutterFiles _owner )
312 _this.scoller = this;
313 this.el = new Clutter.ScrollActor();
316 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
317 this.missing_thumb_pixbuf = null;
319 // set gobject values
320 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
321 this.el.reactive = true;
322 var child_0 = new Xcls_filelayout( _this );
324 this.el.add_child ( child_0.el );
327 this.el.scroll_event.connect( ( event) => {
328 //Sprint("scroll event");
329 var y = _this.filelayout.el.y;
330 var dir = event.direction;
332 case Clutter.ScrollDirection.UP:
335 case Clutter.ScrollDirection.DOWN:
341 // range of scroll -- can go up -- eg.. -ve value.
345 // to work out the max -ve number
346 // height of filelayout
347 // height of scrollactor..
349 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
350 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
357 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
358 // last_child_bottom - this.el.height,
360 // y = float.min(0, y); //??
361 // print("scroll event of %f - new y = %f ".printf(event.y, y));
362 _this.filelayout.el.y = y;
368 // user defined functions
370 public class Xcls_filelayout : Object
372 public Clutter.Actor el;
373 private Xcls_ClutterFiles _this;
379 public Xcls_filelayout(Xcls_ClutterFiles _owner )
382 _this.filelayout = this;
383 this.el = new Clutter.Actor();
387 // set gobject values
388 this.el.reactive = true;
389 var child_0 = new Xcls_filelayout_manager( _this );
391 this.el.layout_manager = child_0.el;
395 this.el.add_constraint(
396 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
400 // user defined functions
402 public class Xcls_filelayout_manager : Object
404 public Clutter.FlowLayout el;
405 private Xcls_ClutterFiles _this;
411 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
414 _this.filelayout_manager = this;
415 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
419 // set gobject values
420 this.el.homogeneous = true;
421 this.el.row_spacing = 20f;
422 this.el.column_spacing = 20f;
425 // user defined functions
428 public class Xcls_fileitem : Object
430 public Clutter.Actor el;
431 private Xcls_ClutterFiles _this;
435 public JsRender.JsRender file;
436 public Xcls_image image;
437 public Xcls_typetitle typetitle;
438 public Xcls_title title;
441 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
444 this.el = new Clutter.Actor();
448 // set gobject values
449 this.el.reactive = true;
450 var child_0 = new Xcls_BoxLayout11( _this );
452 this.el.layout_manager = child_0.el;
453 var child_1 = new Xcls_image( _this ,file);
455 this.el.add_child ( child_1.el );
456 this.image = child_1;
457 var child_2 = new Xcls_typetitle( _this ,file);
459 this.el.add_child ( child_2.el );
460 this.typetitle = child_2;
461 var child_3 = new Xcls_title( _this ,file);
463 this.el.add_child ( child_3.el );
464 this.title = child_3;
469 this.el.set_size(100,100);
472 this.el.button_press_event.connect( ( event) => {
473 _this.open(this.file);
476 this.el.enter_event.connect( ( event) => {
477 this.el.background_color = Clutter.Color.from_string("#333");
480 this.el.leave_event.connect( ( event) => {
481 this.el.background_color = Clutter.Color.from_string("#000");
486 // user defined functions
488 public class Xcls_BoxLayout11 : Object
490 public Clutter.BoxLayout el;
491 private Xcls_ClutterFiles _this;
497 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
500 this.el = new Clutter.BoxLayout();
504 // set gobject values
506 this.el.orientation = Clutter.Orientation.VERTICAL;
509 // user defined functions
512 public class Xcls_image : Object
514 public Clutter.Actor el;
515 private Xcls_ClutterFiles _this;
521 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
524 this.el = new Clutter.Actor();
528 // set gobject values
529 this.el.margin_right = 5f;
530 this.el.margin_left = 5f;
531 this.el.x_align = Clutter.ActorAlign.START;
532 this.el.x_expand = true;
533 this.el.y_align = Clutter.ActorAlign.START;
534 this.el.margin_top = 5f;
535 this.el.y_expand = true;
540 Gdk.Pixbuf pixbuf= null;
542 var fname = file.getIconFileName(false);
545 if (FileUtils.test(fname, FileTest.EXISTS)) {
546 pixbuf = new Gdk.Pixbuf.from_file(fname);
552 if (pixbuf == null) {
555 if (_this.missing_thumb_pixbuf == null) {
556 var icon_theme = Gtk.IconTheme.get_default ();
557 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
558 _this.missing_thumb_pixbuf.ref();
560 pixbuf = _this.missing_thumb_pixbuf;
567 var img = new Clutter.Image();
568 img.set_data(pixbuf.get_pixels(),
570 ? Cogl.PixelFormat.RGBA_8888
571 : Cogl.PixelFormat.RGB_888,
573 pixbuf.get_height (),
574 pixbuf.get_rowstride ()
576 this.el.set_content(img);
580 // should probably do smarter scaling...
583 this.el.set_size(90, 70);
587 // user defined functions
590 public class Xcls_typetitle : Object
592 public Clutter.Text el;
593 private Xcls_ClutterFiles _this;
599 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
602 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
606 // set gobject values
607 this.el.x_align = Clutter.ActorAlign.START;
608 this.el.x_expand = true;
609 this.el.y_align = Clutter.ActorAlign.START;
610 this.el.y_expand = true;
613 // user defined functions
616 public class Xcls_title : Object
618 public Clutter.Text el;
619 private Xcls_ClutterFiles _this;
625 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
628 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
632 // set gobject values
633 this.el.x_align = Clutter.ActorAlign.START;
634 this.el.x_expand = true;
635 this.el.y_align = Clutter.ActorAlign.START;
636 this.el.y_expand = true;
639 // user defined functions
643 public class Xcls_folderitem : Object
645 public Clutter.Actor el;
646 private Xcls_ClutterFiles _this;
650 public Xcls_foldertitle foldertitle;
653 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
656 this.el = new Clutter.Actor();
660 // set gobject values
661 this.el.reactive = true;
662 var child_0 = new Xcls_BoxLayout16( _this );
664 this.el.layout_manager = child_0.el;
665 var child_1 = new Xcls_foldertitle( _this ,folderpath);
667 this.el.add_child ( child_1.el );
668 this.foldertitle = child_1;
672 //this.el.set_size(100,100);
675 // user defined functions
677 public class Xcls_BoxLayout16 : Object
679 public Clutter.BoxLayout el;
680 private Xcls_ClutterFiles _this;
686 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
689 this.el = new Clutter.BoxLayout();
693 // set gobject values
695 this.el.orientation = Clutter.Orientation.VERTICAL;
698 // user defined functions
701 public class Xcls_foldertitle : Object
703 public Clutter.Text el;
704 private Xcls_ClutterFiles _this;
710 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
713 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
717 // set gobject values
718 this.el.x_align = Clutter.ActorAlign.START;
719 this.el.x_expand = true;
720 this.el.y_align = Clutter.ActorAlign.START;
721 this.el.y_expand = true;
724 // user defined functions
727 public class Xcls_folderfile : Object
729 public Clutter.Text el;
730 private Xcls_ClutterFiles _this;
734 public string filepath;
737 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
740 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
744 // set gobject values
745 this.el.x_align = Clutter.ActorAlign.START;
746 this.el.x_expand = true;
747 this.el.y_align = Clutter.ActorAlign.START;
748 this.el.y_expand = true;
753 this.filepath = filepath;
757 this.el.button_press_event.connect( ( event) => {
758 // _this.open(this.filepath);
761 this.el.enter_event.connect( ( event) => {
762 this.el.background_color = Clutter.Color.from_string("#333");
765 this.el.leave_event.connect( ( event) => {
766 this.el.background_color = Clutter.Color.from_string("#000");
771 // user defined functions