3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 MainWindow=new XObject({
16 // hide the file editing..
18 //this.hideViewEditing();
20 delete_event : ( event) => {
27 destroy : "() => {\n Gtk.main_quit();\n}",
29 init : this.state = "files";
31 //this.el.show_all();,
32 type : Gtk.WindowType.TOPLEVEL,
33 'void:hideAddListener' : () {
34 _this.addpropsview.el.save_easing_state();
35 var el = _this.rooview.el;
36 el.save_easing_state();
39 el.set_scale(1.0f,1.0f);
40 _this.addpropsview.el.set_scale(0.0f,0.0f);
44 //_this.clutterfiles.loadProject(_this.project);
46 el.restore_easing_state();
47 _this.addpropsview.el.restore_easing_state();
49 'void:hideAddProp' : () {
50 _this.addpropsview.el.save_easing_state();
51 var el = _this.rooview.el;
52 el.save_easing_state();
55 el.set_scale(1.0f,1.0f);
56 _this.addpropsview.el.set_scale(0.0f,0.0f);
60 //_this.clutterfiles.loadProject(_this.project);
62 el.restore_easing_state();
63 _this.addpropsview.el.restore_easing_state();
65 'void:hideCodeEdit' : () {
66 //this.code_editor.saveContents();
68 _this.codeeditview.el.save_easing_state();
69 var el = _this.rooview.el;
70 el.save_easing_state();
73 el.set_scale(1.0f,1.0f);
74 _this.codeeditview.el.set_scale(0.0f,0.0f);
78 //_this.clutterfiles.loadProject(_this.project);
80 el.restore_easing_state();
81 _this.codeeditview.el.restore_easing_state();
83 'void:hideObject' : () {
84 // return to editing state..
90 _this.objectview.el.save_easing_state();
91 var el = _this.rooview.el;
92 el.save_easing_state();
95 el.set_scale(1.0f,1.0f);
96 _this.objectview.el.set_scale(0.0f,0.0f);
100 //_this.clutterfiles.loadProject(_this.project);
102 el.restore_easing_state();
103 _this.objectview.el.restore_easing_state();
107 'void:hideProjectEdit' : () {
108 // return to editing state..
110 _this.projectbutton.el.show();
111 _this.projecteditbutton.el.show();
114 //this.rooview.el.hide();
115 //this.edit_project.el.show();
116 _this.projecteditview.el.save_easing_state();
117 var el = _this.rooview.el;
118 el.save_easing_state();
121 el.set_scale(1.0f,1.0f);
122 _this.projecteditview.el.set_scale(1.0f,0.0f);
123 _this.state = "edit";
126 //_this.clutterfiles.loadProject(_this.project);
128 el.restore_easing_state();
129 _this.projecteditview.el.restore_easing_state();
132 'void:hideViewEditing' : ( ) {
134 if (this.left_tree.getActiveFile() != null) {
135 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
136 this.window_rooview.createThumb();
138 this.window_gladeview.createThumb();
141 _this.projecteditbutton.el.hide();
142 this.editpane.el.hide();
143 //this.rooview.el.hide();
144 this.left_projects.el.show();
146 var el = _this.rooview.el;
147 el.save_easing_state();
148 el.set_easing_duration(1000);
149 // show project / file view..
150 //_this.mainpane.lastWidth = _this.leftpane.el.get_position();
151 //_this.mainpane.el.set_position(0);
153 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
154 el.set_scale(0.0f,0.0f);
156 _this.state = "files";
158 _this.left_projects.selectProject(_this.project);
159 //_this.clutterfiles.loadProject(_this.project);
161 el.restore_easing_state();
163 print("show view browsing");
165 'void:initChildren' : () {
166 // this needs putting in a better place..
168 print("init children");
169 this.left_tree = new Xcls_WindowLeftTree();
170 this.left_tree.ref();
171 this.tree.el.pack_start(this.left_tree.el,true, true,0);
172 this.left_tree.el.show_all();
174 this.left_tree.before_node_change.connect(() => {
175 if (this.state != "codeedit") {
176 this.left_props.finish_editing();
179 if (!this.code_editor.saveContents()) {
186 this.left_tree.node_selected.connect((sel) => {
188 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
191 this.left_props.el.hide();
193 this.left_props.el.show();
194 this.left_props.load(this.left_tree.getActiveFile(), sel);
195 switch (this.state) {
199 this.rightpalete.clear();
202 this.rightpalete.load(_this.left_tree.getActiveFile().palete(), sel.fqn());
208 this.add_props.clear();
211 this.add_props.show(_this.left_tree.getActiveFile().palete(), "props", sel.fqn());
216 this.add_props.clear();
219 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
233 this.left_tree.changed.connect(() => {
234 this.window_rooview.requestRedraw();
241 this.left_props =new Xcls_LeftProps();
242 this.left_props.ref();
243 this.props.el.pack_start(this.left_props.el,true, true,0);
244 this.left_props.el.show_all();
246 this.left_props.show_editor.connect( (file, node, type, key) => {
247 this.showCodeEdit(node, type, key);
249 this.left_props.stop_editor.connect( () => {
250 if (this.state != "codeedit") {
254 var ret = this.code_editor.saveContents();
261 this.left_props.changed.connect(() => {
262 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
263 this.window_rooview.requestRedraw();
265 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
273 this.left_projects = new Xcls_WindowLeftProjects();
274 this.left_projects.ref();
275 this.leftpane.el.pack_start(this.left_projects.el,true, true,0);
276 //this.left_projects.el.show_all();
277 this.left_projects.project_selected.connect((proj) => {
279 _this.clutterfiles.loadProject(proj);
285 this.projectsettings =new Xcls_ProjectSettings();
286 this.projectsettings.ref(); /// really?
287 ((Gtk.Container)(this.projecteditview.el.get_widget())).add(this.projectsettings.el);
288 this.projectsettings.el.show_all();
290 var stage = _this.projecteditview.el.get_stage();
291 stage.set_background_color( Clutter.Color.from_string("#000"));
293 this.projectsettings.buttonPressed.connect((btn) => {
294 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
297 _this.window_rooview.view.renderJS(true);
299 if (btn == "apply") {
300 _this.window_rooview.view.renderJS(true);
304 // do nothing for gtk..
306 this.hideProjectEdit();
311 // objects (palate..)
312 this.rightpalete = new Xcls_RightPalete();
313 this.rightpalete.ref(); /// really?
314 ((Gtk.Container)(this.objectview.el.get_widget())).add(this.rightpalete.el);
315 //this.projectsettings.el.show_all();
317 stage = _this.objectview.el.get_stage();
318 stage.set_background_color( Clutter.Color.from_string("#000"));
320 /*this.projectsettings.buttonPressed.connect((btn) => {
322 _this.window_rooview.view.renderJS(true);
324 if (btn == "apply") {
325 _this.window_rooview.view.renderJS(true);
328 this.hideProjectEdit();
336 this.add_props = new Xcls_WindowAddProp();
337 this.add_props.ref(); /// really?
338 ((Gtk.Container)(this.addpropsview.el.get_widget())).add(this.add_props.el);
339 //this.projectsettings.el.show_all();
341 stage = _this.addpropsview.el.get_stage();
342 stage.set_background_color( Clutter.Color.from_string("#000"));
345 _this.add_props.select.connect( (key,type,skel, etype) => {
346 this.left_props.addProp(etype, key, skel, type);
352 this.code_editor = new Xcls_Editor();
353 this.code_editor.ref(); /// really?
354 ((Gtk.Container)(this.codeeditview.el.get_widget())).add(this.code_editor.el);
355 //this.projectsettings.el.show_all();
357 stage = _this.codeeditview.el.get_stage();
358 stage.set_background_color( Clutter.Color.from_string("#000"));
368 this.window_rooview =new Xcls_WindowRooView();
369 this.window_rooview.ref();
370 ((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_rooview.el);
371 this.window_rooview.el.show_all();
373 stage = _this.rooview.el.get_stage();
374 stage.set_background_color( Clutter.Color.from_string("#000"));
379 this.window_gladeview =new Xcls_GladeView();
380 this.window_gladeview.ref();
382 //((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_gladeview.el);
383 ///this.window_gladeview.el.hide();
390 this.clutterfiles = new Xcls_ClutterFiles();
391 this.clutterfiles.ref();
392 stage.add_child(this.clutterfiles.el);
393 this.clutterfiles.el.show_all();
396 this.clutterfiles.open.connect((file) => {
397 _this.project = file.project;
398 _this.showViewEditing();
399 this.left_tree.model.loadFile(file);
400 var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));
401 if (file.xtype == "Roo" ) {
402 ctr.foreach( (w) => { ctr.remove(w); });
403 ctr.add(this.window_rooview.el);
404 this.window_rooview.loadFile(file);
406 this.window_rooview.el.show_all();
408 ctr.foreach( (w) => { ctr.remove(w); });
409 ctr.add(this.window_gladeview.el);
410 this.window_gladeview.loadFile(file);
411 this.window_gladeview.el.show_all();
413 print("OPEN : " + file.name);
423 var tl = new Clutter.Timeline(6000);
424 tl.set_repeat_count(-1);
428 this.children_loaded = true;
434 'void:setTitle' : (string str) {
435 this.el.set_title(this.title + " - " + str);
438 this.left_tree =new Xcls_WindowLeftTree();
439 _this.vbox.el.pack_start(this.left_tree.el,true, true,0);
443 'void:showAddListener' : () {
447 var ae = this.left_tree.getActiveElement();
452 //this.rooview.el.hide();
453 this.add_props.el.show_all();
455 Palete.factory(this.project.xtype),
459 //this.rightpalete.show(this.project);
461 _this.addpropsview.el.save_easing_state();
463 var el = _this.rooview.el;
464 el.save_easing_state();
467 el.set_scale(0.5f,0.5f);
469 _this.addpropsview.el.set_scale(1.0f,1.0f);
473 //_this.clutterfiles.loadProject(_this.project);
475 el.restore_easing_state();
476 _this.addpropsview.el.restore_easing_state();
477 this.state = "addlistener";
479 'void:showAddProp' : () {
482 var ae = this.left_tree.getActiveElement();
490 //this.rooview.el.hide();
491 this.add_props.el.show_all();
493 Palete.factory(this.project.xtype),
498 _this.addpropsview.el.save_easing_state();
500 var el = _this.rooview.el;
501 el.save_easing_state();
504 el.set_scale(0.5f,0.5f);
506 _this.addpropsview.el.set_scale(1.0f,1.0f);
510 //_this.clutterfiles.loadProject(_this.project);
512 el.restore_easing_state();
513 _this.addpropsview.el.restore_easing_state();
514 this.state = "addprop";
516 'void:showCodeEdit' : (JsRender.Node node, string ptype, string key)
518 // this is a bit different,
519 // it's not called via a button - but triggered by the prop edit class signal.
520 // so it has to hide any other state..
530 this.hideAddListener();
537 //this.rooview.el.hide();
538 this.code_editor.el.show_all();
539 this.code_editor.show(
545 _this.codeeditview.el.save_easing_state();
547 var el = _this.rooview.el;
548 el.save_easing_state();
551 el.set_scale(0.5f,0.5f);
553 _this.codeeditview.el.set_scale(1.0f,1.0f);
557 //_this.clutterfiles.loadProject(_this.project);
559 el.restore_easing_state();
560 _this.codeeditview.el.restore_easing_state();
561 this.state = "codeedit";
563 'void:showObject' : () {
566 // what's the active node on the left hand side..
568 var n = _this.left_tree.getActiveElement();
576 //this.rooview.el.hide();
577 this.rightpalete.el.show_all();
578 this.rightpalete.load(_this.left_tree.getActiveFile().palete(), n.fqn());
581 //this.rightpalete.show(this.project);
583 _this.objectview.el.save_easing_state();
585 var el = _this.rooview.el;
586 el.save_easing_state();
589 el.set_scale(0.5f,0.5f);
591 _this.objectview.el.set_scale(1.0f,1.0f);
595 //_this.clutterfiles.loadProject(_this.project);
597 el.restore_easing_state();
598 _this.objectview.el.restore_easing_state();
599 this.state = "object";
601 'void:showProjectEdit' : () {
602 // make the browser smaller, and show the edit dialog
605 _this.projectbutton.el.hide();
606 _this.projecteditbutton.el.hide();
609 //this.rooview.el.hide();
610 this.projectsettings.el.show_all();
611 this.projectsettings.show(this.project);
612 _this.projecteditview.el.save_easing_state();
614 var el = _this.rooview.el;
615 el.save_easing_state();
618 el.set_scale(0.5f,0.5f);
620 _this.projecteditview.el.set_scale(1.0f,1.0f);
622 _this.state = "projectedit";
625 //_this.clutterfiles.loadProject(_this.project);
627 el.restore_easing_state();
628 _this.projecteditview.el.restore_easing_state();
629 // print("show view browsing");
632 'void:showViewEditing' : ( ) {
633 this.editpane.el.show();
634 // this.rooview.el.show();
635 this.left_projects.el.hide();
637 _this.projecteditbutton.el.show();
639 var el = _this.rooview.el;
640 el.save_easing_state();
643 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
644 el.set_scale(1.0f,1.0f);
645 _this.state = "edit";
646 // _this.mainpane.el.set_position(_this.leftpane.lastWidth);
647 _this.clutterfiles.el.hide();
649 el.restore_easing_state();
651 print("show view editing");
664 pack : "pack_start,false,true,0",
671 pack : "pack_end,true,true,0",
682 pack : "pack_start,false,true,0",
703 xtype: GtkClutter.Embed,
705 size_allocate : ( alloc) => {
706 if (!_this.children_loaded) { return; }
707 //print("size_allocation %d,%d\n".printf(alloc.width, alloc.height));
709 /* _this.rooview.el.set_size(this.el.get_stage().width-50,
710 this.el.get_stage().height);
711 _this.clutterfiles.set_size(this.el.get_stage().width-50,
712 this.el.get_stage().height);
714 // this.el.set_size_request(alloc.width,alloc.height);
715 // this.el.get_stage().set_size(alloc.width,alloc.height);
716 _this.rooview.el.set_size(alloc.width-50,
721 _this.clutterfiles.set_size(alloc.width-50,
723 _this.projecteditview.el.set_size(alloc.width-50,
724 alloc.height / 2.0f);
726 _this.objectview.el.set_size((alloc.width -50)/2.0f,
729 _this.addpropsview.el.set_size((alloc.width -50)/2.0f,
732 _this.codeeditview.el.set_size((alloc.width -50)/2.0f,
737 pack : "pack_start,true,true,0",
738 init : var stage = this.el.get_stage();
739 stage.set_background_color( Clutter.Color.from_string("#000"));,
742 xtype: GtkClutter.Actor,
744 pack : "get_stage().add_child",
748 this.el.add_constraint(
749 new Clutter.AlignConstraint(
750 _this.clutterembed.el.get_stage(),
751 Clutter.AlignAxis.X_AXIS,
756 //this.el.set_position(100,100);
757 this.el.set_pivot_point(1.0f,1.0f);
759 this.el.set_size(_this.clutterembed.el.get_stage().width-50,
760 _this.clutterembed.el.get_stage().height);
765 xtype: GtkClutter.Actor,
767 pack : "get_stage().add_child",
771 this.el.add_constraint(
772 new Clutter.AlignConstraint(
773 _this.clutterembed.el.get_stage(),
774 Clutter.AlignAxis.X_AXIS,
779 this.el.fixed_x = 50.0f;
780 this.el.fixed_y = 0.0f;
781 //this.el.set_position(100,100);
782 this.el.set_pivot_point(0.0f,0.0f);
783 this.el.set_scale(0.0f,1.0f);
784 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
785 _this.clutterembed.el.get_stage().height);
790 xtype: GtkClutter.Actor,
792 pack : "get_stage().add_child",
796 this.el.add_constraint(
797 new Clutter.AlignConstraint(
798 _this.clutterembed.el.get_stage(),
799 Clutter.AlignAxis.X_AXIS,
804 this.el.fixed_x = 50.0f;
805 this.el.fixed_y = 0.0f;
806 //this.el.set_position(100,100);
807 this.el.set_pivot_point(0.0f,0.0f);
808 this.el.set_scale(0.0f,1.0f);
809 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
810 _this.clutterembed.el.get_stage().height);
815 xtype: GtkClutter.Actor,
817 pack : "get_stage().add_child",
821 this.el.add_constraint(
822 new Clutter.AlignConstraint(
823 _this.clutterembed.el.get_stage(),
824 Clutter.AlignAxis.X_AXIS,
829 this.el.fixed_x = 50.0f;
830 this.el.fixed_y = 0.0f;
831 //this.el.set_position(100,100);
832 this.el.set_pivot_point(0.0f,0.0f);
833 this.el.set_scale(0.0f,1.0f);
834 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
835 _this.clutterembed.el.get_stage().height);
840 xtype: GtkClutter.Actor,
841 id : "projecteditview",
842 pack : "get_stage().add_child",
846 this.el.add_constraint(
847 new Clutter.AlignConstraint(
848 _this.clutterembed.el.get_stage(),
849 Clutter.AlignAxis.X_AXIS,
854 //this.el.set_position(100,100);
855 this.el.set_pivot_point(0.0f,0.0f);
856 this.el.set_scale(1.0f,0.0f);
857 this.el.set_size(_this.clutterembed.el.get_stage().width-50,
858 _this.clutterembed.el.get_stage().height /2);
863 xtype: Clutter.Actor,
865 pack : "get_stage().add_child",
868 this.el.add_constraint(
869 new Clutter.AlignConstraint(
870 _this.clutterembed.el.get_stage(),
871 Clutter.AlignAxis.X_AXIS,
877 //this.el.set_position(100,100);
878 this.el.set_pivot_point(0.5f,0.5f);
880 _this.clutterembed.el.get_stage().height);
885 xtype: Clutter.Actor,
887 enter_event : ( event) => {
888 this.el.background_color = new Clutter.Color.from_string("#333");
891 leave_event : ( event) => {
892 this.el.background_color = new Clutter.Color.from_string("#000");
895 button_press_event : ( ) => {
896 switch (_this.state) {
899 _this.hideViewEditing();
902 _this.showViewEditing();
907 _this.hideViewEditing();
910 _this.hideAddListener();
911 _this.hideViewEditing();
916 _this.hideViewEditing();
926 id : "projectbutton",
928 init : this.el.set_size(50,50);,
934 line_alignment : Pango.Alignment.CENTER,
935 x_align : Clutter.ActorAlign.CENTER,
937 y_align : Clutter.ActorAlign.CENTER,
943 xtype: Clutter.Actor,
945 enter_event : ( event) => {
946 this.el.background_color = new Clutter.Color.from_string("#333");
949 leave_event : ( event) => {
950 this.el.background_color = new Clutter.Color.from_string("#000");
953 button_press_event : ( ) => {
954 switch (_this.state) {
956 _this.showProjectEdit();
959 // _this.showViewEditing();
962 _this.hideProjectEdit();
969 _this.showProjectEdit();
972 _this.hideAddListener();
973 _this.showProjectEdit();
978 _this.showProjectEdit();
988 id : "projecteditbutton",
990 init : this.el.set_size(50,50);,
995 line_alignment : Pango.Alignment.CENTER,
997 x_align : Clutter.ActorAlign.CENTER,
999 y_align : Clutter.ActorAlign.CENTER,
1005 xtype: Clutter.Actor,
1007 enter_event : ( event) => {
1008 this.el.background_color = new Clutter.Color.from_string("#333");
1011 leave_event : ( event) => {
1012 this.el.background_color = new Clutter.Color.from_string("#000");
1015 button_press_event : ( ) => {
1019 switch (_this.state) {
1023 _this.hideAddProp();
1027 _this.hideAddListener();
1043 print("unhandled add objects from %s\n",_this.state);
1051 id : "objectshowbutton",
1053 init : this.el.set_size(50,50);,
1057 xtype: Clutter.Text,
1059 line_alignment : Pango.Alignment.CENTER,
1060 x_align : Clutter.ActorAlign.CENTER,
1062 y_align : Clutter.ActorAlign.CENTER,
1068 xtype: Clutter.Actor,
1070 enter_event : ( event) => {
1071 this.el.background_color = new Clutter.Color.from_string("#333");
1074 leave_event : ( event) => {
1075 this.el.background_color = new Clutter.Color.from_string("#000");
1078 button_press_event : ( ) => {
1082 switch (_this.state) {
1084 _this.showAddProp();
1089 _this.showAddProp();
1093 _this.hideAddListener();
1094 _this.showAddProp();
1099 _this.hideAddProp();
1103 print("unhandled add property from %s\n",_this.state);
1112 id : "addpropbutton",
1114 init : this.el.set_size(50,50);,
1118 xtype: Clutter.Text,
1120 line_alignment : Pango.Alignment.CENTER,
1121 x_align : Clutter.ActorAlign.CENTER,
1123 y_align : Clutter.ActorAlign.CENTER,
1129 xtype: Clutter.Actor,
1131 enter_event : ( event) => {
1132 this.el.background_color = new Clutter.Color.from_string("#333");
1135 leave_event : ( event) => {
1136 this.el.background_color = new Clutter.Color.from_string("#000");
1139 button_press_event : ( ) => {
1143 switch (_this.state) {
1145 _this.showAddListener();
1150 _this.hideAddListener();
1155 _this.hideAddProp();
1156 _this.showAddListener();
1160 _this.showAddListener();
1164 print("unhandled add listener from %s\n",_this.state);
1174 id : "addlistenerbutton",
1176 init : this.el.set_size(50,50);,
1180 xtype: Clutter.Text,
1182 line_alignment : Pango.Alignment.CENTER,
1183 x_align : Clutter.ActorAlign.CENTER,
1185 y_align : Clutter.ActorAlign.CENTER,
1192 xtype: Clutter.BoxLayout,
1193 orientation : Clutter.Orientation.VERTICAL
1207 XObject.cache['/MainWindow'] = MainWindow;