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) => {
23 destroy : function (self) {
31 init : this.state = "files";
33 //this.el.show_all();,
34 type : Gtk.WindowType.TOPLEVEL,
35 'void:hideAddListener' : () {
36 _this.addpropsview.el.save_easing_state();
37 var el = _this.rooview.el;
38 el.save_easing_state();
41 el.set_scale(1.0f,1.0f);
42 _this.addpropsview.el.set_scale(0.0f,0.0f);
46 //_this.clutterfiles.loadProject(_this.project);
48 el.restore_easing_state();
49 _this.addpropsview.el.restore_easing_state();
51 'void:hideAddProp' : () {
52 _this.addpropsview.el.save_easing_state();
53 var el = _this.rooview.el;
54 el.save_easing_state();
57 el.set_scale(1.0f,1.0f);
58 _this.addpropsview.el.set_scale(0.0f,0.0f);
62 //_this.clutterfiles.loadProject(_this.project);
64 el.restore_easing_state();
65 _this.addpropsview.el.restore_easing_state();
67 'void:hideCodeEdit' : () {
68 //this.code_editor.saveContents();
70 _this.codeeditview.el.save_easing_state();
71 var el = _this.rooview.el;
72 el.save_easing_state();
75 el.set_scale(1.0f,1.0f);
76 _this.codeeditview.el.set_scale(0.0f,0.0f);
80 //_this.clutterfiles.loadProject(_this.project);
82 el.restore_easing_state();
83 _this.codeeditview.el.restore_easing_state();
85 'void:hideObject' : () {
86 // return to editing state..
92 _this.objectview.el.save_easing_state();
93 var el = _this.rooview.el;
94 el.save_easing_state();
97 el.set_scale(1.0f,1.0f);
98 _this.objectview.el.set_scale(0.0f,0.0f);
102 //_this.clutterfiles.loadProject(_this.project);
104 el.restore_easing_state();
105 _this.objectview.el.restore_easing_state();
109 'void:hideProjectEdit' : () {
110 // return to editing state..
112 _this.projectbutton.el.show();
113 _this.projecteditbutton.el.show();
116 //this.rooview.el.hide();
117 //this.edit_project.el.show();
118 _this.projecteditview.el.save_easing_state();
119 var el = _this.rooview.el;
120 el.save_easing_state();
123 el.set_scale(1.0f,1.0f);
124 _this.projecteditview.el.set_scale(1.0f,0.0f);
125 _this.state = "edit";
128 //_this.clutterfiles.loadProject(_this.project);
130 el.restore_easing_state();
131 _this.projecteditview.el.restore_easing_state();
134 'void:hideViewEditing' : ( ) {
136 if (this.left_tree.getActiveFile() != null) {
137 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
138 this.window_rooview.createThumb();
140 this.window_gladeview.createThumb();
143 _this.projecteditbutton.el.hide();
144 this.editpane.el.hide();
145 //this.rooview.el.hide();
146 this.left_projects.el.show();
148 var el = _this.rooview.el;
149 el.save_easing_state();
150 el.set_easing_duration(1000);
151 // show project / file view..
152 //_this.mainpane.lastWidth = _this.leftpane.el.get_position();
153 //_this.mainpane.el.set_position(0);
155 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
156 el.set_scale(0.0f,0.0f);
158 _this.state = "files";
160 _this.left_projects.selectProject(_this.project);
161 //_this.clutterfiles.loadProject(_this.project);
163 el.restore_easing_state();
165 print("show view browsing");
167 'void:initChildren' : () {
168 // this needs putting in a better place..
170 print("init children");
171 this.left_tree = new Xcls_WindowLeftTree();
172 this.left_tree.ref();
173 this.tree.el.pack_start(this.left_tree.el,true, true,0);
174 this.left_tree.el.show_all();
176 this.left_tree.before_node_change.connect(() => {
177 if (this.state != "codeedit") {
178 this.left_props.finish_editing();
181 if (!this.code_editor.saveContents()) {
188 this.left_tree.node_selected.connect((sel) => {
190 print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
193 this.left_props.el.hide();
195 this.left_props.el.show();
196 this.left_props.load(this.left_tree.getActiveFile(), sel);
197 switch (this.state) {
201 this.rightpalete.clear();
204 this.rightpalete.load(_this.left_tree.getActiveFile().palete(), sel.fqn());
210 this.add_props.clear();
213 this.add_props.show(_this.left_tree.getActiveFile().palete(), "props", sel.fqn());
218 this.add_props.clear();
221 this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
235 this.left_tree.changed.connect(() => {
236 this.window_rooview.requestRedraw();
243 this.left_props =new Xcls_LeftProps();
244 this.left_props.ref();
245 this.props.el.pack_start(this.left_props.el,true, true,0);
246 this.left_props.el.show_all();
248 this.left_props.show_editor.connect( (file, node, type, key) => {
249 this.showCodeEdit(node, type, key);
251 this.left_props.stop_editor.connect( () => {
252 if (this.state != "codeedit") {
256 var ret = this.code_editor.saveContents();
263 this.left_props.changed.connect(() => {
264 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
265 this.window_rooview.requestRedraw();
267 this.window_gladeview.loadFile(this.left_tree.getActiveFile());
275 this.left_projects = new Xcls_WindowLeftProjects();
276 this.left_projects.ref();
277 this.leftpane.el.pack_start(this.left_projects.el,true, true,0);
278 this.left_projects.el.show_all();
279 this.left_projects.project_selected.connect((proj) => {
281 _this.clutterfiles.loadProject(proj);
287 this.projectsettings =new Xcls_ProjectSettings();
288 this.projectsettings.ref(); /// really?
289 ((Gtk.Container)(this.projecteditview.el.get_widget())).add(this.projectsettings.el);
290 //this.projectsettings.el.show_all();
292 var stage = _this.projecteditview.el.get_stage();
293 stage.set_background_color( Clutter.Color.from_string("#000"));
295 this.projectsettings.buttonPressed.connect((btn) => {
296 if (this.left_tree.getActiveFile().xtype == "Roo" ) {
299 _this.window_rooview.view.renderJS(true);
301 if (btn == "apply") {
302 _this.window_rooview.view.renderJS(true);
306 // do nothing for gtk..
308 this.hideProjectEdit();
313 // objects (palate..)
314 this.rightpalete = new Xcls_RightPalete();
315 this.rightpalete.ref(); /// really?
316 ((Gtk.Container)(this.objectview.el.get_widget())).add(this.rightpalete.el);
317 //this.projectsettings.el.show_all();
319 stage = _this.objectview.el.get_stage();
320 stage.set_background_color( Clutter.Color.from_string("#000"));
322 /*this.projectsettings.buttonPressed.connect((btn) => {
324 _this.window_rooview.view.renderJS(true);
326 if (btn == "apply") {
327 _this.window_rooview.view.renderJS(true);
330 this.hideProjectEdit();
338 this.add_props = new Xcls_WindowAddProp();
339 this.add_props.ref(); /// really?
340 ((Gtk.Container)(this.addpropsview.el.get_widget())).add(this.add_props.el);
341 //this.projectsettings.el.show_all();
343 stage = _this.addpropsview.el.get_stage();
344 stage.set_background_color( Clutter.Color.from_string("#000"));
347 _this.add_props.select.connect( (key,type,skel, etype) => {
348 this.left_props.addProp(etype, key, skel, type);
354 this.code_editor = new Xcls_Editor();
355 this.code_editor.ref(); /// really?
356 ((Gtk.Container)(this.codeeditview.el.get_widget())).add(this.code_editor.el);
357 //this.projectsettings.el.show_all();
359 stage = _this.codeeditview.el.get_stage();
360 stage.set_background_color( Clutter.Color.from_string("#000"));
370 this.window_rooview =new Xcls_WindowRooView();
371 this.window_rooview.ref();
372 ((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_rooview.el);
373 this.window_rooview.el.show_all();
375 stage = _this.rooview.el.get_stage();
376 stage.set_background_color( Clutter.Color.from_string("#000"));
381 this.window_gladeview =new Xcls_GladeView();
382 this.window_gladeview.ref();
384 //((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_gladeview.el);
385 ///this.window_gladeview.el.hide();
392 this.clutterfiles = new Xcls_ClutterFiles();
393 this.clutterfiles.ref();
394 stage.add_child(this.clutterfiles.el);
395 this.clutterfiles.el.show_all();
398 this.clutterfiles.open.connect((file) => {
399 _this.project = file.project;
400 _this.showViewEditing();
401 this.left_tree.model.loadFile(file);
402 var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));
403 if (file.xtype == "Roo" ) {
404 ctr.foreach( (w) => { ctr.remove(w); });
405 ctr.add(this.window_rooview.el);
406 this.window_rooview.loadFile(file);
408 this.window_rooview.el.show_all();
410 ctr.foreach( (w) => { ctr.remove(w); });
411 ctr.add(this.window_gladeview.el);
412 this.window_gladeview.loadFile(file);
413 this.window_gladeview.el.show_all();
415 print("OPEN : " + file.name);
425 var tl = new Clutter.Timeline(6000);
426 tl.set_repeat_count(-1);
430 this.children_loaded = true;
436 'void:setTitle' : (string str) {
437 this.el.set_title(this.title + " - " + str);
440 this.left_tree =new Xcls_WindowLeftTree();
441 _this.vbox.el.pack_start(this.left_tree.el,true, true,0);
445 'void:showAddListener' : () {
449 var ae = this.left_tree.getActiveElement();
454 //this.rooview.el.hide();
455 this.add_props.el.show_all();
457 Palete.factory(this.project.xtype),
461 //this.rightpalete.show(this.project);
463 _this.addpropsview.el.save_easing_state();
465 var el = _this.rooview.el;
466 el.save_easing_state();
469 el.set_scale(0.5f,0.5f);
471 _this.addpropsview.el.set_scale(1.0f,1.0f);
475 //_this.clutterfiles.loadProject(_this.project);
477 el.restore_easing_state();
478 _this.addpropsview.el.restore_easing_state();
479 this.state = "addlistener";
481 'void:showAddProp' : () {
484 var ae = this.left_tree.getActiveElement();
492 //this.rooview.el.hide();
493 this.add_props.el.show_all();
495 Palete.factory(this.project.xtype),
500 _this.addpropsview.el.save_easing_state();
502 var el = _this.rooview.el;
503 el.save_easing_state();
506 el.set_scale(0.5f,0.5f);
508 _this.addpropsview.el.set_scale(1.0f,1.0f);
512 //_this.clutterfiles.loadProject(_this.project);
514 el.restore_easing_state();
515 _this.addpropsview.el.restore_easing_state();
516 this.state = "addprop";
518 'void:showCodeEdit' : (JsRender.Node node, string ptype, string key)
520 // this is a bit different,
521 // it's not called via a button - but triggered by the prop edit class signal.
522 // so it has to hide any other state..
532 this.hideAddListener();
539 //this.rooview.el.hide();
540 this.code_editor.el.show_all();
541 this.code_editor.show(
547 _this.codeeditview.el.save_easing_state();
549 var el = _this.rooview.el;
550 el.save_easing_state();
553 el.set_scale(0.5f,0.5f);
555 _this.codeeditview.el.set_scale(1.0f,1.0f);
559 //_this.clutterfiles.loadProject(_this.project);
561 el.restore_easing_state();
562 _this.codeeditview.el.restore_easing_state();
563 this.state = "codeedit";
565 'void:showObject' : () {
568 // what's the active node on the left hand side..
570 var n = _this.left_tree.getActiveElement();
578 //this.rooview.el.hide();
579 this.rightpalete.el.show_all();
580 this.rightpalete.load(_this.left_tree.getActiveFile().palete(), n.fqn());
583 //this.rightpalete.show(this.project);
585 _this.objectview.el.save_easing_state();
587 var el = _this.rooview.el;
588 el.save_easing_state();
591 el.set_scale(0.5f,0.5f);
593 _this.objectview.el.set_scale(1.0f,1.0f);
597 //_this.clutterfiles.loadProject(_this.project);
599 el.restore_easing_state();
600 _this.objectview.el.restore_easing_state();
601 this.state = "object";
603 'void:showProjectEdit' : () {
604 // make the browser smaller, and show the edit dialog
607 _this.projectbutton.el.hide();
608 _this.projecteditbutton.el.hide();
611 //this.rooview.el.hide();
612 this.projectsettings.el.show_all();
613 this.projectsettings.show(this.project);
614 _this.projecteditview.el.save_easing_state();
616 var el = _this.rooview.el;
617 el.save_easing_state();
620 el.set_scale(0.5f,0.5f);
622 _this.projecteditview.el.set_scale(1.0f,1.0f);
624 _this.state = "projectedit";
627 //_this.clutterfiles.loadProject(_this.project);
629 el.restore_easing_state();
630 _this.projecteditview.el.restore_easing_state();
631 // print("show view browsing");
634 'void:showViewEditing' : ( ) {
635 this.editpane.el.show();
636 // this.rooview.el.show();
637 this.left_projects.el.hide();
639 _this.projecteditbutton.el.show();
641 var el = _this.rooview.el;
642 el.save_easing_state();
645 el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
646 el.set_scale(1.0f,1.0f);
647 _this.state = "edit";
648 // _this.mainpane.el.set_position(_this.leftpane.lastWidth);
649 _this.clutterfiles.el.hide();
651 el.restore_easing_state();
653 print("show view editing");
666 pack : "pack_start,false,true,0",
673 pack : "pack_end,true,true,0",
684 pack : "pack_start,false,true,0",
705 xtype: GtkClutter.Embed,
707 size_allocate : ( alloc) => {
708 if (!_this.children_loaded) { return; }
709 //print("size_allocation %d,%d\n".printf(alloc.width, alloc.height));
711 /* _this.rooview.el.set_size(this.el.get_stage().width-50,
712 this.el.get_stage().height);
713 _this.clutterfiles.set_size(this.el.get_stage().width-50,
714 this.el.get_stage().height);
716 // this.el.set_size_request(alloc.width,alloc.height);
717 // this.el.get_stage().set_size(alloc.width,alloc.height);
718 _this.rooview.el.set_size(alloc.width-50,
723 _this.clutterfiles.set_size(alloc.width-50,
725 _this.projecteditview.el.set_size(alloc.width-50,
726 alloc.height / 2.0f);
728 _this.objectview.el.set_size((alloc.width -50)/2.0f,
731 _this.addpropsview.el.set_size((alloc.width -50)/2.0f,
734 _this.codeeditview.el.set_size((alloc.width -50)/2.0f,
739 pack : "pack_start,true,true,0",
740 init : var stage = this.el.get_stage();
741 stage.set_background_color( Clutter.Color.from_string("#000"));,
744 xtype: GtkClutter.Actor,
746 pack : "get_stage().add_child",
750 this.el.add_constraint(
751 new Clutter.AlignConstraint(
752 _this.clutterembed.el.get_stage(),
753 Clutter.AlignAxis.X_AXIS,
758 //this.el.set_position(100,100);
759 this.el.set_pivot_point(1.0f,1.0f);
761 this.el.set_size(_this.clutterembed.el.get_stage().width-50,
762 _this.clutterembed.el.get_stage().height);
767 xtype: GtkClutter.Actor,
769 pack : "get_stage().add_child",
773 this.el.add_constraint(
774 new Clutter.AlignConstraint(
775 _this.clutterembed.el.get_stage(),
776 Clutter.AlignAxis.X_AXIS,
781 this.el.fixed_x = 50.0f;
782 this.el.fixed_y = 0.0f;
783 //this.el.set_position(100,100);
784 this.el.set_pivot_point(0.0f,0.0f);
785 this.el.set_scale(0.0f,1.0f);
786 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
787 _this.clutterembed.el.get_stage().height);
792 xtype: GtkClutter.Actor,
794 pack : "get_stage().add_child",
798 this.el.add_constraint(
799 new Clutter.AlignConstraint(
800 _this.clutterembed.el.get_stage(),
801 Clutter.AlignAxis.X_AXIS,
806 this.el.fixed_x = 50.0f;
807 this.el.fixed_y = 0.0f;
808 //this.el.set_position(100,100);
809 this.el.set_pivot_point(0.0f,0.0f);
810 this.el.set_scale(0.0f,1.0f);
811 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
812 _this.clutterembed.el.get_stage().height);
817 xtype: GtkClutter.Actor,
819 pack : "get_stage().add_child",
823 this.el.add_constraint(
824 new Clutter.AlignConstraint(
825 _this.clutterembed.el.get_stage(),
826 Clutter.AlignAxis.X_AXIS,
831 this.el.fixed_x = 50.0f;
832 this.el.fixed_y = 0.0f;
833 //this.el.set_position(100,100);
834 this.el.set_pivot_point(0.0f,0.0f);
835 this.el.set_scale(0.0f,1.0f);
836 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
837 _this.clutterembed.el.get_stage().height);
842 xtype: GtkClutter.Actor,
843 id : "projecteditview",
844 pack : "get_stage().add_child",
848 this.el.add_constraint(
849 new Clutter.AlignConstraint(
850 _this.clutterembed.el.get_stage(),
851 Clutter.AlignAxis.X_AXIS,
856 //this.el.set_position(100,100);
857 this.el.set_pivot_point(0.0f,0.0f);
858 this.el.set_scale(1.0f,0.0f);
859 this.el.set_size(_this.clutterembed.el.get_stage().width-50,
860 _this.clutterembed.el.get_stage().height /2);
865 xtype: Clutter.Actor,
867 pack : "get_stage().add_child",
870 this.el.add_constraint(
871 new Clutter.AlignConstraint(
872 _this.clutterembed.el.get_stage(),
873 Clutter.AlignAxis.X_AXIS,
879 //this.el.set_position(100,100);
880 this.el.set_pivot_point(0.5f,0.5f);
882 _this.clutterembed.el.get_stage().height);
887 xtype: Clutter.Actor,
889 enter_event : ( event) => {
890 this.el.background_color = new Clutter.Color.from_string("#333");
893 leave_event : ( event) => {
894 this.el.background_color = new Clutter.Color.from_string("#000");
897 button_press_event : ( ) => {
898 switch (_this.state) {
901 _this.hideViewEditing();
904 _this.showViewEditing();
909 _this.hideViewEditing();
912 _this.hideAddListener();
913 _this.hideViewEditing();
918 _this.hideViewEditing();
928 id : "projectbutton",
930 init : this.el.set_size(50,50);,
936 line_alignment : Pango.Alignment.CENTER,
937 x_align : Clutter.ActorAlign.CENTER,
939 y_align : Clutter.ActorAlign.CENTER,
945 xtype: Clutter.Actor,
947 enter_event : ( event) => {
948 this.el.background_color = new Clutter.Color.from_string("#333");
951 leave_event : ( event) => {
952 this.el.background_color = new Clutter.Color.from_string("#000");
955 button_press_event : ( ) => {
956 switch (_this.state) {
958 _this.showProjectEdit();
961 // _this.showViewEditing();
964 _this.hideProjectEdit();
971 _this.showProjectEdit();
974 _this.hideAddListener();
975 _this.showProjectEdit();
980 _this.showProjectEdit();
990 id : "projecteditbutton",
992 init : this.el.set_size(50,50);,
997 line_alignment : Pango.Alignment.CENTER,
999 x_align : Clutter.ActorAlign.CENTER,
1001 y_align : Clutter.ActorAlign.CENTER,
1007 xtype: Clutter.Actor,
1009 enter_event : ( event) => {
1010 this.el.background_color = new Clutter.Color.from_string("#333");
1013 leave_event : ( event) => {
1014 this.el.background_color = new Clutter.Color.from_string("#000");
1017 button_press_event : ( ) => {
1021 switch (_this.state) {
1025 _this.hideAddProp();
1029 _this.hideAddListener();
1045 print("unhandled add objects from %s\n",_this.state);
1053 id : "objectshowbutton",
1055 init : this.el.set_size(50,50);,
1059 xtype: Clutter.Text,
1061 line_alignment : Pango.Alignment.CENTER,
1062 x_align : Clutter.ActorAlign.CENTER,
1064 y_align : Clutter.ActorAlign.CENTER,
1070 xtype: Clutter.Actor,
1072 enter_event : ( event) => {
1073 this.el.background_color = new Clutter.Color.from_string("#333");
1076 leave_event : ( event) => {
1077 this.el.background_color = new Clutter.Color.from_string("#000");
1080 button_press_event : ( ) => {
1084 switch (_this.state) {
1086 _this.showAddProp();
1091 _this.showAddProp();
1095 _this.hideAddListener();
1096 _this.showAddProp();
1101 _this.hideAddProp();
1105 print("unhandled add property from %s\n",_this.state);
1114 id : "addpropbutton",
1116 init : this.el.set_size(50,50);,
1120 xtype: Clutter.Text,
1122 line_alignment : Pango.Alignment.CENTER,
1123 x_align : Clutter.ActorAlign.CENTER,
1125 y_align : Clutter.ActorAlign.CENTER,
1131 xtype: Clutter.Actor,
1133 enter_event : ( event) => {
1134 this.el.background_color = new Clutter.Color.from_string("#333");
1137 leave_event : ( event) => {
1138 this.el.background_color = new Clutter.Color.from_string("#000");
1141 button_press_event : ( ) => {
1145 switch (_this.state) {
1147 _this.showAddListener();
1152 _this.hideAddListener();
1157 _this.hideAddProp();
1158 _this.showAddListener();
1162 _this.showAddListener();
1166 print("unhandled add listener from %s\n",_this.state);
1176 id : "addlistenerbutton",
1178 init : this.el.set_size(50,50);,
1182 xtype: Clutter.Text,
1184 line_alignment : Pango.Alignment.CENTER,
1185 x_align : Clutter.ActorAlign.CENTER,
1187 y_align : Clutter.ActorAlign.CENTER,
1194 xtype: Clutter.BoxLayout,
1195 orientation : Clutter.Orientation.VERTICAL
1209 XObject.cache['/MainWindow'] = MainWindow;