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;
26 public Xcls_ClutterFiles()
29 this.el = new Clutter.Actor();
32 var child_0 = new Xcls_project_title( _this );
34 this.el.add_child ( child_0.el );
35 var child_1 = new Xcls_scroller( _this );
37 this.el.add_child ( child_1.el );
40 // user defined functions
41 public void clearFiles () {
43 this.filelayout.el.remove_all_children();
44 // we need to unref all the chidren that we loaded though...
47 public void loadProject (Project.Project pr) {
48 // list all the files, and create new Xcls_fileitem for each one.
53 // LEAK --- we should unref all the chilren...
54 this.filelayout.el.y = 0;
57 print("clutter files - load project: " + pr.name +"\n");
58 // should unref.. them hopefully.
60 this.project_title_name.el.text = pr.name;
61 this.project_title_path.el.text = pr.firstPath();
63 // file items contains a reference until we reload ...
64 this.fileitems = new Gee.ArrayList<Object>();
68 var fiter = pr.sortedFiles().list_iterator();
69 while (fiter.next()) {
70 var a = new Xcls_fileitem(this,fiter.get());
71 this.fileitems.add(a);
74 print("add to clutter file view: " + fiter.get().name + "\n");
75 this.filelayout.el.add_child(a.el);
80 if (!(pr is Project.Gtk)) {
81 print ("not gtk... skipping files");
84 var gpr = (Project.Gtk)pr;
85 var def = gpr.compilegroups.get("_default_");
86 // not sure why the above is returng null!??
88 def = new Project.GtkValaSettings("_default_");
89 gpr.compilegroups.set("_default_", def);
91 var items = def.sources;
95 for(var i =0 ; i < items.size; i++) {
96 print ("cheking folder %s\n", items.get(i));
97 var files = gpr.filesForOpen(items.get(i));
102 // add the directory... items.get(i);
103 var x = new Xcls_folderitem(this,items.get(i));
104 this.fileitems.add(x);
105 this.filelayout.el.add_child(x.el);
107 for(var j =0 ; j < files.size; j++) {
108 print ("adding file %s\n", files.get(j));
110 var y = new Xcls_folderfile(this, files.get(j));
111 this.fileitems.add(y);
112 x.el.add_child(y.el);
114 // add file to files.get(j);
119 //this.el.set_value(citer, 1, items.get(i) );
126 public void set_size (float w, float h)
129 // called by window resize... with is alreaddy -50 (for the buttons?)
134 if (this.el == null) {
135 print("object not ready yet?");
139 print("recv width %f, filelayoutw = %f", w, w-200);
141 w = GLib.Math.floorf ( w/120.0f) * 120.0f;
146 //_this.filelayout_manager.el.max_column_width = w - 200;
147 _this.filelayout.el.width = w ;
150 // this.el.get_stage().width-150,
152 h // this.el.get_stage().height
155 // 100 right for buttons ..
156 this.el.set_position(75,0);
159 this.scroller.el.set_size(
160 // this.el.get_stage().width-150,
162 h // this.el.get_stage().height
165 // 100 right for buttons ..
166 this.scroller.el.set_position(0,50);
168 _this.filelayout.el.y = 0.0f;
171 public class Xcls_project_title : Object
173 public Clutter.Actor el;
174 private Xcls_ClutterFiles _this;
180 public Xcls_project_title(Xcls_ClutterFiles _owner )
183 _this.project_title = this;
184 this.el = new Clutter.Actor();
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 );
201 // user defined functions
203 public class Xcls_project_title_manager : Object
205 public Clutter.FlowLayout el;
206 private Xcls_ClutterFiles _this;
212 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
215 _this.project_title_manager = this;
216 this.el = new Clutter.FlowLayout();
221 // user defined functions
224 public class Xcls_FixedLayout4 : Object
226 public Clutter.FixedLayout el;
227 private Xcls_ClutterFiles _this;
233 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
236 this.el = new Clutter.FixedLayout();
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"));
262 // user defined functions
265 public class Xcls_project_title_path : Object
267 public Clutter.Text el;
268 private Xcls_ClutterFiles _this;
274 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
277 _this.project_title_path = this;
278 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
283 // user defined functions
287 public class Xcls_scroller : Object
289 public Clutter.ScrollActor el;
290 private Xcls_ClutterFiles _this;
296 public Xcls_scroller(Xcls_ClutterFiles _owner )
299 _this.scroller = this;
300 this.el = new Clutter.ScrollActor();
303 var child_0 = new Xcls_filelayout( _this );
305 this.el.add_child ( child_0.el );
308 this.el.scroll_event.connect( ( event) => {
309 print("scroll event\n");
310 var y = _this.filelayout.el.y;
311 var dir = event.direction;
313 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
314 var bottompos = -1 * ( last_child_bottom - (0.5f * this.el.height));
317 case Clutter.ScrollDirection.UP:
318 print("Scroll up by %f\n", event.y);
320 y = float.min(0, y); //
323 case Clutter.ScrollDirection.DOWN:
324 print("Scroll down by %f\n", event.y);
326 y = float.max(bottompos, y);
330 case Clutter.ScrollDirection.SMOOTH:
331 double delta_x, delta_y;
332 event.get_scroll_delta(out delta_x, out delta_y);
333 //print("Scroll SMOOTH? by %f\n", delta_y * event.y);
334 y += ((float)delta_y * event.y * -1.0f) /2 ;
335 y = float.max(bottompos, y);
336 y = float.min(0, y); //
340 print("scroll event = bad direction %s\n", dir.to_string());
343 // range of scroll -- can go up -- eg.. -ve value.
347 print("Set scroll to %f (lcb=%f / height = %f)\n", y, last_child_bottom, this.el.height);
349 _this.filelayout.el.y = y;
355 // user defined functions
357 public class Xcls_filelayout : Object
359 public Clutter.Actor el;
360 private Xcls_ClutterFiles _this;
366 public Xcls_filelayout(Xcls_ClutterFiles _owner )
369 _this.filelayout = this;
370 this.el = new Clutter.Actor();
373 var child_0 = new Xcls_filelayout_manager( _this );
375 this.el.layout_manager = child_0.el;
378 // user defined functions
380 public class Xcls_filelayout_manager : Object
382 public Clutter.FlowLayout el;
383 private Xcls_ClutterFiles _this;
389 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
392 _this.filelayout_manager = this;
393 this.el = new Clutter.FlowLayout();
398 // user defined functions
401 public class Xcls_fileitem : Object
403 public Clutter.Actor el;
404 private Xcls_ClutterFiles _this;
408 public Xcls_image image;
409 public Xcls_typetitle typetitle;
410 public Xcls_title title;
413 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
416 this.el = new Clutter.Actor();
419 var child_0 = new Xcls_BoxLayout11( _this );
421 this.el.layout_manager = child_0.el;
422 var child_1 = new Xcls_image( _this ,file);
424 this.el.add_child ( child_1.el );
425 this.image = child_1;
426 var child_2 = new Xcls_typetitle( _this ,file);
428 this.el.add_child ( child_2.el );
429 this.typetitle = child_2;
430 var child_3 = new Xcls_title( _this ,file);
432 this.el.add_child ( child_3.el );
433 this.title = child_3;
436 this.el.button_press_event.connect( ( event ) => {
437 _this.open(this.file);
440 this.el.enter_event.connect( ( event) => {
441 this.el.background_color = Clutter.Color.from_string("#333");
442 this.title.el.background_color = Clutter.Color.from_string("#fff");
443 this.typetitle.el.background_color = Clutter.Color.from_string("#fff");
444 this.title.el.color = Clutter.Color.from_string("#000");
445 this.typetitle.el.color = Clutter.Color.from_string("#000");
449 this.el.leave_event.connect( ( event) => {
450 this.el.background_color = Clutter.Color.from_string("#000");
451 this.title.el.background_color = Clutter.Color.from_string("#000");
452 this.typetitle.el.background_color = Clutter.Color.from_string("#000");
453 this.title.el.color = Clutter.Color.from_string("#fff");
454 this.typetitle.el.color = Clutter.Color.from_string("#fff");
461 // user defined functions
463 public class Xcls_BoxLayout11 : Object
465 public Clutter.BoxLayout el;
466 private Xcls_ClutterFiles _this;
472 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
475 this.el = new Clutter.BoxLayout();
480 // user defined functions
483 public class Xcls_image : Object
485 public Clutter.Actor el;
486 private Xcls_ClutterFiles _this;
492 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
495 this.el = new Clutter.Actor();
500 // user defined functions
503 public class Xcls_typetitle : Object
505 public Clutter.Text el;
506 private Xcls_ClutterFiles _this;
512 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
515 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
520 // user defined functions
523 public class Xcls_title : Object
525 public Clutter.Text el;
526 private Xcls_ClutterFiles _this;
532 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
535 this.el = new Clutter.Text.full("Sans 10px", file.nickNameSplit(), Clutter.Color.from_string("#fff"));
540 // user defined functions
544 public class Xcls_folderitem : Object
546 public Clutter.Actor el;
547 private Xcls_ClutterFiles _this;
551 public Xcls_foldertitle foldertitle;
554 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
557 this.el = new Clutter.Actor();
560 var child_0 = new Xcls_BoxLayout16( _this );
562 this.el.layout_manager = child_0.el;
563 var child_1 = new Xcls_foldertitle( _this ,folderpath);
565 this.el.add_child ( child_1.el );
566 this.foldertitle = child_1;
569 // user defined functions
571 public class Xcls_BoxLayout16 : Object
573 public Clutter.BoxLayout el;
574 private Xcls_ClutterFiles _this;
580 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
583 this.el = new Clutter.BoxLayout();
588 // user defined functions
591 public class Xcls_foldertitle : Object
593 public Clutter.Text el;
594 private Xcls_ClutterFiles _this;
600 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
603 this.el = new Clutter.Text.full("Sans bold 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
608 // user defined functions
611 public class Xcls_folderfile : Object
613 public Clutter.Text el;
614 private Xcls_ClutterFiles _this;
620 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
623 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
628 this.el.button_press_event.connect( ( event) => {
630 var f = JsRender.JsRender.factory("PlainFile", _this.project, this.filepath);
634 this.el.enter_event.connect( ( event) => {
635 this.el.background_color = Clutter.Color.from_string("#fff");
636 this.el.color = Clutter.Color.from_string("#000");
639 this.el.leave_event.connect( ( event) => {
640 this.el.background_color = Clutter.Color.from_string("#000");
641 this.el.color = Clutter.Color.from_string("#fff");
646 // user defined functions