From: Alan Knowles Date: Tue, 22 Jun 2010 11:15:21 +0000 (+0800) Subject: ClutterTest X-Git-Url: http://git.roojs.org/?p=app.Builder.js;a=commitdiff_plain;h=32f084a023702de82cc536815614efbf512330a3 ClutterTest --- diff --git a/ClutterTest/Window.bjs b/ClutterTest/Window.bjs new file mode 100644 index 000000000..89fe19fb5 --- /dev/null +++ b/ClutterTest/Window.bjs @@ -0,0 +1,70 @@ +{ + "id": "file-gtk-11", + "name": "Window", + "parent": "", + "title": false, + "path": "/home/alan/cluttertest/Window.bjs", + "items": [ + { + "default_height": 600, + "default_width": 600, + "xtype": "Window", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.show_all();\n}\n", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "show": "function() { \n var stage = this.el.get_stage(); \n print(this.items.length);\n this.items.forEach( \n function(e) { \n print(e.xtype);\n stage.add_actor(e.el);\n }\n );\n}" + }, + "pack": "add", + "xtype": "Embed", + "|xns": "GtkClutter", + "items": [ + { + "pack": false, + "x": 100, + "xtype": "Actor", + "y": 100, + "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", + "|xns": "GtkClutter", + "items": [ + { + "listeners": { + "clicked": "function (self) {\n Clutter = imports.gi.Clutter;\n var animate = this.parent.el.animate(\n\t\tClutter.AnimationMode.EASE_OUT_ELASTIC, 2000,\n\t\t{\n\t\t\t scale_x : 5,\n\t\t\t scale_y: 5,\n\n\t\t}\n\t\t);\n\t\tanimate.timeline.start();\n\n}" + }, + "height_request": 100, + "label": "test", + "pack": false, + "width_request": 100, + "xtype": "Button", + "|xns": "Gtk" + } + ] + }, + { + "pack": false, + "x": 300, + "xtype": "Actor", + "y": 100, + "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n print (\"actor.items\");\n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", + "|xns": "GtkClutter", + "items": [ + { + "listeners": { + "clicked": "function (self) {\n Clutter = imports.gi.Clutter;\n var animate = this.parent.el.animate(\n\t\tClutter.AnimationMode.EASE_OUT_ELASTIC, 2000,\n\t\t{\n\t\t\t scale_x : 5,\n\t\t\t scale_y: 5,\n\n\t\t}\n\t\t);\n\t\tanimate.timeline.start();\n\n}" + }, + "height_request": 100, + "label": "test", + "pack": false, + "width_request": 100, + "xtype": "Button", + "|xns": "Gtk" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ClutterTest/Window.js b/ClutterTest/Window.js new file mode 100644 index 000000000..820f409e8 --- /dev/null +++ b/ClutterTest/Window.js @@ -0,0 +1,131 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +GtkClutter = imports.gi.GtkClutter; +console = imports.console; +XObject = imports.XObject.XObject; +Window=new XObject({ + xtype: Gtk.Window, + default_height : 600, + default_width : 600, + init : function() { + XObject.prototype.init.call(this); + this.el.show_all(); + }, + items : [ + { + xtype: GtkClutter.Embed, + listeners : { + show : function() { + var stage = this.el.get_stage(); + print(this.items.length); + this.items.forEach( + function(e) { + print(e.xtype); + stage.add_actor(e.el); + } + ); + } + }, + pack : "add", + items : [ + { + xtype: GtkClutter.Actor, + pack : false, + x : 100, + y : 100, + init : function() { + + var child = new XObject(this.items[0]); + child.init(); + child.parent = this; + //var contents = new Gtk.Button({ label: 'test' }); + var contents = child.el; + + print(JSON.stringify(this.items)); + + + this.el = new GtkClutter.Actor.with_contents ( contents) ; + XObject.prototype.init.call(this); + }, + items : [ + { + xtype: Gtk.Button, + listeners : { + clicked : function (self) { + Clutter = imports.gi.Clutter; + var animate = this.parent.el.animate( + Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000, + { + scale_x : 5, + scale_y: 5, + + } + ); + animate.timeline.start(); + + } + }, + height_request : 100, + label : "test", + pack : false, + width_request : 100 + } + ] + }, + { + xtype: GtkClutter.Actor, + pack : false, + x : 300, + y : 100, + init : function() { + + var child = new XObject(this.items[0]); + child.init(); + child.parent = this; + //var contents = new Gtk.Button({ label: 'test' }); + var contents = child.el; + print ("actor.items"); + print(JSON.stringify(this.items)); + + + this.el = new GtkClutter.Actor.with_contents ( contents) ; + XObject.prototype.init.call(this); + }, + items : [ + { + xtype: Gtk.Button, + listeners : { + clicked : function (self) { + Clutter = imports.gi.Clutter; + var animate = this.parent.el.animate( + Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000, + { + scale_x : 5, + scale_y: 5, + + } + ); + animate.timeline.start(); + + } + }, + height_request : 100, + label : "test", + pack : false, + width_request : 100 + } + ] + } + ] + } + ] +}); +Window.init(); +XObject.cache['/Window'] = Window; diff --git a/roojs1 b/roojs1 index e6f019d15..cb5ee27f1 160000 --- a/roojs1 +++ b/roojs1 @@ -1 +1 @@ -Subproject commit e6f019d1535671672e34eb6a46fa31b9a98fedb2 +Subproject commit cb5ee27f164e32ed59a801c560c417db2c461668