green_shoes 0.129.0

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.
Files changed (69) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +104 -0
  3. data/README.rdoc +23 -0
  4. data/README_old.md +132 -0
  5. data/lib/ext/bloops.rb +1 -0
  6. data/lib/ext/bloops/bloops.so +0 -0
  7. data/lib/ext/bloops/libportaudio-2.dll +0 -0
  8. data/lib/ext/bloops/songs/1901_by_Aanand_Prasad.rb +478 -0
  9. data/lib/ext/bloops/songs/bloopsaphone_theme_song_by_why.rb +31 -0
  10. data/lib/ext/bloops/songs/feepogram.rb +67 -0
  11. data/lib/ext/bloops/songs/simpsons_theme_song_by_why.rb +14 -0
  12. data/lib/ext/chipmunk.rb +34 -0
  13. data/lib/ext/chipmunk/chipmunk.so +0 -0
  14. data/lib/ext/projector.rb +1 -0
  15. data/lib/ext/projector/matrix3d.rb +73 -0
  16. data/lib/ext/projector/projector.rb +306 -0
  17. data/lib/green_shoes.rb +45 -0
  18. data/lib/shoes/anim.rb +19 -0
  19. data/lib/shoes/app.rb +591 -0
  20. data/lib/shoes/basic.rb +242 -0
  21. data/lib/shoes/colors.rb +150 -0
  22. data/lib/shoes/download.rb +26 -0
  23. data/lib/shoes/help.rb +171 -0
  24. data/lib/shoes/helper_methods.rb +308 -0
  25. data/lib/shoes/main.rb +99 -0
  26. data/lib/shoes/manual.rb +6 -0
  27. data/lib/shoes/mask.rb +29 -0
  28. data/lib/shoes/projector.rb +42 -0
  29. data/lib/shoes/ruby.rb +73 -0
  30. data/lib/shoes/slot.rb +68 -0
  31. data/lib/shoes/text.rb +44 -0
  32. data/lib/shoes/url.rb +14 -0
  33. data/lib/shoes/widget.rb +18 -0
  34. data/static/Coolvetica.ttf +0 -0
  35. data/static/Lacuna.ttf +0 -0
  36. data/static/downloading.png +0 -0
  37. data/static/gshoes-heading-icon.png +0 -0
  38. data/static/gshoes-icon.png +0 -0
  39. data/static/man-app.png +0 -0
  40. data/static/man-builds.png +0 -0
  41. data/static/man-builds1.png +0 -0
  42. data/static/man-editor-notepad.png +0 -0
  43. data/static/man-editor-osx.png +0 -0
  44. data/static/man-ele-background.png +0 -0
  45. data/static/man-ele-border.png +0 -0
  46. data/static/man-ele-button.png +0 -0
  47. data/static/man-ele-check.png +0 -0
  48. data/static/man-ele-editbox.png +0 -0
  49. data/static/man-ele-editline.png +0 -0
  50. data/static/man-ele-image.png +0 -0
  51. data/static/man-ele-listbox.png +0 -0
  52. data/static/man-ele-progress.png +0 -0
  53. data/static/man-ele-radio.png +0 -0
  54. data/static/man-ele-shape.png +0 -0
  55. data/static/man-ele-textblock.png +0 -0
  56. data/static/man-ele-video.png +0 -0
  57. data/static/man-intro-dmg.png +0 -0
  58. data/static/man-intro-exe.png +0 -0
  59. data/static/man-look-tiger.png +0 -0
  60. data/static/man-look-ubuntu.png +0 -0
  61. data/static/man-look-vista.png +0 -0
  62. data/static/man-run-osx.png +0 -0
  63. data/static/man-run-vista.png +0 -0
  64. data/static/man-run-xp.png +0 -0
  65. data/static/man-shot1.png +0 -0
  66. data/static/manual-en.txt +3523 -0
  67. data/static/manual-ja.txt +2825 -0
  68. data/static/shoes-manual-apps.png +0 -0
  69. metadata +146 -0
@@ -0,0 +1,308 @@
1
+ class Shoes
2
+ module Mod
3
+ def set_margin
4
+ @margin ||= [0, 0, 0, 0]
5
+ @margin = [@margin, @margin, @margin, @margin] if @margin.is_a? Integer
6
+ margin_left, margin_top, margin_right, margin_bottom = @margin
7
+ @margin_left ||= margin_left
8
+ @margin_top ||= margin_top
9
+ @margin_right ||= margin_right
10
+ @margin_bottom ||= margin_bottom
11
+ end
12
+
13
+ attr_reader :margin_left, :margin_top, :margin_right, :margin_bottom
14
+ end
15
+
16
+ module Mod2
17
+ def init_app_vars
18
+ @contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics =
19
+ [], [], [], [], [], [], [], [], [], [], []
20
+ @cmask = nil
21
+ @mouse_button, @mouse_pos = 0, [0, 0]
22
+ @fill, @stroke = black, black
23
+ end
24
+
25
+ def set_rotate_angle args
26
+ @context_angle2 = Math::PI/2 - @context_angle
27
+ m = args[:height] * Math.sin(@context_angle)
28
+ w = args[:width] * Math.sin(@context_angle2) + m
29
+ h = args[:width] * Math.sin(@context_angle) + args[:height] * Math.sin(@context_angle2)
30
+ mx, my = m * Math.sin(@context_angle2), m * Math.sin(@context_angle)
31
+ if @pixbuf_rotate.even?
32
+ args[:left] += (args[:width] - w)/2.0
33
+ args[:top] -= (h - args[:height])/2.0
34
+ else
35
+ args[:left] -= (h - args[:width])/2.0
36
+ args[:top] += (args[:height] - w)/2.0
37
+ end
38
+ return w, h, mx, my
39
+ end
40
+ end
41
+
42
+ class App
43
+ def basic_attributes args={}
44
+ default = {left: 0, top: 0, width: 0, height: 0, angle: 0, curve: 0}
45
+ default.merge!({nocontrol: true}) if @nolayout
46
+ default.merge args
47
+ end
48
+
49
+ def slot_attributes args={}
50
+ default = {left: nil, top: nil, width: 1.0, height: 0}
51
+ default.merge args
52
+ end
53
+
54
+ def create_tmp_png surface
55
+ surface.write_to_png TMP_PNG_FILE
56
+ Gtk::Image.new TMP_PNG_FILE
57
+ end
58
+
59
+ def make_link_index msg
60
+ start, links = 0, []
61
+ msg.each do |e|
62
+ len = e.to_s.gsub(/<\/.*?>/, '').gsub(/<.*?>/, '').length
63
+ (links << e; e.index = [start, start + len - 1]) if e.is_a? Link
64
+ start += len
65
+ end
66
+ links
67
+ end
68
+
69
+ def make_link_pos links, layout, line_height
70
+ links.each do |e|
71
+ e.pos = [layout.index_to_pos(e.index[0]).x / Pango::SCALE, layout.index_to_pos(e.index[0]).y / Pango::SCALE]
72
+ e.pos << (layout.index_to_pos(e.index[1]).x / Pango::SCALE + line_height / 2) << (layout.index_to_pos(e.index[1]).y / Pango::SCALE)
73
+ e.pos << line_height
74
+ end
75
+ end
76
+ end
77
+
78
+ def self.contents_alignment slot
79
+ x, y = slot.left.to_i, slot.top.to_i
80
+ max = Struct.new(:top, :height).new
81
+ max.top, max.height = y, 0
82
+ slot_height = 0
83
+
84
+ slot.contents.each do |ele|
85
+ if ele.is_a? ShapeBase
86
+ ele.hide if slot.masked
87
+ next
88
+ end
89
+ if slot.masked and ele.is_a? Image
90
+ ele.hide
91
+ next
92
+ end
93
+ tmp = max
94
+ max = ele.positioning x, y, max
95
+ x, y = ele.left + ele.width, ele.top + ele.height
96
+ slot_height += max.height unless max == tmp
97
+ end
98
+ slot_height
99
+ end
100
+
101
+ def self.repaint_all slot
102
+ return if slot.masked
103
+ slot.contents.each do |ele|
104
+ next if ele.is_a? ShapeBase
105
+ ele.is_a?(Basic) ? ele.move2(ele.left + ele.margin_left, ele.top + ele.margin_top) : repaint_all(ele)
106
+ end
107
+ end
108
+
109
+ def self.repaint_all_by_order app
110
+ app.order.each do |e|
111
+ if e.real and !e.is_a?(Pattern) and !e.hided
112
+ app.canvas.remove e.real
113
+ app.canvas.put e.real, e.left, e.top
114
+ end
115
+ end
116
+ end
117
+
118
+ def self.call_back_procs app
119
+ init_contents app.cslot.contents
120
+ app.cslot.width, app.cslot.height = app.width, app.height
121
+ scrollable_height = contents_alignment app.cslot
122
+ repaint_all app.cslot
123
+ mask_control app
124
+ repaint_all_by_order app
125
+ app.canvas.set_size 0, scrollable_height unless app.prjct
126
+ true
127
+ end
128
+
129
+ def self.init_contents contents
130
+ contents.each do |ele|
131
+ next unless ele.is_a? Slot
132
+ ele.initials.each do |k, v|
133
+ ele.send "#{k}=", v
134
+ end
135
+ end
136
+ end
137
+
138
+ def self.mouse_click_control app
139
+ app.mccs.each do |e|
140
+ e.click_proc.call if mouse_on? e
141
+ end
142
+ end
143
+
144
+ def self.mouse_release_control app
145
+ app.mrcs.each do |e|
146
+ e.release_proc.call if mouse_on? e
147
+ end
148
+ end
149
+
150
+ def self.mouse_motion_control app
151
+ app.mmcs.each do |blk|
152
+ blk[*app.win.pointer]
153
+ end
154
+ end
155
+
156
+ def self.mouse_hover_control app
157
+ app.mhcs.each do |e|
158
+ if mouse_on?(e) and !e.hovered
159
+ e.hovered = true
160
+ e.hover_proc.call if e.hover_proc
161
+ end
162
+ end
163
+ end
164
+
165
+ def self.mouse_leave_control app
166
+ app.mhcs.each do |e|
167
+ if !mouse_on?(e) and e.hovered
168
+ e.hovered = false
169
+ e.leave_proc.call if e.leave_proc
170
+ end
171
+ end
172
+ end
173
+
174
+ def self.mouse_link_control app
175
+ app.mlcs.each do |tb|
176
+ link_proc, = mouse_on_link(tb, app)
177
+ link_proc.call if link_proc
178
+ end
179
+ end
180
+
181
+ def self.set_cursor_type app
182
+ app.mccs.each do |e|
183
+ e.real.window.cursor = ARROW if e.real.window
184
+ (e.real.window.cursor = HAND; return) if mouse_on? e
185
+ end
186
+
187
+ app.mlcs.each do |tb|
188
+ tb.text = tb.text unless tb.real
189
+ tb.real.window.cursor = ARROW if tb.real.window
190
+ if ret = mouse_on_link(tb, app)
191
+ tb.real.window.cursor = HAND
192
+ unless tb.links[ret[1]].link_hover
193
+ markup = tb.args[:markup].gsub(app.linkhover_style, app.link_style)
194
+ links = markup.mindex app.link_style
195
+ n = links[ret[1]]
196
+ tb.text = markup[0...n] + markup[n..-1].sub(app.link_style, app.linkhover_style)
197
+ tb.links.each{|e| e.link_hover = false}
198
+ tb.links[ret[1]].link_hover = true
199
+ end
200
+ return
201
+ end
202
+ if tb.links.map(&:link_hover).include? true
203
+ tb.text = tb.args[:markup].gsub(app.linkhover_style, app.link_style)
204
+ tb.links.each{|e| e.link_hover = false}
205
+ end
206
+ end
207
+ end
208
+
209
+ def self.mouse_on? e
210
+ mouse_x, mouse_y = e.real.pointer
211
+ (0..e.width).include?(mouse_x) and (0..e.height).include?(mouse_y)
212
+ end
213
+
214
+ def self.mouse_on_link tb, app
215
+ mouse_x, mouse_y = app.win.pointer
216
+ mouse_y += app.scroll_top
217
+ mouse_x -= tb.left
218
+ mouse_y -= tb.top
219
+ tb.links.each_with_index do |e, n|
220
+ return [e.link_proc, n] if ((0..tb.width).include?(mouse_x) and (e.pos[1]..(e.pos[3]+e.pos[4])).include?(mouse_y) \
221
+ and !((0..e.pos[0]).include?(mouse_x) and (e.pos[1]..(e.pos[1]+e.pos[4])).include?(mouse_y)) \
222
+ and !((e.pos[2]..tb.width).include?(mouse_x) and (e.pos[3]..(e.pos[3]+e.pos[4])).include?(mouse_y)) \
223
+ )
224
+ end
225
+ return false
226
+ end
227
+
228
+ def self.size_allocated? app
229
+ not (app.width_pre == app.width and app.height_pre == app.height)
230
+ end
231
+
232
+ def self.show_hide_control app
233
+ flag = false
234
+ app.shcs.each do |e|
235
+ case
236
+ when(!e.shows and !e.hided)
237
+ e.remove
238
+ e.hided = true
239
+ flag = true
240
+ when(e.shows and e.hided)
241
+ e.hided = false
242
+ e.is_a?(Pattern) ? e.move2(e.left, e.top) : app.canvas.put(e.real, e.left, e.top)
243
+ flag = true
244
+ else
245
+ end
246
+ end
247
+ repaint_all_by_order app if flag
248
+ end
249
+
250
+ def self.mask_control app
251
+ app.mcs.each do |m|
252
+ w, h = m.parent.width, m.parent.height
253
+ w = app.width if w.zero?
254
+ h = app.height if h.zero?
255
+ surface = Cairo::ImageSurface.new Cairo::FORMAT_ARGB32, w, h
256
+ context = Cairo::Context.new surface
257
+ context.push_group do
258
+ m.parent.contents.each do |ele|
259
+ x, y = ele.left - m.parent.left, ele.top - m.parent.top
260
+ context.translate x, y
261
+ context.set_source_pixbuf ele.real.pixbuf
262
+ context.paint
263
+ context.translate -x, -y
264
+ end
265
+ end
266
+
267
+ sf = Cairo::ImageSurface.new Cairo::FORMAT_ARGB32, w, h
268
+ ct = Cairo::Context.new surface
269
+ pat = ct.push_group nil, false do
270
+ m.contents.each do |ele|
271
+ if ele.is_a? TextBlock
272
+ ele.height = h
273
+ ele.text = ele.args[:markup]
274
+ end
275
+ x, y = ele.left - m.parent.left, ele.top - m.parent.top
276
+ ct.translate x, y
277
+ ct.set_source_pixbuf ele.real.pixbuf
278
+ ct.paint
279
+ ct.translate -x, -y
280
+ end
281
+ end
282
+
283
+ context.mask pat
284
+ m.real = img = app.create_tmp_png(surface)
285
+ app.canvas.put img, 0, 0
286
+ img.show_now
287
+ end
288
+ end
289
+
290
+ def self.download_images_control app
291
+ app.dics.each do |e, d, tmpname|
292
+ args = e.args
293
+ if d.finished?
294
+ app.canvas.remove e.real
295
+ img = Gtk::Image.new tmpname
296
+ unless args[:width].zero? and args[:height].zero?
297
+ img = Gtk::Image.new img.pixbuf.scale(args[:width], args[:height])
298
+ end
299
+ app.canvas.put img, e.left, e.top
300
+ img.show_now
301
+ e.real = img
302
+ e.width, e.height = img.size_request
303
+ app.dics.delete [e, d, tmpname]
304
+ File.delete tmpname
305
+ end
306
+ end
307
+ end
308
+ end
@@ -0,0 +1,99 @@
1
+ class Shoes
2
+ include Types
3
+ @apps = []
4
+ $urls = {}
5
+
6
+ def self.app args={}, &blk
7
+ args[:width] ||= 600
8
+ args[:height] ||= 500
9
+ args[:title] ||= 'green shoes'
10
+ args[:left] ||= 0
11
+ args[:top] ||= 0
12
+ projector = args[:prjct] = args[:projector]
13
+ args.delete :projector
14
+
15
+ app = App.new args
16
+ @apps.push app
17
+
18
+ app.top_slot = Flow.new app.slot_attributes(app: app, left: 0, top: 0)
19
+
20
+ win = Gtk::Window.new
21
+ win.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
22
+ win.title = args[:title]
23
+ win.set_default_size args[:width], args[:height]
24
+
25
+ style = win.style
26
+ style.set_bg Gtk::STATE_NORMAL, 65535, 65535, 65535
27
+
28
+ class << app; self end.class_eval do
29
+ define_method(:width){win.size[0]}
30
+ define_method(:height){win.size[1]}
31
+ end
32
+
33
+ win.set_events Gdk::Event::BUTTON_PRESS_MASK | Gdk::Event::BUTTON_RELEASE_MASK | Gdk::Event::POINTER_MOTION_MASK
34
+
35
+ win.signal_connect "delete-event" do
36
+ false
37
+ end
38
+
39
+ win.signal_connect "destroy" do
40
+ app.exit
41
+ end if @apps.size == 1
42
+
43
+ win.signal_connect "button_press_event" do |w, e|
44
+ app.mouse_button = e.button
45
+ app.mouse_pos = app.win.pointer
46
+ mouse_click_control app
47
+ mouse_link_control app
48
+ end
49
+
50
+ win.signal_connect "button_release_event" do
51
+ app.mouse_button = 0
52
+ app.mouse_pos = app.win.pointer
53
+ mouse_release_control app
54
+ end
55
+
56
+ win.signal_connect "motion_notify_event" do
57
+ app.mouse_pos = app.win.pointer
58
+ mouse_motion_control app
59
+ mouse_hover_control app
60
+ mouse_leave_control app
61
+ end
62
+
63
+ app.canvas = projector ? Gtk::DrawingArea.new : Gtk::Layout.new
64
+ swin = Gtk::ScrolledWindow.new
65
+ swin.set_policy Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC
66
+ swin.add app.canvas
67
+ win.add swin
68
+ app.canvas.style = style
69
+ app.win, app.swin = win, swin
70
+
71
+ if blk
72
+ app.instance_eval &blk
73
+ elsif projector
74
+ app.send :projector, projector
75
+ else
76
+ app.instance_eval{$urls[/^#{'/'}$/].call app}
77
+ end
78
+
79
+ Gtk.timeout_add 100 do
80
+ unless app.win.destroyed?
81
+ download_images_control app
82
+ if size_allocated? app
83
+ call_back_procs app
84
+ app.width_pre, app.height_pre = app.width, app.height
85
+ end
86
+ show_hide_control app
87
+ set_cursor_type app
88
+ end
89
+ true
90
+ end
91
+
92
+ call_back_procs app
93
+
94
+ win.show_all
95
+ @apps.pop
96
+ Gtk.main if @apps.empty?
97
+ app
98
+ end
99
+ end
@@ -0,0 +1,6 @@
1
+ class Shoes
2
+ def self.show_manual lang
3
+ $lang = lang
4
+ load File.join(DIR, 'shoes/help.rb')
5
+ end
6
+ end
@@ -0,0 +1,29 @@
1
+ class Shoes
2
+ class Mask
3
+ def initialize app, &blk
4
+ @app = app
5
+ @parent = app.cslot
6
+ @real = nil
7
+ app.cslot.masked = true
8
+ mask_block_call &blk
9
+ end
10
+
11
+ attr_reader :parent
12
+ attr_accessor :contents, :real
13
+
14
+ def clear &blk
15
+ @real.clear
16
+ @contents.each &:clear
17
+ mask_block_call &blk
18
+ Shoes.call_back_procs @app
19
+ end
20
+
21
+ def mask_block_call &blk
22
+ @contents = []
23
+ @app.cmask = self
24
+ blk.call if blk
25
+ @app.cmask = nil
26
+ @contents.each &:hide
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,42 @@
1
+ class Shoes
2
+ class App
3
+ def projector file
4
+ projector = Projector.new
5
+ projector.controller = SwingController.new
6
+ projector.controller.content = TextureMappingData.new
7
+ projector.controller.content.face_list = AkatsukiFace::create
8
+ projector.controller.content.texture = Gdk::Pixbuf.new(file)
9
+
10
+ def (projector.controller.content.texture).source_set(context)
11
+ context.set_source_pixbuf(self)
12
+ end
13
+
14
+ @canvas.tap do |drawing_area|
15
+ drawing_area.signal_connect('expose-event') do |widget, event|
16
+ projector.controller.region(widget.allocation)
17
+ projector.update
18
+ projector.draw
19
+ true
20
+ end
21
+ drawing_area.add_events(Gdk::Event::BUTTON_PRESS_MASK)
22
+ drawing_area.signal_connect('button_press_event') do |widget, event|
23
+ projector.controller.press(event)
24
+ true
25
+ end
26
+ drawing_area.add_events(Gdk::Event::POINTER_MOTION_MASK)
27
+ drawing_area.signal_connect('motion_notify_event') do |widget, event|
28
+ projector.controller.motion(event)
29
+ true
30
+ end
31
+ drawing_area.add_events(Gdk::Event::BUTTON_RELEASE_MASK)
32
+ drawing_area.signal_connect('button_release_event') do |widget, event|
33
+ projector.controller.release(event)
34
+ true
35
+ end
36
+ end
37
+
38
+ projector.widget = @canvas
39
+ animate{projector.draw}
40
+ end
41
+ end
42
+ end