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 _this.filelayout.el.y = 0.0f;
168 public class Xcls_project_title : Object
170 public Clutter.Actor el;
171 private Xcls_ClutterFiles _this;
177 public Xcls_project_title(Xcls_ClutterFiles _owner )
180 _this.project_title = this;
181 this.el = new Clutter.Actor();
185 // set gobject values
186 this.el.reactive = true;
187 var child_0 = new Xcls_project_title_manager( _this );
189 this.el.layout_manager = child_0.el;
190 var child_1 = new Xcls_FixedLayout4( _this );
192 this.el.layout_manager = child_1.el;
193 var child_2 = new Xcls_project_title_name( _this );
195 this.el.add_child ( child_2.el );
196 var child_3 = new Xcls_project_title_path( _this );
198 this.el.add_child ( child_3.el );
202 this.el.add_constraint(
203 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
205 this.el.set_position(75,0);
208 // user defined functions
210 public class Xcls_project_title_manager : Object
212 public Clutter.FlowLayout el;
213 private Xcls_ClutterFiles _this;
219 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
222 _this.project_title_manager = this;
223 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
227 // set gobject values
228 this.el.homogeneous = false;
229 this.el.row_spacing = 5f;
230 this.el.column_spacing = 20f;
233 // user defined functions
236 public class Xcls_FixedLayout4 : Object
238 public Clutter.FixedLayout el;
239 private Xcls_ClutterFiles _this;
245 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
248 this.el = new Clutter.FixedLayout();
252 // set gobject values
255 // user defined functions
258 public class Xcls_project_title_name : Object
260 public Clutter.Text el;
261 private Xcls_ClutterFiles _this;
267 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
270 _this.project_title_name = this;
271 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
275 // set gobject values
278 this.el.x_expand = false;
281 // user defined functions
284 public class Xcls_project_title_path : Object
286 public Clutter.Text el;
287 private Xcls_ClutterFiles _this;
293 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
296 _this.project_title_path = this;
297 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
301 // set gobject values
306 // user defined functions
310 public class Xcls_scroller : Object
312 public Clutter.ScrollActor el;
313 private Xcls_ClutterFiles _this;
317 public Gee.ArrayList<Xcls_fileitem> fileitems;
318 public Gdk.Pixbuf missing_thumb_pixbuf;
321 public Xcls_scroller(Xcls_ClutterFiles _owner )
324 _this.scroller = this;
325 this.el = new Clutter.ScrollActor();
328 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
329 this.missing_thumb_pixbuf = null;
331 // set gobject values
332 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
333 this.el.reactive = true;
334 var child_0 = new Xcls_filelayout( _this );
336 this.el.add_child ( child_0.el );
339 this.el.scroll_event.connect( ( event) => {
340 //Sprint("scroll event");
341 var y = _this.filelayout.el.y;
342 var dir = event.direction;
344 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
345 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
348 case Clutter.ScrollDirection.UP:
349 print("Scroll up by %f\n", event.y);
351 y = float.min(0, y); //
354 case Clutter.ScrollDirection.DOWN:
355 print("Scroll down by %f\n", event.y);
357 y = float.max(bottompos, y);
364 // range of scroll -- can go up -- eg.. -ve value.
368 // to work out the max -ve number
369 // height of filelayout
370 // height of scrollactor..
373 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
374 var nv = _this.filelayout.el.y ;
375 if (nv != -1 * ( last_child_bottom - this.el.height)) {
377 _this.filelayout.el.y = -1 * ( last_child_bottom - this.el.height);
387 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
388 // last_child_bottom - this.el.height,
390 // y = float.min(0, y); //??
391 // print("scroll event of %f - new y = %f ".printf(event.y, y));
392 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
394 _this.filelayout.el.y = y;
400 // user defined functions
402 public class Xcls_filelayout : Object
404 public Clutter.Actor el;
405 private Xcls_ClutterFiles _this;
411 public Xcls_filelayout(Xcls_ClutterFiles _owner )
414 _this.filelayout = this;
415 this.el = new Clutter.Actor();
419 // set gobject values
420 this.el.reactive = true;
421 var child_0 = new Xcls_filelayout_manager( _this );
423 this.el.layout_manager = child_0.el;
427 this.el.add_constraint(
428 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
432 // user defined functions
434 public class Xcls_filelayout_manager : Object
436 public Clutter.FlowLayout el;
437 private Xcls_ClutterFiles _this;
443 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
446 _this.filelayout_manager = this;
447 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
451 // set gobject values
452 this.el.homogeneous = false;
453 this.el.max_column_width = 100.0f;
454 this.el.row_spacing = 20f;
455 this.el.column_spacing = 20f;
458 // user defined functions
461 public class Xcls_fileitem : Object
463 public Clutter.Actor el;
464 private Xcls_ClutterFiles _this;
468 public JsRender.JsRender file;
469 public Xcls_image image;
470 public Xcls_typetitle typetitle;
471 public Xcls_title title;
474 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
477 this.el = new Clutter.Actor();
481 // set gobject values
482 this.el.reactive = true;
483 var child_0 = new Xcls_BoxLayout11( _this );
485 this.el.layout_manager = child_0.el;
486 var child_1 = new Xcls_image( _this ,file);
488 this.el.add_child ( child_1.el );
489 this.image = child_1;
490 var child_2 = new Xcls_typetitle( _this ,file);
492 this.el.add_child ( child_2.el );
493 this.typetitle = child_2;
494 var child_3 = new Xcls_title( _this ,file);
496 this.el.add_child ( child_3.el );
497 this.title = child_3;
502 this.el.set_size(100,100);
505 this.el.button_press_event.connect( ( event) => {
506 _this.open(this.file);
509 this.el.enter_event.connect( ( event) => {
510 this.el.background_color = Clutter.Color.from_string("#333");
513 this.el.leave_event.connect( ( event) => {
514 this.el.background_color = Clutter.Color.from_string("#000");
519 // user defined functions
521 public class Xcls_BoxLayout11 : Object
523 public Clutter.BoxLayout el;
524 private Xcls_ClutterFiles _this;
530 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
533 this.el = new Clutter.BoxLayout();
537 // set gobject values
539 this.el.orientation = Clutter.Orientation.VERTICAL;
542 // user defined functions
545 public class Xcls_image : Object
547 public Clutter.Actor el;
548 private Xcls_ClutterFiles _this;
554 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
557 this.el = new Clutter.Actor();
561 // set gobject values
562 this.el.margin_right = 5f;
563 this.el.margin_left = 5f;
564 this.el.x_align = Clutter.ActorAlign.START;
565 this.el.x_expand = false;
566 this.el.y_align = Clutter.ActorAlign.START;
567 this.el.margin_top = 5f;
568 this.el.y_expand = false;
573 Gdk.Pixbuf pixbuf= null;
575 var fname = file.getIconFileName(false);
578 if (FileUtils.test(fname, FileTest.EXISTS)) {
579 pixbuf = new Gdk.Pixbuf.from_file(fname);
585 if (pixbuf == null) {
588 if (_this.missing_thumb_pixbuf == null) {
589 var icon_theme = Gtk.IconTheme.get_default ();
590 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
591 _this.missing_thumb_pixbuf.ref();
593 pixbuf = _this.missing_thumb_pixbuf;
600 var img = new Clutter.Image();
601 img.set_data(pixbuf.get_pixels(),
603 ? Cogl.PixelFormat.RGBA_8888
604 : Cogl.PixelFormat.RGB_888,
606 pixbuf.get_height (),
607 pixbuf.get_rowstride ()
609 this.el.set_content(img);
613 // should probably do smarter scaling...
616 this.el.set_size(90, 70);
620 // user defined functions
623 public class Xcls_typetitle : Object
625 public Clutter.Text el;
626 private Xcls_ClutterFiles _this;
632 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
635 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
639 // set gobject values
640 this.el.x_align = Clutter.ActorAlign.START;
641 this.el.x_expand = false;
642 this.el.y_align = Clutter.ActorAlign.START;
643 this.el.y_expand = false;
646 // user defined functions
649 public class Xcls_title : Object
651 public Clutter.Text el;
652 private Xcls_ClutterFiles _this;
658 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
661 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
665 // set gobject values
666 this.el.x_align = Clutter.ActorAlign.START;
667 this.el.x_expand = false;
668 this.el.y_align = Clutter.ActorAlign.START;
669 this.el.y_expand = false;
672 // user defined functions
676 public class Xcls_folderitem : Object
678 public Clutter.Actor el;
679 private Xcls_ClutterFiles _this;
683 public Xcls_foldertitle foldertitle;
686 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
689 this.el = new Clutter.Actor();
693 // set gobject values
694 this.el.reactive = true;
695 var child_0 = new Xcls_BoxLayout16( _this );
697 this.el.layout_manager = child_0.el;
698 var child_1 = new Xcls_foldertitle( _this ,folderpath);
700 this.el.add_child ( child_1.el );
701 this.foldertitle = child_1;
705 //this.el.set_size(100,100);
708 // user defined functions
710 public class Xcls_BoxLayout16 : Object
712 public Clutter.BoxLayout el;
713 private Xcls_ClutterFiles _this;
719 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
722 this.el = new Clutter.BoxLayout();
726 // set gobject values
728 this.el.orientation = Clutter.Orientation.VERTICAL;
731 // user defined functions
734 public class Xcls_foldertitle : Object
736 public Clutter.Text el;
737 private Xcls_ClutterFiles _this;
743 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
746 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
750 // set gobject values
751 this.el.x_align = Clutter.ActorAlign.START;
752 this.el.x_expand = true;
753 this.el.y_align = Clutter.ActorAlign.START;
754 this.el.y_expand = false;
757 // user defined functions
760 public class Xcls_folderfile : Object
762 public Clutter.Text el;
763 private Xcls_ClutterFiles _this;
767 public string filepath;
770 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
773 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
777 // set gobject values
778 this.el.x_align = Clutter.ActorAlign.START;
779 this.el.x_expand = true;
780 this.el.y_align = Clutter.ActorAlign.START;
781 this.el.reactive = true;
782 this.el.y_expand = false;
787 this.filepath = filepath;
791 this.el.button_press_event.connect( ( event) => {
792 // _this.open(this.filepath);
795 this.el.enter_event.connect( ( event) => {
796 this.el.background_color = Clutter.Color.from_string("#333");
799 this.el.leave_event.connect( ( event) => {
800 this.el.background_color = Clutter.Color.from_string("#000");
805 // user defined functions