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 Project.Project project;
28 public Gee.ArrayList<Object> fileitems;
31 public Xcls_ClutterFiles()
34 this.el = new Clutter.Actor();
37 this.scroll_mode = Clutter.ScrollMode.VERTICALLY;
38 this.missing_thumb_pixbuf = null;
39 this.fileitems = new Gee.ArrayList<Object>();
42 this.el.reactive = true;
43 var child_0 = new Xcls_project_title( _this );
45 this.el.add_child ( child_0.el );
46 var child_1 = new Xcls_scroller( _this );
48 this.el.add_child ( child_1.el );
51 // user defined functions
52 public void clearFiles () {
54 this.filelayout.el.remove_all_children();
55 // we need to unref all the chidren that we loaded though...
58 public void loadProject (Project.Project pr) {
59 // list all the files, and create new Xcls_fileitem for each one.
64 // LEAK --- we should unref all the chilren...
65 this.filelayout.el.y = 0;
68 print("clutter files - load project: " + pr.name +"\n");
69 // should unref.. them hopefully.
71 this.project_title_name.el.text = pr.name;
72 this.project_title_path.el.text = pr.firstPath();
74 // file items contains a reference until we reload ...
75 this.fileitems = new Gee.ArrayList<Object>();
79 var fiter = pr.sortedFiles().list_iterator();
80 while (fiter.next()) {
81 var a = new Xcls_fileitem(this,fiter.get());
82 this.fileitems.add(a);
85 print("add to clutter file view: " + fiter.get().name + "\n");
86 this.filelayout.el.add_child(a.el);
91 if (!(pr is Project.Gtk)) {
92 print ("not gtk... skipping files");
95 var gpr = (Project.Gtk)pr;
96 var def = gpr.compilegroups.get("_default_");
97 var items = def.sources;
101 for(var i =0 ; i < items.size; i++) {
102 print ("cheking folder %s\n", items.get(i));
103 var files = gpr.filesForOpen(items.get(i));
104 if (files.size < 1) {
108 // add the directory... items.get(i);
109 var x = new Xcls_folderitem(this,items.get(i));
110 this.fileitems.add(x);
111 this.filelayout.el.add_child(x.el);
113 for(var j =0 ; j < files.size; j++) {
114 print ("adding file %s\n", files.get(j));
116 var y = new Xcls_folderfile(this, files.get(j));
117 this.fileitems.add(y);
118 x.el.add_child(y.el);
120 // add file to files.get(j);
125 //this.el.set_value(citer, 1, items.get(i) );
132 public void set_size (float w, float h)
135 // called by window resize... with is alreaddy -50 (for the buttons?)
140 if (this.el == null) {
141 print("object not ready yet?");
145 print("recv width %f, filelayoutw = %f", w, w-200);
147 w = GLib.Math.floorf ( w/120.0f) * 120.0f;
152 //_this.filelayout_manager.el.max_column_width = w - 200;
153 _this.filelayout.el.width = w ;
156 // this.el.get_stage().width-150,
158 h // this.el.get_stage().height
161 // 100 right for buttons ..
162 this.el.set_position(75,0);
165 this.scroller.el.set_size(
166 // this.el.get_stage().width-150,
168 h // this.el.get_stage().height
171 // 100 right for buttons ..
172 this.scroller.el.set_position(0,50);
174 _this.filelayout.el.y = 0.0f;
177 public class Xcls_project_title : Object
179 public Clutter.Actor el;
180 private Xcls_ClutterFiles _this;
186 public Xcls_project_title(Xcls_ClutterFiles _owner )
189 _this.project_title = this;
190 this.el = new Clutter.Actor();
194 // set gobject values
195 this.el.reactive = true;
196 var child_0 = new Xcls_project_title_manager( _this );
198 this.el.layout_manager = child_0.el;
199 var child_1 = new Xcls_FixedLayout4( _this );
201 this.el.layout_manager = child_1.el;
202 var child_2 = new Xcls_project_title_name( _this );
204 this.el.add_child ( child_2.el );
205 var child_3 = new Xcls_project_title_path( _this );
207 this.el.add_child ( child_3.el );
211 this.el.add_constraint(
212 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
214 this.el.set_position(0,0);
217 // user defined functions
219 public class Xcls_project_title_manager : Object
221 public Clutter.FlowLayout el;
222 private Xcls_ClutterFiles _this;
228 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
231 _this.project_title_manager = this;
232 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
236 // set gobject values
237 this.el.homogeneous = false;
238 this.el.row_spacing = 5f;
239 this.el.column_spacing = 20f;
242 // user defined functions
245 public class Xcls_FixedLayout4 : Object
247 public Clutter.FixedLayout el;
248 private Xcls_ClutterFiles _this;
254 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
257 this.el = new Clutter.FixedLayout();
261 // set gobject values
264 // user defined functions
267 public class Xcls_project_title_name : Object
269 public Clutter.Text el;
270 private Xcls_ClutterFiles _this;
276 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
279 _this.project_title_name = this;
280 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
284 // set gobject values
287 this.el.x_expand = false;
290 // user defined functions
293 public class Xcls_project_title_path : Object
295 public Clutter.Text el;
296 private Xcls_ClutterFiles _this;
302 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
305 _this.project_title_path = this;
306 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
310 // set gobject values
315 // user defined functions
319 public class Xcls_scroller : Object
321 public Clutter.ScrollActor el;
322 private Xcls_ClutterFiles _this;
326 public Gee.ArrayList<Xcls_fileitem> fileitems;
327 public Gdk.Pixbuf missing_thumb_pixbuf;
330 public Xcls_scroller(Xcls_ClutterFiles _owner )
333 _this.scroller = this;
334 this.el = new Clutter.ScrollActor();
337 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
338 this.missing_thumb_pixbuf = null;
340 // set gobject values
341 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
342 this.el.reactive = true;
343 var child_0 = new Xcls_filelayout( _this );
345 this.el.add_child ( child_0.el );
348 this.el.scroll_event.connect( ( event) => {
349 print("scroll event\n");
350 var y = _this.filelayout.el.y;
351 var dir = event.direction;
353 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
354 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
357 case Clutter.ScrollDirection.UP:
358 print("Scroll up by %f\n", event.y);
360 y = float.min(0, y); //
363 case Clutter.ScrollDirection.DOWN:
364 print("Scroll down by %f\n", event.y);
366 y = float.max(bottompos, y);
370 case Clutter.ScrollDirection.SMOOTH:
371 double delta_x, delta_y;
372 event.get_scroll_delta(out delta_x, out delta_y);
373 //print("Scroll SMOOTH? by %f\n", delta_y * event.y);
374 y += ((float)delta_y * event.y * -1.0f) /2 ;
375 y = float.max(bottompos, y);
376 y = float.min(0, y); //
380 print("scroll event = bad direction %s\n", dir.to_string());
383 // range of scroll -- can go up -- eg.. -ve value.
387 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
389 _this.filelayout.el.y = y;
395 // user defined functions
397 public class Xcls_filelayout : Object
399 public Clutter.Actor el;
400 private Xcls_ClutterFiles _this;
406 public Xcls_filelayout(Xcls_ClutterFiles _owner )
409 _this.filelayout = this;
410 this.el = new Clutter.Actor();
414 // set gobject values
415 this.el.reactive = true;
416 var child_0 = new Xcls_filelayout_manager( _this );
418 this.el.layout_manager = child_0.el;
422 this.el.add_constraint(
423 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
427 // user defined functions
429 public class Xcls_filelayout_manager : Object
431 public Clutter.FlowLayout el;
432 private Xcls_ClutterFiles _this;
438 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
441 _this.filelayout_manager = this;
442 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
446 // set gobject values
447 this.el.homogeneous = false;
448 this.el.max_column_width = 100.0f;
449 this.el.row_spacing = 20f;
450 this.el.column_spacing = 20f;
453 // user defined functions
456 public class Xcls_fileitem : Object
458 public Clutter.Actor el;
459 private Xcls_ClutterFiles _this;
463 public JsRender.JsRender file;
464 public Xcls_image image;
465 public Xcls_typetitle typetitle;
466 public Xcls_title title;
469 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
472 this.el = new Clutter.Actor();
476 // set gobject values
477 this.el.reactive = true;
478 var child_0 = new Xcls_BoxLayout11( _this );
480 this.el.layout_manager = child_0.el;
481 var child_1 = new Xcls_image( _this ,file);
483 this.el.add_child ( child_1.el );
484 this.image = child_1;
485 var child_2 = new Xcls_typetitle( _this ,file);
487 this.el.add_child ( child_2.el );
488 this.typetitle = child_2;
489 var child_3 = new Xcls_title( _this ,file);
491 this.el.add_child ( child_3.el );
492 this.title = child_3;
497 this.el.set_size(100,100);
500 this.el.button_press_event.connect( ( event) => {
501 _this.open(this.file);
504 this.el.enter_event.connect( ( event) => {
505 this.el.background_color = Clutter.Color.from_string("#333");
506 this.title.el.background_color = Clutter.Color.from_string("#fff");
507 this.typetitle.el.background_color = Clutter.Color.from_string("#fff");
508 this.title.el.color = Clutter.Color.from_string("#000");
509 this.typetitle.el.color = Clutter.Color.from_string("#000");
513 this.el.leave_event.connect( ( event) => {
514 this.el.background_color = Clutter.Color.from_string("#000");
515 this.title.el.background_color = Clutter.Color.from_string("#000");
516 this.typetitle.el.background_color = Clutter.Color.from_string("#000");
517 this.title.el.color = Clutter.Color.from_string("#fff");
518 this.typetitle.el.color = Clutter.Color.from_string("#fff");
525 // user defined functions
527 public class Xcls_BoxLayout11 : Object
529 public Clutter.BoxLayout el;
530 private Xcls_ClutterFiles _this;
536 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
539 this.el = new Clutter.BoxLayout();
543 // set gobject values
545 this.el.orientation = Clutter.Orientation.VERTICAL;
548 // user defined functions
551 public class Xcls_image : Object
553 public Clutter.Actor el;
554 private Xcls_ClutterFiles _this;
560 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
563 this.el = new Clutter.Actor();
567 // set gobject values
568 this.el.margin_right = 5f;
569 this.el.margin_left = 5f;
570 this.el.x_align = Clutter.ActorAlign.START;
571 this.el.x_expand = false;
572 this.el.y_align = Clutter.ActorAlign.START;
573 this.el.margin_top = 5f;
574 this.el.y_expand = false;
579 Gdk.Pixbuf pixbuf= null;
581 var fname = file.getIconFileName(false);
584 if (FileUtils.test(fname, FileTest.EXISTS)) {
585 pixbuf = new Gdk.Pixbuf.from_file(fname);
591 if (pixbuf == null) {
594 if (_this.missing_thumb_pixbuf == null) {
595 var icon_theme = Gtk.IconTheme.get_default ();
596 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
597 _this.missing_thumb_pixbuf.ref();
599 pixbuf = _this.missing_thumb_pixbuf;
606 var img = new Clutter.Image();
607 img.set_data(pixbuf.get_pixels(),
609 ? Cogl.PixelFormat.RGBA_8888
610 : Cogl.PixelFormat.RGB_888,
612 pixbuf.get_height (),
613 pixbuf.get_rowstride ()
615 this.el.set_content(img);
619 // should probably do smarter scaling...
622 this.el.set_size(90, 70);
626 // user defined functions
629 public class Xcls_typetitle : Object
631 public Clutter.Text el;
632 private Xcls_ClutterFiles _this;
638 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
641 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
645 // set gobject values
646 this.el.x_align = Clutter.ActorAlign.START;
647 this.el.x_expand = false;
648 this.el.y_align = Clutter.ActorAlign.START;
649 this.el.y_expand = false;
652 // user defined functions
655 public class Xcls_title : Object
657 public Clutter.Text el;
658 private Xcls_ClutterFiles _this;
664 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
667 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
671 // set gobject values
672 this.el.x_align = Clutter.ActorAlign.START;
673 this.el.x_expand = false;
674 this.el.y_align = Clutter.ActorAlign.START;
675 this.el.y_expand = false;
678 // user defined functions
682 public class Xcls_folderitem : Object
684 public Clutter.Actor el;
685 private Xcls_ClutterFiles _this;
689 public Xcls_foldertitle foldertitle;
692 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
695 this.el = new Clutter.Actor();
699 // set gobject values
700 this.el.reactive = true;
701 var child_0 = new Xcls_BoxLayout16( _this );
703 this.el.layout_manager = child_0.el;
704 var child_1 = new Xcls_foldertitle( _this ,folderpath);
706 this.el.add_child ( child_1.el );
707 this.foldertitle = child_1;
711 //this.el.set_size(100,100);
714 // user defined functions
716 public class Xcls_BoxLayout16 : Object
718 public Clutter.BoxLayout el;
719 private Xcls_ClutterFiles _this;
725 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
728 this.el = new Clutter.BoxLayout();
732 // set gobject values
734 this.el.orientation = Clutter.Orientation.VERTICAL;
737 // user defined functions
740 public class Xcls_foldertitle : Object
742 public Clutter.Text el;
743 private Xcls_ClutterFiles _this;
749 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
752 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
756 // set gobject values
757 this.el.x_align = Clutter.ActorAlign.START;
758 this.el.x_expand = true;
759 this.el.y_align = Clutter.ActorAlign.START;
760 this.el.y_expand = false;
763 // user defined functions
766 public class Xcls_folderfile : Object
768 public Clutter.Text el;
769 private Xcls_ClutterFiles _this;
773 public string filepath;
776 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
779 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
783 // set gobject values
784 this.el.x_align = Clutter.ActorAlign.START;
785 this.el.x_expand = true;
786 this.el.y_align = Clutter.ActorAlign.START;
787 this.el.reactive = true;
788 this.el.y_expand = true;
793 this.filepath = filepath;
797 this.el.button_press_event.connect( ( event) => {
799 var f = JsRender.JsRender.factory("PlainFile", _this.project, this.filepath);
803 this.el.enter_event.connect( ( event) => {
804 this.el.background_color = Clutter.Color.from_string("#fff");
805 this.el.color = Clutter.Color.from_string("#000");
808 this.el.leave_event.connect( ( event) => {
809 this.el.background_color = Clutter.Color.from_string("#000");
810 this.el.color = Clutter.Color.from_string("#fff");
815 // user defined functions