7a54c02359effbcf78956c41d1cd986a007cd232
[app.Builder.js] / ClutterTest / Window.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 GtkClutter = imports.gi.GtkClutter;
11 console = imports.console;
12 XObject = imports.XObject.XObject;
13 Window=new XObject({
14     xtype: Gtk.Window,
15     default_height : 900,
16     default_width : 900,
17     init : function() {
18         XObject.prototype.init.call(this);
19         this.el.show_all();
20     },
21     items : [
22         {
23             xtype: GtkClutter.Embed,
24             listeners : {
25                 show : function() { 
26                    var stage = this.el.get_stage(); 
27                    print(this.items.length);
28                    this.items.forEach( 
29                       function(e) { 
30                           print(e.xtype);
31                           stage.add_actor(e.el);
32                         }
33                      );
34                 }
35             },
36             pack : "add",
37             items : [
38                 {
39                     xtype: GtkClutter.Actor,
40                     pack : false,
41                     x : 10,
42                     y : 10,
43                     init : function() {
44                     
45                         var child = new XObject(this.items[0]);
46                         child.init();
47                         child.parent = this;
48                         //var contents = new Gtk.Button({ label: 'test' }); 
49                         var contents = child.el;
50                        
51                         print(JSON.stringify(this.items));
52                         
53                         
54                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
55                         XObject.prototype.init.call(this);
56                     },
57                     items : [
58                         {
59                             xtype: Gtk.Button,
60                             listeners : {
61                                 clicked : function (self) {
62                                    Clutter = imports.gi.Clutter;
63                                         var animate = this.parent.el.animate(
64                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
65                                                 {
66                                                            scale_x : 5,
67                                                           scale_y: 5,
68                                 
69                                                 }
70                                                 );
71                                                 animate.timeline.start();
72                                 
73                                 }
74                             },
75                             height_request : 100,
76                             label : "project list",
77                             pack : false,
78                             width_request : 100
79                         }
80                     ]
81                 },
82                 {
83                     xtype: GtkClutter.Actor,
84                     pack : false,
85                     x : 10,
86                     y : 150,
87                     init : function() {
88                     
89                         var child = new XObject(this.items[0]);
90                         child.init();
91                         child.parent = this;
92                         //var contents = new Gtk.Button({ label: 'test' }); 
93                         var contents = child.el;
94                         print ("actor.items");
95                         print(JSON.stringify(this.items));
96                         
97                         
98                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
99                         XObject.prototype.init.call(this);
100                     },
101                     items : [
102                         {
103                             xtype: Gtk.Button,
104                             listeners : {
105                                 clicked : function (self) {
106                                    Clutter = imports.gi.Clutter;
107                                         var animate = this.parent.el.animate(
108                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
109                                                 {
110                                                            scale_x : 5,
111                                                           scale_y: 5,
112                                 
113                                                 }
114                                                 );
115                                                 animate.timeline.start();
116                                 
117                                 }
118                             },
119                             height_request : 100,
120                             label : "file list",
121                             pack : false,
122                             width_request : 100
123                         }
124                     ]
125                 },
126                 {
127                     xtype: GtkClutter.Actor,
128                     pack : false,
129                     x : 10,
130                     y : 300,
131                     init : function() {
132                     
133                         var child = new XObject(this.items[0]);
134                         child.init();
135                         child.parent = this;
136                         //var contents = new Gtk.Button({ label: 'test' }); 
137                         var contents = child.el;
138                        
139                         print(JSON.stringify(this.items));
140                         
141                         
142                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
143                         XObject.prototype.init.call(this);
144                     },
145                     items : [
146                         {
147                             xtype: Gtk.Button,
148                             listeners : {
149                                 clicked : function (self) {
150                                    Clutter = imports.gi.Clutter;
151                                         var animate = this.parent.el.animate(
152                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
153                                                 {
154                                                            scale_x : 5,
155                                                           scale_y: 5,
156                                 
157                                                 }
158                                                 );
159                                                 animate.timeline.start();
160                                 
161                                 }
162                             },
163                             height_request : 100,
164                             label : "tree of parts",
165                             pack : false,
166                             width_request : 100
167                         }
168                     ]
169                 },
170                 {
171                     xtype: GtkClutter.Actor,
172                     pack : false,
173                     x : 10,
174                     y : 450,
175                     init : function() {
176                     
177                         var child = new XObject(this.items[0]);
178                         child.init();
179                         child.parent = this;
180                         //var contents = new Gtk.Button({ label: 'test' }); 
181                         var contents = child.el;
182                        
183                         print(JSON.stringify(this.items));
184                         
185                         
186                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
187                         XObject.prototype.init.call(this);
188                     },
189                     items : [
190                         {
191                             xtype: Gtk.Button,
192                             listeners : {
193                                 clicked : function (self) {
194                                    Clutter = imports.gi.Clutter;
195                                         var animate = this.parent.el.animate(
196                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
197                                                 {
198                                                            scale_x : 5,
199                                                           scale_y: 5,
200                                 
201                                                 }
202                                                 );
203                                                 animate.timeline.start();
204                                 
205                                 }
206                             },
207                             height_request : 100,
208                             label : "property editor",
209                             pack : false,
210                             width_request : 100
211                         }
212                     ]
213                 },
214                 {
215                     xtype: GtkClutter.Actor,
216                     pack : false,
217                     x : 150,
218                     y : 450,
219                     init : function() {
220                     
221                         var child = new XObject(this.items[0]);
222                         child.init();
223                         child.parent = this;
224                         //var contents = new Gtk.Button({ label: 'test' }); 
225                         var contents = child.el;
226                        
227                         print(JSON.stringify(this.items));
228                         
229                         
230                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
231                         XObject.prototype.init.call(this);
232                     },
233                     items : [
234                         {
235                             xtype: Gtk.Button,
236                             listeners : {
237                                 clicked : function (self) {
238                                    Clutter = imports.gi.Clutter;
239                                         var animate = this.parent.el.animate(
240                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
241                                                 {
242                                                            scale_x : 5,
243                                                           scale_y: 5,
244                                 
245                                                 }
246                                                 );
247                                                 animate.timeline.start();
248                                 
249                                 }
250                             },
251                             height_request : 100,
252                             label : "text editor",
253                             pack : false,
254                             width_request : 100
255                         }
256                     ]
257                 },
258                 {
259                     xtype: GtkClutter.Actor,
260                     pack : false,
261                     x : 150,
262                     y : 10,
263                     init : function() {
264                     
265                         var child = new XObject(this.items[0]);
266                         child.init();
267                         child.parent = this;
268                         //var contents = new Gtk.Button({ label: 'test' }); 
269                         var contents = child.el;
270                        
271                         print(JSON.stringify(this.items));
272                         
273                         
274                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
275                         XObject.prototype.init.call(this);
276                     },
277                     items : [
278                         {
279                             xtype: Gtk.Button,
280                             listeners : {
281                                 clicked : function (self) {
282                                    Clutter = imports.gi.Clutter;
283                                         var animate = this.parent.el.animate(
284                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
285                                                 {
286                                                            scale_x : 5,
287                                                           scale_y: 5,
288                                 
289                                                 }
290                                                 );
291                                                 animate.timeline.start();
292                                 
293                                 }
294                             },
295                             height_request : 100,
296                             label : "preview app",
297                             pack : false,
298                             width_request : 100
299                         }
300                     ]
301                 },
302                 {
303                     xtype: GtkClutter.Actor,
304                     pack : false,
305                     x : 100,
306                     y : 300,
307                     init : function() {
308                     
309                         var child = new XObject(this.items[0]);
310                         child.init();
311                         child.parent = this;
312                         //var contents = new Gtk.Button({ label: 'test' }); 
313                         var contents = child.el;
314                        
315                         print(JSON.stringify(this.items));
316                         
317                         
318                         this.el = new GtkClutter.Actor.with_contents (  contents) ;
319                         XObject.prototype.init.call(this);
320                     },
321                     items : [
322                         {
323                             xtype: Gtk.Button,
324                             listeners : {
325                                 clicked : function (self) {
326                                    Clutter = imports.gi.Clutter;
327                                         var animate = this.parent.el.animate(
328                                                 Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,
329                                                 {
330                                                            scale_x : 5,
331                                                           scale_y: 5,
332                                 
333                                                 }
334                                                 );
335                                                 animate.timeline.start();
336                                 
337                                 }
338                             },
339                             height_request : 100,
340                             label : "palete",
341                             pack : false,
342                             width_request : 100
343                         }
344                     ]
345                 }
346             ]
347         }
348     ]
349 });
350 Window.init();
351 XObject.cache['/Window'] = Window;