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<Xcls_fileitem>();
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<Object>();
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);
86 if (!(pr is Project.Gtk)) {
89 var gpr = (Project.Gtk)pr;
90 var def = gpr.compilegroups.get("_default_");
91 var items = def.sources;
95 for(var i =0 ; i < items.size; i++) {
97 var files = gpr.files(items.get(i));
102 // add the directory... items.get(i);
103 var x = new Xcls_folderitem(this,items.get(i));
107 for(var j =0 ; j < files.size; j++) {
110 // add file to files.get(j);
115 //this.el.set_value(citer, 1, items.get(i) );
117 this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
123 public void set_size (float w, float h)
126 // called by window resize... with is alreaddy -50 (for the buttons?)
129 if (this.el == null) {
130 print("object not ready yet?");
133 _this.filelayout_manager.el.max_column_width = w - 75;
136 // this.el.get_stage().width-150,
138 h // this.el.get_stage().height
141 // 100 right for buttons ..
142 this.el.set_position(0,0);
145 this.scoller.el.set_size(
146 // this.el.get_stage().width-150,
148 h // this.el.get_stage().height
151 // 100 right for buttons ..
152 this.scoller.el.set_position(75,50);
154 public class Xcls_project_title : Object
156 public Clutter.Actor el;
157 private Xcls_ClutterFiles _this;
163 public Xcls_project_title(Xcls_ClutterFiles _owner )
166 _this.project_title = this;
167 this.el = new Clutter.Actor();
171 // set gobject values
172 this.el.reactive = true;
173 var child_0 = new Xcls_project_title_manager( _this );
175 this.el.layout_manager = child_0.el;
176 var child_1 = new Xcls_FixedLayout4( _this );
178 this.el.layout_manager = child_1.el;
179 var child_2 = new Xcls_project_title_name( _this );
181 this.el.add_child ( child_2.el );
182 var child_3 = new Xcls_project_title_path( _this );
184 this.el.add_child ( child_3.el );
188 this.el.add_constraint(
189 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
191 this.el.set_position(75,0);
194 // user defined functions
196 public class Xcls_project_title_manager : Object
198 public Clutter.FlowLayout el;
199 private Xcls_ClutterFiles _this;
205 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
208 _this.project_title_manager = this;
209 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
213 // set gobject values
214 this.el.homogeneous = false;
215 this.el.row_spacing = 5f;
216 this.el.column_spacing = 20f;
219 // user defined functions
222 public class Xcls_FixedLayout4 : Object
224 public Clutter.FixedLayout el;
225 private Xcls_ClutterFiles _this;
231 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
234 this.el = new Clutter.FixedLayout();
238 // set gobject values
241 // user defined functions
244 public class Xcls_project_title_name : Object
246 public Clutter.Text el;
247 private Xcls_ClutterFiles _this;
253 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
256 _this.project_title_name = this;
257 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
261 // set gobject values
264 this.el.x_expand = false;
267 // user defined functions
270 public class Xcls_project_title_path : Object
272 public Clutter.Text el;
273 private Xcls_ClutterFiles _this;
279 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
282 _this.project_title_path = this;
283 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
287 // set gobject values
292 // user defined functions
296 public class Xcls_scoller : Object
298 public Clutter.ScrollActor el;
299 private Xcls_ClutterFiles _this;
303 public Gee.ArrayList<Xcls_fileitem> fileitems;
304 public Gdk.Pixbuf missing_thumb_pixbuf;
307 public Xcls_scoller(Xcls_ClutterFiles _owner )
310 _this.scoller = this;
311 this.el = new Clutter.ScrollActor();
314 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
315 this.missing_thumb_pixbuf = null;
317 // set gobject values
318 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
319 this.el.reactive = true;
320 var child_0 = new Xcls_filelayout( _this );
322 this.el.add_child ( child_0.el );
325 this.el.scroll_event.connect( ( event) => {
326 //Sprint("scroll event");
327 var y = _this.filelayout.el.y;
328 var dir = event.direction;
330 case Clutter.ScrollDirection.UP:
333 case Clutter.ScrollDirection.DOWN:
339 // range of scroll -- can go up -- eg.. -ve value.
343 // to work out the max -ve number
344 // height of filelayout
345 // height of scrollactor..
347 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
348 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
355 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
356 // last_child_bottom - this.el.height,
358 // y = float.min(0, y); //??
359 // print("scroll event of %f - new y = %f ".printf(event.y, y));
360 _this.filelayout.el.y = y;
366 // user defined functions
368 public class Xcls_filelayout : Object
370 public Clutter.Actor el;
371 private Xcls_ClutterFiles _this;
377 public Xcls_filelayout(Xcls_ClutterFiles _owner )
380 _this.filelayout = this;
381 this.el = new Clutter.Actor();
385 // set gobject values
386 this.el.reactive = true;
387 var child_0 = new Xcls_filelayout_manager( _this );
389 this.el.layout_manager = child_0.el;
393 this.el.add_constraint(
394 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
398 // user defined functions
400 public class Xcls_filelayout_manager : Object
402 public Clutter.FlowLayout el;
403 private Xcls_ClutterFiles _this;
409 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
412 _this.filelayout_manager = this;
413 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
417 // set gobject values
418 this.el.homogeneous = true;
419 this.el.row_spacing = 20f;
420 this.el.column_spacing = 20f;
423 // user defined functions
426 public class Xcls_fileitem : Object
428 public Clutter.Actor el;
429 private Xcls_ClutterFiles _this;
433 public JsRender.JsRender file;
434 public Xcls_image image;
435 public Xcls_typetitle typetitle;
436 public Xcls_title title;
439 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
442 this.el = new Clutter.Actor();
446 // set gobject values
447 this.el.reactive = true;
448 var child_0 = new Xcls_BoxLayout11( _this );
450 this.el.layout_manager = child_0.el;
451 var child_1 = new Xcls_image( _this ,file);
453 this.el.add_child ( child_1.el );
454 this.image = child_1;
455 var child_2 = new Xcls_typetitle( _this ,file);
457 this.el.add_child ( child_2.el );
458 this.typetitle = child_2;
459 var child_3 = new Xcls_title( _this ,file);
461 this.el.add_child ( child_3.el );
462 this.title = child_3;
467 this.el.set_size(100,100);
470 this.el.button_press_event.connect( ( event) => {
471 _this.open(this.file);
474 this.el.enter_event.connect( ( event) => {
475 this.el.background_color = Clutter.Color.from_string("#333");
478 this.el.leave_event.connect( ( event) => {
479 this.el.background_color = Clutter.Color.from_string("#000");
484 // user defined functions
486 public class Xcls_BoxLayout11 : Object
488 public Clutter.BoxLayout el;
489 private Xcls_ClutterFiles _this;
495 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
498 this.el = new Clutter.BoxLayout();
502 // set gobject values
504 this.el.orientation = Clutter.Orientation.VERTICAL;
507 // user defined functions
510 public class Xcls_image : Object
512 public Clutter.Actor el;
513 private Xcls_ClutterFiles _this;
519 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
522 this.el = new Clutter.Actor();
526 // set gobject values
527 this.el.margin_right = 5f;
528 this.el.margin_left = 5f;
529 this.el.x_align = Clutter.ActorAlign.START;
530 this.el.x_expand = true;
531 this.el.y_align = Clutter.ActorAlign.START;
532 this.el.margin_top = 5f;
533 this.el.y_expand = true;
538 Gdk.Pixbuf pixbuf= null;
540 var fname = file.getIconFileName(false);
543 if (FileUtils.test(fname, FileTest.EXISTS)) {
544 pixbuf = new Gdk.Pixbuf.from_file(fname);
550 if (pixbuf == null) {
553 if (_this.missing_thumb_pixbuf == null) {
554 var icon_theme = Gtk.IconTheme.get_default ();
555 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
556 _this.missing_thumb_pixbuf.ref();
558 pixbuf = _this.missing_thumb_pixbuf;
565 var img = new Clutter.Image();
566 img.set_data(pixbuf.get_pixels(),
568 ? Cogl.PixelFormat.RGBA_8888
569 : Cogl.PixelFormat.RGB_888,
571 pixbuf.get_height (),
572 pixbuf.get_rowstride ()
574 this.el.set_content(img);
578 // should probably do smarter scaling...
581 this.el.set_size(90, 70);
585 // user defined functions
588 public class Xcls_typetitle : Object
590 public Clutter.Text el;
591 private Xcls_ClutterFiles _this;
597 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
600 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
604 // set gobject values
605 this.el.x_align = Clutter.ActorAlign.START;
606 this.el.x_expand = true;
607 this.el.y_align = Clutter.ActorAlign.START;
608 this.el.y_expand = true;
611 // user defined functions
614 public class Xcls_title : Object
616 public Clutter.Text el;
617 private Xcls_ClutterFiles _this;
623 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
626 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
630 // set gobject values
631 this.el.x_align = Clutter.ActorAlign.START;
632 this.el.x_expand = true;
633 this.el.y_align = Clutter.ActorAlign.START;
634 this.el.y_expand = true;
637 // user defined functions
641 public class Xcls_folderitem : Object
643 public Clutter.Actor el;
644 private Xcls_ClutterFiles _this;
648 public Xcls_foldertitle foldertitle;
651 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
654 this.el = new Clutter.Actor();
658 // set gobject values
659 this.el.reactive = true;
660 var child_0 = new Xcls_BoxLayout16( _this );
662 this.el.layout_manager = child_0.el;
663 var child_1 = new Xcls_foldertitle( _this ,folderpath);
665 this.el.add_child ( child_1.el );
666 this.foldertitle = child_1;
670 //this.el.set_size(100,100);
673 // user defined functions
675 public class Xcls_BoxLayout16 : Object
677 public Clutter.BoxLayout el;
678 private Xcls_ClutterFiles _this;
684 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
687 this.el = new Clutter.BoxLayout();
691 // set gobject values
693 this.el.orientation = Clutter.Orientation.VERTICAL;
696 // user defined functions
699 public class Xcls_foldertitle : Object
701 public Clutter.Text el;
702 private Xcls_ClutterFiles _this;
708 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
711 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
715 // set gobject values
716 this.el.x_align = Clutter.ActorAlign.START;
717 this.el.x_expand = true;
718 this.el.y_align = Clutter.ActorAlign.START;
719 this.el.y_expand = true;
722 // user defined functions
725 public class Xcls_folderfile : Object
727 public Clutter.Text el;
728 private Xcls_ClutterFiles _this;
732 public string filepath;
735 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
738 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
742 // set gobject values
743 this.el.x_align = Clutter.ActorAlign.START;
744 this.el.x_expand = true;
745 this.el.y_align = Clutter.ActorAlign.START;
746 this.el.y_expand = true;
751 this.filepath = filepath;
755 this.el.button_press_event.connect( ( event) => {
756 // _this.open(this.filepath);
759 this.el.enter_event.connect( ( event) => {
760 this.el.background_color = Clutter.Color.from_string("#333");
763 this.el.leave_event.connect( ( event) => {
764 this.el.background_color = Clutter.Color.from_string("#000");
769 // user defined functions