green_shoes 0.201.0 → 0.207.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/green_shoes.rb +2 -0
- data/lib/shoes/app.rb +11 -18
- data/lib/shoes/basic.rb +22 -2
- data/lib/shoes/helper_methods.rb +52 -7
- data/lib/shoes/slot.rb +19 -0
- data/lib/shoes/style.rb +11 -10
- data/samples/sample44.rb +4 -4
- data/samples/sample51.rb +30 -0
- data/samples/shell.png +0 -0
- data/snapshots/sample51.png +0 -0
- data/static/manual-en.txt +51 -3
- metadata +6 -3
data/README.md
CHANGED
@@ -8,7 +8,7 @@ This is **Green Shoes** written in Ruby. One of the colorful [Shoes](http://shoe
|
|
8
8
|
|
9
9
|
Fantastic logo icon was created by [Zachary Scott](https://github.com/zacharyscott). Thanks!
|
10
10
|
|
11
|
-
Now, there are
|
11
|
+
Now, there are 51 [samples](https://github.com/ashbb/green_shoes/tree/master/samples). Each has a [snapshot](https://github.com/ashbb/green_shoes/tree/master/snapshots).
|
12
12
|
|
13
13
|
|
14
14
|
Tiny Streaming Flash videos
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.207.0
|
data/lib/green_shoes.rb
CHANGED
@@ -19,6 +19,8 @@ module Shoes
|
|
19
19
|
LINKHOVER_DEFAULT = "<span underline='single' underline_color='#039' foreground='#039' weight='normal'>"
|
20
20
|
ROTATE = [Gdk::Pixbuf::ROTATE_NONE, Gdk::Pixbuf::ROTATE_CLOCKWISE, Gdk::Pixbuf::ROTATE_UPSIDEDOWN, Gdk::Pixbuf::ROTATE_COUNTERCLOCKWISE]
|
21
21
|
VERSION = IO.read(File.join(DIR, '../VERSION')).chomp
|
22
|
+
BASIC_ATTRIBUTES_DEFAULT = {left: 0, top: 0, width: 0, height: 0, angle: 0, curve: 0}
|
23
|
+
SLOT_ATTRIBUTES_DEFAULT = {left: nil, top: nil, width: 1.0, height: 0}
|
22
24
|
end
|
23
25
|
|
24
26
|
class Object
|
data/lib/shoes/app.rb
CHANGED
@@ -31,7 +31,7 @@ class Shoes
|
|
31
31
|
attr_accessor :cslot, :cmask, :top_slot, :contents, :canvas, :app, :mccs, :mrcs, :mmcs,
|
32
32
|
:mhcs, :mlcs, :shcs, :mcs, :win, :swin, :width_pre, :height_pre, :order, :dics
|
33
33
|
attr_writer :mouse_button, :mouse_pos
|
34
|
-
attr_reader :link_style, :linkhover_style, :animates, :owner
|
34
|
+
attr_reader :link_style, :linkhover_style, :animates, :owner, :textcursors
|
35
35
|
|
36
36
|
def visit url
|
37
37
|
if url =~ /^(http|https):\/\//
|
@@ -73,9 +73,7 @@ class Shoes
|
|
73
73
|
args = msg.last.class == Hash ? msg.pop : {}
|
74
74
|
args = basic_attributes args
|
75
75
|
args[:markup] = msg.map(&:to_s).join
|
76
|
-
|
77
|
-
dummy_attr_list, text = Pango.parse_markup args[:markup]
|
78
|
-
text = text.gsub('\u0026', '&')
|
76
|
+
text, attr_list = make_pango_attr args[:markup]
|
79
77
|
args[:size] ||= font_size
|
80
78
|
args[:font] ||= (@font_family or 'sans')
|
81
79
|
args[:align] ||= 'left'
|
@@ -92,19 +90,8 @@ class Shoes
|
|
92
90
|
|
93
91
|
if args[:create_real] or !layout_control
|
94
92
|
args[:width] = 1 if args[:width] <= 0
|
95
|
-
surface =
|
96
|
-
|
97
|
-
layout = context.create_pango_layout
|
98
|
-
layout.width = args[:width] * Pango::SCALE
|
99
|
-
layout.wrap = Pango::WRAP_WORD
|
100
|
-
layout.spacing = 5 * Pango::SCALE
|
101
|
-
layout.text = text
|
102
|
-
layout.alignment = eval "Pango::ALIGN_#{args[:align].upcase}"
|
103
|
-
fd = Pango::FontDescription.new
|
104
|
-
fd.family = args[:font]
|
105
|
-
fd.size = args[:size] * Pango::SCALE
|
106
|
-
layout.font_description = fd
|
107
|
-
layout.attributes = attr_list
|
93
|
+
layout, context, surface =
|
94
|
+
make_pango_layout args[:size], args[:width], args[:height], args[:align], args[:font], text, attr_list
|
108
95
|
context.show_pango_layout layout
|
109
96
|
context.show_page
|
110
97
|
|
@@ -114,6 +101,7 @@ class Shoes
|
|
114
101
|
img = create_tmp_png surface
|
115
102
|
@canvas.put img, args[:left], args[:top]
|
116
103
|
img.show_now
|
104
|
+
@canvas.remove img if args[:hidden]
|
117
105
|
args[:real], args[:noorder] = img, layout_control
|
118
106
|
else
|
119
107
|
args[:real] = false
|
@@ -152,6 +140,7 @@ class Shoes
|
|
152
140
|
end
|
153
141
|
@canvas.put img, args[:left], args[:top]
|
154
142
|
img.show_now
|
143
|
+
@canvas.remove img if args[:hidden]
|
155
144
|
args[:real], args[:app] = img, self
|
156
145
|
Image.new(args).tap{|s| @dics.push([s, d, tmpname]) if downloading}
|
157
146
|
end
|
@@ -343,6 +332,7 @@ class Shoes
|
|
343
332
|
img = Gtk::Image.new img.pixbuf.rotate(ROTATE[@pixbuf_rotate])
|
344
333
|
@canvas.put img, args[:left], args[:top]
|
345
334
|
img.show_now
|
335
|
+
@canvas.remove img if args[:hidden]
|
346
336
|
args[:real], args[:app] = img, self
|
347
337
|
Oval.new args
|
348
338
|
end
|
@@ -388,6 +378,7 @@ class Shoes
|
|
388
378
|
img = Gtk::Image.new img.pixbuf.rotate(ROTATE[@pixbuf_rotate])
|
389
379
|
@canvas.put img, args[:left], args[:top]
|
390
380
|
img.show_now
|
381
|
+
@canvas.remove img if args[:hidden]
|
391
382
|
args[:real], args[:app] = img, self
|
392
383
|
Rect.new args
|
393
384
|
end
|
@@ -447,6 +438,7 @@ class Shoes
|
|
447
438
|
img = create_tmp_png surface
|
448
439
|
@canvas.put img, (args[:left]-=cw), (args[:top]-=cw)
|
449
440
|
img.show_now
|
441
|
+
@canvas.remove img if args[:hidden]
|
450
442
|
args[:real], args[:app] = img, self
|
451
443
|
Line.new args
|
452
444
|
end
|
@@ -485,6 +477,7 @@ class Shoes
|
|
485
477
|
img = Gtk::Image.new img.pixbuf.rotate(ROTATE[@pixbuf_rotate])
|
486
478
|
@canvas.put img, args[:left], args[:top]
|
487
479
|
img.show_now
|
480
|
+
@canvas.remove img if args[:hidden]
|
488
481
|
args[:real], args[:app] = img, self
|
489
482
|
klass.new args
|
490
483
|
end
|
@@ -530,7 +523,7 @@ class Shoes
|
|
530
523
|
line_to w*0.58, w*0.5*0.2
|
531
524
|
line_to w, w*0.5
|
532
525
|
line_to w*0.58, w*(1-0.5*0.2)
|
533
|
-
|
526
|
+
line_to w*0.58, w*(1-0.5*0.6)
|
534
527
|
line_to 0, w*(1-0.5*0.6)
|
535
528
|
line_to 0, w*0.5*0.6
|
536
529
|
end
|
data/lib/shoes/basic.rb
CHANGED
@@ -25,7 +25,8 @@ class Shoes
|
|
25
25
|
@proc = nil
|
26
26
|
[:app, :real].each{|k| args.delete k}
|
27
27
|
@args = args
|
28
|
-
@
|
28
|
+
@hovered = false
|
29
|
+
@hidden ? (@hided, @shows = true, false) : (@hided, @shows = false, true)
|
29
30
|
end
|
30
31
|
|
31
32
|
attr_reader :args, :shows, :initials
|
@@ -66,6 +67,7 @@ class Shoes
|
|
66
67
|
@app.shcs.delete self
|
67
68
|
@app.shcs << self
|
68
69
|
@shows = true
|
70
|
+
@args.delete :hidden
|
69
71
|
self
|
70
72
|
end
|
71
73
|
|
@@ -164,7 +166,7 @@ class Shoes
|
|
164
166
|
end
|
165
167
|
|
166
168
|
def text= s
|
167
|
-
style markup: s
|
169
|
+
style markup: s if !@hided or @args[:hidden]
|
168
170
|
end
|
169
171
|
|
170
172
|
alias :replace :text=
|
@@ -178,6 +180,24 @@ class Shoes
|
|
178
180
|
self.text = @args[:markup]
|
179
181
|
super
|
180
182
|
end
|
183
|
+
|
184
|
+
def remove
|
185
|
+
flag = @args[:hidden] ? @shows : @hided
|
186
|
+
@app.canvas.remove @real unless flag
|
187
|
+
end
|
188
|
+
|
189
|
+
def cursor=(n)
|
190
|
+
if !n
|
191
|
+
@app.textcursors[self][1].clear if @app.textcursors[self][1]
|
192
|
+
@app.textcursors.delete self
|
193
|
+
else
|
194
|
+
@app.textcursors[self] ? (@app.textcursors[self][0] = n) : (@app.textcursors[self] = [n, nil])
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def cursor
|
199
|
+
@app.textcursors[self][0]
|
200
|
+
end
|
181
201
|
end
|
182
202
|
|
183
203
|
class Banner < TextBlock; end
|
data/lib/shoes/helper_methods.rb
CHANGED
@@ -36,8 +36,8 @@ class Shoes
|
|
36
36
|
|
37
37
|
module Mod2
|
38
38
|
def init_app_vars
|
39
|
-
@contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics, @animates, @radio_groups =
|
40
|
-
[], [], [], [], [], [], [], [], [], [], [], {}
|
39
|
+
@contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics, @animates, @radio_groups, @textcursors =
|
40
|
+
[], [], [], [], [], [], [], [], [], [], [], {}, {}
|
41
41
|
@cmask = nil
|
42
42
|
@mouse_button, @mouse_pos = 0, [0, 0]
|
43
43
|
@fill, @stroke = black, black
|
@@ -62,13 +62,13 @@ class Shoes
|
|
62
62
|
|
63
63
|
class App
|
64
64
|
def basic_attributes args={}
|
65
|
-
default =
|
65
|
+
default = BASIC_ATTRIBUTES_DEFAULT
|
66
66
|
default.merge!({nocontrol: true}) if @nolayout
|
67
67
|
default.merge args
|
68
68
|
end
|
69
69
|
|
70
70
|
def slot_attributes args={}
|
71
|
-
default =
|
71
|
+
default = SLOT_ATTRIBUTES_DEFAULT
|
72
72
|
default.merge args
|
73
73
|
end
|
74
74
|
|
@@ -81,7 +81,7 @@ class Shoes
|
|
81
81
|
start, links = 0, []
|
82
82
|
msg.each do |e|
|
83
83
|
len = e.to_s.gsub(/<\/.*?>/, '').gsub(/<.*?>/, '').length
|
84
|
-
(links << e; e.index = [start, start + len
|
84
|
+
(links << e; e.index = [start, start + len]) if e.is_a? Link
|
85
85
|
start += len
|
86
86
|
end
|
87
87
|
links
|
@@ -90,10 +90,43 @@ class Shoes
|
|
90
90
|
def make_link_pos links, layout, line_height
|
91
91
|
links.each do |e|
|
92
92
|
e.pos = [layout.index_to_pos(e.index[0]).x / Pango::SCALE, layout.index_to_pos(e.index[0]).y / Pango::SCALE]
|
93
|
-
e.pos << (layout.index_to_pos(e.index[1]).x / Pango::SCALE
|
93
|
+
e.pos << (layout.index_to_pos(e.index[1]).x / Pango::SCALE) << (layout.index_to_pos(e.index[1]).y / Pango::SCALE)
|
94
94
|
e.pos << line_height
|
95
95
|
end
|
96
96
|
end
|
97
|
+
|
98
|
+
def make_textcursor_pos tb, n
|
99
|
+
markup, size, width, height, align, font =
|
100
|
+
%w[@markup @size @width @height @align @font].map{|v| tb.instance_variable_get v}
|
101
|
+
text, attr_list = make_pango_attr markup
|
102
|
+
layout, = make_pango_layout size, width, height, align, font, text, attr_list
|
103
|
+
n = tb.text.length if n == -1
|
104
|
+
return layout.index_to_pos(n).x / Pango::SCALE, layout.index_to_pos(n).y / Pango::SCALE
|
105
|
+
end
|
106
|
+
|
107
|
+
def make_pango_attr markup
|
108
|
+
attr_list, dummy_text = Pango.parse_markup markup.gsub('\u0026', '@')
|
109
|
+
dummy_attr_list, text = Pango.parse_markup markup
|
110
|
+
text = text.gsub('\u0026', '&')
|
111
|
+
return text, attr_list
|
112
|
+
end
|
113
|
+
|
114
|
+
def make_pango_layout size, width, height, align, font, text, attr_list
|
115
|
+
surface = Cairo::ImageSurface.new Cairo::FORMAT_ARGB32, width, height
|
116
|
+
context = Cairo::Context.new surface
|
117
|
+
layout = context.create_pango_layout
|
118
|
+
layout.width = width * Pango::SCALE
|
119
|
+
layout.wrap = Pango::WRAP_WORD
|
120
|
+
layout.spacing = 5 * Pango::SCALE
|
121
|
+
layout.text = text
|
122
|
+
layout.alignment = eval "Pango::ALIGN_#{align.upcase}"
|
123
|
+
fd = Pango::FontDescription.new
|
124
|
+
fd.family = font
|
125
|
+
fd.size = size * Pango::SCALE
|
126
|
+
layout.font_description = fd
|
127
|
+
layout.attributes = attr_list
|
128
|
+
return layout, context, surface
|
129
|
+
end
|
97
130
|
end
|
98
131
|
|
99
132
|
def self.contents_alignment slot
|
@@ -135,6 +168,15 @@ class Shoes
|
|
135
168
|
end
|
136
169
|
end
|
137
170
|
end
|
171
|
+
|
172
|
+
def self.repaint_textcursors app
|
173
|
+
app.textcursors.each do |tb, v|
|
174
|
+
n, cursor = v
|
175
|
+
x, y = app.make_textcursor_pos(tb, n)
|
176
|
+
x += tb.left; y += tb.top
|
177
|
+
cursor ? cursor.move(x, y) : app.textcursors[tb][1] = app.line(x, y, x, y+tb.size*1.7)
|
178
|
+
end
|
179
|
+
end
|
138
180
|
|
139
181
|
def self.call_back_procs app
|
140
182
|
init_contents app.cslot.contents
|
@@ -143,6 +185,7 @@ class Shoes
|
|
143
185
|
repaint_all app.cslot
|
144
186
|
mask_control app
|
145
187
|
repaint_all_by_order app
|
188
|
+
repaint_textcursors app
|
146
189
|
app.canvas.set_size 0, scrollable_height unless app.prjct
|
147
190
|
true
|
148
191
|
end
|
@@ -194,6 +237,7 @@ class Shoes
|
|
194
237
|
|
195
238
|
def self.mouse_link_control app
|
196
239
|
app.mlcs.each do |tb|
|
240
|
+
next if tb.hided
|
197
241
|
link_proc, = mouse_on_link(tb, app)
|
198
242
|
link_proc.call if link_proc
|
199
243
|
end
|
@@ -207,10 +251,11 @@ class Shoes
|
|
207
251
|
end
|
208
252
|
|
209
253
|
app.mlcs.each do |tb|
|
254
|
+
return false if tb.hided
|
210
255
|
tb.text = tb.text unless tb.real
|
211
256
|
tb.real.window.cursor = ARROW if tb.real.window
|
212
257
|
if ret = mouse_on_link(tb, app)
|
213
|
-
tb.real.window.cursor = HAND
|
258
|
+
tb.real.window.cursor = HAND if tb.real.window
|
214
259
|
unless tb.links[ret[1]].link_hover
|
215
260
|
markup = tb.args[:markup].gsub(app.linkhover_style, app.link_style)
|
216
261
|
links = markup.mindex app.link_style
|
data/lib/shoes/slot.rb
CHANGED
@@ -20,7 +20,16 @@ class Shoes
|
|
20
20
|
@contents = []
|
21
21
|
(@parent.contents << self) unless @nocontrol
|
22
22
|
if block_given?
|
23
|
+
if args[:hidden]
|
24
|
+
BASIC_ATTRIBUTES_DEFAULT.merge! hidden: true
|
25
|
+
SLOT_ATTRIBUTES_DEFAULT.merge! hidden: true
|
26
|
+
@hidden_flag = true unless @parent.instance_variable_get '@hidden'
|
27
|
+
end
|
23
28
|
yield
|
29
|
+
if @hidden_flag
|
30
|
+
BASIC_ATTRIBUTES_DEFAULT.delete :hidden
|
31
|
+
SLOT_ATTRIBUTES_DEFAULT.delete :hidden
|
32
|
+
end
|
24
33
|
@app.cslot = @parent
|
25
34
|
else
|
26
35
|
@left = @top = 0
|
@@ -102,6 +111,16 @@ class Shoes
|
|
102
111
|
n = n ? n+1 : contents.length
|
103
112
|
prepend n, &blk
|
104
113
|
end
|
114
|
+
|
115
|
+
def show
|
116
|
+
@contents.each &:show
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
def hide
|
121
|
+
@contents.each &:hide
|
122
|
+
self
|
123
|
+
end
|
105
124
|
end
|
106
125
|
|
107
126
|
class Stack < Slot; end
|
data/lib/shoes/style.rb
CHANGED
@@ -2,17 +2,17 @@ class Shoes
|
|
2
2
|
class App
|
3
3
|
def style klass, args={}
|
4
4
|
if klass == Shoes::Link
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
@link_style = LINK_DEFAULT
|
6
|
+
@link_style.sub!('single', 'none') if args[:underline] == false
|
7
|
+
@link_style.sub!("foreground='#06E'", "foreground='#{args[:stroke]}'") if args[:stroke]
|
8
|
+
@link_style.sub!('>', " background='#{args[:fill]}'>") if args[:fill]
|
9
|
+
@link_style.sub!('normal', "#{args[:weight]}") if args[:weight]
|
10
10
|
elsif klass == Shoes::LinkHover
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
@linkhover_style = LINKHOVER_DEFAULT
|
12
|
+
@linkhover_style.sub!('single', 'none') if args[:underline] == false
|
13
|
+
@linkhover_style.sub!("foreground='#039'", "foreground='#{args[:stroke]}'") if args[:stroke]
|
14
|
+
@linkhover_style.sub!('>', " background='#{args[:fill]}'>") if args[:fill]
|
15
|
+
@linkhover_style.sub!('normal', "#{args[:weight]}") if args[:weight]
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -55,6 +55,7 @@ class Shoes
|
|
55
55
|
tb = @app.send(m, *args)
|
56
56
|
@real, @height = tb.real, tb.height
|
57
57
|
@args[:markup], @args[:size], @args[:font], @args[:align] = tb.markup, tb.size, tb.font, tb.align
|
58
|
+
@markup, @size, @font, @align = @args[:markup], @args[:size], @args[:font], @args[:align]
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
data/samples/sample44.rb
CHANGED
@@ -33,7 +33,7 @@ Shoes.app height: 260, width: 250 do
|
|
33
33
|
_y = radius_local * Math.cos( time * Math::PI / unit )
|
34
34
|
stroke color
|
35
35
|
strokewidth sw
|
36
|
-
line
|
36
|
+
line @centerx, @centery, @centerx + _x, @centery - _y, hidden: true
|
37
37
|
end
|
38
38
|
|
39
39
|
@radius, @centerx, @centery = 90, 126, 140
|
@@ -43,9 +43,9 @@ Shoes.app height: 260, width: 250 do
|
|
43
43
|
@msg = para '', margin: 4, align: 'center'
|
44
44
|
end
|
45
45
|
hour, min, sec = [], [], []
|
46
|
-
12.times{|i| 5.times{|j| hour << clock_hand(i+(j/5.0), 8, 6)
|
47
|
-
60.times{|i| 4.times{|j| min << clock_hand(i+(j/4.0), 5)
|
48
|
-
60.times{|i| 8.times{|j| sec << clock_hand(i+(j/8.0), 2, 30, red)
|
46
|
+
12.times{|i| 5.times{|j| hour << clock_hand(i+(j/5.0), 8, 6)}}
|
47
|
+
60.times{|i| 4.times{|j| min << clock_hand(i+(j/4.0), 5)}}
|
48
|
+
60.times{|i| 8.times{|j| sec << clock_hand(i+(j/8.0), 2, 30, red)}}
|
49
49
|
|
50
50
|
animate 8 do |i|
|
51
51
|
t = Time.new
|
data/samples/sample51.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require '../lib/green_shoes'
|
2
|
+
|
3
|
+
# The same as gallery2 : http://shoes-tutorial-note.heroku.com/html/01110_Fancy_Gallery_1-5.html
|
4
|
+
# But revised for Green Shoes
|
5
|
+
|
6
|
+
Shoes.app width: 200, height: 200 do
|
7
|
+
background mintcream
|
8
|
+
flow margin: 5 do
|
9
|
+
flow height: 190 do
|
10
|
+
background './shell.png', curve: 5
|
11
|
+
@line = para ' '
|
12
|
+
@line.cursor = -1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
keypress do |k|
|
17
|
+
#p k
|
18
|
+
msg = case k
|
19
|
+
when 'BackSpace'; @line.text[0..-2]
|
20
|
+
when 'Return'; @line.text + "\n"
|
21
|
+
when 'space'; @line.text + ' '
|
22
|
+
when 'exclam'; @line.text + '!'
|
23
|
+
when 'period'; @line.text + '.'
|
24
|
+
else
|
25
|
+
k.length == 1 ? @line.text + k : nil
|
26
|
+
end
|
27
|
+
(@line.text = strong fg msg, white) if msg
|
28
|
+
flush
|
29
|
+
end
|
30
|
+
end
|
data/samples/shell.png
ADDED
Binary file
|
Binary file
|
data/static/manual-en.txt
CHANGED
@@ -1335,10 +1335,25 @@ being 100%.)
|
|
1335
1335
|
|
1336
1336
|
For: ''all slots and elements''.
|
1337
1337
|
|
1338
|
-
Hides or shows this object. Any object with
|
1338
|
+
Hides or shows this object. Any object with `hidden: true` are not
|
1339
1339
|
displayed on the screen. Neither are its children.
|
1340
1340
|
|
1341
|
-
|
1341
|
+
{{{
|
1342
|
+
Shoes.app do
|
1343
|
+
slot = stack hidden: true do
|
1344
|
+
title 'hello'
|
1345
|
+
flow do
|
1346
|
+
image File.join DIR, '../samples/loogink.png'
|
1347
|
+
end
|
1348
|
+
para link('Go go!'){alert 'hi'}
|
1349
|
+
end
|
1350
|
+
timer(2){slot.show}
|
1351
|
+
timer(5){slot.hide}
|
1352
|
+
end
|
1353
|
+
}}}
|
1354
|
+
|
1355
|
+
'''Note:''' Green Shoes supports `:hidden` style for only slots, shapes, textblocks
|
1356
|
+
and images so far.
|
1342
1357
|
|
1343
1358
|
=== :inner » a number ===
|
1344
1359
|
|
@@ -3347,7 +3362,8 @@ To create an image, use the `image` method in a slot:
|
|
3347
3362
|
#!ruby
|
3348
3363
|
Shoes.app do
|
3349
3364
|
para "Nice, nice, very nice. Busy, busy, busy."
|
3350
|
-
image
|
3365
|
+
image File.join DIR,
|
3366
|
+
"../static/shoes-manual-apps.png"
|
3351
3367
|
end
|
3352
3368
|
}}}
|
3353
3369
|
|
@@ -3676,6 +3692,38 @@ TextBlock's contents.
|
|
3676
3692
|
|
3677
3693
|
'''Note:''' Green Shoes doesn't support `to_s` method.
|
3678
3694
|
|
3695
|
+
=== cursor() » an index ===
|
3696
|
+
|
3697
|
+
Return a text cursor position. That is an index of the text which is a string
|
3698
|
+
of all of the characters in this text box.
|
3699
|
+
|
3700
|
+
=== cursor = an index or nil ===
|
3701
|
+
|
3702
|
+
Shows or hides the text cursor.
|
3703
|
+
Using `cursor = 3`, for instance, shows the text cursor at index 3 from the front.
|
3704
|
+
Using `cursor = -1` shows the text cursor at the end of the text.
|
3705
|
+
Using `cursor = nil` hides the text cursor.
|
3706
|
+
|
3707
|
+
{{{
|
3708
|
+
Shoes.app do
|
3709
|
+
msg = para 'hello ' * 20
|
3710
|
+
msg.cursor = -1
|
3711
|
+
keypress do |k|
|
3712
|
+
n = case k
|
3713
|
+
when 'Left'; -1
|
3714
|
+
when 'Right'; 1
|
3715
|
+
else
|
3716
|
+
next
|
3717
|
+
end
|
3718
|
+
n += msg.cursor
|
3719
|
+
len = msg.text.length
|
3720
|
+
n = len unless n > -1
|
3721
|
+
msg.cursor = n % (len+1)
|
3722
|
+
flush
|
3723
|
+
end
|
3724
|
+
end
|
3725
|
+
}}}
|
3726
|
+
|
3679
3727
|
== Timers ==
|
3680
3728
|
|
3681
3729
|
Green Shoes contains three timers: the animate, every and
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 207
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.207.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- ashbb
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-16 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -195,11 +195,13 @@ files:
|
|
195
195
|
- samples/sample49.rb
|
196
196
|
- samples/sample5.rb
|
197
197
|
- samples/sample50.rb
|
198
|
+
- samples/sample51.rb
|
198
199
|
- samples/sample6.rb
|
199
200
|
- samples/sample7.rb
|
200
201
|
- samples/sample8.rb
|
201
202
|
- samples/sample9.rb
|
202
203
|
- samples/sample99.rb
|
204
|
+
- samples/shell.png
|
203
205
|
- samples/splash-hand.png
|
204
206
|
- snapshots/helloworld.png
|
205
207
|
- snapshots/mini-hh.png
|
@@ -252,6 +254,7 @@ files:
|
|
252
254
|
- snapshots/sample49.png
|
253
255
|
- snapshots/sample5.png
|
254
256
|
- snapshots/sample50.png
|
257
|
+
- snapshots/sample51.png
|
255
258
|
- snapshots/sample6.png
|
256
259
|
- snapshots/sample7.png
|
257
260
|
- snapshots/sample8.png
|