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)) {
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 - 75;
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.scoller.el.set_size(
151 // this.el.get_stage().width-150,
153 h // this.el.get_stage().height
156 // 100 right for buttons ..
157 this.scoller.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_scoller : 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_scoller(Xcls_ClutterFiles _owner )
315 _this.scoller = 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.row_spacing = 20f;
425 this.el.column_spacing = 20f;
428 // user defined functions
431 public class Xcls_fileitem : Object
433 public Clutter.Actor el;
434 private Xcls_ClutterFiles _this;
438 public JsRender.JsRender file;
439 public Xcls_image image;
440 public Xcls_typetitle typetitle;
441 public Xcls_title title;
444 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
447 this.el = new Clutter.Actor();
451 // set gobject values
452 this.el.reactive = true;
453 var child_0 = new Xcls_BoxLayout11( _this );
455 this.el.layout_manager = child_0.el;
456 var child_1 = new Xcls_image( _this ,file);
458 this.el.add_child ( child_1.el );
459 this.image = child_1;
460 var child_2 = new Xcls_typetitle( _this ,file);
462 this.el.add_child ( child_2.el );
463 this.typetitle = child_2;
464 var child_3 = new Xcls_title( _this ,file);
466 this.el.add_child ( child_3.el );
467 this.title = child_3;
472 this.el.set_size(100,100);
475 this.el.button_press_event.connect( ( event) => {
476 _this.open(this.file);
479 this.el.enter_event.connect( ( event) => {
480 this.el.background_color = Clutter.Color.from_string("#333");
483 this.el.leave_event.connect( ( event) => {
484 this.el.background_color = Clutter.Color.from_string("#000");
489 // user defined functions
491 public class Xcls_BoxLayout11 : Object
493 public Clutter.BoxLayout el;
494 private Xcls_ClutterFiles _this;
500 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
503 this.el = new Clutter.BoxLayout();
507 // set gobject values
509 this.el.orientation = Clutter.Orientation.VERTICAL;
512 // user defined functions
515 public class Xcls_image : Object
517 public Clutter.Actor el;
518 private Xcls_ClutterFiles _this;
524 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
527 this.el = new Clutter.Actor();
531 // set gobject values
532 this.el.margin_right = 5f;
533 this.el.margin_left = 5f;
534 this.el.x_align = Clutter.ActorAlign.START;
535 this.el.x_expand = true;
536 this.el.y_align = Clutter.ActorAlign.START;
537 this.el.margin_top = 5f;
538 this.el.y_expand = true;
543 Gdk.Pixbuf pixbuf= null;
545 var fname = file.getIconFileName(false);
548 if (FileUtils.test(fname, FileTest.EXISTS)) {
549 pixbuf = new Gdk.Pixbuf.from_file(fname);
555 if (pixbuf == null) {
558 if (_this.missing_thumb_pixbuf == null) {
559 var icon_theme = Gtk.IconTheme.get_default ();
560 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
561 _this.missing_thumb_pixbuf.ref();
563 pixbuf = _this.missing_thumb_pixbuf;
570 var img = new Clutter.Image();
571 img.set_data(pixbuf.get_pixels(),
573 ? Cogl.PixelFormat.RGBA_8888
574 : Cogl.PixelFormat.RGB_888,
576 pixbuf.get_height (),
577 pixbuf.get_rowstride ()
579 this.el.set_content(img);
583 // should probably do smarter scaling...
586 this.el.set_size(90, 70);
590 // user defined functions
593 public class Xcls_typetitle : Object
595 public Clutter.Text el;
596 private Xcls_ClutterFiles _this;
602 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
605 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
609 // set gobject values
610 this.el.x_align = Clutter.ActorAlign.START;
611 this.el.x_expand = true;
612 this.el.y_align = Clutter.ActorAlign.START;
613 this.el.y_expand = true;
616 // user defined functions
619 public class Xcls_title : Object
621 public Clutter.Text el;
622 private Xcls_ClutterFiles _this;
628 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
631 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
635 // set gobject values
636 this.el.x_align = Clutter.ActorAlign.START;
637 this.el.x_expand = true;
638 this.el.y_align = Clutter.ActorAlign.START;
639 this.el.y_expand = true;
642 // user defined functions
646 public class Xcls_folderitem : Object
648 public Clutter.Actor el;
649 private Xcls_ClutterFiles _this;
653 public Xcls_foldertitle foldertitle;
656 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
659 this.el = new Clutter.Actor();
663 // set gobject values
664 this.el.reactive = true;
665 var child_0 = new Xcls_BoxLayout16( _this );
667 this.el.layout_manager = child_0.el;
668 var child_1 = new Xcls_foldertitle( _this ,folderpath);
670 this.el.add_child ( child_1.el );
671 this.foldertitle = child_1;
675 //this.el.set_size(100,100);
678 // user defined functions
680 public class Xcls_BoxLayout16 : Object
682 public Clutter.BoxLayout el;
683 private Xcls_ClutterFiles _this;
689 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
692 this.el = new Clutter.BoxLayout();
696 // set gobject values
698 this.el.orientation = Clutter.Orientation.VERTICAL;
701 // user defined functions
704 public class Xcls_foldertitle : Object
706 public Clutter.Text el;
707 private Xcls_ClutterFiles _this;
713 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
716 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
720 // set gobject values
721 this.el.x_align = Clutter.ActorAlign.START;
722 this.el.x_expand = true;
723 this.el.y_align = Clutter.ActorAlign.START;
724 this.el.y_expand = true;
727 // user defined functions
730 public class Xcls_folderfile : Object
732 public Clutter.Text el;
733 private Xcls_ClutterFiles _this;
737 public string filepath;
740 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
743 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
747 // set gobject values
748 this.el.x_align = Clutter.ActorAlign.START;
749 this.el.x_expand = true;
750 this.el.y_align = Clutter.ActorAlign.START;
751 this.el.y_expand = true;
756 this.filepath = filepath;
760 this.el.button_press_event.connect( ( event) => {
761 // _this.open(this.filepath);
764 this.el.enter_event.connect( ( event) => {
765 this.el.background_color = Clutter.Color.from_string("#333");
768 this.el.leave_event.connect( ( event) => {
769 this.el.background_color = Clutter.Color.from_string("#000");
774 // user defined functions