scarpe 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.yardopts +11 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +112 -0
  6. data/README.md +31 -24
  7. data/Rakefile +13 -1
  8. data/docs/yard/catscradle.md +44 -0
  9. data/docs/yard/template/default/fulldoc/html/setup.rb +13 -0
  10. data/docs/yard/template/default/layout/html/setup.rb +9 -0
  11. data/examples/background_with_image.rb +16 -0
  12. data/examples/bloopsaphone/working/bronx_army_knife.rb +66 -0
  13. data/examples/bloopsaphone/working/morning_serenity.rb +21 -0
  14. data/examples/bloopsaphone/working/simpsons_theme_song_by_why.rb +6 -4
  15. data/examples/button_go_away.rb +1 -1
  16. data/examples/check.rb +18 -0
  17. data/examples/clear_and_append.rb +24 -0
  18. data/examples/download_and_show_image.rb +28 -0
  19. data/examples/edit_box.rb +3 -5
  20. data/examples/fonts.rb +2 -2
  21. data/examples/get_headers.rb +10 -0
  22. data/examples/highlander.rb +2 -0
  23. data/examples/link.rb +2 -2
  24. data/examples/local_fonts.rb +4 -0
  25. data/examples/local_images.rb +4 -0
  26. data/examples/motion_events.rb +20 -0
  27. data/examples/parse_xl_funnies.rb +58 -0
  28. data/examples/radio/radio.rb +16 -0
  29. data/examples/radio/radio_groups.rb +18 -0
  30. data/examples/radio/radio_same_slot.rb +6 -0
  31. data/examples/ruby_racer.rb +13 -15
  32. data/examples/selfitude.rb +18 -0
  33. data/examples/shapes/shapes_fill.rb +4 -3
  34. data/examples/shoes_school.rb +2 -4
  35. data/examples/show_hide.rb +6 -0
  36. data/examples/skip_ci/change_my_audio_source.rb +21 -0
  37. data/examples/skip_ci/guitar_fretboard.rb +137 -0
  38. data/examples/video.rb +10 -0
  39. data/exe/scarpe +42 -66
  40. data/fonts/Pacifico.ttf +0 -0
  41. data/lacci/Gemfile +22 -0
  42. data/lacci/Gemfile.lock +72 -0
  43. data/lacci/Rakefile +12 -0
  44. data/lacci/lacci.gemspec +37 -0
  45. data/lacci/lib/lacci/scarpe_cli.rb +70 -0
  46. data/lacci/lib/lacci/scarpe_core.rb +21 -0
  47. data/lacci/lib/lacci/version.rb +13 -0
  48. data/lacci/lib/shoes/app.rb +264 -0
  49. data/{lib/scarpe → lacci/lib/shoes}/background.rb +1 -1
  50. data/{lib/scarpe → lacci/lib/shoes}/border.rb +1 -1
  51. data/{lib/scarpe → lacci/lib/shoes}/colors.rb +1 -1
  52. data/lacci/lib/shoes/constants.rb +29 -0
  53. data/{lib/scarpe → lacci/lib/shoes}/display_service.rb +40 -45
  54. data/lacci/lib/shoes/download.rb +123 -0
  55. data/lacci/lib/shoes/log.rb +71 -0
  56. data/lacci/lib/shoes/spacing.rb +9 -0
  57. data/{lib/scarpe → lacci/lib/shoes}/widget.rb +63 -43
  58. data/{lib/scarpe → lacci/lib/shoes/widgets}/alert.rb +3 -3
  59. data/{lib/scarpe → lacci/lib/shoes/widgets}/arc.rb +7 -5
  60. data/{lib/scarpe → lacci/lib/shoes/widgets}/button.rb +3 -3
  61. data/lacci/lib/shoes/widgets/check.rb +28 -0
  62. data/lacci/lib/shoes/widgets/document_root.rb +20 -0
  63. data/{lib/scarpe → lacci/lib/shoes/widgets}/edit_box.rb +10 -5
  64. data/{lib/scarpe → lacci/lib/shoes/widgets}/edit_line.rb +2 -2
  65. data/lacci/lib/shoes/widgets/flow.rb +22 -0
  66. data/lacci/lib/shoes/widgets/font.rb +14 -0
  67. data/{lib/scarpe → lacci/lib/shoes/widgets}/image.rb +3 -7
  68. data/lacci/lib/shoes/widgets/line.rb +18 -0
  69. data/{lib/scarpe → lacci/lib/shoes/widgets}/link.rb +2 -2
  70. data/{lib/scarpe → lacci/lib/shoes/widgets}/list_box.rb +2 -2
  71. data/{lib/scarpe → lacci/lib/shoes/widgets}/para.rb +4 -26
  72. data/lacci/lib/shoes/widgets/radio.rb +35 -0
  73. data/lacci/lib/shoes/widgets/shape.rb +37 -0
  74. data/lacci/lib/shoes/widgets/slot.rb +75 -0
  75. data/{lib/scarpe → lacci/lib/shoes/widgets}/span.rb +2 -2
  76. data/lacci/lib/shoes/widgets/stack.rb +24 -0
  77. data/{lib/scarpe → lacci/lib/shoes/widgets}/star.rb +6 -9
  78. data/lacci/lib/shoes/widgets/subscription_item.rb +60 -0
  79. data/lacci/lib/shoes/widgets/text_widget.rb +51 -0
  80. data/lacci/lib/shoes/widgets/video.rb +15 -0
  81. data/lacci/lib/shoes/widgets.rb +29 -0
  82. data/lacci/lib/shoes.rb +127 -0
  83. data/lacci/test/test_colors.rb +39 -0
  84. data/lacci/test/test_helper.rb +9 -0
  85. data/lacci/test/test_lacci.rb +9 -0
  86. data/lib/scarpe/cats_cradle.rb +249 -0
  87. data/lib/scarpe/evented_assertions.rb +88 -0
  88. data/lib/scarpe/version.rb +1 -1
  89. data/lib/scarpe/wv/alert.rb +3 -2
  90. data/lib/scarpe/wv/app.rb +30 -8
  91. data/lib/scarpe/wv/arc.rb +5 -6
  92. data/lib/scarpe/wv/background.rb +10 -1
  93. data/lib/scarpe/wv/border.rb +5 -3
  94. data/lib/scarpe/wv/button.rb +11 -9
  95. data/lib/scarpe/wv/check.rb +29 -0
  96. data/lib/scarpe/wv/control_interface.rb +14 -20
  97. data/lib/scarpe/wv/control_interface_test.rb +13 -28
  98. data/lib/scarpe/wv/document_root.rb +3 -45
  99. data/lib/scarpe/wv/edit_box.rb +5 -7
  100. data/lib/scarpe/wv/edit_line.rb +2 -2
  101. data/lib/scarpe/wv/flow.rb +10 -20
  102. data/lib/scarpe/wv/font.rb +36 -0
  103. data/lib/scarpe/wv/html.rb +3 -2
  104. data/lib/scarpe/wv/image.rb +7 -2
  105. data/lib/scarpe/wv/line.rb +4 -7
  106. data/lib/scarpe/wv/link.rb +1 -0
  107. data/lib/scarpe/wv/list_box.rb +3 -3
  108. data/lib/scarpe/wv/para.rb +16 -14
  109. data/lib/scarpe/wv/radio.rb +34 -0
  110. data/lib/scarpe/wv/shape.rb +44 -8
  111. data/lib/scarpe/wv/slot.rb +81 -0
  112. data/lib/scarpe/wv/spacing.rb +1 -1
  113. data/lib/scarpe/wv/span.rb +10 -8
  114. data/lib/scarpe/wv/stack.rb +10 -30
  115. data/lib/scarpe/wv/star.rb +11 -12
  116. data/lib/scarpe/wv/subscription_item.rb +50 -0
  117. data/lib/scarpe/wv/video.rb +34 -0
  118. data/lib/scarpe/wv/web_wrangler.rb +238 -58
  119. data/lib/scarpe/wv/webview_local_display.rb +27 -5
  120. data/lib/scarpe/wv/webview_relay_display.rb +18 -119
  121. data/lib/scarpe/wv/webview_relay_util.rb +143 -0
  122. data/lib/scarpe/wv/widget.rb +80 -11
  123. data/lib/scarpe/wv/wv_display_worker.rb +17 -4
  124. data/lib/scarpe/wv.rb +33 -4
  125. data/lib/scarpe/wv_local.rb +1 -1
  126. data/lib/scarpe/wv_relay.rb +1 -1
  127. data/lib/scarpe.rb +3 -32
  128. data/scarpe-components/.gitignore +1 -0
  129. data/scarpe-components/Gemfile +22 -0
  130. data/scarpe-components/README.md +35 -0
  131. data/scarpe-components/Rakefile +12 -0
  132. data/scarpe-components/lib/scarpe/components/base64.rb +29 -0
  133. data/scarpe-components/lib/scarpe/components/file_helpers.rb +65 -0
  134. data/scarpe-components/lib/scarpe/components/modular_logger.rb +113 -0
  135. data/scarpe-components/lib/scarpe/components/print_logger.rb +43 -0
  136. data/{lib/scarpe → scarpe-components/lib/scarpe/components}/promises.rb +102 -35
  137. data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +170 -0
  138. data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +217 -0
  139. data/scarpe-components/lib/scarpe/components/version.rb +7 -0
  140. data/scarpe-components/scarpe-components.gemspec +38 -0
  141. data/scarpe-components/test/test_components.rb +9 -0
  142. data/scarpe-components/test/test_helper.rb +23 -0
  143. data/scarpe-components/test/test_promises.rb +260 -0
  144. data/scarpe-components/test/test_segmented_app_files.rb +182 -0
  145. data/{lib/scarpe → spikes}/glibui/widget.rb +2 -2
  146. data/{lib/scarpe → spikes}/glibui.rb +1 -1
  147. data/templates/basic_class_template.erb +1 -1
  148. data/templates/class_template_with_event_bind.erb +1 -1
  149. data/templates/class_template_with_shapes.erb +1 -1
  150. data/templates/webview_template.erb +0 -3
  151. metadata +151 -118
  152. data/examples/fill.rb +0 -25
  153. data/examples/legacy/not_checked/shoes-contrib/basic/class-book.yaml +0 -387
  154. data/examples/legacy/not_checked/shoes-contrib/good/good-clock.rb +0 -51
  155. data/examples/legacy/not_checked/shoes-contrib/good/good-follow.rb +0 -26
  156. data/examples/legacy/not_checked/shoes-contrib/good/good-reminder.rb +0 -174
  157. data/examples/legacy/not_checked/shoes-contrib/good/good-vjot.rb +0 -56
  158. data/examples/legacy/not_checked/shoes-contrib/simple/simple-timer.rb +0 -13
  159. data/examples/legacy/not_checked/shoes-dep-samples/good-clock.rb +0 -51
  160. data/examples/legacy/not_checked/shoes-dep-samples/good-follow.rb +0 -26
  161. data/examples/legacy/not_checked/shoes-dep-samples/good-reminder.rb +0 -174
  162. data/examples/legacy/not_checked/shoes-dep-samples/good-vjot.rb +0 -56
  163. data/examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb +0 -75
  164. data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-shapes.rb +0 -17
  165. data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-text.rb +0 -13
  166. data/examples/legacy/not_checked/shoes-dep-samples/simple-arc.rb +0 -23
  167. data/examples/legacy/not_checked/shoes-dep-samples/simple-bounce.rb +0 -24
  168. data/examples/legacy/not_checked/shoes-dep-samples/simple-calc.rb +0 -70
  169. data/examples/legacy/not_checked/shoes-dep-samples/simple-chipmunk.rb +0 -26
  170. data/examples/legacy/not_checked/shoes-dep-samples/simple-control-sizes.rb +0 -24
  171. data/examples/legacy/not_checked/shoes-dep-samples/simple-curve.rb +0 -26
  172. data/examples/legacy/not_checked/shoes-dep-samples/simple-dialogs.rb +0 -29
  173. data/examples/legacy/not_checked/shoes-dep-samples/simple-draw.rb +0 -13
  174. data/examples/legacy/not_checked/shoes-dep-samples/simple-editor.rb +0 -28
  175. data/examples/legacy/not_checked/shoes-dep-samples/simple-form.rb +0 -28
  176. data/examples/legacy/not_checked/shoes-dep-samples/simple-form.shy +0 -0
  177. data/examples/legacy/not_checked/shoes-dep-samples/simple-mask.rb +0 -21
  178. data/examples/legacy/not_checked/shoes-dep-samples/simple-menu.rb +0 -31
  179. data/examples/legacy/not_checked/shoes-dep-samples/simple-menu1.rb +0 -35
  180. data/examples/legacy/not_checked/shoes-dep-samples/simple-rubygems.rb +0 -29
  181. data/examples/legacy/not_checked/shoes-dep-samples/simple-slide.rb +0 -45
  182. data/examples/legacy/not_checked/shoes-dep-samples/simple-sphere.rb +0 -28
  183. data/examples/legacy/not_checked/shoes-dep-samples/simple-sqlite3.rb +0 -13
  184. data/examples/legacy/not_checked/shoes-dep-samples/simple-timer.rb +0 -13
  185. data/examples/legacy/not_checked/shoes-dep-samples/simple-video.rb +0 -13
  186. data/examples/legacy/not_checked/simple/anim-text.rb +0 -13
  187. data/examples/legacy/not_checked/simple/arc.rb +0 -23
  188. data/examples/legacy/not_checked/simple/bounce.rb +0 -24
  189. data/examples/legacy/not_checked/simple/chipmunk.rb +0 -26
  190. data/examples/legacy/not_checked/simple/curve.rb +0 -26
  191. data/examples/legacy/not_checked/simple/dialogs.rb +0 -29
  192. data/examples/legacy/not_checked/simple/downloader.rb +0 -40
  193. data/examples/legacy/not_checked/simple/draw.rb +0 -13
  194. data/examples/legacy/not_checked/simple/mask.rb +0 -21
  195. data/examples/legacy/not_checked/simple/slide.rb +0 -45
  196. data/examples/legacy/not_checked/simple/sphere.rb +0 -28
  197. data/lib/constants.rb +0 -5
  198. data/lib/scarpe/app.rb +0 -78
  199. data/lib/scarpe/document_root.rb +0 -20
  200. data/lib/scarpe/fill.rb +0 -23
  201. data/lib/scarpe/flow.rb +0 -19
  202. data/lib/scarpe/line.rb +0 -25
  203. data/lib/scarpe/logger.rb +0 -155
  204. data/lib/scarpe/shape.rb +0 -19
  205. data/lib/scarpe/spacing.rb +0 -9
  206. data/lib/scarpe/stack.rb +0 -70
  207. data/lib/scarpe/text_widget.rb +0 -42
  208. data/lib/scarpe/unit_test_helpers.rb +0 -163
  209. data/lib/scarpe/widgets.rb +0 -30
  210. data/lib/scarpe/wv/fill.rb +0 -30
  211. data/lib/scarpe/wv/shape_helper.rb +0 -44
  212. data/scarpe-0.2.0.gem +0 -0
  213. /data/{lib/scarpe → spikes}/glibui/README.md +0 -0
  214. /data/{lib/scarpe → spikes}/glibui/alert.rb +0 -0
  215. /data/{lib/scarpe → spikes}/glibui/app.rb +0 -0
  216. /data/{lib/scarpe → spikes}/glibui/background.rb +0 -0
  217. /data/{lib/scarpe → spikes}/glibui/border.rb +0 -0
  218. /data/{lib/scarpe → spikes}/glibui/button.rb +0 -0
  219. /data/{lib/scarpe → spikes}/glibui/dimensions.rb +0 -0
  220. /data/{lib/scarpe → spikes}/glibui/document_root.rb +0 -0
  221. /data/{lib/scarpe → spikes}/glibui/edit_box.rb +0 -0
  222. /data/{lib/scarpe → spikes}/glibui/edit_line.rb +0 -0
  223. /data/{lib/scarpe → spikes}/glibui/flow.rb +0 -0
  224. /data/{lib/scarpe → spikes}/glibui/html.rb +0 -0
  225. /data/{lib/scarpe → spikes}/glibui/image.rb +0 -0
  226. /data/{lib/scarpe → spikes}/glibui/link.rb +0 -0
  227. /data/{lib/scarpe → spikes}/glibui/local_display.rb +0 -0
  228. /data/{lib/scarpe → spikes}/glibui/para.rb +0 -0
  229. /data/{lib/scarpe → spikes}/glibui/spacing.rb +0 -0
  230. /data/{lib/scarpe → spikes}/glibui/stack.rb +0 -0
  231. /data/{lib/scarpe → spikes}/glibui/text_widget.rb +0 -0
  232. /data/{lib/scarpe → spikes}/libui/alert.rb +0 -0
  233. /data/{lib/scarpe → spikes}/libui/button.rb +0 -0
  234. /data/{lib/scarpe → spikes}/libui/colors.rb +0 -0
  235. /data/{lib/scarpe → spikes}/libui/core.rb +0 -0
  236. /data/{lib/scarpe → spikes}/libui/flow.rb +0 -0
  237. /data/{lib/scarpe → spikes}/libui/libui.rb +0 -0
  238. /data/{lib/scarpe → spikes}/libui/notepad.md +0 -0
  239. /data/{lib/scarpe → spikes}/libui/para.rb +0 -0
  240. /data/{lib/scarpe → spikes}/libui/stack.rb +0 -0
@@ -1,174 +0,0 @@
1
- require 'yaml'
2
-
3
- Shoes.app :title => "A Gentle Reminder",
4
- :width => 370, :height => 560, :resizable => false do
5
-
6
- background white
7
- background tan, :height => 40
8
-
9
- caption "A Gentle Reminder", :margin => 8, :stroke => white
10
-
11
- stack :margin => 10, :margin_top => 50 do
12
- para "You need to", :stroke => red, :fill => yellow
13
-
14
- stack :margin_left => 5, :margin_right => 10, :width => 1.0, :height => 200, :scroll => true do
15
- background white
16
- border white, :strokewidth => 3
17
- @gui_todo = para
18
- end
19
-
20
- flow :margin_top => 10 do
21
- para "Remember to"
22
- @add = edit_line(:margin_left => 10, :width => 180)
23
- button("Add", :margin_left => 5) { add_todo(@add.text); @add.text = '' }
24
- end
25
- end
26
-
27
- stack :margin_top => 10 do
28
- background darkgray
29
- para strong('Completed'), :stroke => white
30
- end
31
-
32
- @gui_completed = stack :width => 1.0, :height => 207, :margin_right => 20
33
-
34
-
35
- def data_path
36
- if RUBY_PLATFORM =~ /win32/
37
- if ENV['USERPROFILE']
38
- if File.exist?(File.join(File.expand_path(ENV['USERPROFILE']), "Application Data"))
39
- user_data_directory = File.join File.expand_path(ENV['USERPROFILE']), "Application Data", "GentleReminder"
40
- else
41
- user_data_directory = File.join File.expand_path(ENV['USERPROFILE']), "GentleReminder"
42
- end
43
- else
44
- user_data_directory = File.join File.expand_path(Dir.getwd), "data"
45
- end
46
- else
47
- user_data_directory = File.expand_path(File.join("~", ".gentlereminder"))
48
- end
49
-
50
- unless File.exist?(user_data_directory)
51
- Dir.mkdir(user_data_directory)
52
- end
53
-
54
- return File.join(user_data_directory, "data.yaml")
55
- end
56
-
57
-
58
- def refresh_todo
59
- @gui_todo.replace *(
60
- @todo.map { |item|
61
- [ item, ' ' ] + [ link('Done') { complete_todo item } ] + [ ' ' ] +
62
- [ link('Forget it') { forget_todo item } ] + [ "\n" ]
63
- }.flatten
64
- )
65
- end
66
-
67
-
68
- def refresh
69
- refresh_todo
70
-
71
- @gui_completed.clear
72
-
73
- @gui_completed.append do
74
- background white
75
-
76
- @completed.keys.sort.reverse.each { |day|
77
- stack do
78
- background lightgrey
79
- para strong(Time.at(day).strftime('%B %d, %Y')), :stroke => white
80
- end
81
-
82
- stack do
83
- inscription *(
84
- @completed[day].map { |item|
85
- [ item ] + [ ' ' ] + [ link('Not Done') { undo_todo day, item } ] +
86
- (@completed[day].index(item) == @completed[day].length - 1 ? [ '' ] : [ "\n" ])
87
- }.flatten
88
- )
89
- end
90
-
91
- }
92
- end
93
- end
94
-
95
-
96
- def complete_todo(item)
97
- day = Time.today.to_i
98
-
99
- if @completed.keys.include? day
100
- @completed[day] << item
101
- else
102
- @completed[day] = [ item ]
103
- end
104
-
105
- @todo.delete(item)
106
-
107
- save
108
-
109
- refresh
110
- end
111
-
112
-
113
- def undo_todo(day, item)
114
- @completed[day].delete item
115
-
116
- @completed.delete(day) if @completed[day].empty?
117
-
118
- @todo << item unless @todo.include? item
119
-
120
- save
121
-
122
- refresh
123
- end
124
-
125
-
126
- def add_todo(item)
127
- item = item.strip
128
-
129
- return if item == ''
130
-
131
- if @todo.include? item
132
- alert('You have already added that to the list!')
133
- return
134
- end
135
-
136
- @todo << item
137
-
138
- save
139
-
140
- refresh_todo
141
- end
142
-
143
-
144
- def forget_todo(item)
145
- @todo.delete item
146
-
147
- save
148
-
149
- refresh_todo
150
- end
151
-
152
-
153
- def load
154
- if File.exist?(data_path)
155
- @todo, @completed = YAML::load(File.open(data_path, 'r'))
156
- else
157
- @todo = []
158
- @completed = {}
159
- end
160
-
161
- refresh
162
- end
163
-
164
-
165
- def save
166
- File.open(data_path, 'w') { |f|
167
- f.write [ @todo, @completed ].to_yaml
168
- }
169
- end
170
-
171
-
172
- load
173
-
174
- end
@@ -1,56 +0,0 @@
1
- NOTES = [['Welcome to the vJot Clone', <<-'END']]
2
- This sample app is a notetaker, a clone of PJ Hyett's vjot.com.
3
-
4
- Creating
5
- ----------
6
- Click "Add a New Note" and the jot will be loaded into the editor for reading or editing.
7
-
8
- Editing
9
- ---------
10
- Click a jot's title to load it.
11
-
12
- Saving
13
- --------
14
- There is no save button, the jot is saved as you edit.
15
-
16
- END
17
-
18
- Shoes.app :title => "vJot",
19
- :width => 420, :height => 560, :resizable => false do
20
-
21
- @note = NOTES.first
22
- background "#C7EAFB"
23
- stack :width => 400, :margin => 20 do
24
- background "#eee", :curve => 12
25
- border "#00D0FF", :strokewidth => 3, :curve => 12
26
- stack :margin => 20 do
27
- caption "vJot"
28
- @title = edit_line @note[0], :width => 1.0 do
29
- @note[0] = @title.text
30
- load_list
31
- end
32
- stack :width => 1.0, :height => 200, :scroll => true do
33
- @list = para
34
- end
35
- @jot = edit_box @note[1], :width => 1.0, :height => 200, :margin_bottom => 20 do
36
- @note[1] = @jot.text
37
- end
38
- end
39
- end
40
-
41
- def load_list
42
- @list.replace *(NOTES.map { |note|
43
- [link(note.first) { @note = load_note(note); load_list }, "\n"]
44
- }.flatten +
45
- [link("+ Add a new Note") { NOTES << (@note = load_note); load_list }])
46
- end
47
-
48
- def load_note(note = ['New Note', ''])
49
- @note = note
50
- @title.text = note[0]
51
- @jot.text = note[1]
52
- note
53
- end
54
-
55
- load_list
56
- end
@@ -1,13 +0,0 @@
1
- Shoes.app :height => 150, :width => 250 do
2
- background rgb(240, 250, 208)
3
- stack :margin => 10 do
4
- button "Start" do
5
- @time = Time.now
6
- @label.replace "Stop watch started at #@time"
7
- end
8
- button "Stop" do
9
- @label.replace "Stopped, ", strong("#{Time.now - @time}"), " seconds elapsed."
10
- end
11
- @label = para "Press ", strong("start"), " to begin timing."
12
- end
13
- end
@@ -1,51 +0,0 @@
1
- #
2
- # Shoes Clock by Thomas Bell
3
- # posted to the Shoes mailing list on 04 Dec 2007
4
- #
5
- Shoes.app :height => 260, :width => 250 do
6
- @radius, @centerx, @centery = 90, 126, 140
7
- animate(8) do
8
- @time = Time.now
9
- clear do
10
- draw_background
11
- stack do
12
- background black
13
- para @time.strftime("%a"),
14
- span(@time.strftime(" %b %d, %Y "), :stroke => "#ccc"),
15
- strong(@time.strftime("%I:%M"), :stroke => white),
16
- @time.strftime(".%S"), :align => "center", :stroke => "#666",
17
- :margin => 4
18
- end
19
- clock_hand @time.sec + (@time.usec * 0.000001),2,30,red
20
- clock_hand @time.min + (@time.sec / 60.0),5
21
- clock_hand @time.hour + (@time.min / 60.0),8,6
22
- end
23
- end
24
- def draw_background
25
- background rgb(230, 240, 200)
26
-
27
- fill white
28
- stroke black
29
- strokewidth 4
30
- oval @centerx - 102, @centery - 102, 204, 204
31
-
32
- fill black
33
- nostroke
34
- oval @centerx - 5, @centery - 5, 10, 10
35
-
36
- stroke black
37
- strokewidth 1
38
- line(@centerx, @centery - 102, @centerx, @centery - 95)
39
- line(@centerx - 102, @centery, @centerx - 95, @centery)
40
- line(@centerx + 95, @centery, @centerx + 102, @centery)
41
- line(@centerx, @centery + 95, @centerx, @centery + 102)
42
- end
43
- def clock_hand(time, sw, unit=30, color=black)
44
- radius_local = unit == 30 ? @radius : @radius - 15
45
- _x = radius_local * Math.sin( time * Math::PI / unit )
46
- _y = radius_local * Math.cos( time * Math::PI / unit )
47
- stroke color
48
- strokewidth sw
49
- line(@centerx, @centery, @centerx + _x, @centery - _y)
50
- end
51
- end
@@ -1,26 +0,0 @@
1
- trails = [[0, 0]] * 60
2
- Shoes.app :width => 200, :height => 200, :resizable => false do
3
- nostroke
4
- fill rgb(0x3, 0x1, 0x3, 0.6)
5
-
6
- # animation at 100 frames per second
7
- animate(60) do
8
- trails.shift
9
- trails << self.mouse[1, 2]
10
-
11
- clear do
12
- # change the background based on where the pointer is
13
- background rgb(
14
- 20 + (70 * (trails.last[0].to_f / self.width)).to_i,
15
- 20 + (70 * (trails.last[1].to_f / self.height)).to_i,
16
- 51)
17
-
18
- # draw circles progressively bigger
19
- trails.each_with_index do |(x, y), i|
20
- i += 1
21
- oval :left => x, :top => y, :radius => (i*0.5), :center => true
22
- end
23
- end
24
- end
25
-
26
- end
@@ -1,174 +0,0 @@
1
- require 'yaml'
2
-
3
- Shoes.app :title => "A Gentle Reminder",
4
- :width => 370, :height => 560, :resizable => false do
5
-
6
- background white
7
- background tan, :height => 40
8
-
9
- caption "A Gentle Reminder", :margin => 8, :stroke => white
10
-
11
- stack :margin => 10, :margin_top => 50 do
12
- para "You need to", :stroke => red, :fill => yellow
13
-
14
- stack :margin_left => 5, :margin_right => 10, :width => 1.0, :height => 200, :scroll => true do
15
- background white
16
- border white, :strokewidth => 3
17
- @gui_todo = para
18
- end
19
-
20
- flow :margin_top => 10 do
21
- para "Remember to"
22
- @add = edit_line(:margin_left => 10, :width => 180)
23
- button("Add", :margin_left => 5) { add_todo(@add.text); @add.text = '' }
24
- end
25
- end
26
-
27
- stack :margin_top => 10 do
28
- background darkgray
29
- para strong('Completed'), :stroke => white
30
- end
31
-
32
- @gui_completed = stack :width => 1.0, :height => 207, :margin_right => 20
33
-
34
-
35
- def data_path
36
- if RUBY_PLATFORM =~ /win32/
37
- if ENV['USERPROFILE']
38
- if File.exist?(File.join(File.expand_path(ENV['USERPROFILE']), "Application Data"))
39
- user_data_directory = File.join File.expand_path(ENV['USERPROFILE']), "Application Data", "GentleReminder"
40
- else
41
- user_data_directory = File.join File.expand_path(ENV['USERPROFILE']), "GentleReminder"
42
- end
43
- else
44
- user_data_directory = File.join File.expand_path(Dir.getwd), "data"
45
- end
46
- else
47
- user_data_directory = File.expand_path(File.join("~", ".gentlereminder"))
48
- end
49
-
50
- unless File.exist?(user_data_directory)
51
- Dir.mkdir(user_data_directory)
52
- end
53
-
54
- return File.join(user_data_directory, "data.yaml")
55
- end
56
-
57
-
58
- def refresh_todo
59
- @gui_todo.replace *(
60
- @todo.map { |item|
61
- [ item, ' ' ] + [ link('Done') { complete_todo item } ] + [ ' ' ] +
62
- [ link('Forget it') { forget_todo item } ] + [ "\n" ]
63
- }.flatten
64
- )
65
- end
66
-
67
-
68
- def refresh
69
- refresh_todo
70
-
71
- @gui_completed.clear
72
-
73
- @gui_completed.append do
74
- background white
75
-
76
- @completed.keys.sort.reverse.each { |day|
77
- stack do
78
- background lightgrey
79
- para strong(Time.at(day).strftime('%B %d, %Y')), :stroke => white
80
- end
81
-
82
- stack do
83
- inscription *(
84
- @completed[day].map { |item|
85
- [ item ] + [ ' ' ] + [ link('Not Done') { undo_todo day, item } ] +
86
- (@completed[day].index(item) == @completed[day].length - 1 ? [ '' ] : [ "\n" ])
87
- }.flatten
88
- )
89
- end
90
-
91
- }
92
- end
93
- end
94
-
95
-
96
- def complete_todo(item)
97
- day = Time.today.to_i
98
-
99
- if @completed.keys.include? day
100
- @completed[day] << item
101
- else
102
- @completed[day] = [ item ]
103
- end
104
-
105
- @todo.delete(item)
106
-
107
- save
108
-
109
- refresh
110
- end
111
-
112
-
113
- def undo_todo(day, item)
114
- @completed[day].delete item
115
-
116
- @completed.delete(day) if @completed[day].empty?
117
-
118
- @todo << item unless @todo.include? item
119
-
120
- save
121
-
122
- refresh
123
- end
124
-
125
-
126
- def add_todo(item)
127
- item = item.strip
128
-
129
- return if item == ''
130
-
131
- if @todo.include? item
132
- alert('You have already added that to the list!')
133
- return
134
- end
135
-
136
- @todo << item
137
-
138
- save
139
-
140
- refresh_todo
141
- end
142
-
143
-
144
- def forget_todo(item)
145
- @todo.delete item
146
-
147
- save
148
-
149
- refresh_todo
150
- end
151
-
152
-
153
- def load
154
- if File.exist?(data_path)
155
- @todo, @completed = YAML::load(File.open(data_path, 'r'))
156
- else
157
- @todo = []
158
- @completed = {}
159
- end
160
-
161
- refresh
162
- end
163
-
164
-
165
- def save
166
- File.open(data_path, 'w') { |f|
167
- f.write [ @todo, @completed ].to_yaml
168
- }
169
- end
170
-
171
-
172
- load
173
-
174
- end
@@ -1,56 +0,0 @@
1
- NOTES = [['Welcome to the vJot Clone', <<-'END']]
2
- This sample app is a notetaker, a clone of PJ Hyett's vjot.com.
3
-
4
- Creating
5
- ----------
6
- Click "Add a New Note" and the jot will be loaded into the editor for reading or editing.
7
-
8
- Editing
9
- ---------
10
- Click a jot's title to load it.
11
-
12
- Saving
13
- --------
14
- There is no save button, the jot is saved as you edit.
15
-
16
- END
17
-
18
- Shoes.app :title => "vJot",
19
- :width => 420, :height => 560, :resizable => false do
20
-
21
- @note = NOTES.first
22
- background "#C7EAFB"
23
- stack :width => 400, :margin => 20 do
24
- background "#eee", :curve => 12
25
- border "#00D0FF", :strokewidth => 3, :curve => 12
26
- stack :margin => 20 do
27
- caption "vJot"
28
- @title = edit_line @note[0], :width => 1.0 do
29
- @note[0] = @title.text
30
- load_list
31
- end
32
- stack :width => 1.0, :height => 200, :scroll => true do
33
- @list = para
34
- end
35
- @jot = edit_box @note[1], :width => 1.0, :height => 200, :margin_bottom => 20 do
36
- @note[1] = @jot.text
37
- end
38
- end
39
- end
40
-
41
- def load_list
42
- @list.replace *(NOTES.map { |note|
43
- [link(note.first) { @note = load_note(note); load_list }, "\n"]
44
- }.flatten +
45
- [link("+ Add a new Note") { NOTES << (@note = load_note); load_list }])
46
- end
47
-
48
- def load_note(note = ['New Note', ''])
49
- @note = note
50
- @title.text = note[0]
51
- @jot.text = note[1]
52
- note
53
- end
54
-
55
- load_list
56
- end
@@ -1,75 +0,0 @@
1
- module Accordion
2
- def open_page stack
3
- active = app.slot.contents.map { |x| x.contents[1] }.
4
- detect { |x| x.height > 0 }
5
- return if active == stack
6
- a = animate 60 do
7
- stack.height += 20
8
- active.height = 240 - stack.height if active
9
- a.stop if stack.height == 240
10
- end
11
- end
12
- def page title, text
13
- @pages ||= []
14
- @pages <<
15
- stack do
16
- page_text = nil
17
- stack :width => "100%" do
18
- background "#fff".."#eed"
19
- hi = background "#ddd".."#ba9", :hidden => true
20
- para link(title) {}, :size => 26
21
- hover { hi.show }
22
- leave { hi.hide }
23
- click { open_page page_text }
24
- end
25
- page_text =
26
- stack :width => "100%", :height => (@pages.empty? ? 240 : 0) do
27
- stack :margin => 10 do
28
- text.split(/\n{2,}/).each do |pg|
29
- para pg
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
36
-
37
- Shoes.app do
38
- extend Accordion
39
- style(Link, :stroke => black, :underline => nil, :weight => "strong")
40
- style(LinkHover, :stroke => black, :fill => nil, :underline => nil)
41
-
42
- page "0.0", <<-'END'
43
- There is a thought
44
- I have just had
45
- Which I don’t care to pass to
46
- Anyone at all at this time.
47
-
48
- I have even forgotten it now,
49
- But kept only the pleasures
50
- Of my property
51
- And of my controlled mental slippage.
52
- END
53
- page "0.1", <<-'END'
54
- My eyes have blinked again
55
- And I have just realized
56
- This upright world
57
- I have been in.
58
-
59
- My eyelids wipe
60
- My eyes hundreds of times
61
- Reseting and renovating
62
- The scenery.
63
- END
64
- page "0.2", <<-'END'
65
- Sister, without you,
66
- The universe would
67
- Have such a hole through it,
68
- Where infinity has been shot.
69
-
70
- This cannot be, though.
71
- There will always be room
72
- For you—all of us are
73
- Holding the way open.
74
- END
75
- end
@@ -1,17 +0,0 @@
1
- Shoes.app do
2
- background rgb(0, 0, 0)
3
- fill rgb(255, 255, 255)
4
- rects = [
5
- rect(0, 0, 50, 50),
6
- rect(0, 0, 100, 100),
7
- rect(0, 0, 75, 75)
8
- ]
9
- animate(24) do |i|
10
- rects.each do |r|
11
- r.move((0..400).rand, (0..400).rand)
12
- end
13
- end
14
- button "OK", :top => 0.5, :left => 0.5 do
15
- quit unless confirm "You ARE sure you're OK??"
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- Shoes.app do
2
- stack :top => 0.5, :left => 0.5 do
3
- para "Counting up:"
4
- l = para "0"
5
- animate(24) do |i|
6
- f = ['Arial 14px', 'Serif 34px', 'Monospace 18px', 'Arial 48px'][rand(3)]
7
- l.replace "#{i}", :font => f
8
- end
9
- motion do |x, y|
10
- Shoes.p [x, y]
11
- end
12
- end
13
- end
@@ -1,23 +0,0 @@
1
- #
2
- # a translation from a processing example
3
- # http://vormplus.be/weging/an-introduction-to-processing/
4
- #
5
- Shoes.app :width => 420, :height => 420, :resizable => false do
6
- rotation = -(Shoes::HALF_PI / 3)
7
- step = 20
8
-
9
- background gray(240)
10
- stroke gray(127)
11
- cap :curve
12
- nofill
13
-
14
- 10.times do |i|
15
- strokewidth i
16
- size = 200 + (step * i)
17
- shape do
18
- arc self.width / 2, self.height / 2,
19
- size, size,
20
- rotation * i, rotation * i + Shoes::TWO_PI - Shoes::HALF_PI
21
- end
22
- end
23
- end
@@ -1,24 +0,0 @@
1
- xspeed, yspeed = 8.4, 6.6
2
- xdir, ydir = 1, 1
3
-
4
- Shoes.app do
5
- background "#DFA"
6
- border black, :strokewidth => 6
7
-
8
- nostroke
9
- @icon = image "#{DIR}/static/shoes-icon.png", :left => 100, :top => 100 do
10
- alert "You're soooo quick."
11
- end
12
-
13
- x, y = self.width / 2, self.height / 2
14
- size = @icon.size
15
- animate(30) do
16
- x += xspeed * xdir
17
- y += yspeed * ydir
18
-
19
- xdir *= -1 if x > self.width - size[0] or x < 0
20
- ydir *= -1 if y > self.height - size[1] or y < 0
21
-
22
- @icon.move x.to_i, y.to_i
23
- end
24
- end