clutter-gtk 2.0.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +74 -0
- data/lib/clutter-gtk.rb +65 -0
- data/sample/events.rb +178 -0
- data/sample/multistage.rb +176 -0
- data/sample/redhand.png +0 -0
- data/sample/test-actor.rb +165 -0
- data/sample/test-scroll.rb +176 -0
- data/sample/test.rb +171 -0
- data/sample/window-test.rb +115 -0
- data/sample/window-test2.rb +134 -0
- data/test/clutter-gtk-test-utils.rb +21 -0
- data/test/run-test.rb +50 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/clutter-gtk.h +17 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-actor.h +87 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-embed.h +94 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-texture.h +115 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-util.h +46 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-version.h +111 -0
- data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-window.h +90 -0
- data/vendor/local/lib/girepository-1.0/GtkClutter-1.0.typelib +0 -0
- data/vendor/local/lib/libclutter-gtk-1.0.a +0 -0
- data/vendor/local/lib/libclutter-gtk-1.0.la +41 -0
- data/vendor/local/lib/pkgconfig/clutter-gtk-1.0.pc +13 -0
- data/vendor/local/share/gir-1.0/GtkClutter-1.0.gir +669 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/GtkClutterActor.html +275 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/GtkClutterEmbed.html +272 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/GtkClutterWindow.html +170 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/annotation-glossary.html +58 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ch01.html +36 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ch02.html +42 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ch03.html +34 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/clutter-gtk-1.0-Utility-Functions.html +257 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/clutter-gtk-1.0.devhelp2 +50 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-glossary.html +35 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-object-hierarchy.html +45 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-object-index.html +60 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-objects.html +38 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/home.png +0 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/index.html +82 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/index.sgml +53 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix01.html +100 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix02.html +203 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix03.html +71 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix04.html +32 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/left.png +0 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/license.html +59 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/right.png +0 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/style.css +266 -0
- data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/up.png +0 -0
- data/vendor/local/share/license/clutter-gtk/COPYING +504 -0
- data/vendor/local/share/locale/ja/LC_MESSAGES/cluttergtk-1.0.mo +0 -0
- data/vendor/local/share/locale/pl/LC_MESSAGES/cluttergtk-1.0.mo +0 -0
- data/vendor/local/share/locale/zh_CN/LC_MESSAGES/cluttergtk-1.0.mo +0 -0
- metadata +145 -0
data/sample/redhand.png
ADDED
Binary file
|
@@ -0,0 +1,165 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This sample code is a port of clutter-gtk/examples/gtk-clutter-test-actor.c.
|
4
|
+
# It is licensed under the terms of the GNU Lesser General Public
|
5
|
+
# License, version 2.1 or (at your option) later.
|
6
|
+
#
|
7
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
8
|
+
#
|
9
|
+
# This library is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU Lesser General Public
|
11
|
+
# License as published by the Free Software Foundation; either
|
12
|
+
# version 2.1 of the License, or (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU Lesser General Public
|
20
|
+
# License along with this library; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
|
23
|
+
require "clutter-gtk"
|
24
|
+
|
25
|
+
ClutterGtk.init
|
26
|
+
|
27
|
+
MAX_N_WIDGETS = 4
|
28
|
+
WINDOW_WIDTH = 400
|
29
|
+
WINDOW_HEIGHT = 400
|
30
|
+
RADIUS = 80
|
31
|
+
|
32
|
+
do_rotate_p = true
|
33
|
+
|
34
|
+
window = Gtk::Window.new
|
35
|
+
window.signal_connect("destroy") do
|
36
|
+
Gtk.main_quit
|
37
|
+
end
|
38
|
+
|
39
|
+
vbox = Gtk::Box.new(:vertical, 6)
|
40
|
+
window.add(vbox)
|
41
|
+
|
42
|
+
clutter = ClutterGtk::Embed.new
|
43
|
+
clutter.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)
|
44
|
+
|
45
|
+
vbox.pack_start(clutter, :expand => true, :fill => true, :padding => 0)
|
46
|
+
|
47
|
+
stage = clutter.stage
|
48
|
+
|
49
|
+
button = Gtk::Button.new(:stock_id => Gtk::Stock::QUIT)
|
50
|
+
button.signal_connect("clicked") do |_button|
|
51
|
+
window.destroy
|
52
|
+
end
|
53
|
+
vbox.pack_end(button, :expand => false, :fill => false, :padding => 0)
|
54
|
+
|
55
|
+
stage.background_color = Clutter::Color.new(0x61, 0x64, 0x8c, 0xff)
|
56
|
+
|
57
|
+
widgets = []
|
58
|
+
|
59
|
+
# create a new group to hold multiple actors in a group
|
60
|
+
group = Clutter::Actor.new
|
61
|
+
|
62
|
+
create_gtk_actor = lambda do
|
63
|
+
gtk_actor = ClutterGtk::Actor.new
|
64
|
+
bin = gtk_actor.widget
|
65
|
+
|
66
|
+
vbox = Gtk::Box.new(:vertical, 6)
|
67
|
+
bin.add(vbox)
|
68
|
+
|
69
|
+
button = Gtk::Button.new(:label => "A Button")
|
70
|
+
vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
71
|
+
|
72
|
+
button.signal_connect("clicked") do |_button|
|
73
|
+
puts("button clicked")
|
74
|
+
label = Gtk::Label.new("A new label")
|
75
|
+
label.show
|
76
|
+
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
77
|
+
end
|
78
|
+
|
79
|
+
button = Gtk::CheckButton.new("Another button")
|
80
|
+
vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
81
|
+
|
82
|
+
entry = Gtk::Entry.new
|
83
|
+
vbox.pack_start(entry, :expand => false, :fill => false, :padding => 0)
|
84
|
+
|
85
|
+
bin.show_all
|
86
|
+
|
87
|
+
gtk_actor
|
88
|
+
end
|
89
|
+
|
90
|
+
add_clutter_actor = lambda do |actor, container, i|
|
91
|
+
container.add_child(actor)
|
92
|
+
|
93
|
+
# Place around a circle
|
94
|
+
w = widgets.first.width
|
95
|
+
h = widgets.first.height
|
96
|
+
|
97
|
+
x = WINDOW_WIDTH / 2 +
|
98
|
+
RADIUS * Math.cos(i * 2 * Math::PI / (MAX_N_WIDGETS)) - w / 2
|
99
|
+
y = WINDOW_HEIGHT / 2 +
|
100
|
+
RADIUS * Math.sin(i * 2 * Math::PI / (MAX_N_WIDGETS)) - h / 2
|
101
|
+
|
102
|
+
actor.set_position(x, y)
|
103
|
+
end
|
104
|
+
|
105
|
+
MAX_N_WIDGETS.times do |i|
|
106
|
+
widget = create_gtk_actor.call
|
107
|
+
widgets[i] = widget
|
108
|
+
add_clutter_actor.call(widget, group, i)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Add the group to the stage and center it
|
112
|
+
stage.add_child(group)
|
113
|
+
group.add_constraint(Clutter::AlignConstraint.new(stage, :x_axis, 0.5))
|
114
|
+
group.add_constraint(Clutter::AlignConstraint.new(stage, :y_axis, 0.5))
|
115
|
+
|
116
|
+
window.show_all
|
117
|
+
|
118
|
+
# Create a timeline to manage animation
|
119
|
+
timeline = Clutter::Timeline.new(6000)
|
120
|
+
timeline.repeat_count = -1
|
121
|
+
|
122
|
+
# fire a callback for frame change
|
123
|
+
timeline.signal_connect("new-frame") do |_timeline, m_secs|
|
124
|
+
rotation = _timeline.progress * 360.0
|
125
|
+
if do_rotate_p
|
126
|
+
# Rotate everything clockwise about stage center
|
127
|
+
group.set_rotation(:z_axis,
|
128
|
+
rotation,
|
129
|
+
WINDOW_WIDTH / 2,
|
130
|
+
WINDOW_HEIGHT / 2,
|
131
|
+
0)
|
132
|
+
|
133
|
+
widgets.each do |widget|
|
134
|
+
# rotate each widget around its center
|
135
|
+
w = widget.width
|
136
|
+
h = widget.height
|
137
|
+
|
138
|
+
widget.set_rotation(:z_axis,
|
139
|
+
-(2 * rotation),
|
140
|
+
w / 2,
|
141
|
+
h / 2,
|
142
|
+
0)
|
143
|
+
widget.opacity = 50 * Math.sin(2 * Math::PI * rotation / 360) + (255 - 50)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# and start it
|
149
|
+
timeline.start
|
150
|
+
|
151
|
+
GLib::Timeout.add_seconds(3) do
|
152
|
+
if MAX_N_WIDGETS == widgets.size
|
153
|
+
# Removing an item
|
154
|
+
group.remove_child(widgets.pop)
|
155
|
+
else
|
156
|
+
# Adding an item
|
157
|
+
widget = create_gtk_actor.call
|
158
|
+
widgets << widget
|
159
|
+
add_clutter_actor.call(widget, group, MAX_N_WIDGETS - 1)
|
160
|
+
end
|
161
|
+
keep_callback = true
|
162
|
+
keep_callback
|
163
|
+
end
|
164
|
+
|
165
|
+
Gtk.main
|
@@ -0,0 +1,176 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This sample code is a port of clutter-gtk/examples/gtk-clutter-test-scroll.c.
|
4
|
+
# It is licensed under the terms of the GNU Lesser General Public
|
5
|
+
# License, version 2.1 or (at your option) later.
|
6
|
+
#
|
7
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
8
|
+
#
|
9
|
+
# This library is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU Lesser General Public
|
11
|
+
# License as published by the Free Software Foundation; either
|
12
|
+
# version 2.1 of the License, or (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU Lesser General Public
|
20
|
+
# License along with this library; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
+
|
23
|
+
require "clutter-gtk"
|
24
|
+
|
25
|
+
ClutterGtk.init
|
26
|
+
|
27
|
+
N_WIDGETS = 5
|
28
|
+
WINDOW_WIDTH = 400
|
29
|
+
WINDOW_HEIGHT = 400
|
30
|
+
RADIUS = 80
|
31
|
+
|
32
|
+
do_rotate_p = true
|
33
|
+
|
34
|
+
window = Gtk::Window.new
|
35
|
+
window.signal_connect("destroy") do
|
36
|
+
Gtk.main_quit
|
37
|
+
end
|
38
|
+
|
39
|
+
vbox = Gtk::Box.new(:vertical, 6)
|
40
|
+
window.add(vbox)
|
41
|
+
|
42
|
+
clutter = ClutterGtk::Embed.new
|
43
|
+
clutter.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)
|
44
|
+
|
45
|
+
vbox.add(clutter)
|
46
|
+
|
47
|
+
stage = clutter.stage
|
48
|
+
|
49
|
+
button = Gtk::Button.new(:stock_id => Gtk::Stock::QUIT)
|
50
|
+
button.signal_connect("clicked") do |_button|
|
51
|
+
window.destroy
|
52
|
+
end
|
53
|
+
vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
54
|
+
|
55
|
+
# and its background color
|
56
|
+
stage.background_color = Clutter::Color.new(0x61, 0x64, 0x8c, 0xff)
|
57
|
+
|
58
|
+
widgets = []
|
59
|
+
|
60
|
+
# create a new group to hold multiple actors in a group
|
61
|
+
group = Clutter::Group.new
|
62
|
+
|
63
|
+
create_gtk_actor = lambda do
|
64
|
+
gtk_actor = ClutterGtk::Actor.new
|
65
|
+
bin = gtk_actor.widget
|
66
|
+
|
67
|
+
scroll = Gtk::ScrolledWindow.new
|
68
|
+
scroll.set_policy(:never, :automatic)
|
69
|
+
bin.add(scroll)
|
70
|
+
|
71
|
+
vbox = Gtk::Box.new(:vertical, 6)
|
72
|
+
scroll.add_with_viewport(vbox)
|
73
|
+
|
74
|
+
button = Gtk::Button.new(:label => "A Button")
|
75
|
+
vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
76
|
+
|
77
|
+
button.signal_connect("clicked") do |_button|
|
78
|
+
puts("button clicked")
|
79
|
+
label = Gtk::Label.new("A new label")
|
80
|
+
label.show
|
81
|
+
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
82
|
+
end
|
83
|
+
|
84
|
+
6.times do |i|
|
85
|
+
button = Gtk::CheckButton.new("Another button")
|
86
|
+
vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
87
|
+
end
|
88
|
+
|
89
|
+
entry = Gtk::Entry.new
|
90
|
+
vbox.pack_start(entry, :expand => false, :fill => false, :padding => 0)
|
91
|
+
|
92
|
+
bin.show_all
|
93
|
+
|
94
|
+
gtk_actor
|
95
|
+
end
|
96
|
+
|
97
|
+
N_WIDGETS.times do |i|
|
98
|
+
widget = create_gtk_actor.call
|
99
|
+
widgets[i] = widget
|
100
|
+
|
101
|
+
# Place around a circle
|
102
|
+
w = widgets.first.width
|
103
|
+
h = widgets.first.height
|
104
|
+
|
105
|
+
x = WINDOW_WIDTH / 2 +
|
106
|
+
RADIUS * Math.cos(i * 2 * Math::PI / (N_WIDGETS)) - w / 2
|
107
|
+
y = WINDOW_HEIGHT / 2 +
|
108
|
+
RADIUS * Math.sin(i * 2 * Math::PI / (N_WIDGETS)) - h / 2
|
109
|
+
|
110
|
+
widget.set_position(x, y)
|
111
|
+
|
112
|
+
# Add to our group group
|
113
|
+
group.add_actor(widget)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Add the group to the stage
|
117
|
+
stage.add_actor(group)
|
118
|
+
stage.signal_connect("button-press-event") do |_stage, event|
|
119
|
+
x, y = event.coords
|
120
|
+
|
121
|
+
actor = _stage.get_actor_at_pos(:all, x, y)
|
122
|
+
puts("click at #{x}, #{y} -> #{actor.gtype.name}:#{actor}")
|
123
|
+
if !actor.is_a?(Clutter::Stage) and !actor.is_a?(Clutter::Group)
|
124
|
+
actor.hide
|
125
|
+
end
|
126
|
+
end
|
127
|
+
stage.signal_connect("key-release-event") do |_sage, event|
|
128
|
+
unichar = [event.key_unicode].pack("U*")
|
129
|
+
puts("*** key press event (key:#{unichar}) ***")
|
130
|
+
|
131
|
+
if event.key_symbol == Clutter::Keys::KEY_q
|
132
|
+
Gtk.main_quit
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
window.show_all
|
137
|
+
|
138
|
+
# Only show the actors after parent show otherwise it will just be
|
139
|
+
# unrealized when the clutter foreign window is set. widget_show
|
140
|
+
# will call show on the stage.
|
141
|
+
group.show_all
|
142
|
+
|
143
|
+
# Create a timeline to manage animation
|
144
|
+
timeline = Clutter::Timeline.new(6000)
|
145
|
+
timeline.loop = true
|
146
|
+
|
147
|
+
# fire a callback for frame change
|
148
|
+
timeline.signal_connect("new-frame") do |_timeline, m_secs|
|
149
|
+
rotation = _timeline.progress * 360.0
|
150
|
+
if do_rotate_p
|
151
|
+
# Rotate everything clockwise about stage center
|
152
|
+
group.set_rotation(:z_axis,
|
153
|
+
rotation,
|
154
|
+
WINDOW_WIDTH / 2,
|
155
|
+
WINDOW_HEIGHT / 2,
|
156
|
+
0)
|
157
|
+
|
158
|
+
widgets.each do |widget|
|
159
|
+
# rotate each widget around its center
|
160
|
+
w = widget.width
|
161
|
+
h = widget.height
|
162
|
+
|
163
|
+
widget.set_rotation(:z_axis,
|
164
|
+
-(2 * rotation),
|
165
|
+
w / 2,
|
166
|
+
h / 2,
|
167
|
+
0)
|
168
|
+
widget.opacity = 50 * Math.sin(2 * Math::PI * rotation / 360) + (255 - 50)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# and start it
|
174
|
+
timeline.start
|
175
|
+
|
176
|
+
Gtk.main
|
data/sample/test.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This sample code is a port of
|
4
|
+
# clutter-gtk/examples/gtk-clutter-test.c. The image file used in
|
5
|
+
# this sample code is copied from
|
6
|
+
# clutter-gtk/examples/redhand.png. They are licensed under the terms
|
7
|
+
# of the GNU Lesser General Public License, version 2.1 or (at your
|
8
|
+
# option) later.
|
9
|
+
#
|
10
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
11
|
+
#
|
12
|
+
# This library is free software; you can redistribute it and/or
|
13
|
+
# modify it under the terms of the GNU Lesser General Public
|
14
|
+
# License as published by the Free Software Foundation; either
|
15
|
+
# version 2.1 of the License, or (at your option) any later version.
|
16
|
+
#
|
17
|
+
# This library is distributed in the hope that it will be useful,
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20
|
+
# Lesser General Public License for more details.
|
21
|
+
#
|
22
|
+
# You should have received a copy of the GNU Lesser General Public
|
23
|
+
# License along with this library; if not, write to the Free Software
|
24
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
25
|
+
|
26
|
+
require "clutter-gtk"
|
27
|
+
require "gdk_pixbuf2"
|
28
|
+
|
29
|
+
ClutterGtk.init
|
30
|
+
|
31
|
+
N_HANDS = 4
|
32
|
+
WINDOW_WIDTH = 400
|
33
|
+
WINDOW_HEIGHT = 400
|
34
|
+
RADIUS = 150
|
35
|
+
|
36
|
+
fade_p = false
|
37
|
+
fullscreen_p = false
|
38
|
+
|
39
|
+
pixbuf = Gdk::Pixbuf.new(File.expand_path("redhand.png", File.dirname(__FILE__)))
|
40
|
+
|
41
|
+
window = Gtk::Window.new
|
42
|
+
window.set_default_size(WINDOW_WIDTH, WINDOW_HEIGHT)
|
43
|
+
window.title = "Clutter Embedding"
|
44
|
+
window.signal_connect("destroy") do
|
45
|
+
Gtk.main_quit
|
46
|
+
end
|
47
|
+
|
48
|
+
vbox = Gtk::Grid.new
|
49
|
+
vbox.orientation = :vertical
|
50
|
+
vbox.hexpand = true
|
51
|
+
vbox.vexpand = true
|
52
|
+
window.add(vbox)
|
53
|
+
|
54
|
+
clutter = ClutterGtk::Embed.new
|
55
|
+
vbox.add(clutter)
|
56
|
+
|
57
|
+
stage = clutter.stage
|
58
|
+
stage.background_color = Clutter::Color.new(:sky_blue_light)
|
59
|
+
|
60
|
+
label = Gtk::Label.new("This is a label")
|
61
|
+
vbox.add(label)
|
62
|
+
label.hexpand = true
|
63
|
+
|
64
|
+
button = Gtk::Button.new(:label => "This is a button...clicky")
|
65
|
+
button.signal_connect("clicked") do |_button|
|
66
|
+
fade_p = !fade_p
|
67
|
+
end
|
68
|
+
vbox.add(button)
|
69
|
+
button.hexpand = true
|
70
|
+
|
71
|
+
button = Gtk::Button.new(:label => "Fullscreen")
|
72
|
+
button.image = Gtk::Image.new(:stock => Gtk::Stock::FULLSCREEN, :size => :button)
|
73
|
+
button.signal_connect("clicked") do |_button|
|
74
|
+
if fullscreen_p
|
75
|
+
window.unfullscreen
|
76
|
+
fullscreen_p = false
|
77
|
+
else
|
78
|
+
window.fullscreen
|
79
|
+
fullscreen_p = true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
vbox.add(button)
|
83
|
+
button.hexpand = true
|
84
|
+
|
85
|
+
button = Gtk::Button.new(:stock_id => Gtk::Stock::QUIT)
|
86
|
+
button.signal_connect("clicked") do |_button|
|
87
|
+
_button.destroy
|
88
|
+
end
|
89
|
+
vbox.add(button)
|
90
|
+
button.hexpand = true
|
91
|
+
|
92
|
+
group = Clutter::Actor.new
|
93
|
+
hands = []
|
94
|
+
N_HANDS.times do |i|
|
95
|
+
if i.zero?
|
96
|
+
hands[i] = ClutterGtk::Texture.new
|
97
|
+
hands[i].set_from_pixbuf(pixbuf)
|
98
|
+
else
|
99
|
+
hands[i] = Clutter::Clone.new(hands[0])
|
100
|
+
end
|
101
|
+
|
102
|
+
# Place around a circle
|
103
|
+
w = hands[0].width
|
104
|
+
h = hands[0].height
|
105
|
+
|
106
|
+
x = WINDOW_WIDTH / 2 + RADIUS * Math.cos(i * Math::PI / (N_HANDS / 2)) - w / 2
|
107
|
+
y = WINDOW_HEIGHT / 2 + RADIUS * Math.sin(i * Math::PI / (N_HANDS / 2)) - h / 2
|
108
|
+
|
109
|
+
hands[i].set_position(x, y)
|
110
|
+
|
111
|
+
# Add to our group group
|
112
|
+
group.add_child(hands[i])
|
113
|
+
end
|
114
|
+
|
115
|
+
# Add the group to the stage
|
116
|
+
stage.add_child(group)
|
117
|
+
|
118
|
+
constraint = Clutter::AlignConstraint.new(stage, :x_axis, 0.5)
|
119
|
+
group.add_constraint(constraint)
|
120
|
+
constraint = Clutter::AlignConstraint.new(stage, :y_axis, 0.5)
|
121
|
+
group.add_constraint(constraint)
|
122
|
+
|
123
|
+
stage.signal_connect("button-press-event") do |_stage, event|
|
124
|
+
x, y = event.coords
|
125
|
+
actor = _stage.get_actor_at_pos(:all, x, y)
|
126
|
+
if actor.is_a?(ClutterGtk::Texture) or actor.is_a?(Clutter::Clone)
|
127
|
+
actor.hide
|
128
|
+
end
|
129
|
+
|
130
|
+
Clutter::Event::STOP
|
131
|
+
end
|
132
|
+
stage.signal_connect("key-release-event") do |_stage, event|
|
133
|
+
puts("*** key press event (key:#{[event.key_unicode].pack('U*')}) ***")
|
134
|
+
case event.key_symbol
|
135
|
+
when Clutter::Keys::KEY_q
|
136
|
+
Gtk.main_quit
|
137
|
+
when Clutter::Keys::KEY_r
|
138
|
+
N_HANDS.times do |i|
|
139
|
+
hands[i].show
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
Clutter::Event::STOP
|
144
|
+
end
|
145
|
+
|
146
|
+
window.show_all
|
147
|
+
|
148
|
+
# Create a timeline to manage animation
|
149
|
+
timeline = Clutter::Timeline.new(6000)
|
150
|
+
timeline.repeat_count = -1
|
151
|
+
|
152
|
+
# fire a callback for frame change
|
153
|
+
timeline.signal_connect("new-frame") do |_timeline, msecs|
|
154
|
+
rotation = _timeline.progress * 360.0
|
155
|
+
group.set_rotation(:z_axis, rotation, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 0)
|
156
|
+
N_HANDS.times do |i|
|
157
|
+
hands[i].set_rotation(:z_axis,
|
158
|
+
-(6.0 * rotation),
|
159
|
+
hands[i].width / 2,
|
160
|
+
hands[i].height / 2,
|
161
|
+
0)
|
162
|
+
if fade_p
|
163
|
+
hands[i].opacity = (255 - (rotation % 255))
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# and start it
|
169
|
+
timeline.start
|
170
|
+
|
171
|
+
Gtk.main
|