green_shoes 0.129.0

Sign up to get free protection for your applications and to get access to all the features.
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,73 @@
1
+ class Range
2
+ def rand
3
+ conv = (Integer === self.end && Integer === self.begin ? :to_i : :to_f)
4
+ ((Kernel.rand * (self.end - self.begin)) + self.begin).send(conv)
5
+ end
6
+ end
7
+
8
+ class Object
9
+ def alert msg
10
+ dialog = Gtk::MessageDialog.new(
11
+ app.win,
12
+ Gtk::Dialog::MODAL,
13
+ Gtk::MessageDialog::INFO,
14
+ Gtk::MessageDialog::BUTTONS_OK,
15
+ msg
16
+ )
17
+ dialog.title = "Shoes says:"
18
+ dialog.run
19
+ dialog.destroy
20
+ end
21
+
22
+ def ask_open_file
23
+ dialog = Gtk::FileChooserDialog.new(
24
+ "Open File",
25
+ app.win,
26
+ Gtk::FileChooser::ACTION_OPEN,
27
+ nil,
28
+ [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
29
+ [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT]
30
+ )
31
+ ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? dialog.filename : nil
32
+ dialog.destroy
33
+ ret
34
+ end
35
+
36
+ def exit
37
+ Gtk.main_quit
38
+ File.delete Shoes::TMP_PNG_FILE if File.exist? Shoes::TMP_PNG_FILE
39
+ end
40
+ end
41
+
42
+ class String
43
+ def mindex str
44
+ n, links = 0, []
45
+ loop do
46
+ break unless n= self.index(str, n)
47
+ links << n
48
+ n += 1
49
+ end
50
+ links
51
+ end
52
+ end
53
+
54
+ class Array
55
+ def / len
56
+ a = []
57
+ each_with_index do |x, i|
58
+ a << [] if i % len == 0
59
+ a.last << x
60
+ end
61
+ a
62
+ end
63
+
64
+ def dark?
65
+ r, g, b = self
66
+ r + g + b < 0x55 * 3
67
+ end
68
+
69
+ def light?
70
+ r, g, b = self
71
+ r + g + b > 0xAA * 3
72
+ end
73
+ end
@@ -0,0 +1,68 @@
1
+ class Shoes
2
+ class Slot
3
+ include Mod
4
+ def initialize args={}
5
+ @initials = args
6
+ args.each do |k, v|
7
+ instance_variable_set "@#{k}", v
8
+ end
9
+
10
+ Slot.class_eval do
11
+ attr_accessor *args.keys
12
+ end
13
+
14
+ set_margin
15
+
16
+ @masked = false
17
+ @parent = @app.cslot
18
+ @app.cslot = self
19
+ @contents = []
20
+ (@parent.contents << self) unless @nocontrol
21
+ if block_given?
22
+ yield
23
+ @app.cslot = @parent
24
+ else
25
+ @left = @top = 0
26
+ end
27
+ end
28
+
29
+ attr_accessor :contents, :masked
30
+ attr_reader :parent, :initials
31
+
32
+ def move3 x, y
33
+ @left, @top = x, y
34
+ end
35
+
36
+ def positioning x, y, max
37
+ @width = (parent.width * @initials[:width]).to_i if @initials[:width].is_a? Float
38
+ @width -= (margin_left + margin_right)
39
+ if parent.is_a?(Flow) and x + @width <= parent.left + parent.width
40
+ move3 x + parent.margin_left, max.top + parent.margin_top
41
+ @height = Shoes.contents_alignment self
42
+ max = self if max.height < @height
43
+ else
44
+ move3 parent.left + parent.margin_left, max.top + max.height + parent.margin_top
45
+ @height = Shoes.contents_alignment self
46
+ max = self
47
+ end
48
+ max.height = @height = @initials[:height] unless @initials[:height].zero?
49
+ max
50
+ end
51
+
52
+ def clear &blk
53
+ @contents.each &:clear
54
+ if blk
55
+ args = {}
56
+ initials.keys.each{|k| args[k] = instance_variable_get "@#{k}"}
57
+ args[:nocontrol] = true
58
+ tmp = self.is_a?(Stack) ? Stack.new(@app.slot_attributes(args), &blk) : Flow.new(@app.slot_attributes(args), &blk)
59
+ self.contents = tmp.contents
60
+ Shoes.call_back_procs @app
61
+ Shoes.set_cursor_type @app
62
+ end
63
+ end
64
+ end
65
+
66
+ class Stack < Slot; end
67
+ class Flow < Slot; end
68
+ end
@@ -0,0 +1,44 @@
1
+ class Shoes
2
+ class App
3
+ [[:code, :tt], [:del, :s], [:em, :i], [:ins, :u], [:strong, :b], [:sub, :sub], [:sup, :sup]].each do |m, tag|
4
+ define_method m do |*str|
5
+ "<#{tag}>#{str.join}</#{tag}>"
6
+ end
7
+ end
8
+
9
+ [[:bg, :background], [:fg, :foreground]].each do |m, tag|
10
+ define_method m do |*str|
11
+ color = str.pop
12
+ str = str.join
13
+ rgb = color[0, 3].map{|e| (e*255.0).to_i}.map{|i| sprintf("%#02X", i)[-2,2]}.join
14
+ "<span #{tag}='##{rgb}'>#{str}</span>"
15
+ end
16
+ end
17
+
18
+ def link str, &blk
19
+ Link.new "#{LINK_DEFAULT}#{str}</span>", &blk
20
+ end
21
+
22
+ def font name
23
+ @font_family = name
24
+ end
25
+ end
26
+
27
+ class Text
28
+ def initialize str
29
+ @to_s = str
30
+ end
31
+ attr_reader :to_s
32
+ end
33
+
34
+ class Link < Text
35
+ def initialize str, &blk
36
+ @link_proc, @pos, @index, @link_hover = blk, nil, nil, false
37
+ super str
38
+ end
39
+ attr_reader :link_proc
40
+ attr_accessor :pos, :index, :link_hover
41
+ end
42
+
43
+ class LinkHover < Text; end
44
+ end
@@ -0,0 +1,14 @@
1
+ class Shoes
2
+ def self.url page, m
3
+ klass = self
4
+ page = /^#{page}$/
5
+ $urls[page] = proc do |s, arg|
6
+ klass.class_eval do
7
+ define_method :method_missing do |m, *args, &blk|
8
+ s.send m, *args, &blk
9
+ end
10
+ end
11
+ arg ? klass.new.send(m, arg) : klass.new.send(m)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ class Shoes
2
+ class Widget
3
+ def self.inherited klass, &blk
4
+ m = klass.inspect.downcase
5
+ Shoes::App.class_eval do
6
+ define_method m do |*args, &blk|
7
+ klass.class_variable_set :@@app, self
8
+ klass.new *args, &blk
9
+ end
10
+ end
11
+ klass.class_eval do
12
+ def method_missing m, *arg, &blk
13
+ @@app.send m, *arg, &blk
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,3523 @@
1
+ = Hello! =
2
+
3
+ Shoes is a tiny graphics toolkit. It's simple and straightforward. Shoes was
4
+ born to be easy! Really, it was made for absolute beginners. There's really
5
+ nothing to it. Green Shoes is one of colorful Shoes. It is written in pure Ruby
6
+ with Ruby/GTK2.
7
+
8
+ You see, the trivial Shoes program can be just one line:
9
+
10
+ {{{
11
+ #!ruby
12
+ Shoes.app { button("Click me!") { alert("Good job.") } }
13
+ }}}
14
+
15
+ Shoes programs are written in a language called Ruby. When Shoes is handed
16
+ this simple line of Ruby code, a window appears with a button inside reading
17
+ "Click me!" When the button is clicked, a message pops up.
18
+
19
+ On Windows 7, here's how this might look: !{margin_left: 100}man-shot1.png!
20
+
21
+ While lots of Shoes apps are graphical games and art programs, you can also
22
+ layout text and edit controls easily. !{margin_left: 80}shoes-manual-apps.png!
23
+
24
+ And, ideally, Shoes programs will run on any of the major platforms out there.
25
+ Microsoft Windows, Apple's Mac OS X, Linux and many others.
26
+
27
+ ^So, welcome to Green Shoes' built-in manual. This manual is a Green Shoes program itself!^
28
+
29
+ == Introducing Green Shoes ==
30
+
31
+ How does Green Shoes look on OS X and Linux? Does it really look okay? Is it all
32
+ ugly and awkward? People must immediately convulse! It must be so watered down
33
+ trying to do everything.
34
+
35
+ Well, before getting into the stuff about installing and running Green Shoes, time to
36
+ just check out some screenshots, to give you an idea of what you can do.
37
+
38
+ ==== Mac OS X ====
39
+
40
+ Green Shoes is confirmed on Apple Mac OSX10.5 PPC via X11.
41
+ !{margin_left: 100}../snapshots/sample3-osx.png!
42
+
43
+ This is the `sample3.rb` on Mac OS X.
44
+
45
+ All circles are drawn randomly. You can draw and animate shapes in Green Shoes.
46
+
47
+ ==== Windows ====
48
+
49
+ Green Shoes is confirmed to run on '''Microsoft Windows XP''' and '''Windows 7'''.
50
+ !{margin_left: 0}../snapshots/sample33.png!
51
+
52
+ Above is pictured the `sample33.rb` running on Windows 7. Green Shoes
53
+ has three extended libraries for chipmunk physics, bloopsaphone and 3D texture
54
+ mapping. First two are binary libraries, so far work on Windows only.
55
+
56
+ ==== Linux ====
57
+
58
+ Here's a screenshot of the `sample44.rb` running on '''Ubuntu
59
+ on VirtualBox for Windows'''. !{margin_left: 130}../snapshots/sample44-linux.png!
60
+
61
+ This example is also draws ovals and lines to build the clock, which is animated to
62
+ show or hide itself several times each second.
63
+
64
+ Notice the text on the top of the app, showing the current time. Green Shoes has the
65
+ skills to layout words using any color, bold, italics, underlines, and supports
66
+ loading fonts.
67
+
68
+ == Installing Green Shoes ==
69
+
70
+ Okay, on to installing Green Shoes. I'm sure you're wondering: do I need to install
71
+ Ruby? Do I need to unzip anything? What commands do I need to type?
72
+
73
+ Yeah. You need to install Ruby and Gems. But, no need to worry about it.
74
+ We'll talk through all the steps.
75
+
76
+ ==== Step 1: Installing Green Shoes ====
77
+
78
+ At first, install Ruby. On '''Windows''',
79
+ visit the site of [[http://rubyinstaller.org/ RubyInstaller for Windows]] to
80
+ download '''RubyInstaller 1.9.2-p136'''.
81
+
82
+ Then just do the following.
83
+
84
+ * gem install gtk2 --no-ri --no-rdoc
85
+ * gem install green_shoes
86
+
87
+ That's all. Too easy?
88
+
89
+ ''Note: green_shoes gem is now under development.''
90
+
91
+ ==== Step 2: Start a New Text File ====
92
+
93
+ Shoes programs are just plain text files ending with a '''.rb''' extension.
94
+
95
+ Here are a few ways to create a blank text file:
96
+
97
+ * On '''Mac OS X''', visit your '''Applications''' folder and double-click on the '''TextEdit''' app. A blank editor window should come up. Now, go to the '''Format''' menu and select the '''Make Plain Text''' option. Okay, you're all set! !man-editor-osx.png!
98
+ * On '''Windows''', go to the Start menu. Select '''All Programs''', then '''Accessories''', then '''Notepad'''. !man-editor-notepad.png!
99
+ * On '''Linux''', most distros come with '''gedit'''. You might try running that. Or, if your distro is KDE-based, run '''kate'''.
100
+
101
+ Now, in your blank window, type in the following:
102
+
103
+ {{{
104
+ Shoes.app do
105
+ background "#DFA"
106
+ para "Welcome to Shoes"
107
+ end
108
+ }}}
109
+
110
+ Save to your desktop as `welcome.rb`.
111
+
112
+ ==== Step 3: Run It! Go Shoes! ====
113
+
114
+ To run your program, just open console window and run the following.
115
+
116
+ * ruby welcome.rb !man-editor-osx.png!
117
+
118
+ So, not much of a program yet. But it's something! You've got the knack of it, at least!
119
+
120
+ ==== What Can You Make With Shoes? ====
121
+
122
+ Well, you can make windowing applications. But Shoes is inspired by the web, so
123
+ applications tend to use images and text layout rather than a lot of widgets.
124
+ For example, Shoes doesn't come with tabbed controls or toolbars. Shoes is a
125
+ ''tiny'' toolkit, remember?
126
+
127
+ Still, Shoes does have a few widgets like buttons and edit boxes. And many
128
+ missing elements (like tabbed controls or toolbars) can be simulated with
129
+ images.
130
+
131
+ Shoes is written in part thanks to a very good art engine called Cairo, which
132
+ is used for drawing with shapes and colors. Also thanks to an awesome text
133
+ lay out engine called Pango. In this way, Shoes is inspired by
134
+ NodeBox and Processing, two very good languages for drawing animated graphics.
135
+
136
+ == The Rules of Green Shoes ==
137
+
138
+ Time to stop guessing how Green Shoes works. Some of the tricky things will come
139
+ back to haunt you. I've boiled down the central rules to Green Shoes. These are the
140
+ things you MUST know to really make it all work.
141
+
142
+ These are general rules found throughout Green Shoes. While Green Shoes has an overall
143
+ philosophy of simplicity and clarity, there are a few points that need to be
144
+ studied and remembered.
145
+
146
+ ==== Shoes Tricky Blocks ====
147
+
148
+ Okay, this is absolutely crucial. Green Shoes does a trick with blocks. This trick
149
+ makes everything easier to read. But it also can make blocks harder to use
150
+ once you're in deep.
151
+
152
+ '''Let's take a normal Ruby block:'''
153
+
154
+ {{{
155
+ Shoes.app do
156
+ ary = ['potion', 'swords', 'shields']
157
+ ary.each do |item|
158
+ puts item
159
+ end
160
+ end
161
+ }}}
162
+
163
+ In Green Shoes, these sorts of blocks work the same. This block above loops through
164
+ the array and stores each object in the `item` variable. The `item` variable
165
+ disappears (goes out of scope) when the block ends.
166
+
167
+ One other thing to keep in mind is that `self` stays the same inside normal
168
+ Ruby blocks. Whatever `self` was before the call to `each`, it is the same
169
+ inside the `each` block.
170
+
171
+ '''Both of these things are also true for most Green Shoes blocks.'''
172
+
173
+ {{{
174
+ Shoes.app do
175
+ stack do
176
+ para "First"
177
+ para "Second"
178
+ para "Third"
179
+ end
180
+ end
181
+ }}}
182
+
183
+ Here we have two blocks. The first block is sent to `Shoes.app`. This `app`
184
+ block changes `self`.
185
+
186
+ The other block is the `stack` block. That block does NOT change self.
187
+
188
+ '''For what reason does the `app` block change self?''' Let's start by
189
+ spelling out that last example completely.
190
+
191
+ {{{
192
+ Shoes.app do
193
+ self.stack do
194
+ self.para "First"
195
+ self.para "Second"
196
+ self.para "Third"
197
+ end
198
+ end
199
+ }}}
200
+
201
+ All of the `self`s in the above example are the App object. Green Shoes uses Ruby's
202
+ `instance_eval` to change self inside the `app` block. So the method calls to
203
+ `stack` and `para` get sent to the app.
204
+
205
+ '''This also is why you can use instance variables throughout a Shoes app:'''
206
+
207
+ {{{
208
+ Shoes.app do
209
+ @s = stack do
210
+ @p1 = para "First"
211
+ @p2 = para "Second"
212
+ @p3 = para "Third"
213
+ end
214
+ end
215
+ }}}
216
+
217
+ These instance variables will all end up inside the App object.
218
+
219
+ '''Whenever you create a new Shoes.app window, `self` is also changed.'''
220
+
221
+ {{{
222
+ Shoes.app title: "MAIN" do
223
+ para self
224
+ button "Spawn" do
225
+ Shoes.app title: "CHILD" do
226
+ para self
227
+ end
228
+ end
229
+ end
230
+ }}}
231
+
232
+ ''Note: para method displays self with [ and ] in Green Shoes.''
233
+
234
+ ==== Block Redirection ====
235
+
236
+ The `stack` block is a different story, though. It doesn't change `self` and
237
+ it's basically a regular block.
238
+
239
+ '''But there's a trick:''' when you attach a `stack` and give it a block, the
240
+ App object places that stack in its memory. The stack gets popped off when the
241
+ block ends. So all drawing inside the block gets '''redirected''' from the
242
+ App's top slot to the new stack.
243
+
244
+ So those three `para`s will get drawn on the `stack`, even though they actually
245
+ get sent to the App object first.
246
+
247
+ {{{
248
+ Shoes.app do
249
+ stack do
250
+ para "First"
251
+ para "Second"
252
+ para "Third"
253
+ end
254
+ end
255
+ }}}
256
+
257
+ A bit tricky, you see? This can bite you even if you know about it.
258
+
259
+ One way it'll get you is if you try to edit a stack somewhere else in your
260
+ program, outside the `app` block.
261
+
262
+ Like let's say you pass around a stack object. And you have a class that edits
263
+ that object.
264
+
265
+ {{{
266
+ class Messenger
267
+ def initialize(stack)
268
+ @stack = stack
269
+ end
270
+ def add(msg)
271
+ @stack.append do
272
+ para msg
273
+ end
274
+ end
275
+ end
276
+ }}}
277
+
278
+ So, let's assume you pass the stack object into your Messenger class when the
279
+ app starts. And, later, when a message comes in, the `add` method gets used to
280
+ append a paragraph to that stack. Should work, right?
281
+
282
+ Nope, it won't work. The `para` method won't be found. The App object isn't
283
+ around any more. And it's the one with the `para` method.
284
+
285
+ Fortunately, each Shoes object has an `app` method that will let you reopen the
286
+ App object so you can do somefurther editing.
287
+
288
+ {{{
289
+ class Messenger
290
+ def initialize(stack)
291
+ @stack = stack
292
+ end
293
+ def add(msg)
294
+ @stack.app do
295
+ @stack.append do
296
+ para msg
297
+ end
298
+ end
299
+ end
300
+ end
301
+ }}}
302
+
303
+ As you can imagine, the `app` object changes `self` to the App object.
304
+
305
+ So the rules here are:
306
+
307
+ 1. '''Methods named "app" or which create new windows alter `self` to the App
308
+ object.'''[[BR]](This is true for both Shoes.app and Slot.app, as well as
309
+ [[Element.window]] and [[Element.dialog]].)[[BR]]
310
+ 2. '''Blocks attached to stacks, flows or any manipulation method (such as
311
+ append) do not change self. Instead, they pop the slot on to the app's editing
312
+ stack.'''
313
+
314
+ ==== Careful With Fixed Heights ====
315
+
316
+ Fixed widths on slots are great so you can split the window into columns.
317
+
318
+ {{{
319
+ Shoes.app do
320
+ flow do
321
+ stack :width => 200 do
322
+ caption "Column one"
323
+ para "is 200 pixels wide"
324
+ end
325
+ stack :width => -200 do
326
+ caption "Column two"
327
+ para "is 100% minus 200 pixels wide"
328
+ end
329
+ end
330
+ end
331
+ }}}
332
+
333
+ Fixed heights on slots should be less common. Usually you want your text and
334
+ images to just flow down the window as far as they can. Height usually happens
335
+ naturally.
336
+
337
+ The important thing here is that fixed heights actually force slots to behave
338
+ differently. To be sure that the end of the slot is chopped off perfectly, the
339
+ slot becomes a '''nested window'''. A new layer is created by the operating
340
+ system to keep the slot in a fixed square.
341
+
342
+ On difference between normal slots and nested window slots is that the latter
343
+ can have scrollbars.
344
+
345
+ {{{
346
+ Shoes.app do
347
+ stack :width => 200, :height => 200, :scroll => true do
348
+ background "#DFA"
349
+ 100.times do |i|
350
+ para "Paragraph No. #{i}"
351
+ end
352
+ end
353
+ end
354
+ }}}
355
+
356
+ These nested windows require more memory. They tax the application a bit more.
357
+ So if you're experiencing some slowness with hundreds of fixed-height slots,
358
+ try a different approach.
359
+
360
+ ==== Image and Shape Blocks ====
361
+
362
+ Most beginners start littering the window with shapes. It's just easier to
363
+ throw all your rectangles and ovals in a slot.
364
+
365
+ '''However, bear in mind that Shoes will create objects for all those
366
+ shapes!'''
367
+
368
+ {{{
369
+ Shoes.app do
370
+ fill black(0.1)
371
+ 100.times do |i|
372
+ oval i, i, i * 2
373
+ end
374
+ end
375
+ }}}
376
+
377
+ In this example, one-hundred Oval objects are created. This isn't too bad.
378
+ But things would be slimmer if we made these into a single shape.
379
+
380
+ {{{
381
+ Shoes.app do
382
+ fill black(0.1)
383
+ shape do
384
+ 100.times do |i|
385
+ oval i, i, i * 2
386
+ end
387
+ end
388
+ end
389
+ }}}
390
+
391
+ Oh, wait. The ovals aren't filled in this time! That's because the ovals have
392
+ been combined into a single huge shape. And Shoes isn't sure where to fill in
393
+ this case.
394
+
395
+ So you usually only want to combine into a single shape when you're dealing
396
+ strictly with outlines.
397
+
398
+ Another option is to combine all those ovals into a single image.
399
+
400
+ {{{
401
+ Shoes.app do
402
+ fill black(0.1)
403
+ image 300, 300 do
404
+ 100.times do |i|
405
+ oval i, i, i * 2
406
+ end
407
+ end
408
+ end
409
+ }}}
410
+
411
+ There we go! The ovals are all combined into a single 300 x 300 pixel image.
412
+ In this case, storing that image in memory might be much bigger than having
413
+ one-hundred ovals around. But when you're dealing with thousands of shapes,
414
+ the image block can be cheaper.
415
+
416
+ The point is: it's easy to group shapes together into image or shape blocks, so
417
+ give it a try if you're looking to gain some speed. Shape blocks particularly
418
+ will save you some memory and speed.
419
+
420
+ ==== UTF-8 Everywhere ====
421
+
422
+ Ruby itself isn't Unicode aware. And UTF-8 is a type of Unicode. (See
423
+ [[http://en.wikipedia.org/wiki/UTF-8 Wikipedia]] for a full explanation of
424
+ UTF-8.)
425
+
426
+ However, UTF-8 is common on the web. And lots of different platforms support
427
+ it. So to cut down on the amount of conversion that Shoes has to do, Shoes
428
+ expects all strings to be in UTF-8 format.
429
+
430
+ This is great because you can show a myriad of languages (Russian, Japanese,
431
+ Spanish, English) using UTF-8 in Shoes. Just be sure that your text editor
432
+ uses UTF-8!
433
+
434
+ To illustrate:
435
+
436
+ {{{
437
+ Shoes.app do
438
+ stack :margin => 10 do
439
+ @edit = edit_box :width => 1.0 do
440
+ @para.text = @edit.text
441
+ end
442
+ @para = para ""
443
+ end
444
+ end
445
+ }}}
446
+
447
+ This app will copy anything you paste into the edit box and display it in a
448
+ Shoes paragraph. You can try copying some foreign text (such as Greek or
449
+ Japanese) into this box to see how it displays.
450
+
451
+ This is a good test because it proves that the edit box gives back UTF-8
452
+ characters. And the paragraph can be set to any UTF-8 characters.
453
+
454
+ '''Important note:''' if some UTF-8 characters don't display for you, you will
455
+ need to change the paragraph's font. This is especially common on OS X.
456
+
457
+ So, a good Japanese font on OS X is '''AppleGothic''' and on Windows is '''MS
458
+ UI Gothic'''.
459
+
460
+ {{{
461
+ Shoes.app do
462
+ para "てすと (te-su-to)", :font => case RUBY_PLATFORM
463
+ when /mingw/; "MS UI Gothic"
464
+ when /darwin/; "AppleGothic, Arial"
465
+ else "Arial"
466
+ end
467
+ end
468
+ }}}
469
+
470
+ Again, anything which takes a string in Shoes will need a UTF-8 string. Edit
471
+ boxes, edit lines, list boxes, window titles and text blocks all take UTF-8. If
472
+ you give a string with bad characters in it, an error will show up in the
473
+ console.
474
+
475
+ ==== The Main App and Its Requires ====
476
+
477
+ '''NOTE:''' This rule is for Raisins. Policeman uses TOPLEVEL_BINDING. So, you
478
+ can get `main`, Ruby top-level object, with the first snippet. Although you
479
+ need to use `Shoes::Para` instead of `Para` outside `Shoes.app` block.
480
+
481
+ Each Shoes app is given a little room where it can create itself. You can
482
+ create classes and set variables and they won't be seen by other Shoes
483
+ programs. Each program runs inside its own anonymous class.
484
+
485
+ {{{
486
+ main = self
487
+ Shoes.app do
488
+ para main.to_s
489
+ end
490
+ }}}
491
+
492
+ This anonymous class is called `(shoes)` and it's just an empty, unnamed class.
493
+ The `Shoes` module is mixed into this class (using `include Shoes`) so that you
494
+ can use either `Para` or `Shoes::Para` when referring to the paragraph class.
495
+
496
+ The advantages of this approach are:
497
+
498
+ * Shoes apps cannot share local variables.
499
+ * Classes created in the main app code are temporary.
500
+ * The Shoes module can be mixed in to the anonymous class, but not the top-level environment of Ruby itself.
501
+ * Garbage collection can clean up apps entirely once they complete.
502
+
503
+ The second part is especially important to remember.
504
+
505
+ {{{
506
+ class Storage; end
507
+
508
+ Shoes.app do
509
+ para Storage.new
510
+ end
511
+ }}}
512
+
513
+ The `Storage` class will disappear once the app completes. Other apps aren't
514
+ able to use the Storage class. And it can't be gotten to from files that are
515
+ loaded using `require`.
516
+
517
+ When you `require` code, though, that code will stick around. It will be kept
518
+ in the Ruby top-level environment.
519
+
520
+ So, the rule is: '''keep your temporary classes in the code with the app and
521
+ keep your permanent classes in requires.'''
522
+
523
+ = Shoes =
524
+
525
+ Shoes is all about drawing windows and the stuff inside those windows. Let's
526
+ focus on the window itself, for now. The other sections [[Slots]] and
527
+ [[Elements]] cover everything that goes inside the window.
528
+
529
+ For here on, the manual reads more like a dictionary. Each page is mostly a
530
+ list of methods you can use for each topic covered. The idea is to be very
531
+ thorough and clear about everything.
532
+
533
+ So, if you've hit this far in the manual and you're still hazy about getting
534
+ started, you should probably either go back to the [[Hello! beginning]] of the
535
+ manual. Or you could try [[https://github.com/downloads/shoes/shoes/nks.pdf Nobody Knows
536
+ Shoes]], the beginner's leaflet PDF.
537
+
538
+ ==== Finding Your Way ====
539
+
540
+ This section covers:
541
+
542
+ * [[Built-in Built-in methods]] - general methods available anywhere in a Shoes program.
543
+ * [[App The App window]] - methods found attached to every main Shoes window.
544
+ * [[Styles The Styles Master List]] - a complete list of every style in Shoes.
545
+ * [[Classes The Classes list]] - a chart showing what Shoes classes subclass what.
546
+ * [[Colors The Colors list]] - a chart of all built-in colors and the [[Built-in.rgb]] numbers for each.
547
+
548
+ If you find yourself paging around a lot and not finding something, give the
549
+ [[Search]] page a try. It's the quickest way to get around.
550
+
551
+ After this general reference, there are two other more specific sections:
552
+
553
+ * [[Slots]] - covering [[Element.stack]] and [[Element.flow]], the two types of slots.
554
+ * [[Elements]] - documentation for all the buttons, shapes, images, and so on.
555
+
556
+ Two really important pages in there are the [[Element Element Creation]] page
557
+ (which lists all the elements you can add) and the [[Common Common Methods]]
558
+ page (which lists methods you'll find on any slot or element.)
559
+
560
+ == Built-in Methods ==
561
+
562
+ These methods can be used anywhere throughout Shoes programs.
563
+
564
+ All of these commands are unusual because you don't attach them with a dot.
565
+ '''Every other method in this manual must be attached to an object with a dot.'''
566
+ But these are built-in methods (also called: Kernel methods.) Which means no dot!
567
+
568
+ A common one is `alert`:
569
+
570
+ {{{
571
+ #!ruby
572
+ alert "No dots in sight"
573
+ }}}
574
+
575
+ Compare that to the method `reverse`, which isn't a Kernel method and is only
576
+ available for Arrays and Strings:
577
+
578
+ {{{
579
+ #!ruby
580
+ "Plaster of Paris".reverse
581
+ #=> "siraP fo retsalP"
582
+ [:dogs, :cows, :snakes].reverse
583
+ #=> [:snakes, :cows, :dogs]
584
+ }}}
585
+
586
+ Most Shoes methods for drawing and making buttons and so on are attached to
587
+ slots. See the section on [[Slots]] for more.
588
+
589
+ ==== Built-in Constants ====
590
+
591
+ Shoes also has a handful of built-in constants which may prove useful if you
592
+ are trying to sniff out what release of Shoes is running.
593
+
594
+ '''Shoes::RELEASE_NAME''' contains a string with the name of the Shoes release.
595
+ All Shoes releases are named, starting with Curious.
596
+
597
+ '''Shoes::RELEASE_ID''' contains a number representing the Shoes release. So,
598
+ for example, Curious is number 1, as it was the first official release.
599
+
600
+ '''Shoes::REVISION''' is the Subversion revision number for this build.
601
+
602
+ '''Shoes::FONTS''' is a complete list of fonts available to the app. This list
603
+ includes any fonts loaded by the [[Built-in.font]] method.
604
+
605
+ === alert(message: a string) » nil ===
606
+
607
+ Pops up a window containing a short message.
608
+
609
+ {{{
610
+ #!ruby
611
+ alert("I'm afraid I must interject!")
612
+ }}}
613
+
614
+ Please use alerts sparingly, as they are incredibly annoying! If you are using
615
+ alerts to show messages to help you debug your program, try checking out the
616
+ [[Built-in.debug]] or [[Built-in.info]] methods.
617
+
618
+ === ask(message: a string) » a string ===
619
+
620
+ Pops up a window and asks a question. For example, you may want to ask someone
621
+ their name.
622
+
623
+ {{{
624
+ #!ruby
625
+ name = ask("Please, enter your name:")
626
+ }}}
627
+
628
+ When the above script is run, the person at the computer will see a window with
629
+ a blank box for entering their name. The name will then be saved in the `name`
630
+ variable.
631
+
632
+ === ask_color(title: a string) » Shoes::Color ===
633
+
634
+ Pops up a color picker window. The program will wait for a color to be picked,
635
+ then gives you back a Color object. See the `Color` help for some ways you can
636
+ use this color.
637
+
638
+ {{{
639
+ #!ruby
640
+ backcolor = ask_color("Pick a background")
641
+ Shoes.app do
642
+ background backcolor
643
+ end
644
+ }}}
645
+
646
+ === ask_open_file() » a string ===
647
+
648
+ Pops up an "Open file..." window. It's the standard window which shows all of
649
+ your folders and lets you select a file to open. Hands you back the name of the
650
+ file.
651
+
652
+ {{{
653
+ #!ruby
654
+ filename = ask_open_file
655
+ Shoes.app do
656
+ para File.read(filename)
657
+ end
658
+ }}}
659
+
660
+ === ask_save_file() » a string ===
661
+
662
+ Pops up a "Save file..." window, similiar to `ask_open_file`, described
663
+ previously.
664
+
665
+ {{{
666
+ #!ruby
667
+ save_as = ask_save_file
668
+ }}}
669
+
670
+ === ask_open_folder() » a string ===
671
+
672
+ Pops up an "Open folder..." window. It's the standard window which shows all of
673
+ your folders and lets you select a folder to open. Hands you back the name of
674
+ the folder.
675
+
676
+ {{{
677
+ #!ruby
678
+ folder = ask_open_folder
679
+ Shoes.app do
680
+ para Dir.entries(folder)
681
+ end
682
+ }}}
683
+
684
+ === ask_save_folder() » a string ===
685
+
686
+ Pops up a "Save folder..." window, similiar to `ask_open_folder`, described
687
+ previously. On OS X, this method currently behaves like an alias of
688
+ `ask_open_folder`.
689
+
690
+ {{{
691
+ #!ruby
692
+ save_to = ask_save_folder
693
+ }}}
694
+
695
+
696
+ === confirm(question: a string) » true or false ===
697
+
698
+ Pops up a yes-or-no question. If the person at the computer, clicks '''yes''',
699
+ you'll get back a `true`. If not, you'll get back `false`.
700
+
701
+ {{{
702
+ #!ruby
703
+ if confirm("Draw a circle?")
704
+ Shoes.app{ oval :top => 0, :left => 0, :radius => 50 }
705
+ end
706
+ }}}
707
+
708
+ === debug(message: a string) » nil ===
709
+
710
+ Sends a debug message to the Shoes console. You can bring up the Shoes console
711
+ by pressing `Alt-/` on any Shoes window (or `⌘-/` on OS X.)
712
+
713
+ {{{
714
+ #!ruby
715
+ debug("Running Shoes on " + RUBY_PLATFORM)
716
+ }}}
717
+
718
+ Also check out the [[Built-in.error]], [[Built-in.warn]] and [[Built-in.info]]
719
+ methods.
720
+
721
+ === error(message: a string) » nil ===
722
+
723
+ Sends an error message to the Shoes console. This method should only be used
724
+ to log errors. Try the [[Built-in.debug]] method for logging messages to
725
+ yourself.
726
+
727
+ Oh, and, rather than a string, you may also hand exceptions directly to this
728
+ method and they'll be formatted appropriately.
729
+
730
+ === exit() ===
731
+
732
+ Stops your program. Call this anytime you want to suddenly call it quits.
733
+
734
+ '''PLEASE NOTE:''' If you need to use Ruby's own `exit` method (like in a
735
+ forked Ruby process,) call `Kernel.exit`.
736
+
737
+ === font(message: a string) » an array of font family names ===
738
+
739
+ Loads a TrueType (or other type of font) from a file. While TrueType is
740
+ supported by all platforms, your platform may support other types of fonts.
741
+ Shoes uses each operating system's built-in font system to make this work.
742
+
743
+ Here's a rough idea of what fonts work on which platforms:
744
+
745
+ * Bitmap fonts (.bdf, .pcf, .snf) - Linux
746
+ * Font resource (.fon) - Windows
747
+ * Windows bitmap font file (.fnt) - Linux, Windows
748
+ * PostScript OpenType font (.otf) - Mac OS X, Linux, Windows
749
+ * Type1 multiple master (.mmm) - Windows
750
+ * Type1 font bits (.pfb) - Linux, Windows
751
+ * Type1 font metrics (.pfm) - Linux, Windows
752
+ * TrueType font (.ttf) - Mac OS X, Linux, Windows
753
+ * TrueType collection (.ttc) - Mac OS X, Linux, Windows
754
+
755
+ If the font is properly loaded, you'll get back an array of font names found in
756
+ the file. Otherwise, `nil` is returned if no fonts were found in the file.
757
+
758
+ Also of interest: the `Shoes::FONTS` constant is a complete list of fonts
759
+ available to you on this platform. You can check for a certain font by using
760
+ `include?`.
761
+
762
+ {{{
763
+ if Shoes::FONTS.include? "Helvetica"
764
+ alert "Helvetica is available on this system."
765
+ else
766
+ alert "You do not have the Helvetica font."
767
+ end
768
+ }}}
769
+
770
+ If you have trouble with fonts showing up, make sure your app loads the font
771
+ before it is used. Especially on OS X, if fonts are used before they are
772
+ loaded, the font cache will tend to ignore loaded fonts.
773
+
774
+ === gradient(color1, color2) » Shoes::Pattern ===
775
+
776
+ Builds a linear gradient from two colors. For each color, you may pass in a
777
+ Shoes::Color object or a string describing the color.
778
+
779
+ === gray(the numbers: darkness, alpha) » Shoes::Color ===
780
+
781
+ Create a grayscale color from a level of darkness and, optionally, an alpha
782
+ level.
783
+
784
+ {{{
785
+ black = gray(0.0)
786
+ white = gray(1.0)
787
+ }}}
788
+
789
+ === info(message: a string) » nil ===
790
+
791
+ Logs an informational message to the user in the Shoes console. So, where
792
+ debug messages are designed to help the program figure out what's happening,
793
+ `info` messages tell the user extra information about the program.
794
+
795
+ {{{
796
+ #!ruby
797
+
798
+ info("You just ran the info example on Shoes #{Shoes::RELEASE_NAME}.")
799
+ }}}
800
+
801
+ For example, whenever a Shy file loads, Shoes prints an informational message
802
+ in the console describing the author of the Shy and its version.
803
+
804
+ === rgb(a series of numbers: red, green, blue, alpha) » Shoes::Color ===
805
+
806
+ Create a color from red, green and blue components. An alpha level (indicating
807
+ transparency) can also be added, optionally.
808
+
809
+ When passing in a whole number, use values from 0 to 255.
810
+
811
+ {{{
812
+ blueviolet = rgb(138, 43, 226)
813
+ darkgreen = rgb(0, 100, 0)
814
+ }}}
815
+
816
+ Or, use a decimal number from 0.0 to 1.0.
817
+
818
+ {{{
819
+ blueviolet = rgb(0.54, 0.17, 0.89)
820
+ darkgreen = rgb(0, 0.4, 0)
821
+ }}}
822
+
823
+ This method may also be called as `Shoes.rgb`.
824
+
825
+ === warn(message: a string) » nil ===
826
+
827
+ Logs a warning for the user. A warning is not a catastrophic error (see
828
+ [[Built-in.error]] for that.) It is just a notice that the program will be
829
+ changing in the future or that certain parts of the program aren't reliable
830
+ yet.
831
+
832
+ To view warnings and errors, open the Shoes console with `Alt-/` (or `⌘-/` on
833
+ OS X.)
834
+
835
+ == The App Object ==
836
+
837
+ An App is a single window running code at a URL. When you switch URLs, a new
838
+ App object is created and filled up with stacks, flows and other Shoes
839
+ elements.
840
+
841
+ The App is the window itself. Which may be closed or cleared and filled with
842
+ new elements. !{:margin_left => 100}man-app.png!
843
+
844
+ The App itself, in slot/box terminology, is a flow. See the ''Slots'' section
845
+ for more, but this just means that any elements placed directly at the
846
+ top-level will flow.
847
+
848
+ === Shoes.app(styles) { ... } » Shoes::App ===
849
+
850
+ Starts up a Shoes app window. This is the starting place for making a Shoes
851
+ program. Inside the block, you fill the window with various Shoes elements
852
+ (buttons, artwork, etc.) and, outside the block, you use the `styles` to
853
+ describe how big the window is. Perhaps also the name of the app or if it's
854
+ resizable.
855
+
856
+ {{{
857
+ #!ruby
858
+ Shoes.app(:title => "White Circle",
859
+ :width => 200, :height => 200, :resizable => false) {
860
+ background black
861
+ fill white
862
+ oval :top => 20, :left => 20, :radius => 160
863
+ }
864
+ }}}
865
+
866
+ In the case above, a small window is built. 200 pixels by 200 pixels. It's
867
+ not resizable. And, inside the window, two elements: a black background and a
868
+ white circle.
869
+
870
+ Once an app is created, it is added to the [[App.Shoes.APPS]] list. If you
871
+ want an app to spawn more windows, see the [[Element.window]] method and the
872
+ [[Element.dialog]] method.
873
+
874
+ === Shoes.APPS() » An array of Shoes::App objects ===
875
+
876
+ Builds a complete list of all the Shoes apps that are open right now. Once an
877
+ app is closed, it is removed from the list. Yes, you can run many apps at once
878
+ in Shoes. It's completely encouraged.
879
+
880
+ === clipboard() » a string ===
881
+
882
+ Returns a string containing all of the text that's on the system clipboard.
883
+ This is the global clipboard that every program on the computer cuts and pastes
884
+ into.
885
+
886
+ === clipboard = a string ===
887
+
888
+ Stores `a string` of text in the system clipboard.
889
+
890
+ === close() ===
891
+
892
+ Closes the app window. If multiple windows are open and you want to close the
893
+ entire application, use the built-in method `exit`.
894
+
895
+ === download(url: a string, styles) ===
896
+
897
+ Starts a download thread (much like XMLHttpRequest, if you're familiar with
898
+ JavaScript.) This method returns immediately and runs the download in the
899
+ background. Each download thread also fires `start`, `progress` and `finish`
900
+ events. You can send the download to a file or just get back a string (in the
901
+ `finish` event.)
902
+
903
+ If you attach a block to a download, it'll get called as the `finish` event.
904
+
905
+ {{{
906
+ #!ruby
907
+ Shoes.app do
908
+ stack do
909
+ title "Searching Google", :size => 16
910
+ @status = para "One moment..."
911
+
912
+ # Search Google for 'shoes' and print the HTTP headers
913
+ download "http://www.google.com/search?q=shoes" do |goog|
914
+ @status.text = "Headers: " + goog.response.headers.inspect
915
+ end
916
+ end
917
+ end
918
+ }}}
919
+
920
+ And, if we wanted to use the downloaded data, we'd get it using
921
+ `goog.response.body`. This example is truly the simplest form of `download`:
922
+ pulling some web data down into memory and handling it once it's done.
923
+
924
+ Another simple use of `download` is to save some web data to a file, using the
925
+ `:save` style.
926
+
927
+ {{{
928
+ #!ruby
929
+ Shoes.app do
930
+ stack do
931
+ title "Downloading Google image", :size => 16
932
+ @status = para "One moment..."
933
+
934
+ download "http://www.google.com/logos/nasa50th.gif",
935
+ :save => "nasa50th.gif" do
936
+ @status.text = "Okay, is downloaded."
937
+ end
938
+ end
939
+ end
940
+ }}}
941
+
942
+ In this case, you can still get the headers for the downloaded file, but
943
+ `response.body` will be `nil`, since the data wasn't saved to memory. You will
944
+ need to open the file to get the downloaded goods.
945
+
946
+ If you need to send certain headers or actions to the web server, you can use
947
+ the `:method`, `:headers` and `:body` styles to customize the HTTP request.
948
+ (And, if you need to go beyond these, you can always break out Ruby's OpenURI
949
+ class.)
950
+
951
+ {{{
952
+ #!ruby
953
+ Shoes.app do
954
+ stack do
955
+ title "GET Google", :size => 16
956
+ @status = para "One moment..."
957
+
958
+ download "http://www.google.com/search?q=shoes",
959
+ :method => "GET" do |dump|
960
+ @status.text = dump.response.body
961
+ end
962
+ end
963
+ end
964
+ }}}
965
+
966
+ As you can see from the above example, Shoes makes use of the "GET" method to
967
+ query google's search engine.
968
+
969
+ === location() » a string ===
970
+
971
+ Gets a string containing the URL of the current app.
972
+
973
+ === mouse() » an array of numbers: button, left, top ===
974
+
975
+ Identifies the mouse cursor's location, along with which button is being
976
+ pressed.
977
+
978
+ {{{
979
+ #!ruby
980
+ Shoes.app do
981
+ @p = para
982
+ animate do
983
+ button, left, top = self.mouse
984
+ @p.replace "mouse: #{button}, #{left}, #{top}"
985
+ end
986
+ end
987
+ }}}
988
+
989
+ === owner() » Shoes::App ===
990
+
991
+ Gets the app which launched this app. In most cases, this will be `nil`. But
992
+ if this app was launched using the [[Element.window]] method, the owner will be
993
+ the app which called `window`.
994
+
995
+ === started?() » true or false ===
996
+
997
+ Has the window been fully constructed and displayed? This is useful for
998
+ threaded code which may try to use the window before it is completely built.
999
+ (Also see the `start` event which fires once the window is open.)
1000
+
1001
+ === visit(url: a string) ===
1002
+
1003
+ Changes the location, in order to view a different Shoes URL.
1004
+
1005
+ Absolute URLs (such as http://google.com) are okay, but Shoes will be expecting
1006
+ a Shoes application to be at that address. (So, google.com won't work, as it's
1007
+ an HTML app.)
1008
+
1009
+ == The Styles Master List ==
1010
+
1011
+ You want to mess with the look of things? Well, throughout Shoes, styles are
1012
+ used to change the way elements appear. In some cases, you can even style an
1013
+ entire class of elements. (Like giving all paragraphs a certain font.)
1014
+
1015
+ Styles are easy to spot. They usually show up when the element is created.
1016
+
1017
+ {{{
1018
+ Shoes.app :title => "A Styling Sample" do
1019
+ para "Red with an underline", :stroke => red, :underline => "single"
1020
+ end
1021
+ }}}
1022
+
1023
+ Here we've got a `:title` style on the app. And on the paragraph inside the
1024
+ app, a red `:stroke` style and an `:underline` style.
1025
+
1026
+ The style hash can also be changed by using the [[Common.style]] method,
1027
+ available on every element and slot.
1028
+
1029
+ {{{
1030
+ Shoes.app :title => "A Styling Sample" do
1031
+ @text = para "Red with an underline"
1032
+ @text.style(:stroke => red, :underline => "single")
1033
+ end
1034
+ }}}
1035
+
1036
+ Most styles can also be set by calling them as methods. (I'd use the manual
1037
+ search to find the method.)
1038
+
1039
+ {{{
1040
+ Shoes.app :title => "A Styling Sample" do
1041
+ @text = para "Red with an underline"
1042
+ @text.stroke = red
1043
+ @text.underline = "single"
1044
+ end
1045
+ }}}
1046
+
1047
+ Rather than making you plow through the whole manual to figure out what styles
1048
+ go where, this helpful page speeds through every style in Shoes and suggests
1049
+ where that style is used.
1050
+
1051
+ === :align » a string ===
1052
+
1053
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1054
+ strong, sub, sup, subtitle, tagline, title''
1055
+
1056
+ The alignment of the text. It is either:
1057
+
1058
+ * "left" - Align the text to the left.
1059
+ * "center" - Align the text in the center.
1060
+ * "right" - Align the text to the right.
1061
+
1062
+ === :angle » a number ===
1063
+
1064
+ For: ''background, border, gradient''.
1065
+
1066
+ The angle at which to apply a gradient. Normally, gradient colors range from
1067
+ top to bottom. If the `:angle` is set to 90, the gradient will rotate 90
1068
+ degrees counter-clockwise and the gradient will go from left to right.
1069
+
1070
+ === :attach » a slot or element ===
1071
+
1072
+ For: ''flow, stack''.
1073
+
1074
+ Pins a slot relative to another slot or element. Also, one may write `:attach
1075
+ => Window` to position the slot at the window's top, left corner. Taking this
1076
+ a bit further, the style `:top => 10, :left => 10, :attach => Window` would
1077
+ place the slot at (10, 10) in the window's coordinates.
1078
+
1079
+ If a slot is attached to an element that moves, the slot will move with it. If
1080
+ the attachment is reset to `nil`, the slot will flow in with the other objects
1081
+ that surround, as normal.
1082
+
1083
+ === :autoplay » true or false ===
1084
+
1085
+ For: ''video''.
1086
+
1087
+ Should this video begin playing after it appears? If set to `true`, the video
1088
+ will start without asking the user.
1089
+
1090
+ === :bottom » a number ===
1091
+
1092
+ For: ''all slots and elements''.
1093
+
1094
+ Sets the pixel coordinate of an element's lower edge. The edge is placed
1095
+ relative to its container's lower edge. So, `:bottom => 0` will align the
1096
+ element so that its bottom edge and the bottom edge of its slot touch.
1097
+
1098
+ === :cap » :curve or :rect or :project ===
1099
+
1100
+ For: ''arc, arrow, border, flow, image, mask, rect, star, shape, stack''.
1101
+
1102
+ Sets the shape of the line endpoint, whether curved or square. See the
1103
+ [[Art.cap]] method for more explanation.
1104
+
1105
+ === :center » true or false ===
1106
+
1107
+ For: ''arc, image, oval, rect, shape''.
1108
+
1109
+ Indicates whether the `:top` and `:left` coordinates refer to the center of the
1110
+ shape or not. If set to `true`, this is similar to setting the
1111
+ [[Art.transform]] method to `:center`.
1112
+
1113
+ === :change » a proc ===
1114
+
1115
+ For: ''edit_box, edit_line, list_box''.
1116
+
1117
+ The `change` event handler is stored in this style. See the [[EditBox.change]]
1118
+ method for the edit_box, as an example.
1119
+
1120
+ === :checked » true or false ===
1121
+
1122
+ For: ''check, radio''.
1123
+
1124
+ Is this checkbox or radio button checked? If set to `true`, the box is
1125
+ checked. Also see the [[Check.checked=]] method.
1126
+
1127
+ === :choose » a string ===
1128
+
1129
+ For: ''list_box''.
1130
+
1131
+ Sets the currently chosen item in the list. More information at
1132
+ [[ListBox.choose]].
1133
+
1134
+ === :click » a proc ===
1135
+
1136
+ For: ''arc, arrow, banner, button, caption, check, flow, image, inscription,
1137
+ line, link, mask, oval, para, radio, rect, shape, stack, star, subtitle,
1138
+ tagline, title''.
1139
+
1140
+ The `click` event handler is stored in this style. See the [[Events.click]]
1141
+ method for a description.
1142
+
1143
+ === :curve » a number ===
1144
+
1145
+ For: ''background, border, rect''.
1146
+
1147
+ The radius of curved corners on each of these rectangular elements. As an
1148
+ example, if this is set to 6, the corners of the rectangle are given a curve
1149
+ with a 6-pixel radius.
1150
+
1151
+ === :displace_left » a number ===
1152
+
1153
+ For: ''all slots and elements''.
1154
+
1155
+ Moves a shape, text block or any other kind of object to the left or right. A
1156
+ positive number displaces to the right by the given number of pixels; a
1157
+ negative number displaces to the left. Displacing an object doesn't effect the
1158
+ actual layout of the page. Before using this style, be sure to read the
1159
+ [[Position.displace]] docs, since its behavior can be a bit surprising.
1160
+
1161
+ === :displace_top » a number ===
1162
+
1163
+ For: ''all slots and elements''.
1164
+
1165
+ Moves a shape, text block or any other kind of object up or down. A positive
1166
+ number moves the object down by this number of pixels; a negative number moves
1167
+ it up. Displacing doesn't effect the actual layout of the page or the object's
1168
+ true coordinates. Read the [[Position.displace]] docs, since its behavior can
1169
+ be a bit surprising.
1170
+
1171
+ === :emphasis » a string ===
1172
+
1173
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1174
+ strong, sub, sup, subtitle, tagline, title''.
1175
+
1176
+ Styles the text with an emphasis (commonly italicized.)
1177
+
1178
+ This style recognizes three possible settings:
1179
+
1180
+ * "normal" - the font is upright.
1181
+ * "oblique" - the font is slanted, but in a roman style.
1182
+ * "italic" - the font is slanted in an italic style.
1183
+
1184
+ === :family » a string ===
1185
+
1186
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1187
+ strong, sub, sup, subtitle, tagline, title''.
1188
+
1189
+ Styles the text with a given font family. The string should contain the family
1190
+ name or a comma-separated list of families.
1191
+
1192
+ === :fill » a hex code, a Shoes::Color or a range of either ===
1193
+
1194
+ For: ''arc, arrow, background, banner, caption, code, del, em, flow, image,
1195
+ ins, inscription, line, link, mask, oval, para, rect, shape, span, stack, star,
1196
+ strong, sub, sup, subtitle, tagline, title''.
1197
+
1198
+ The color of the background pen. For shapes, this is the fill color, the paint
1199
+ inside the shape. For text stuffs, this color is painted in the background (as
1200
+ if marked with a highlighter pen.)
1201
+
1202
+ === :font » a string ===
1203
+
1204
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1205
+ strong, sub, sup, subtitle, tagline, title''.
1206
+
1207
+ Styles the text with a font description. The string is pretty flexible, but
1208
+ can take the form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is
1209
+ a comma separated list of families optionally terminated by a comma,
1210
+ STYLE_OPTIONS is a whitespace separated list of words where each WORD describes
1211
+ one of style, variant, weight, stretch, or gravity, and SIZE is a decimal
1212
+ number (size in points) or optionally followed by the unit modifier "px" for
1213
+ absolute size. Any one of the options may be absent. If FAMILY-LIST is absent,
1214
+ then the default font family (Arial) will be used.
1215
+
1216
+ === :group » a string ===
1217
+
1218
+ For: ''radio''.
1219
+
1220
+ Indicates what group a radio button belongs to. Without this setting, radio
1221
+ buttons are grouped together with other radio buttons in their immediate slot.
1222
+ "Grouping" radio buttons doesn't mean they'll be grouped next to each other on
1223
+ the screen. It means that only one radio button from the group can be selected
1224
+ at a time.
1225
+
1226
+ By giving this style a string, the radio button will be grouped with other
1227
+ radio buttons that have the same group name.
1228
+
1229
+ === :height » a number ===
1230
+
1231
+ For: ''all slots and elements''.
1232
+
1233
+ Sets the pixel height of this object. If the number is a decimal number, the
1234
+ height becomes a percentage of its parent's height (with 0.0 being 0% and 1.0
1235
+ being 100%.)
1236
+
1237
+ === :hidden » true or false ===
1238
+
1239
+ For: ''all slots and elements''.
1240
+
1241
+ Hides or shows this object. Any object with `:hidden => true` are not
1242
+ displayed on the screen. Neither are its children.
1243
+
1244
+ === :inner » a number ===
1245
+
1246
+ For: ''star''.
1247
+
1248
+ The size of the inner radius (in pixels.) The inner radius describes the solid
1249
+ circle within the star where the points begin to separate.
1250
+
1251
+ === :items » an array ===
1252
+
1253
+ For: ''list_box''.
1254
+
1255
+ The list of selections in the list box. See the [[Element.list_box]] method
1256
+ for an example.
1257
+
1258
+ === :justify » true or false ===
1259
+
1260
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1261
+ strong, sub, sup, subtitle, tagline, title''
1262
+
1263
+ Evenly spaces the text horizontally.
1264
+
1265
+ === :kerning » a number ===
1266
+
1267
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1268
+ strong, sub, sup, subtitle, tagline, title''.
1269
+
1270
+ Adds to the natural spacing between letters, in pixels.
1271
+
1272
+ === :leading » a number ===
1273
+
1274
+ For: ''banner, caption, inscription, para, subtitle, tagline, title''.
1275
+
1276
+ Sets the spacing between lines in a text block. Defaults to 4 pixels.
1277
+
1278
+ === :left » a number ===
1279
+
1280
+ For: ''all slots and elements''.
1281
+
1282
+ Sets the left coordinate of this object to a specific pixel. Setting `:left =>
1283
+ 10` places the object's left edge ten pixels away from the left edge of the
1284
+ slot containing it. If this style is left unset (or set to `nil`,) the object
1285
+ will flow in with the other objects surrounding it.
1286
+
1287
+ === :margin » a number or an array of four numbers ===
1288
+
1289
+ For: ''all slots and elements''.
1290
+
1291
+ Margins space an element out from its surroundings. Each element has a left,
1292
+ top, right, and bottom margin. If the `:margin` style is set to a single
1293
+ number, the spacing around the element uniformly matches that number. In other
1294
+ words, if `:margin => 8` is set, all the margins around the element are set to
1295
+ eight pixels in length.
1296
+
1297
+ This style can also be given an array of four numbers in the form `[left, top,
1298
+ right, bottom]`.
1299
+
1300
+ === :margin_bottom » a number ===
1301
+
1302
+ For: ''all slots and elements''.
1303
+
1304
+ Sets the bottom margin of the element to a specific pixel size.
1305
+
1306
+ === :margin_left » a number ===
1307
+
1308
+ For: ''all slots and elements''.
1309
+
1310
+ Sets the left margin of the element to a specific pixel size.
1311
+
1312
+ === :margin_right » a number ===
1313
+
1314
+ For: ''all slots and elements''.
1315
+
1316
+ Sets the right margin of the element to a specific pixel size.
1317
+
1318
+ === :margin_top » a number ===
1319
+
1320
+ For: ''all slots and elements''.
1321
+
1322
+ Sets the top margin of the element to a specific pixel size.
1323
+
1324
+ === :outer » a number ===
1325
+
1326
+ For: ''star''.
1327
+
1328
+ Sets the outer radius (half of the ''total'' width) of the star, in pixels.
1329
+
1330
+ === :points » a number ===
1331
+
1332
+ For: ''star''.
1333
+
1334
+ How many points does this star have? A style of `:points => 5` creates a
1335
+ five-pointed star.
1336
+
1337
+ === :radius » a number ===
1338
+
1339
+ For: ''arc, arrow, background, border, gradient, oval, rect, shape''.
1340
+
1341
+ Sets the radius (half of the diameter or total width) for each of these
1342
+ elements. Setting this is equivalent to setting both `:width` and `:height` to
1343
+ double this number.
1344
+
1345
+ === :right » a number ===
1346
+
1347
+ For: ''all slots and elements''.
1348
+
1349
+ Sets the pixel coordinate of an element's right edge. The edge is placed
1350
+ relative to its container's rightmost edge. So, `:right => 0` will align the
1351
+ element so that its own right edge and the right edge of its slot touch.
1352
+ Whereas `:right => 20` will position the right edge of the element off to the
1353
+ left of its slot's right edge by twenty pixels.
1354
+
1355
+ === :rise » a number ===
1356
+
1357
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1358
+ strong, sub, sup, subtitle, tagline, title''.
1359
+
1360
+ Lifts or plunges the font baseline for some text. For example, a
1361
+ [[Element.sup]] has a `:rise` of 10 pixels. Conversely, the [[Element.sub]]
1362
+ element has a `:rise` of -10 pixels.
1363
+
1364
+ === :scroll » true or false ===
1365
+
1366
+ For: ''flow, stack''.
1367
+
1368
+ Establishes this slot as a scrolling slot. If `:scroll => true` is set, the
1369
+ slot will show a scrollbar if any of its contents go past its height. The
1370
+ scrollbar will appear and disappear as needed. It will also appear inside the
1371
+ width of the slot, meaning the slot's width will never change, regardless of
1372
+ whether there is a scrollbar or not.
1373
+
1374
+ === :secret » true or false ===
1375
+
1376
+ For: ''ask, edit_line''.
1377
+
1378
+ Used for password fields, this setting keeps any characters typed in from
1379
+ becoming visible on the screen. Instead, a replacement character (such as an
1380
+ asterisk) is show for each letter typed.
1381
+
1382
+ === :size » a number ===
1383
+
1384
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1385
+ strong, sub, sup, subtitle, tagline, title''.
1386
+
1387
+ Sets the pixel size for the font used inside this text block or text fragment.
1388
+
1389
+ Font size may also be augmented, through use of the following strings:
1390
+
1391
+ * "xx-small" - 57% of present size.
1392
+ * "x-small" - 64% of present size.
1393
+ * "small" - 83% of present size.
1394
+ * "medium" - no change in size.
1395
+ * "large" - 120% of present size.
1396
+ * "x-large" - 143% of present size.
1397
+ * "xx-large" - 173% of present size.
1398
+
1399
+ === :state » a string ===
1400
+
1401
+ For: ''button, check, edit_box, edit_line, list_box, radio''.
1402
+
1403
+ The `:state` style is for disabling or locking certain controls, if you don't
1404
+ want them to be edited.
1405
+
1406
+ Here are the possible style settings:
1407
+
1408
+ * nil - the control is active and editable.
1409
+ * "readonly" - the control is active but cannot be edited.
1410
+ * "disabled" - the control is not active (grayed out) and cannot be edited.
1411
+
1412
+ === :stretch » a string ===
1413
+
1414
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1415
+ strong, sub, sup, subtitle, tagline, title''.
1416
+
1417
+ Sets the font stretching used for a text object.
1418
+
1419
+ Possible settings are:
1420
+
1421
+ * "condensed" - a smaller width of letters.
1422
+ * "normal" - the standard width of letters.
1423
+ * "expanded" - a larger width of letters.
1424
+
1425
+ === :strikecolor » a Shoes::Color ===
1426
+
1427
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1428
+ strong, sub, sup, subtitle, tagline, title''.
1429
+
1430
+ The color used to paint any lines stricken through this text.
1431
+
1432
+ === :strikethrough » a string ===
1433
+
1434
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1435
+ strong, sub, sup, subtitle, tagline, title''.
1436
+
1437
+ Is this text stricken through? Two options here:
1438
+
1439
+ * "none" - no strikethrough
1440
+ * "single" - a single-line strikethrough.
1441
+
1442
+ === :stroke » a hex code, a Shoes::Color or a range of either ===
1443
+
1444
+ For: ''arc, arrow, banner, border, caption, code, del, em, flow, image, ins,
1445
+ inscription, line, link, mask, oval, para, rect, shape, span, stack, star,
1446
+ strong, sub, sup, subtitle, tagline, title''.
1447
+
1448
+ The color of the foreground pen. In the case of shapes, this is the color the
1449
+ lines are drawn with. For paragraphs and other text, the letters are printed
1450
+ in this color.
1451
+
1452
+ === :strokewidth » a number ===
1453
+
1454
+ For: ''arc, arrow, border, flow, image, line, mask, oval, rect, shape, star, stack''.
1455
+
1456
+ The thickness of the stroke, in pixels, of the line defining each of these
1457
+ shapes. For example, the number two would set the strokewidth to 2 pixels.
1458
+
1459
+ === :text » a string ===
1460
+
1461
+ For: ''button, edit_box, edit_line''.
1462
+
1463
+ Sets the message displayed on a button control, or the contents of an edit_box
1464
+ or edit_line.
1465
+
1466
+ === :top » a number ===
1467
+
1468
+ For: ''all slots and elements''.
1469
+
1470
+ Sets the top coordinate for an object, relative to its parent slot. If an
1471
+ object is set with `:top => 40`, this means the object's top edge will be
1472
+ placed 40 pixels beneath the top edge of the slot that contains it. If no
1473
+ `:top` style is given, the object is automatically placed in the natural flow
1474
+ of its slot.
1475
+
1476
+ === :undercolor » a Shoes::Color ===
1477
+
1478
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1479
+ strong, sub, sup, subtitle, tagline, title''.
1480
+
1481
+ The color used to underline text.
1482
+
1483
+ === :underline » a string ===
1484
+
1485
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1486
+ strong, sub, sup, subtitle, tagline, title''.
1487
+
1488
+ Dictates the style of underline used in the text.
1489
+
1490
+ The choices for this setting are:
1491
+
1492
+ * "none" - no underline at all.
1493
+ * "single" - a continuous underline.
1494
+ * "double" - two continuous parallel underlines.
1495
+ * "low" - a lower underline, beneath the font baseline. (This is generally recommended only for single characters, particularly when showing keyboard accelerators.)
1496
+ * "error" - a wavy underline, usually found indicating a misspelling.
1497
+
1498
+ === :variant » a string ===
1499
+
1500
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1501
+ strong, sub, sup, subtitle, tagline, title''.
1502
+
1503
+ Vary the font for a group of text. Two choices:
1504
+
1505
+ * "normal" - standard font.
1506
+ * "smallcaps" - font with the lower case characters replaced by smaller variants of the capital characters.
1507
+
1508
+ === :weight » a string ===
1509
+
1510
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1511
+ strong, sub, sup, subtitle, tagline, title''.
1512
+
1513
+ Set the boldness of the text. Commonly, this style is set to one of the
1514
+ following strings:
1515
+
1516
+ * "ultralight" - the ultralight weight (= 200)
1517
+ * "light" - the light weight (= 300)
1518
+ * "normal" - the default weight (= 400)
1519
+ * "semibold" - a weight intermediate between normal and bold (= 600)
1520
+ * "bold" - the bold weight (= 700)
1521
+ * "ultrabold" - the ultrabold weight (= 800)
1522
+ * "heavy" - the heavy weight (= 900)
1523
+
1524
+ However, you may also pass in the numerical weight directly.
1525
+
1526
+ === :width » a number ===
1527
+
1528
+ For: ''all slots and elements''.
1529
+
1530
+ Sets the pixel width for the element. If the number is a decimal, the width is
1531
+ converted to a percentage (with 0.0 being 0% and 1.0 being 100%.) A width of
1532
+ 100% means the object fills its parent slot.
1533
+
1534
+ === :wrap » a string ===
1535
+
1536
+ For: ''banner, caption, code, del, em, ins, inscription, link, para, span,
1537
+ strong, sub, sup, subtitle, tagline, title''
1538
+
1539
+ How should the text wrap when it fills its width? Possible options are:
1540
+
1541
+ * "word" - Break lines at word breaks.
1542
+ * "char" - Break lines between characters, thus breaking some words.
1543
+ * "trim" - Cut the line off with an ellipsis if it goes too long.
1544
+
1545
+ == Classes List ==
1546
+
1547
+ Here is a complete list of all the classes introduced by Shoes. This chart is
1548
+ laid out according to how classes inherits from each other. Subclasses are
1549
+ indented one level to the right, beneath their parent class.
1550
+
1551
+ {INDEX}
1552
+
1553
+ == Colors List ==
1554
+
1555
+ The following list of colors can be used throughout Shoes. As background
1556
+ colors or border colors. As stroke and fill colors. Most of these colors come
1557
+ from the X11 and HTML palettes.
1558
+
1559
+ All of these colors can be used by name. (So calling the `tomato` method from
1560
+ inside any slot will get you a nice reddish color.) Below each color, also
1561
+ find the exact numbers which can be used with the [[Built-in.rgb]] method.
1562
+
1563
+ {COLORS}
1564
+
1565
+ = Slots =
1566
+
1567
+ Slots are boxes used to lay out images, text and so on. The two most common
1568
+ slots are `stacks` and `flows`. Slots can also be referred to as "boxes" or
1569
+ "canvases" in Shoes terminology.
1570
+
1571
+ Since the mouse wheel and PageUp and PageDown are so pervasive on every
1572
+ platform, vertical scrolling has really become the only overflow that matters.
1573
+ So, in Shoes, just as on the web, width is generally fixed. While height goes
1574
+ on and on.
1575
+
1576
+ Now, you can also just use specific widths and heights for everything, if you
1577
+ want. That'll take some math, but everything could be perfect.
1578
+
1579
+ Generally, I'd suggest using stacks and flows. The idea here is that you want
1580
+ to fill up a certain width with things, then advance down the page, filling up
1581
+ further widths. You can think of these as being analogous to HTML's "block" and
1582
+ "inline" styles.
1583
+
1584
+ ==== Stacks ====
1585
+
1586
+ A stack is simply a vertical stack of elements. Each element in a stack is
1587
+ placed directly under the element preceding it.
1588
+
1589
+ A stack is also shaped like a box. So if a stack is given a width of 250, that
1590
+ stack is itself an element which is 250 pixels wide.
1591
+
1592
+ To create a new stack, use the [[Element.stack]] method, which is available
1593
+ inside any slot. So stacks can contain other stacks and flows.
1594
+
1595
+ ==== Flows ====
1596
+
1597
+ A flow will pack elements in as tightly as it can. A width will be filled, then
1598
+ will wrap beneath those elements. Text elements placed next to each other will
1599
+ appear as a single paragraph. Images and widgets will run together as a series.
1600
+
1601
+ Like the stack, a flow is a box. So stacks and flows can safely be embedded
1602
+ and, without respect to their contents, are identical. They just treat their
1603
+ contents differently.
1604
+
1605
+ Making a flow means calling the [[Element.flow]] method. Flows may contain
1606
+ other flows and stacks.
1607
+
1608
+ Last thing: The Shoes window itself is a flow.
1609
+
1610
+ == Art for Slots ==
1611
+
1612
+ Each slot is like a canvas, a blank surface which can be covered with an
1613
+ assortment of colored shapes or gradients.
1614
+
1615
+ Many common shapes can be drawn with methods like `oval` and `rect`. You'll
1616
+ need to set up the paintbrush colors first, though.
1617
+
1618
+ The `stroke` command sets the line color. And the `fill` command sets the
1619
+ color used to paint inside the lines.
1620
+
1621
+ {{{
1622
+ #!ruby
1623
+ Shoes.app do
1624
+ stroke red
1625
+ fill blue
1626
+ oval :top => 10, :left => 10,
1627
+ :radius => 100
1628
+ end
1629
+ }}}
1630
+
1631
+ That code gives you a blue pie with a red line around it. One-hundred pixels
1632
+ wide, placed just a few pixels southeast of the window's upper left corner.
1633
+
1634
+ The `blue` and `red` methods above are Color objects. See the section on
1635
+ Colors for more on how to mix colors.
1636
+
1637
+ ==== Inspiration from Processing and NodeBox ====
1638
+
1639
+ The artful methods generally come verbatim from NodeBox, a drawing kit for
1640
+ Python. In turn, NodeBox gets much of its ideas from Processing, a Java-like
1641
+ language for graphics and animation. I owe a great debt to the creators of
1642
+ these wonderful programs!
1643
+
1644
+ Shoes does a few things differently from NodeBox and Processing. For example,
1645
+ Shoes has different color methods, including having its own Color objects,
1646
+ though these are very similar to Processing's color methods. And Shoes also
1647
+ allows images and gradients to be used for drawing lines and filling in shapes.
1648
+
1649
+ Shoes also borrows some animation ideas from Processing and will continue to
1650
+ closely consult Processing's methods as it expands.
1651
+
1652
+ === arc(left, top, width, height, angle1, angle2) » Shoes::Shape ===
1653
+
1654
+ Draws an arc shape (a section of an oval) at coordinates (left, top). This
1655
+ method just give you a bit more control than [[oval]], by offering the
1656
+ `:angle1` and `:angle2` styles. (In fact, you can mimick the `oval` method by
1657
+ setting `:angle1` to 0 and `:angle2` to `Shoes::TWO_PI`.)
1658
+
1659
+ === arrow(left, top, width) » Shoes::Shape ===
1660
+
1661
+ Draws an arrow at coordinates (left, top) with a pixel `width`.
1662
+
1663
+ === cap(:curve or :rect or :project) » self ===
1664
+
1665
+ Sets the line cap, which is the shape at the end of every line you draw. If
1666
+ set to `:curve`, the end is rounded. The default is `:rect`, a line which ends
1667
+ abruptly flat. The `:project` cap is also fat, but sticks out a bit longer.
1668
+
1669
+ === fill(pattern) » pattern ===
1670
+
1671
+ Sets the fill bucket to a specific color (or pattern.) Patterns can be colors,
1672
+ gradients or images. So, once the fill bucket is set, you can draw shapes and
1673
+ they will be colored in with the pattern you've chosen.
1674
+
1675
+ To draw a star with an image pattern:
1676
+
1677
+ {{{
1678
+ #!ruby
1679
+ Shoes.app do
1680
+ fill "static/avatar.png"
1681
+ star 200, 200, 5
1682
+ end
1683
+ }}}
1684
+
1685
+ To clear the fill bucket, use `nofill`. And to set the line color (the border
1686
+ of the star,) use the `stroke` method.
1687
+
1688
+ === nofill() » self ===
1689
+
1690
+ Blanks the fill color, so that any shapes drawn will not be filled in.
1691
+ Instead, shapes will have only a lining, leaving the middle transparent.
1692
+
1693
+ === nostroke() » self ===
1694
+
1695
+ Empties the line color. Shapes drawn will have no outer line. If `nofill` is
1696
+ also set, shapes drawn will not be visible.
1697
+
1698
+ === line(left, top, x2, y2) » Shoes::Shape ===
1699
+
1700
+ Draws a line using the current line color (aka "stroke") starting at
1701
+ coordinates (left, top) and ending at coordinates (x2, y2).
1702
+
1703
+ === oval(left, top, radius) » Shoes::Shape ===
1704
+
1705
+ Draws a circular form at pixel coordinates (left, top) with a width and height
1706
+ of `radius` pixels. The line and fill colors are used to draw the shape. By
1707
+ default, the coordinates are for the oval's leftmost, top corner, but this can
1708
+ be changed by calling the [[Art.transform]] method or by using the `:center`
1709
+ style on the next method below.
1710
+
1711
+ {{{
1712
+ #!ruby
1713
+ Shoes.app do
1714
+ stroke blue
1715
+ strokewidth 4
1716
+ fill black
1717
+ oval 10, 10, 50
1718
+ end
1719
+ }}}
1720
+
1721
+ To draw an oval of varied proportions, you may also use the syntax: `oval(left, top, width, height)`.
1722
+
1723
+ === oval(styles) » Shoes::Shape ===
1724
+
1725
+ Draw circular form using a style hash. The following styles are supported:
1726
+
1727
+ * `top`: the y-coordinate for the oval pen.
1728
+ * `left`: the x-coordinate for the oval pen.
1729
+ * `radius`: the width and height of the circle.
1730
+ * `width`: a specific pixel width for the oval.
1731
+ * `height`: a specific pixel height for the oval.
1732
+ * `center`: do the coordinates specific the oval's center? (true or false)
1733
+
1734
+ These styles may also be altered using the `style` method on the Shape object.
1735
+
1736
+ === rect(top, left, width, height, corners = 0) » Shoes::Shape ===
1737
+
1738
+ Draws a rectangle starting from coordinates (top, left) with dimensions of
1739
+ width x height. Optionally, you may give the rectangle rounded corners with a
1740
+ fifth argument: the radius of the corners in pixels.
1741
+
1742
+ As with all other shapes, the rectangle is drawn using the stroke and fill colors.
1743
+
1744
+ {{{
1745
+ #!ruby
1746
+ Shoes.app do
1747
+ stroke rgb(0.5, 0.5, 0.7)
1748
+ fill rgb(1.0, 1.0, 0.9)
1749
+ rect 10, 10, self.width - 20, self.height - 20
1750
+ end
1751
+ }}}
1752
+
1753
+ The above sample draws a rectangle which fills the area of its parent box,
1754
+ leaving a margin of 10 pixels around the edge. Also see the `background`
1755
+ method for a rectangle which defaults to filling its parent box.
1756
+
1757
+ === rect(styles) » Shoes::Shape ===
1758
+
1759
+ Draw a rectangle using a style hash. The following styles are supported:
1760
+
1761
+ * `top`: the y-coordinate for the rectangle.
1762
+ * `left`: the x-coordinate for the rectangle.
1763
+ * `curve`: the pixel radius of the rectangle's corners.
1764
+ * `width`: a specific pixel width for the rectangle.
1765
+ * `height`: a specific pixel height for the rectangle.
1766
+ * `center`: do the coordinates specific the rectangle's center? (true or false)
1767
+
1768
+ These styles may also be altered using the `style` method on the Shape object.
1769
+
1770
+ === rotate(degrees: a number) » self ===
1771
+
1772
+ Rotates the pen used for drawing by a certain number of `degrees`, so that any
1773
+ shapes will be drawn at that angle.
1774
+
1775
+ In this example below, the rectangle drawn at (30, 30) will be rotated 45 degrees.
1776
+
1777
+ {{{
1778
+ #!ruby
1779
+ Shoes.app do
1780
+ fill "#333"
1781
+ rotate 45
1782
+ rect 30, 30, 40, 40
1783
+ end
1784
+ }}}
1785
+
1786
+ === shape(left, top) { ... } » Shoes::Shape ===
1787
+
1788
+ Describes an arbitrary shape to draw, beginning at coordinates (left, top) and
1789
+ continued by calls to `line_to`, `move_to`, `curve_to` and `arc_to` inside the
1790
+ block. You can look at it as sketching a shape with a long line that curves
1791
+ and arcs and bends.
1792
+
1793
+ {{{
1794
+ #!ruby
1795
+ Shoes.app do
1796
+ fill red(0.2)
1797
+ shape do
1798
+ move_to(90, 55)
1799
+ arc_to(50, 55, 50, 50, 0, PI/2)
1800
+ arc_to(50, 55, 60, 60, PI/2, PI)
1801
+ arc_to(50, 55, 70, 70, PI, TWO_PI-PI/2)
1802
+ arc_to(50, 55, 80, 80, TWO_PI-PI/2, TWO_PI)
1803
+ end
1804
+ end
1805
+ }}}
1806
+
1807
+ A shape can also contain other shapes. So, you can place an [[Art.oval]], a
1808
+ [[Art.rect]], a [[Art.line]], a [[Art.star]] or an [[Art.arrow]] (and all of
1809
+ the other methods in this [[Art]] section) inside a shape, but they will not be
1810
+ part of the line. They will be more like a group of shapes are all drawn as
1811
+ one.
1812
+
1813
+ === star(left, top, points = 10, outer = 100.0, inner = 50.0) » Shoes::Shape ===
1814
+
1815
+ Draws a star using the stroke and fill colors. The star is positioned with its
1816
+ center point at coordinates (left, top) with a certain number of `points`. The
1817
+ `outer` width defines the full radius of the star; the `inner` width specifies
1818
+ the radius of the star's middle, where points stem from.
1819
+
1820
+ === stroke(pattern) » pattern ===
1821
+
1822
+ Set the active line color for this slot. The `pattern` may be a color, a
1823
+ gradient or an image, all of which are categorized as "patterns." The line
1824
+ color is then used to draw the borders of any subsequent shape.
1825
+
1826
+ So, to draw an arrow with a red line around it:
1827
+
1828
+ {{{
1829
+ #!ruby
1830
+ Shoes.app do
1831
+ stroke red
1832
+ arrow 0, 100, 10
1833
+ end
1834
+ }}}
1835
+
1836
+ To clear the line color, use the `nostroke` method.
1837
+
1838
+ === strokewidth(a number) » self ===
1839
+
1840
+ Sets the line size for all drawing within this slot. Whereas the `stroke`
1841
+ method alters the line color, the `strokewidth` method alters the line size in
1842
+ pixels. Calling `strokewidth(4)` will cause lines to be drawn 4 pixels wide.
1843
+
1844
+ === transform(:center or :corner) » self ===
1845
+
1846
+ Should transformations (such as `skew` and `rotate`) be performed around the
1847
+ center of the shape? Or the corner of the shape? Shoes defaults to `:corner`.
1848
+
1849
+ === translate(left, top) » self ===
1850
+
1851
+ Moves the starting point of the drawing pen for this slot. Normally, the pen
1852
+ starts at (0, 0) in the top-left corner, so that all shapes are drawn from that
1853
+ point. With `translate`, if the starting point is moved to (10, 20) and a
1854
+ shape is drawn at (50, 60), then the shape is actually drawn at (60, 80) on the
1855
+ slot.
1856
+
1857
+ == Element Creation ==
1858
+
1859
+ Shoes has a wide variety of elements, many cherry-picked from HTML. This page
1860
+ describes how to create these elements in a slot. See the Elements section of
1861
+ the manual for more on how to modify and use these elements after they have
1862
+ been placed.
1863
+
1864
+ === animate(fps) { |frame| ... } » Shoes::Animation ===
1865
+
1866
+ Starts an animation timer, which runs parallel to the rest of the app. The
1867
+ `fps` is a number, the frames per seconds. This number dictates how many times
1868
+ per second the attached block will be called.
1869
+
1870
+ The block is given a `frame` number. Starting with zero, the `frame` number
1871
+ tells the block how many frames of the animation have been shown.
1872
+
1873
+ {{{
1874
+ #!ruby
1875
+ Shoes.app do
1876
+ @counter = para "STARTING"
1877
+ animate(24) do |frame|
1878
+ @counter.replace "FRAME #{frame}"
1879
+ end
1880
+ end
1881
+ }}}
1882
+
1883
+ The above animation is shown 24 times per second. If no number is given, the
1884
+ `fps` defaults to 10.
1885
+
1886
+ === background(pattern) » Shoes::Background ===
1887
+
1888
+ Draws a Background element with a specific color (or pattern.) Patterns can be
1889
+ colors, gradients or images. Colors and images will tile across the
1890
+ background. Gradients stretch to fill the background.
1891
+
1892
+ '''PLEASE NOTE:''' Backgrounds are actual elements, not styles. HTML treats
1893
+ backgrounds like styles. Which means every box can only have one background.
1894
+ Shoes layers background elements.
1895
+
1896
+ {{{
1897
+ #!ruby
1898
+ Shoes.app do
1899
+ background black
1900
+ background white, :width => 50
1901
+ end
1902
+ }}}
1903
+
1904
+ The above example paints two backgrounds. First, a black background is painted
1905
+ over the entire app's surface area. Then a 50 pixel white stripe is painted
1906
+ along the left side.
1907
+
1908
+ === banner(text) » Shoes::Banner ===
1909
+
1910
+ Creates a Banner text block. Shoes automatically styles this text to 48 pixels high.
1911
+
1912
+ === border(text, :strokewidth => a number) » Shoes::Border ===
1913
+
1914
+ Draws a Border element using a specific color (or pattern.) Patterns can be
1915
+ colors, gradients or images. Colors and images will tile across the border.
1916
+ Gradients stretch to fill the border.
1917
+
1918
+ '''PLEASE NOTE:''' Like Backgrounds, Borders are actual elements, not styles.
1919
+ HTML treats backgrounds and borders like styles. Which means every box can
1920
+ only have one borders. Shoes layers border and background elements, along with
1921
+ text blocks, images, and everything else.
1922
+
1923
+ === button(text) { ... } » Shoes::Button ===
1924
+
1925
+ Adds a push button with the message `text` written across its surface. An
1926
+ optional block can be attached, which is called if the button is pressed.
1927
+
1928
+ === caption(text) » Shoes::Caption ===
1929
+
1930
+ Creates a Caption text block. Shoes styles this text to 14 pixels high.
1931
+
1932
+ === check() » Shoes::Check ===
1933
+
1934
+ Adds a check box.
1935
+
1936
+ === code(text) » Shoes::Code ===
1937
+
1938
+ Create a Code text fragment. This text defaults to a monospaced font.
1939
+
1940
+ === del(text) » Shoes::Del ===
1941
+
1942
+ Creates a Del text fragment (short for "deleted") which defaults to text with a
1943
+ single strikethrough in its middle.
1944
+
1945
+ === dialog(styles) { ... } » Shoes::App ===
1946
+
1947
+ Opens a new app window (just like the [[Element.window]] method does,) but the
1948
+ window is given a dialog box look.
1949
+
1950
+ === edit_box(text) » Shoes::EditBox ===
1951
+
1952
+ Adds a large, multi-line textarea to this slot. The `text` is optional and
1953
+ should be a string that will start out the box. An optional block can be
1954
+ attached here which is called any type the user changes the text in the box.
1955
+
1956
+ {{{
1957
+ #!ruby
1958
+ Shoes.app do
1959
+ edit_box
1960
+ edit_box "HORRAY EDIT ME"
1961
+ edit_box "small one", :width => 100, :height => 160
1962
+ end
1963
+ }}}
1964
+
1965
+ === edit_line(text) » Shoes::EditLine ===
1966
+
1967
+ Adds a single-line text box to this slot. The `text` is optional and should be
1968
+ a string that will start out the box. An optional block can be attached here
1969
+ which is called any type the user changes the text in the box.
1970
+
1971
+ === em(text) » Shoes::Em ===
1972
+
1973
+ Creates an Em text fragment (short for "emphasized") which, by default, is
1974
+ styled with italics.
1975
+
1976
+ === every(seconds) { |count| ... } » Shoes::Every ===
1977
+
1978
+ A timer similar to the `animation` method, but much slower. This timer fires a
1979
+ given number of seconds, running the block attached. So, for example, if you
1980
+ need to check a web site every five minutes, you'd call `every(300)` with a
1981
+ block containing the code to actually ping the web site.
1982
+
1983
+ === flow(styles) { ... } » Shoes::Flow ===
1984
+
1985
+ A flow is an invisible box (or "slot") in which you place Shoes elements. Both
1986
+ flows and stacks are explained in great detail on the main [[Slots]] page.
1987
+
1988
+ Flows organize elements horizontally. Where one would use a [[Element.stack]]
1989
+ to keep things stacked vertically, a flow places its contents end-to-end across
1990
+ the page. Once the end of the page is reached, the flow starts a new line of
1991
+ elements.
1992
+
1993
+ === image(path) » Shoes::Image ===
1994
+
1995
+ Creates an [[Image]] element for displaying a picture. PNG, JPEG and GIF
1996
+ formats are allowed.
1997
+
1998
+ The `path` can be a file path or a URL. All images loaded are temporarily
1999
+ cached in memory, but remote images are also cached locally in the user's
2000
+ personal Shoes directory. Remote images are loaded in the background; as with
2001
+ browsers, the images will not appear right away, but will be shown when they
2002
+ are loaded.
2003
+
2004
+ === imagesize(path) » [width, height] ===
2005
+
2006
+ Quickly grab the width and height of an image. The image won't be loaded into
2007
+ the cache or displayed.
2008
+
2009
+ URGENT NOTE: This method cannot be used with remote images (loaded from HTTP,
2010
+ rather than the hard drive.)
2011
+
2012
+ === ins(text) » Shoes::Ins ===
2013
+
2014
+ Creates an Ins text fragment (short for "inserted") which Shoes styles with a
2015
+ single underline.
2016
+
2017
+ === inscription(text) » Shoes::Inscription ===
2018
+
2019
+ Creates an Inscription text block. Shoes styles this text at 10 pixels high.
2020
+
2021
+ === link(text, :click => proc or string) » Shoes::Link ===
2022
+
2023
+ Creates a Link text block, which Shoes styles with a single underline and
2024
+ colors with a #06E (blue) colored stroke.
2025
+
2026
+ The default LinkHover style is also single-underlined with a #039 (dark blue) stroke.
2027
+
2028
+ === list_box(:items => [strings, ...]) » Shoes::ListBox ===
2029
+
2030
+ Adds a drop-down list box containing entries for everything in the `items`
2031
+ array. An optional block may be attached, which is called if anything in the
2032
+ box becomes selected by the user.
2033
+
2034
+ {{{
2035
+ #!ruby
2036
+ Shoes.app do
2037
+ stack :margin => 10 do
2038
+ para "Pick a card:"
2039
+ list_box :items => ["Jack", "Ace", "Joker"]
2040
+ end
2041
+ end
2042
+ }}}
2043
+
2044
+ Call `ListBox#text` to get the selected string. See the `ListBox` section
2045
+ under `Native` controls for more help.
2046
+
2047
+ === progress() » Shoes::Progress ===
2048
+
2049
+ Adds a progress bar.
2050
+
2051
+ === para(text) » Shoes::Para ===
2052
+
2053
+ Create a Para text block (short for "paragraph") which Shoes styles at 12
2054
+ pixels high.
2055
+
2056
+ === radio(group name: a string or symbol) » Shoes::Radio ===
2057
+
2058
+ Adds a radio button. If a `group name` is given, the radio button is
2059
+ considered part of a group. Among radio buttons in the same group, only one
2060
+ may be checked. (If no group name is given, the radio button is grouped with
2061
+ any other radio buttons in the same slot.)
2062
+
2063
+ === span(text) » Shoes::Span ===
2064
+
2065
+ Creates a Span text fragment, unstyled by default.
2066
+
2067
+ === stack(styles) { ... } » Shoes::Stack ===
2068
+
2069
+ Creates a new stack. A stack is a type of slot. (See the main [[Slots]] page
2070
+ for a full explanation of both stacks and flows.)
2071
+
2072
+ In short, stacks are an invisible box (a "slot") for placing stuff. As you add
2073
+ things to the stack, such as buttons or images, those things pile up
2074
+ vertically. Yes, they stack up!
2075
+
2076
+ === strong(text) » Shoes::Strong ===
2077
+
2078
+ Creates a Strong text fragment, styled in bold by default.
2079
+
2080
+ === sub(text) » Shoes::Sub ===
2081
+
2082
+ Creates a Sub text fragment (short for "subscript") which defaults to lowering
2083
+ the text by 10 pixels and styling it in an x-small font.
2084
+
2085
+ === subtitle(text) » Shoes::Subtitle ===
2086
+
2087
+ Creates a Subtitle text block. Shoes styles this text to 26 pixels high.
2088
+
2089
+ === sup(text) » Shoes::Sup ===
2090
+
2091
+ Creates a Sup text fragment (short for "superscript") which defaults to raising
2092
+ the text by 10 pixels and styling it in an x-small font.
2093
+
2094
+ === tagline(text) » Shoes::Tagline ===
2095
+
2096
+ Creates a Tagline text block. Shoes styles this text to 18 pixels high.
2097
+
2098
+ === timer(seconds) { ... } » Shoes::Timer ===
2099
+
2100
+ A one-shot timer. If you want to schedule to run some code in a few seconds
2101
+ (or minutes, hours) you can attach the code as a block here.
2102
+
2103
+ To display an alert box five seconds from now:
2104
+
2105
+ {{{
2106
+ #!ruby
2107
+ Shoes.app do
2108
+ timer(5) do
2109
+ alert("Your five seconds are up.")
2110
+ end
2111
+ end
2112
+ }}}
2113
+
2114
+ === title(text) » Shoes::Title ===
2115
+
2116
+ Creates a Title text block. Shoes styles these elements to 34 pixels high.
2117
+
2118
+ === video(path or url) » Shoes::Video ===
2119
+
2120
+ Embeds a movie in this slot.
2121
+
2122
+ === window(styles) { ... } » Shoes::App ===
2123
+
2124
+ Opens a new app window. This method is almost identical to the
2125
+ [[App.Shoes.app]] method used to start an app in the first place. The
2126
+ difference is that the `window` method sets the new window's [[App.owner]]
2127
+ property. (A normal Shoes.app has its `owner` set to `nil`.)
2128
+
2129
+ So, the new window's `owner` will be set to the Shoes::App which launched the
2130
+ window. This way the child window can call the parent.
2131
+
2132
+ {{{
2133
+ #!ruby
2134
+ Shoes.app :title => "The Owner" do
2135
+ button "Pop up?" do
2136
+ window do
2137
+ para "Okay, popped up from #{owner}"
2138
+ end
2139
+ end
2140
+ end
2141
+ }}}
2142
+
2143
+ == Events ==
2144
+
2145
+ Wondering how to catch stray mouse clicks or keyboard typing? Events are sent
2146
+ to a slot whenever a mouse moves inside the slot. Or whenever a key is
2147
+ pressed. Even when the slot is created or destroyed. You can attach a block
2148
+ to each of these events.
2149
+
2150
+ Mouse events include `motion`, `click`, `hover` and `leave`. Keyboard typing
2151
+ is represented by the `keypress` event. And the `start` and `finish` events
2152
+ indicate when a canvas comes into play or is discarded.
2153
+
2154
+ So, let's say you want to change the background of a slot whenever the mouse
2155
+ floats over it. We can use the `hover` event to change the background when the
2156
+ mouse comes inside the slot. And `leave` to change back when the mouse floats
2157
+ away.
2158
+
2159
+ {{{
2160
+ #!ruby
2161
+ Shoes.app do
2162
+ s = stack :width => 200, :height => 200 do
2163
+ background red
2164
+ hover do
2165
+ s.clear { background blue }
2166
+ end
2167
+ leave do
2168
+ s.clear { background red }
2169
+ end
2170
+ end
2171
+ end
2172
+ }}}
2173
+
2174
+ === click { |button, left, top| ... } » self ===
2175
+
2176
+ The click block is called when a mouse button is clicked. The `button` is the
2177
+ number of the mouse button which has been pressed. The `left` and `top` are
2178
+ the mouse coordinates at which the click happened.
2179
+
2180
+ To catch the moment when the mouse is unclicked, see the [[Events.release]] event.
2181
+
2182
+ === finish { |self| ... } » self ===
2183
+
2184
+ When a slot is removed, it's finish event occurs. The finish block is
2185
+ immediately handed `self`, the slot object which has been removed.
2186
+
2187
+ === hover { |self| ... } » self ===
2188
+
2189
+ The hover event happens when the mouse enters the slot. The block gets `self`,
2190
+ meaning the object which was hovered over.
2191
+
2192
+ To catch the mouse exiting the slot, check out the [[Events.leave]] event.
2193
+
2194
+ === keypress { |key| ... } » self ===
2195
+
2196
+ Whenever a key (or combination of keys) is pressed, the block gets called. The
2197
+ block is sent a `key` which is a string representing the character (such as the
2198
+ letter or number) on the key. For special keys and key combos, a Ruby symbol
2199
+ is sent, rather than a string.
2200
+
2201
+ So, for example, if `Shift-a` is pressed, the block will get the string `"A"`.
2202
+
2203
+ However, if the F1 key is pressed, the `:f1` symbol is received. For
2204
+ `Shift-F1`, the symbol would be `:shift_f1`.
2205
+
2206
+ The modifier keys are `control`, `shift` and `alt`. They appear in that order.
2207
+ If `Shift-Control-Alt-PgUp` is pressed, the symbol will be
2208
+ `:control_shift_alt_page_up`.
2209
+
2210
+ One thing about the shift key. You won't see the shift key on most keys. On
2211
+ US keyboards, `Shift-7` is an ampersand. So you'll get the string `"&"` rather
2212
+ than `:shift_5`. And, if you press `Shift-Alt-7` on such a keyboard, you'll
2213
+ get the symbol: `:alt_&`. You'll only see the shift modifier on the special
2214
+ keys listed a few paragraphs down.
2215
+
2216
+ {{{
2217
+ #!ruby
2218
+ Shoes.app do
2219
+ @info = para "NO KEY is PRESSED."
2220
+ keypress do |k|
2221
+ @info.replace "#{k.inspect} was PRESSED."
2222
+ end
2223
+ end
2224
+ }}}
2225
+
2226
+ Keep in mind that Shoes itself uses a few hotkeys. Alt-Period (`:alt_.`),
2227
+ Alt-Question (`:alt_?`) and Alt-Slash (`:alt_/`) are reserved for Shoes.
2228
+
2229
+ The list of special keys is as follows: `:escape`, `:delete`, `:backspace`,
2230
+ `:tab`, `:page_up`, `:page_down`, `:home`, `:end`, `:left`, `:up`, `:right`,
2231
+ `:down`, `:f1`, `:f2`, `:f3`, `:f4`, `:f5`, `:f6`, `:f7`, `:f8`, `:f9`, `:f10`,
2232
+ `:f11` and `:f12`.
2233
+
2234
+ One caveat to all of those rules: normally the Return key gives you a string
2235
+ `"\n"`. When pressed with modifier keys, however, you end up with
2236
+ `:control_enter`, `:control_alt_enter`, `:shift_alt_enter` and the like.
2237
+
2238
+ === leave { |self| ... } » self ===
2239
+
2240
+ The leave event takes place when the mouse cursor exits a slot. The moment it
2241
+ no longer is inside the slot's edges. When that takes place, the block is
2242
+ called with `self`, the slot object which is being left.
2243
+
2244
+ Also see [[Events.hover]] if you'd like to detect the mouse entering a slot.
2245
+
2246
+ === motion { |left, top| ... } » self ===
2247
+
2248
+ The motion block gets called every time the mouse moves around inside the slot.
2249
+ The block is handed the cursor's `left` and `top` coordinates.
2250
+
2251
+ {{{
2252
+ #!ruby
2253
+ Shoes.app :width => 200, :height => 200 do
2254
+ background black
2255
+ fill white
2256
+ @circ = oval 0, 0, 100, 100
2257
+
2258
+ motion do |top, left|
2259
+ @circ.move top - 50, left - 50
2260
+ end
2261
+ end
2262
+ }}}
2263
+
2264
+ === release { |button, left, top| ... } » self ===
2265
+
2266
+ The release block runs whenever the mouse is unclicked (on mouse up). When the
2267
+ finger is lifted. The `button` is the number of the button that was depressed.
2268
+ The `left` and `top` are the coordinates of the mouse at the time the button
2269
+ was released.
2270
+
2271
+ To catch the actual mouse click, use the [[Events.click]] event.
2272
+
2273
+ === start { |self| ... } » self ===
2274
+
2275
+ The first time the slot is drawn, the start event fires. The block is handed
2276
+ `self`, the slot object which has just been drawn.
2277
+
2278
+ == Manipulation Blocks ==
2279
+
2280
+ The manipulation methods below make quick work of shifting around slots and
2281
+ inserting new elements.
2282
+
2283
+ === append() { ... } » self ===
2284
+
2285
+ Adds elements to the end of a slot.
2286
+
2287
+ {{{
2288
+ #!ruby
2289
+ Shoes.app do
2290
+ @slot = stack { para 'Good Morning' }
2291
+ timer 3 do
2292
+ @slot.append do
2293
+ title "Breaking News"
2294
+ tagline "Astronauts arrested for space shuttle DUI."
2295
+ end
2296
+ end
2297
+ end
2298
+ }}}
2299
+
2300
+ The `title` and `tagline` elements will be added to the end of the `@slot`.
2301
+
2302
+ === after(element) { ... } » self ===
2303
+
2304
+ Adds elements to a specific place in a slot, just after the `element` which is
2305
+ a child of the slot.
2306
+
2307
+ === before(element) { ... } » self ===
2308
+
2309
+ Adds elements to a specific place in a slot, just before the `element` which is
2310
+ a child of the slot.
2311
+
2312
+ === clear() » self ===
2313
+
2314
+ Empties the slot of any elements, timers and nested slots. This is effectively
2315
+ identical to looping through the contents of the slot and calling each
2316
+ element's `remove` method.
2317
+
2318
+ === clear() { ... } » self ===
2319
+
2320
+ The clear method also takes an optional block. The block will be used to
2321
+ replace the contents of the slot.
2322
+
2323
+ {{{
2324
+ #!ruby
2325
+ Shoes.app do
2326
+ @slot = stack { para "Old text" }
2327
+ timer 3 do
2328
+ @slot.clear { para "Brand new text" }
2329
+ end
2330
+ end
2331
+ }}}
2332
+
2333
+ In this example, the "Old text" paragraph will be cleared out, replaced by the
2334
+ "Brand new text" paragraph.
2335
+
2336
+ === prepend() { ... } » self ===
2337
+
2338
+ Adds elements to the beginning of a slot.
2339
+
2340
+ {{{
2341
+ #!ruby
2342
+ Shoes.app do
2343
+ @slot = stack { para 'Good Morning' }
2344
+ timer 3 do
2345
+ @slot.prepend { para "Your car is ready." }
2346
+ end
2347
+ end
2348
+ }}}
2349
+
2350
+ The `para` element is added to the beginning of the `@slot`.
2351
+
2352
+ == Position of a Slot ==
2353
+
2354
+ Like any other element, slots can be styled and customized when they are created.
2355
+
2356
+ To set the width of a stack to 150 pixels:
2357
+
2358
+ {{{
2359
+ #!ruby
2360
+ Shoes.app do
2361
+ stack(:width => 150) { para "Now that's precision." }
2362
+ end
2363
+ }}}
2364
+
2365
+ Each style setting also has a method, which can be used to grab that particular
2366
+ setting. (So, like, the `width` method returns the width of the slot in
2367
+ pixels.)
2368
+
2369
+ === displace(left: a number, top: a number) » self ===
2370
+
2371
+ A shortcut method for setting the :displace_left and :displace_top styles.
2372
+ Displacing is a handy way of moving a slot without altering the layout. In
2373
+ fact, the `top` and `left` methods will not report displacement at all. So,
2374
+ generally, displacement is only for temporary animations. For example,
2375
+ jiggling a button in place.
2376
+
2377
+ The `left` and `top` numbers sent to `displace` are added to the slot's own
2378
+ top-left coordinates. To subtract from the top-left coordinate, use negative
2379
+ numbers.
2380
+
2381
+ === gutter() » a number ===
2382
+
2383
+ The size of the scrollbar area. When Shoes needs to show a scrollbar, the
2384
+ scrollbar may end up covering up some elements that touch the edge of the
2385
+ window. The `gutter` tells you how many pixels to expect the scrollbar to
2386
+ cover.
2387
+
2388
+ This is commonly used to pad elements on the right, like so:
2389
+
2390
+ {{{
2391
+ #!ruby
2392
+ Shoes.app do
2393
+ stack :margin_right => 20 + gutter do
2394
+ para "Insert fat and ratified declaration of independence here..."
2395
+ end
2396
+ end
2397
+ }}}
2398
+
2399
+ === height() » a number ===
2400
+
2401
+ The vertical size of the viewable slot in pixels. So, if this is a scrolling
2402
+ slot, you'll need to use `scroll_height()` to get the full size of the slot.
2403
+
2404
+ === hide() » self ===
2405
+
2406
+ Hides the slot, so that it can't be seen. See also [[Position.show]] and [[Position.toggle]].
2407
+
2408
+ === left() » a number ===
2409
+
2410
+ The left pixel location of the slot. Also known as the x-axis coordinate.
2411
+
2412
+ === move(left, top) » self ===
2413
+
2414
+ Moves the slot to specific coordinates, the (left, top) being the upper left
2415
+ hand corner of the slot.
2416
+
2417
+ === remove() » self ===
2418
+
2419
+ Removes the slot. It will no longer be displayed and will not be listed in its
2420
+ parent's contents. It's gone.
2421
+
2422
+ === scroll() » true or false ===
2423
+
2424
+ Is this slot allowed to show a scrollbar? True or false. The scrollbar will
2425
+ only appear if the height of the slot is also fixed.
2426
+
2427
+ === scroll_height() » a number ===
2428
+
2429
+ The vertical size of the full slot, including any of it which is hidden by scrolling.
2430
+
2431
+ === scroll_max() » a number ===
2432
+
2433
+ The top coordinate which this slot can be scrolled down to. The top coordinate
2434
+ of a scroll bar is always zero. The bottom coordinate is the full height of
2435
+ the slot minus one page of scrolling. This bottom coordinate is what
2436
+ `scroll_max` returns.
2437
+
2438
+ This is basically a shortcut for writing `slot.scroll_height - slot.height`.
2439
+
2440
+ To scroll to the bottom of a slot, use `slot.scroll_top = slot.scroll_max`.
2441
+
2442
+ === scroll_top() » a number ===
2443
+
2444
+ The top coordinate which this slot is scrolled down to. So, if the slot is
2445
+ scrolled down twenty pixels, this method will return `20`.
2446
+
2447
+ === scroll_top = a number ===
2448
+
2449
+ Scrolls the slot to a certain coordinate. This must be between zero and
2450
+ `scroll_max`.
2451
+
2452
+ === show() » self ===
2453
+
2454
+ Reveals the slot, if it is hidden. See also [[Position.hide]] and
2455
+ [[Position.toggle]].
2456
+
2457
+ === style() » styles ===
2458
+
2459
+ Calling the `style` method with no arguments returns a hash of the styles
2460
+ presently applied to this slot.
2461
+
2462
+ While methods such as `height` and `width` return the true pixel dimensions of
2463
+ the slot, you can use `style[:height]` or `style[:width]` to get the dimensions
2464
+ originally requested.
2465
+
2466
+ {{{
2467
+ #!ruby
2468
+ Shoes.app do
2469
+ @s = stack :width => "100%"
2470
+ para @s.style[:width]
2471
+ end
2472
+ }}}
2473
+
2474
+ In this example, the paragraph under the stack will display the string "100%".
2475
+
2476
+ === style(styles) » styles ===
2477
+
2478
+ Alter the slot using a hash of style settings. Any of the methods on this page
2479
+ (aside from this method, of course) can be used as a style setting. So, for
2480
+ example, there is a `width` method, thus there is also a `width` style.
2481
+
2482
+ {{{
2483
+ #!ruby
2484
+ Shoes.app do
2485
+ @s = stack { background green }
2486
+ @s.style(:width => 400, :height => 200)
2487
+ end
2488
+ }}}
2489
+
2490
+ === toggle() » self ===
2491
+
2492
+ Hides the slot, if it is shown. Or shows the slot, if it is hidden.
2493
+
2494
+ === top() » a number ===
2495
+
2496
+ The top pixel location of the slot. Also known as the y-axis coordinate.
2497
+
2498
+ === width() » a number ===
2499
+
2500
+ The horizontal size of the slot in pixels.
2501
+
2502
+ == Traversing the Page ==
2503
+
2504
+ You may find yourself needing to loop through the elements inside a slot. Or
2505
+ maybe you need to climb the page, looking for a stack that is the parent of an
2506
+ element.
2507
+
2508
+ On any element, you may call the `parent` method to get the slot directly above
2509
+ it. And on slots, you can call the `contents` method to get all of the
2510
+ children. (Some elements, such as text blocks, also have a `contents` method
2511
+ for getting their children.)
2512
+
2513
+ === contents() » an array of elements ===
2514
+
2515
+ Lists all elements in a slot.
2516
+
2517
+ === parent() » a Shoes::Stack or Shoes::Flow ===
2518
+
2519
+ Gets the object for this element's container.
2520
+
2521
+ = Elements =
2522
+
2523
+ Ah, here's the stuff of Shoes. An element can be as simple as an oval shape. Or
2524
+ as complex as a video stream. You've encountered all of these elements before
2525
+ in the Slots section of th manual.
2526
+
2527
+ Shoes has seven native controls: the Button, the EditLine, the EditBox, the
2528
+ ListBox, the Progress meter, the Check box and the Radio. By "native"
2529
+ controls, we mean that each of these seven elements is drawn by the operating
2530
+ system. So, a Progress bar will look one way on Windows and another way on OS
2531
+ X.
2532
+
2533
+ Shoes also has seven basic other types of elements: Background, Border, Image,
2534
+ Shape, TextBlock, Timer and Video. These all should look and act the same on
2535
+ every operating system.
2536
+
2537
+ Once an element is created, you will often still want to change it. To move it
2538
+ or hide it or get rid of it. You'll use the commands in this section to do that
2539
+ sort of stuff. (Especially check out the [[Common Common Methods]] section for
2540
+ commands you can use on any element.)
2541
+
2542
+ So, for example, use the `image` method of a Slot to place a PNG on the screen.
2543
+ The `image` method gives you back an Image object. Use the methods of the Image
2544
+ object to change things up.
2545
+
2546
+ == Common Methods ==
2547
+
2548
+ A few methods are shared by every little element in Shoes. Moving, showing,
2549
+ hiding. Removing an element. Basic and very general things. This list
2550
+ encompasses those common commands.
2551
+
2552
+ One of the most general methods of all is the `style` method (which is also
2553
+ covered as the [[Position.style]] method for slots.)
2554
+
2555
+ {{{
2556
+ #!ruby
2557
+ Shoes.app do
2558
+ stack do
2559
+ # Background, text and a button: both are elements!
2560
+ @back = background green
2561
+ @text = banner "A Message for You, Rudy"
2562
+ @press = button "Stop your messin about!"
2563
+
2564
+ # And so, both can be styled.
2565
+ @text.style :size => 12, :stroke => red, :margin => 10
2566
+ @press.style :width => 400
2567
+ @back.style :height => 10
2568
+ end
2569
+ end
2570
+ }}}
2571
+
2572
+ For specific commands, see the other links to the left in the Elements section.
2573
+ Like if you want to pause or play a video file, check the [[Video]] section,
2574
+ since pausing and playing is peculiar to videos. No sense pausing a button.
2575
+
2576
+ === displace(left: a number, top: a number) » self ===
2577
+
2578
+ Displacing an element moves it. But without changing the layout around it.
2579
+ This is great for subtle animations, especially if you want to reserve a place
2580
+ for an element while it is still animating. Like maybe a quick button shake or
2581
+ a slot sliding into view.
2582
+
2583
+ When you displace an element, it moves relative to the upper-left corner where
2584
+ it was placed. So, if an element is at the coordinates (20, 40) and you
2585
+ displace it 2 pixels left and 6 pixels on top, you end up with the coordinates
2586
+ (22, 46).
2587
+
2588
+ {{{
2589
+ #!ruby
2590
+ Shoes.app do
2591
+ flow :margin => 12 do
2592
+ # Set up three buttons
2593
+ button "One"
2594
+ @two = button "Two"
2595
+ button "Three"
2596
+
2597
+ # Bounce the second button
2598
+ animate do |i|
2599
+ @two.displace(0, (Math.sin(i) * 6).to_i)
2600
+ end
2601
+ end
2602
+ end
2603
+ }}}
2604
+
2605
+ Notice that while the second button bounces, the other two buttons stay put.
2606
+ If we used a normal `move` in this situation, the second button would be moved
2607
+ out of the layout and the buttons would act as if the second button wasn't
2608
+ there at all. (See the [[Common.move]] example.)
2609
+
2610
+ '''Of particular note:''' if you use the `left` and `top` methods to get the
2611
+ coordinates of a displaced element, you'll just get back the normal
2612
+ coordinates. As if there was no displacement. Displacing is just intended for
2613
+ quick animations!
2614
+
2615
+ === height() » a number ===
2616
+
2617
+ The vertical screen size of the element in pixels. In the case of images, this
2618
+ is not the full size of the image. This is the height of the element as it is
2619
+ shown right now.
2620
+
2621
+ If you have a 150x150 pixel image and you set the width to 50 pixels, this
2622
+ method will return 50.
2623
+
2624
+ Also see the [[Common.width]] method for an example and some other comments.
2625
+
2626
+ === hide() » self ===
2627
+
2628
+ Hides the element, so that it can't be seen. See also [[Common.show]] and
2629
+ [[Common.toggle]].
2630
+
2631
+ === left() » a number ===
2632
+
2633
+ Gets you the pixel position of the left edge of the element.
2634
+
2635
+ === move(left: a number, top: a number) » self ===
2636
+
2637
+ Moves the element to a specific pixel position within its slot. The element is
2638
+ still inside the slot. But it will no longer be stacked or flowed in with the
2639
+ other stuff in the slot. The element will float freely, now absolutely
2640
+ positioned instead.
2641
+
2642
+ {{{
2643
+ #!ruby
2644
+ Shoes.app do
2645
+ flow :margin => 12 do
2646
+ # Set up three buttons
2647
+ button "One"
2648
+ @two = button "Two"
2649
+ button "Three"
2650
+
2651
+ # Bounce the second button
2652
+ animate do |i|
2653
+ @two.move(40, 40 + (Math.sin(i) * 6).to_i)
2654
+ end
2655
+ end
2656
+ end
2657
+ }}}
2658
+
2659
+ The second button is moved to a specific place, allowing the third button to
2660
+ slide over into its place. If you want to move an element without shifting
2661
+ other pieces, see the [[Common.displace]] method.
2662
+
2663
+ === parent() » a Shoes::Stack or Shoes::Flow ===
2664
+
2665
+ Gets the object for this element's container. Also see the slot's
2666
+ [[Traversing.contents]] to do the opposite: get a container's elements.
2667
+
2668
+ === remove() » self ===
2669
+
2670
+ Removes the element from its slot. (In other words: throws it in the garbage.)
2671
+ The element will no longer be displayed.
2672
+
2673
+ === show() » self ===
2674
+
2675
+ Reveals the element, if it is hidden. See also [[Common.hide]] and
2676
+ [[Common.toggle]].
2677
+
2678
+ === style() » styles ===
2679
+
2680
+ Gives you the full set of styles applied to this element, in the form of a
2681
+ Hash. While methods like `width` and `height` and `top` give you back specific
2682
+ pixel dimensions, using `style[:width]` or `style[:top]`, you can get the
2683
+ original setting (things like "100%" for width or "10px" for top.)
2684
+
2685
+ {{{
2686
+ #!ruby
2687
+ Shoes.app do
2688
+ # A button which take up the whole page
2689
+ @b = button "All of it", :width => 1.0, :height => 1.0
2690
+
2691
+ # When clicked, show the styles
2692
+ @b.click { alert(@b.style.inspect) }
2693
+ end
2694
+ }}}
2695
+
2696
+ === style(styles) » styles ===
2697
+
2698
+ Changes the style of an element. This could include the `:width` and `:height`
2699
+ of an element, the font `:size` of some text, the `:stroke` and `:fill` of a
2700
+ shape. Or any other number of style settings.
2701
+
2702
+ === toggle() » self ===
2703
+
2704
+ Hides an element if it is shown. Or shows the element, if it is hidden.
2705
+
2706
+ === top() » a number ===
2707
+
2708
+ Gets the pixel position of the top edge of the element.
2709
+
2710
+ === width() » a number ===
2711
+
2712
+ Gets the pixel width for the full size of the element. This method always
2713
+ returns an exact pixel size. In the case of images, this is not the full width
2714
+ of the image, just the size it is shown at. See the [[Common.height]] method
2715
+ for more.
2716
+
2717
+ Also, if you create an element with a width of 100% and that element is inside
2718
+ a stack which is 120 pixels wide, you'll get back `120`. However, if you call
2719
+ `style[:width]`, you'll get `"100%"`.
2720
+
2721
+ {{{
2722
+ #!ruby
2723
+ Shoes.app do
2724
+ stack :width => 120 do
2725
+ @b = button "Click me", :width => "100%" do
2726
+ alert "button.width = #{@b.width}\n" +
2727
+ "button.style[:width] = #{@b.style[:width]}"
2728
+ end
2729
+ end
2730
+ end
2731
+ }}}
2732
+
2733
+ In order to set the width, you'll have to go through the [[Common.style]]
2734
+ method again. So, to set the button to 150 pixels wide: `@b.style(:width =>
2735
+ 150)`.
2736
+
2737
+ To let Shoes pick the element's width, go with `@b.style(:width => nil)` to
2738
+ empty out the setting.
2739
+
2740
+ == Background ==
2741
+
2742
+ A background is a color, a gradient or an image that is painted across an
2743
+ entire slot. Both backgrounds and borders are a type of Shoes::Pattern.
2744
+ !{:margin_left => 100}man-ele-background.png!
2745
+
2746
+ Even though it's called a ''background'', you may still place this element in
2747
+ front of other elements. If a background comes after something else painted on
2748
+ the slot (like a `rect` or an `oval`,) the background will be painted over that
2749
+ element.
2750
+
2751
+ The simplest background is just a plain color background, created with the
2752
+ [[Element.background]] method, such as this black background:
2753
+
2754
+ {{{
2755
+ #!ruby
2756
+ Shoes.app do
2757
+ background black
2758
+ end
2759
+ }}}
2760
+
2761
+ A simple background like that paints the entire slot that contains it. (In
2762
+ this case, the whole window is painted black.)
2763
+
2764
+ You can use styles to cut down the size or move around the background to your liking.
2765
+
2766
+ To paint a black background across the top fifty pixels of the window:
2767
+
2768
+ {{{
2769
+ #!ruby
2770
+ Shoes.app do
2771
+ background black, :height => 50
2772
+ end
2773
+ }}}
2774
+
2775
+ Or, to paint a fifty pixel column on the right-side of the window:
2776
+
2777
+ {{{
2778
+ #!ruby
2779
+ Shoes.app do
2780
+ background black, :width => 50, :right => 50
2781
+ end
2782
+ }}}
2783
+
2784
+ Since Backgrounds are normal elements as well, see also the start of the
2785
+ [[Elements]] section for all of its other methods.
2786
+
2787
+ === to_pattern() » a Shoes::Pattern ===
2788
+
2789
+ Yanks out the color, gradient or image used to paint this background and places
2790
+ it in a normal Shoes::Pattern object. You can then pass that object to other
2791
+ backgrounds and borders. Reuse it as you like.
2792
+
2793
+ == Border ==
2794
+
2795
+ A border is a color, gradient or image painted in a line around the edge of any
2796
+ slot. Like the Background element in the last section, a Border is a kind of
2797
+ Shoes::Pattern. !{:margin_left => 100}man-ele-border.png!
2798
+
2799
+ The first, crucial thing to know about border is that all borders paint a line
2800
+ around the '''inside''' of a slot, not the outside. So, if you have a slot
2801
+ which is fifty pixels wide and you paint a five pixel border on it, that means
2802
+ there is a fourty pixel wide area inside the slot which is surrounded by the
2803
+ border.
2804
+
2805
+ This also means that if you paint a Border on top of a [[Background]], the
2806
+ edges of the background will be painted over by the border.
2807
+
2808
+ Here is just such a slot:
2809
+
2810
+ {{{
2811
+ #!ruby
2812
+ Shoes.app do
2813
+ stack :width => 50 do
2814
+ border black, :strokewidth => 5
2815
+ para "=^.^=", :stroke => green
2816
+ end
2817
+ end
2818
+ }}}
2819
+
2820
+ If you want to paint a border around the outside of a slot, you'll need to wrap
2821
+ that slot in another slot. Then, place the border in the outside slot.
2822
+
2823
+ {{{
2824
+ #!ruby
2825
+ Shoes.app do
2826
+ stack :width => 60 do
2827
+ border black, :strokewidth => 5
2828
+ stack :width => 50 do
2829
+ para "=^.^=", :stroke => green
2830
+ end
2831
+ end
2832
+ end
2833
+ }}}
2834
+
2835
+ In HTML and many other languages, the border is painted on the outside of the
2836
+ box, thus increasing the overall width of the box. Shoes was designed with
2837
+ consistency in mind, so that if you say that a box is fifty pixels wide, it
2838
+ stays fifty pixels wide regardless of its borders or margins or anything else.
2839
+
2840
+ Please also check out the [[Elements]] section for other methods used on borders.
2841
+
2842
+ === to_pattern() » a Shoes::Pattern ===
2843
+
2844
+ Creates a basic pattern object based on the color, gradient or image used to
2845
+ paint this border. The pattern may then be re-used in new borders and
2846
+ backgrounds.
2847
+
2848
+ == Button ==
2849
+
2850
+ Buttons are, you know, push buttons. You click them and they do something.
2851
+ Buttons are known to say "OK" or "Are you sure?" And, then, if you're sure,
2852
+ you click the button. !{:margin_left => 100}man-ele-button.png!
2853
+
2854
+ {{{
2855
+ #!ruby
2856
+ Shoes.app do
2857
+ button "OK!"
2858
+ button "Are you sure?"
2859
+ end
2860
+ }}}
2861
+
2862
+ The buttons in the example above don't do anything when you click them. In
2863
+ order to get them to work, you've got to hook up a block to each button.
2864
+
2865
+ {{{
2866
+ #!ruby
2867
+ Shoes.app do
2868
+ button "OK!" do
2869
+ append { para "Well okay then." }
2870
+ end
2871
+ button "Are you sure?" do
2872
+ append { para "Your confidence is inspiring." }
2873
+ end
2874
+ end
2875
+ }}}
2876
+
2877
+ So now we've got blocks for the buttons. Each block appends a new paragraph to
2878
+ the page. The more you click, the more paragraphs get added.
2879
+
2880
+ It doesn't go much deeper than that. A button is just a clickable phrase.
2881
+
2882
+ Just to be pedantic, though, here's another way to write that last example.
2883
+
2884
+ {{{
2885
+ #!ruby
2886
+ Shoes.app do
2887
+ @b1 = button "OK!"
2888
+ @b1.click { para "Well okay then." }
2889
+ @b2 = button "Are you sure?"
2890
+ @b2.click { para "Your confidence is inspiring." }
2891
+ end
2892
+ }}}
2893
+
2894
+ This looks dramatically different, but it does the same thing. The first
2895
+ difference: rather than attaching the block directly to the button, the block
2896
+ is attached later, through the `click` method.
2897
+
2898
+ The second change isn't related to buttons at all. The `append` block was
2899
+ dropped since Shoes allows you to add new elements directly to the slot. So we
2900
+ can just call `para` directly. (This isn't the case with the `prepend`,
2901
+ `before` or `after` methods.)
2902
+
2903
+ Beside the methods below, buttons also inherit all of the methods that are
2904
+ [[Common]].
2905
+
2906
+ === click() { |self| ... } » self ===
2907
+
2908
+ When a button is clicked, its `click` block is called. The block is handed
2909
+ `self`. Meaning: the button which was clicked.
2910
+
2911
+ === focus() » self ===
2912
+
2913
+ Moves focus to the button. The button will be highlighted and, if the user
2914
+ hits Enter, the button will be clicked.
2915
+
2916
+ == Check ==
2917
+
2918
+ Check boxes are clickable square boxes than can be either checked or unchecked.
2919
+ A single checkbox usually asks a "yes" or "no" question. Sets of checkboxes
2920
+ are also seen in to-do lists. !{:margin_left => 100}man-ele-check.png!
2921
+
2922
+ Here's a sample checklist.
2923
+
2924
+ {{{
2925
+ #!ruby
2926
+ Shoes.app do
2927
+ stack do
2928
+ flow { check; para "Frances Johnson" }
2929
+ flow { check; para "Ignatius J. Reilly" }
2930
+ flow { check; para "Winston Niles Rumfoord" }
2931
+ end
2932
+ end
2933
+ }}}
2934
+
2935
+ You basically have two ways to use a check. You can attach a block to the
2936
+ check and it'll get called when the check gets clicked. And/or you can just
2937
+ use the `checked?` method to go back and see if a box has been checked or not.
2938
+
2939
+ Okay, let's add to the above example.
2940
+
2941
+ {{{
2942
+ #!ruby
2943
+ Shoes.app do
2944
+ @list = ['Frances Johnson', 'Ignatius J. Reilly',
2945
+ 'Winston Niles Rumfoord']
2946
+
2947
+ stack do
2948
+ @list.map! do |name|
2949
+ flow { @c = check; para name }
2950
+ [@c, name]
2951
+ end
2952
+
2953
+ button "What's been checked?" do
2954
+ selected = @list.map { |c, name| name if c.checked? }.compact
2955
+ alert("You selected: " + selected.join(', '))
2956
+ end
2957
+ end
2958
+ end
2959
+ }}}
2960
+
2961
+ So, when the button gets pressed, each of the checks gets asked for its status,
2962
+ using the `checked?` method.
2963
+
2964
+ Button methods are listed below, but also see the list of [[Common]] methods,
2965
+ which all elements respond to.
2966
+
2967
+ === checked?() » true or false ===
2968
+
2969
+ Returns whether the box is checked or not. So, `true` means "yes, the box is checked!"
2970
+
2971
+ === checked = true or false ===
2972
+
2973
+ Marks or unmarks the check box. Using `checked = false`, for instance,
2974
+ unchecks the box.
2975
+
2976
+ === click() { |self| ... } » self ===
2977
+
2978
+ When the check is clicked, its `click` block is called. The block is handed
2979
+ `self`, which is the check object which was clicked.
2980
+
2981
+ Clicks are sent for both checking and unchecking the box.
2982
+
2983
+ === focus() » self ===
2984
+
2985
+ Moves focus to the check. The check will be highlighted and, if the user hits
2986
+ Enter, the check will be toggled between its checked and unchecked states.
2987
+
2988
+ == EditBox ==
2989
+
2990
+ Edit boxes are wide, rectangular boxes for entering text. On the web, they
2991
+ call these textareas. These are multi-line edit boxes for entering longer
2992
+ descriptions. Essays, even! !{:margin_left => 100}man-ele-editbox.png!
2993
+
2994
+ Without any other styling, edit boxes are sized 200 pixels by 108 pixels. You
2995
+ can also use `:width` and `:height` styles to set specific sizes.
2996
+
2997
+ {{{
2998
+ #!ruby
2999
+ Shoes.app do
3000
+ edit_box
3001
+ edit_box :width => 100, :height => 100
3002
+ end
3003
+ }}}
3004
+
3005
+ Other controls (like [[Button]] and [[Check]]) have only click events, but both
3006
+ [[EditLine]] and EditBox have a `change` event. The `change` block is called
3007
+ every time someone types into or deletes from the box.
3008
+
3009
+ {{{
3010
+ #!ruby
3011
+ Shoes.app do
3012
+ edit_box do |e|
3013
+ @counter.text = e.text.size
3014
+ end
3015
+ @counter = strong("0")
3016
+ para @counter, " characters"
3017
+ end
3018
+ }}}
3019
+
3020
+ Notice that the example also uses the [[EditBox.text]] method inside the block.
3021
+ That method gives you a string of all the characters typed into the box.
3022
+
3023
+ More edit box methods are listed below, but also see the list of [[Common]]
3024
+ methods, which all elements respond to.
3025
+
3026
+ === change() { |self| ... } » self ===
3027
+
3028
+ Each time a character is added to or removed from the edit box, its `change`
3029
+ block is called. The block is given `self`, which is the edit box object which
3030
+ has changed.
3031
+
3032
+ === focus() » self ===
3033
+
3034
+ Moves focus to the edit box. The edit box will be highlighted and the user will
3035
+ be able to type into the edit box.
3036
+
3037
+ === text() » self ===
3038
+
3039
+ Return a string of characters which have been typed into the box.
3040
+
3041
+ === text = a string ===
3042
+
3043
+ Fills the edit box with the characters of `a string`.
3044
+
3045
+ == EditLine ==
3046
+
3047
+ Edit lines are a slender, little box for entering text. While the EditBox is
3048
+ multi-line, an edit line is just one. Line, that is. Horizontal, in fact.
3049
+ !{:margin_left => 100}man-ele-editline.png!
3050
+
3051
+ The unstyled edit line is 200 pixels wide and 28 pixels wide. Roughly. The
3052
+ height may vary on some platforms.
3053
+
3054
+ {{{
3055
+ #!ruby
3056
+ Shoes.app do
3057
+ stack do
3058
+ edit_line
3059
+ edit_line :width => 400
3060
+ end
3061
+ end
3062
+ }}}
3063
+
3064
+ You can change the size by styling both the `:width` and the `:height`.
3065
+ However, you generally only want to style the `:width`, as the height will be
3066
+ sized to fit the font. (And, in current versions of Shoes, the font for edit
3067
+ lines and edit boxes cannot be altered anyway.)
3068
+
3069
+ If a block is given to an edit line, it receives `change` events. Check out the
3070
+ [[EditBox]] page for an example of using a change block. In fact, the edit box
3071
+ has all the same methods as an edit line. Also see the list of [[Common]]
3072
+ methods, which all elements respond to.
3073
+
3074
+ === change() { |self| ... } » self ===
3075
+
3076
+ Each time a character is added to or removed from the edit line, its `change`
3077
+ block is called. The block is given `self`, which is the edit line object which
3078
+ has changed.
3079
+
3080
+ === focus() » self ===
3081
+
3082
+ Moves focus to the edit line. The edit line will be highlighted and the user
3083
+ will be able to type into the edit line.
3084
+
3085
+ === text() » self ===
3086
+
3087
+ Return a string of characters which have been typed into the box.
3088
+
3089
+ === text = a string ===
3090
+
3091
+ Fills the edit line with the characters of `a string`.
3092
+
3093
+ == Image ==
3094
+
3095
+ An image is a picture in PNG, JPEG or GIF format. Shoes can resize images or
3096
+ flow them in with text. Images can be loaded from a file or directly off the
3097
+ web. !{:margin_left => 100}man-ele-image.png!
3098
+
3099
+ To create an image, use the `image` method in a slot:
3100
+
3101
+ {{{
3102
+ #!ruby
3103
+ Shoes.app do
3104
+ para "Nice, nice, very nice. Busy, busy, busy."
3105
+ image "static/shoes-manual-apps.gif"
3106
+ end
3107
+ }}}
3108
+
3109
+ When you load any image into Shoes, it is cached in memory. This means that if
3110
+ you load up many image elements from the same file, it'll only really load the
3111
+ file once.
3112
+
3113
+ You can use web URLs directly as well.
3114
+
3115
+ {{{
3116
+ #!ruby
3117
+ Shoes.app do
3118
+ image "http://hacketyhack.heroku.com/images/logo.png"
3119
+ end
3120
+ }}}
3121
+
3122
+ When an image is loaded from the web, it's cached on the hard drive as well as
3123
+ in memory. This prevents a repeat download unless the image has changed. (In
3124
+ case you're wondering: Shoes keeps track of modification times and etags just
3125
+ like a browser would.)
3126
+
3127
+ Shoes also loads remote images in the background using system threads. So,
3128
+ using remote images will not block Ruby or any intense graphical displays you
3129
+ may have going on.
3130
+
3131
+ === full_height() » a number ===
3132
+
3133
+ The full pixel height of the image. Normally, you can just use the
3134
+ [[Common.height]] method to figure out how many pixels high the image is. But
3135
+ if you've resized the image or styled it to be larger or something, then
3136
+ `height` will return the scaled size.
3137
+
3138
+ The `full_height` method gives you the height of image (in pixels) as it was
3139
+ stored in the original file.
3140
+
3141
+ === full_width() » a number ===
3142
+
3143
+ The full pixel width of the image. See the [[Image.full_height]] method for an
3144
+ explanation of why you might use this method rather than [[Common.width]].
3145
+
3146
+ === path() » a string ===
3147
+
3148
+ The URL or file name of the image.
3149
+
3150
+ === path = a string ===
3151
+
3152
+ Swaps the image with a different one, loaded from a file or URL.
3153
+
3154
+ == ListBox ==
3155
+
3156
+ List boxes (also called "combo boxes" or "drop-down boxes" or "select boxes" in
3157
+ some places) are a list of options that drop down when you click on the box.
3158
+ !{:margin_left => 100}man-ele-listbox.png!
3159
+
3160
+ A list box gets its options from an array. An array (a list) of strings,
3161
+ passed into the `:items` style.
3162
+
3163
+ {{{
3164
+ #!ruby
3165
+ Shoes.app do
3166
+ para "Choose a fruit:"
3167
+ list_box :items => ["Grapes", "Pears", "Apricots"]
3168
+ end
3169
+ }}}
3170
+
3171
+ So, the basic size of a list box is about 200 pixels wide and 28 pixels high.
3172
+ You can adjust this length using the `:width` style.
3173
+
3174
+ {{{
3175
+ #!ruby
3176
+ Shoes.app do
3177
+ para "Choose a fruit:"
3178
+ list_box :items => ["Grapes", "Pears", "Apricots"],
3179
+ :width => 120, :choose => "Apricots" do |list|
3180
+ @fruit.text = list.text
3181
+ end
3182
+
3183
+ @fruit = para "No fruit selected"
3184
+ end
3185
+ }}}
3186
+
3187
+ Next to the `:width` style, the example uses another useful option. The
3188
+ `:choose` option tells the list box which of the items should be highlighted
3189
+ from the beginning. (There's also a [[ListBox.choose]] method for highlighting
3190
+ an item after the box is created.)
3191
+
3192
+ List boxes also have a [[ListBox.change]] event. In the last example, we've got
3193
+ a block hooked up to the list box. Well, okay, see, that's a `change` block.
3194
+ The block is called each time someone changes the selected item.
3195
+
3196
+ Those are the basics. Might you also be persuaded to look at the [[Common]]
3197
+ methods page, a complete list of the methods that all elements have?
3198
+
3199
+ === change() { |self| ... } » self ===
3200
+
3201
+ Whenever someone highlights a new option in the list box (by clicking on an
3202
+ item, for instance,) its `change` block is called. The block is given `self`,
3203
+ which is the list box object which has changed.
3204
+
3205
+ === choose(item: a string) » self ===
3206
+
3207
+ Selects the option in the list box that matches the string given by `item`.
3208
+
3209
+ === focus() » self ===
3210
+
3211
+ Moves focus to the list box. The list box will be highlighted and, if the user
3212
+ hits the up and down arrow keys, other options in the list will be selected.
3213
+
3214
+ === items() » an array of strings ===
3215
+
3216
+ Returns the complete list of strings that the list box presently shows as its options.
3217
+
3218
+ === items = an array of strings ===
3219
+
3220
+ Replaces the list box's options with a new list of strings.
3221
+
3222
+ === text() » a string ===
3223
+
3224
+ A string containing whatever text is shown highlighted in the list box right
3225
+ now. If nothing is selected, `nil` will be the reply.
3226
+
3227
+ == Progress ==
3228
+
3229
+ Progress bars show you how far along you are in an activity. Usually, a
3230
+ progress bar represents a percentage (from 0% to 100%.) Shoes thinks of
3231
+ progress in terms of the decimal numbers 0.0 to 1.0. !{:margin_left =>
3232
+ 100}man-ele-progress.png!
3233
+
3234
+ A simple progress bar is 200 pixels wide, but you can use the `:width` style
3235
+ (as with all Shoes elements) to lengthen it.
3236
+
3237
+ {{{
3238
+ Shoes.app do
3239
+ stack :margin => 0.1 do
3240
+ title "Progress example"
3241
+ @p = progress :width => 1.0
3242
+
3243
+ animate do |i|
3244
+ @p.fraction = (i % 100) / 100.0
3245
+ end
3246
+ end
3247
+ end
3248
+ }}}
3249
+
3250
+ Take a look at the [[Common]] methods page for a list of methods found an all
3251
+ elements, including progress bars.
3252
+
3253
+ === fraction() » a decimal number ===
3254
+
3255
+ Returns a decimal number from 0.0 to 1.0, indicating how far along the progress bar is.
3256
+
3257
+ === fraction = a decimal number ===
3258
+
3259
+ Sets the progress to a decimal number between 0.0 and 1.0.
3260
+
3261
+ == Radio ==
3262
+
3263
+ Radio buttons are a group of clickable circles. Click a circle and it'll be
3264
+ marked. Only one radio button can be marked at a time. (This is similar to the
3265
+ ListBox, where only one option can be selected at a time.) !{:margin_left =>
3266
+ 100}man-ele-radio.png!
3267
+
3268
+ So, how do you decide when to use radio buttons and when to use list boxes?
3269
+ Well, list boxes only show one highlighted item unless you click on the box and
3270
+ the drop-down appears. But radio buttons are all shown, regardless of which is
3271
+ marked.
3272
+
3273
+ {{{
3274
+ #!ruby
3275
+ Shoes.app do
3276
+ para "Among these films, which do you prefer?\n"
3277
+ radio; para strong("The Taste of Tea"), " by Katsuhito Ishii\n"
3278
+ radio; para strong("Kin-Dza-Dza"), " by Georgi Danelia\n"
3279
+ radio; para strong("Children of Heaven"), " by Majid Majidi\n"
3280
+ end
3281
+ }}}
3282
+
3283
+ Only one of these three radios can be checked at a time, since they are grouped
3284
+ together in the same slot (along with a bunch of `para`.)
3285
+
3286
+ If we move them each into their own slot, the example breaks.
3287
+
3288
+ {{{
3289
+ #!ruby
3290
+ Shoes.app do
3291
+ stack do
3292
+ para "Among these films, which do you prefer?"
3293
+ flow { radio; para "The Taste of Tea by Katsuhito Ishii" }
3294
+ flow { radio; para "Kin-Dza-Dza by Georgi Danelia" }
3295
+ flow { radio; para "Children of Heaven by Majid Majidi" }
3296
+ end
3297
+ end
3298
+ }}}
3299
+
3300
+ This can be fixed, though. You can group together radios from different slots,
3301
+ you just have to give them all the same group name.
3302
+
3303
+ Here, let's group all these radios in the `:films` group.
3304
+
3305
+ {{{
3306
+ #!ruby
3307
+ Shoes.app do
3308
+ stack do
3309
+ para "Among these films, which do you prefer?"
3310
+ flow do
3311
+ radio :films
3312
+ para "The Taste of Tea by Katsuhito Ishii"
3313
+ end
3314
+ flow do
3315
+ radio :films
3316
+ para "Kin-Dza-Dza by Georgi Danelia"
3317
+ end
3318
+ flow do
3319
+ radio :films
3320
+ para "Children of Heaven by Majid Majidi"
3321
+ end
3322
+ end
3323
+ end
3324
+ }}}
3325
+
3326
+ For more methods beyond those listed below, also look into the [[Common]]
3327
+ methods page. Because you get those methods on every radio as well.
3328
+
3329
+ === checked?() » true or false ===
3330
+
3331
+ Returns whether the radio button is checked or not. So, `true` means "yes, it
3332
+ is checked!"
3333
+
3334
+ === checked = true or false ===
3335
+
3336
+ Marks or unmarks the radio button. Using `checked = false`, for instance,
3337
+ clears the radio.
3338
+
3339
+ === click() { |self| ... } » self ===
3340
+
3341
+ When the radio button is clicked, its `click` block is called. The block is
3342
+ handed `self`, which is an object representing the radio which was clicked.
3343
+
3344
+ Clicks are sent for both marking and unmarking the radio.
3345
+
3346
+ === focus() » self ===
3347
+
3348
+ Moves focus to the radio. The radio will be highlighted and, if the user hits
3349
+ Enter, the radio will be toggled between its marked and unmarked states.
3350
+
3351
+ == Shape ==
3352
+
3353
+ A shape is a path outline usually created by drawing methods like `oval` and
3354
+ `rect`. !{:margin_left => 100}man-ele-shape.png!
3355
+
3356
+ See the [[Common]] methods page. Shapes respond to all of those methods.
3357
+
3358
+ == TextBlock ==
3359
+
3360
+ The TextBlock object represents a group of text organized as a single element.
3361
+ A paragraph containing bolded text, for example. A caption containing links and
3362
+ bolded text. (So, a `caption` is a TextBlock type. However, `link` and
3363
+ `strong` are TextClass types.) !{:margin_left => 100}man-ele-textblock.png!
3364
+
3365
+ All of the various types of TextBlock are found on the [[Element Element
3366
+ Creation]] page.
3367
+
3368
+ * [[Element.banner]], a 48 pixel font.
3369
+ * [[Element.title]], a 34 pixel font.
3370
+ * [[Element.subtitle]], a 26 pixel font.
3371
+ * [[Element.tagline]], an 18 pixel font.
3372
+ * [[Element.caption]], a 14 pixel font.
3373
+ * [[Element.para]], a 12 pixel font.
3374
+ * [[Element.inscription]], a 10 pixel font.
3375
+
3376
+ === contents() » an array of elements ===
3377
+
3378
+ Lists all of the strings and styled text objects inside this block.
3379
+
3380
+ === replace(a string) ===
3381
+
3382
+ Replaces the text of the entire block with the characters of `a string`.
3383
+
3384
+ === text() » a string ===
3385
+
3386
+ Return a string of all of the characters in this text box. This will strip off
3387
+ any style or text classes and just return the actual characters, as if seen on
3388
+ the screen.
3389
+
3390
+ === text = a string ===
3391
+
3392
+ Replaces the text of the entire block with the characters of `a string`.
3393
+
3394
+ === to_s() » a string ===
3395
+
3396
+ An alias for [[TextBlock.text]]. Returns a flattened string of all of this
3397
+ TextBlock's contents.
3398
+
3399
+ == Timers ==
3400
+
3401
+ Shoes contains three timer classes: the Animation class, the Every class and
3402
+ the Timer class. Both Animations and Everies loop over and over after they
3403
+ start. Timers happen once. A one-shot timer.
3404
+
3405
+ Animations and Everies are basically the same thing. The difference is that
3406
+ Animations usually happen many, many times per second. And Everies happen only
3407
+ once every few seconds or rarely.
3408
+
3409
+ === start() » self ===
3410
+
3411
+ Both types of timers automatically start themselves, so there's no need to use
3412
+ this normally. But if you [[Timers.stop]] a timer and would like to start it up
3413
+ again, then by all means: use this!
3414
+
3415
+ === stop() » self ===
3416
+
3417
+ Pauses the animation or timer. In the case of a one-shot timer that's already
3418
+ happened, it's already stopped and this method will have no effect.
3419
+
3420
+ === toggle() » self ===
3421
+
3422
+ If the animation or timer is stopped, it is started. Otherwise, if it is
3423
+ already running, it is stopped.
3424
+
3425
+ == Video ==
3426
+
3427
+ Shoes supports embedding of QuickTime, Flash video (FLV), DivX, Xvid and
3428
+ various other popular video formats. This is all thanks to VideoLAN and ffmpeg,
3429
+ two sensational open source libraries. Use the `video` method on a slot to
3430
+ setup a Shoes::Video object. !{:margin_left => 100}man-ele-video.png!
3431
+
3432
+ In addition to video formats, some audio formats are also supported, such as
3433
+ MP3, WAV and Ogg Vorbis.
3434
+
3435
+ Video support is optional in Shoes and some builds do not support video. For
3436
+ example, video support is unavailable for PowerPC. When you download Shoes, the
3437
+ build for your platform will be marked `novideo` in the filename if no video
3438
+ support is available.
3439
+
3440
+ === hide() » self ===
3441
+
3442
+ Hides the video. If already playing, the video will continue to play. This just
3443
+ turns off display of the video. One possible use of this method is to collapse
3444
+ the video area when it is playing an audio file, such as an MP3.
3445
+
3446
+ === length() » a number ===
3447
+
3448
+ The full length of the video in milliseconds. Returns nil if the video is not
3449
+ yet loaded.
3450
+
3451
+ === move(left, top) » self ===
3452
+
3453
+ Moves the video to specific coordinates, the (left, top) being the upper left
3454
+ hand corner of the video.
3455
+
3456
+ === pause() » self ===
3457
+
3458
+ Pauses the video, if it is playing.
3459
+
3460
+ === playing?() » true of false ===
3461
+
3462
+ Returns true if the video is currently playing. Or, false if the video is
3463
+ paused or stopped.
3464
+
3465
+ === play() » self ===
3466
+
3467
+ Starts playing the video, if it isn't already playing. If already playing, the
3468
+ video is restarted from the beginning.
3469
+
3470
+ === position() » a decimal ===
3471
+
3472
+ The position of the video as a decimanl number (a Float) between the beginning
3473
+ (0.0) and the end (1.0). For instance, a Float value of 0.5 indicates the
3474
+ halfway point of the video.
3475
+
3476
+ === position = a decimal ===
3477
+
3478
+ Sets the position of the video using a Float value. To move the video to its
3479
+ 25% position: `@video.position = 0.25`.
3480
+
3481
+ === remove() » self ===
3482
+
3483
+ Removes the video from its slot. This will stop the video as well.
3484
+
3485
+ === show() » self ===
3486
+
3487
+ Reveals the video, if it has been hidden by the `hide()` method.
3488
+
3489
+ === stop() » self ===
3490
+
3491
+ Stops the video, if it is playing.
3492
+
3493
+ === time() » a number ===
3494
+
3495
+ The time position of the video in milliseconds. So, if the video is 10 seconds
3496
+ into play, this method would return the number 10000.
3497
+
3498
+ === time = a number ===
3499
+
3500
+ Set the position of the video to a time in milliseconds.
3501
+
3502
+ === toggle() » self ===
3503
+
3504
+ Toggles the visibility of the video. If the video can be seen, then `hide` is
3505
+ called. Otherwise, `show` is called.
3506
+
3507
+ = AndSoForth =
3508
+
3509
+ A place for some other information.
3510
+
3511
+ == Sample Apps ==
3512
+
3513
+ Have fun!
3514
+
3515
+ {SAMPLES}
3516
+
3517
+ == FAQ ==
3518
+
3519
+ Hope this helps:
3520
+
3521
+ * You can join [[http://librelist.com/browser/shoes/ Shoes ML]] and feel free ask your questions.
3522
+ * [[http://github.com/shoes/shoes/ Official Current Source Code]] is on GitHub.
3523
+ * [[http://github.com/shoes/shoes/downloads Recent Builds]] for your platform.