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 Gee.ArrayList<Xcls_fileitem> fileitems;
25 public Clutter.ScrollMode scroll_mode;
26 public Gdk.Pixbuf missing_thumb_pixbuf;
27 public signal void open (JsRender.JsRender file);
30 public Xcls_ClutterFiles()
33 this.el = new Clutter.Actor();
36 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
37 this.scroll_mode = Clutter.ScrollMode.VERTICALLY;
38 this.missing_thumb_pixbuf = null;
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 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
74 var fiter = pr.sortedFiles().list_iterator();
75 while (fiter.next()) {
76 var a = new Xcls_fileitem(this,fiter.get());
77 this.fileitems.add(a);
80 print("add to clutter file view: " + fiter.get().name + "\n");
81 this.filelayout.el.add_child(a.el);
88 public void set_size (float w, float h)
91 // called by window resize... with is alreaddy -50 (for the buttons?)
94 if (this.el == null) {
95 print("object not ready yet?");
98 _this.filelayout_manager.el.max_column_width = w - 75;
101 // this.el.get_stage().width-150,
103 h // this.el.get_stage().height
106 // 100 right for buttons ..
107 this.el.set_position(0,0);
110 this.scoller.el.set_size(
111 // this.el.get_stage().width-150,
113 h // this.el.get_stage().height
116 // 100 right for buttons ..
117 this.scoller.el.set_position(75,50);
119 public class Xcls_project_title : Object
121 public Clutter.Actor el;
122 private Xcls_ClutterFiles _this;
128 public Xcls_project_title(Xcls_ClutterFiles _owner )
131 _this.project_title = this;
132 this.el = new Clutter.Actor();
136 // set gobject values
137 this.el.reactive = true;
138 var child_0 = new Xcls_project_title_manager( _this );
140 this.el.layout_manager = child_0.el;
141 var child_1 = new Xcls_FixedLayout4( _this );
143 this.el.layout_manager = child_1.el;
144 var child_2 = new Xcls_project_title_name( _this );
146 this.el.add_child ( child_2.el );
147 var child_3 = new Xcls_project_title_path( _this );
149 this.el.add_child ( child_3.el );
153 this.el.add_constraint(
154 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
156 this.el.set_position(75,0);
159 // user defined functions
161 public class Xcls_project_title_manager : Object
163 public Clutter.FlowLayout el;
164 private Xcls_ClutterFiles _this;
170 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
173 _this.project_title_manager = this;
174 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
178 // set gobject values
179 this.el.homogeneous = false;
180 this.el.row_spacing = 5f;
181 this.el.column_spacing = 20f;
184 // user defined functions
187 public class Xcls_FixedLayout4 : Object
189 public Clutter.FixedLayout el;
190 private Xcls_ClutterFiles _this;
196 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
199 this.el = new Clutter.FixedLayout();
203 // set gobject values
206 // user defined functions
209 public class Xcls_project_title_name : Object
211 public Clutter.Text el;
212 private Xcls_ClutterFiles _this;
218 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
221 _this.project_title_name = this;
222 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
226 // set gobject values
229 this.el.x_expand = false;
232 // user defined functions
235 public class Xcls_project_title_path : Object
237 public Clutter.Text el;
238 private Xcls_ClutterFiles _this;
244 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
247 _this.project_title_path = this;
248 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
252 // set gobject values
257 // user defined functions
261 public class Xcls_scoller : Object
263 public Clutter.ScrollActor el;
264 private Xcls_ClutterFiles _this;
268 public Gee.ArrayList<Xcls_fileitem> fileitems;
269 public Gdk.Pixbuf missing_thumb_pixbuf;
272 public Xcls_scoller(Xcls_ClutterFiles _owner )
275 _this.scoller = this;
276 this.el = new Clutter.ScrollActor();
279 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
280 this.missing_thumb_pixbuf = null;
282 // set gobject values
283 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
284 this.el.reactive = true;
285 var child_0 = new Xcls_filelayout( _this );
287 this.el.add_child ( child_0.el );
290 this.el.scroll_event.connect( ( event) => {
291 //Sprint("scroll event");
292 var y = _this.filelayout.el.y;
293 var dir = event.direction;
295 case Clutter.ScrollDirection.UP:
298 case Clutter.ScrollDirection.DOWN:
304 // range of scroll -- can go up -- eg.. -ve value.
308 // to work out the max -ve number
309 // height of filelayout
310 // height of scrollactor..
312 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
313 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
320 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
321 // last_child_bottom - this.el.height,
323 // y = float.min(0, y); //??
324 // print("scroll event of %f - new y = %f ".printf(event.y, y));
325 _this.filelayout.el.y = y;
331 // user defined functions
333 public class Xcls_filelayout : Object
335 public Clutter.Actor el;
336 private Xcls_ClutterFiles _this;
342 public Xcls_filelayout(Xcls_ClutterFiles _owner )
345 _this.filelayout = this;
346 this.el = new Clutter.Actor();
350 // set gobject values
351 this.el.reactive = true;
352 var child_0 = new Xcls_filelayout_manager( _this );
354 this.el.layout_manager = child_0.el;
358 this.el.add_constraint(
359 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
363 // user defined functions
365 public class Xcls_filelayout_manager : Object
367 public Clutter.FlowLayout el;
368 private Xcls_ClutterFiles _this;
374 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
377 _this.filelayout_manager = this;
378 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
382 // set gobject values
383 this.el.homogeneous = true;
384 this.el.row_spacing = 20f;
385 this.el.column_spacing = 20f;
388 // user defined functions
391 public class Xcls_fileitem : Object
393 public Clutter.Actor el;
394 private Xcls_ClutterFiles _this;
398 public JsRender.JsRender file;
399 public Xcls_image image;
400 public Xcls_typetitle typetitle;
401 public Xcls_title title;
404 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
407 this.el = new Clutter.Actor();
411 // set gobject values
412 this.el.reactive = true;
413 var child_0 = new Xcls_BoxLayout11( _this );
415 this.el.layout_manager = child_0.el;
416 var child_1 = new Xcls_image( _this ,file);
418 this.el.add_child ( child_1.el );
419 this.image = child_1;
420 var child_2 = new Xcls_typetitle( _this ,file);
422 this.el.add_child ( child_2.el );
423 this.typetitle = child_2;
424 var child_3 = new Xcls_title( _this ,file);
426 this.el.add_child ( child_3.el );
427 this.title = child_3;
432 this.el.set_size(100,100);
435 this.el.button_press_event.connect( ( event) => {
436 _this.open(this.file);
439 this.el.enter_event.connect( ( event) => {
440 this.el.background_color = Clutter.Color.from_string("#333");
443 this.el.leave_event.connect( ( event) => {
444 this.el.background_color = Clutter.Color.from_string("#000");
449 // user defined functions
451 public class Xcls_BoxLayout11 : Object
453 public Clutter.BoxLayout el;
454 private Xcls_ClutterFiles _this;
460 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
463 this.el = new Clutter.BoxLayout();
467 // set gobject values
469 this.el.orientation = Clutter.Orientation.VERTICAL;
472 // user defined functions
475 public class Xcls_image : Object
477 public Clutter.Actor el;
478 private Xcls_ClutterFiles _this;
484 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
487 this.el = new Clutter.Actor();
491 // set gobject values
492 this.el.margin_right = 5f;
493 this.el.margin_left = 5f;
494 this.el.x_align = Clutter.ActorAlign.START;
495 this.el.x_expand = true;
496 this.el.y_align = Clutter.ActorAlign.START;
497 this.el.margin_top = 5f;
498 this.el.y_expand = true;
503 Gdk.Pixbuf pixbuf= null;
505 var fname = file.getIconFileName(false);
508 if (FileUtils.test(fname, FileTest.EXISTS)) {
509 pixbuf = new Gdk.Pixbuf.from_file(fname);
515 if (pixbuf == null) {
518 if (_this.missing_thumb_pixbuf == null) {
519 var icon_theme = Gtk.IconTheme.get_default ();
520 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
521 _this.missing_thumb_pixbuf.ref();
523 pixbuf = _this.missing_thumb_pixbuf;
530 var img = new Clutter.Image();
531 img.set_data(pixbuf.get_pixels(),
533 ? Cogl.PixelFormat.RGBA_8888
534 : Cogl.PixelFormat.RGB_888,
536 pixbuf.get_height (),
537 pixbuf.get_rowstride ()
539 this.el.set_content(img);
543 // should probably do smarter scaling...
546 this.el.set_size(90, 70);
550 // user defined functions
553 public class Xcls_typetitle : Object
555 public Clutter.Text el;
556 private Xcls_ClutterFiles _this;
562 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
565 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
569 // set gobject values
570 this.el.x_align = Clutter.ActorAlign.START;
571 this.el.x_expand = true;
572 this.el.y_align = Clutter.ActorAlign.START;
573 this.el.y_expand = true;
576 // user defined functions
579 public class Xcls_title : Object
581 public Clutter.Text el;
582 private Xcls_ClutterFiles _this;
588 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
591 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
595 // set gobject values
596 this.el.x_align = Clutter.ActorAlign.START;
597 this.el.x_expand = true;
598 this.el.y_align = Clutter.ActorAlign.START;
599 this.el.y_expand = true;
602 // user defined functions
606 public class Xcls_folderitem : Object
608 public Clutter.Actor el;
609 private Xcls_ClutterFiles _this;
613 public Xcls_foldertitle foldertitle;
616 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
619 this.el = new Clutter.Actor();
623 // set gobject values
624 this.el.reactive = true;
625 var child_0 = new Xcls_BoxLayout16( _this );
627 this.el.layout_manager = child_0.el;
628 var child_1 = new Xcls_foldertitle( _this ,folderpath);
630 this.el.add_child ( child_1.el );
631 this.foldertitle = child_1;
635 //this.el.set_size(100,100);
638 // user defined functions
640 public class Xcls_BoxLayout16 : Object
642 public Clutter.BoxLayout el;
643 private Xcls_ClutterFiles _this;
649 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
652 this.el = new Clutter.BoxLayout();
656 // set gobject values
658 this.el.orientation = Clutter.Orientation.VERTICAL;
661 // user defined functions
664 public class Xcls_foldertitle : Object
666 public Clutter.Text el;
667 private Xcls_ClutterFiles _this;
673 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
676 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
680 // set gobject values
681 this.el.x_align = Clutter.ActorAlign.START;
682 this.el.x_expand = true;
683 this.el.y_align = Clutter.ActorAlign.START;
684 this.el.y_expand = true;
687 // user defined functions
690 public class Xcls_folderfile : Object
692 public Clutter.Text el;
693 private Xcls_ClutterFiles _this;
699 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
702 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
706 // set gobject values
707 this.el.x_align = Clutter.ActorAlign.START;
708 this.el.x_expand = true;
709 this.el.y_align = Clutter.ActorAlign.START;
710 this.el.y_expand = true;
713 this.el.button_press_event.connect( ( event) => {
714 // _this.open(this.filepath);
717 this.el.enter_event.connect( ( event) => {
718 this.el.background_color = Clutter.Color.from_string("#333");
721 this.el.leave_event.connect( ( event) => {
722 this.el.background_color = Clutter.Color.from_string("#000");
727 // user defined functions