scarpe 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (347) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.yardopts +12 -0
  4. data/CHANGELOG.md +16 -2
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +116 -0
  7. data/README.md +53 -30
  8. data/Rakefile +13 -1
  9. data/docs/yard/catscradle.md +44 -0
  10. data/docs/yard/template/default/fulldoc/html/setup.rb +13 -0
  11. data/docs/yard/template/default/layout/html/setup.rb +9 -0
  12. data/examples/animate.rb +20 -0
  13. data/examples/arrow.rb +10 -0
  14. data/examples/background_with_image.rb +16 -0
  15. data/examples/bloopsaphone/working/bronx_army_knife.rb +66 -0
  16. data/examples/bloopsaphone/working/morning_serenity.rb +21 -0
  17. data/examples/bloopsaphone/working/simpsons_theme_song_by_why.rb +6 -4
  18. data/examples/btn_tooltip.rb +7 -0
  19. data/examples/button_go_away.rb +1 -1
  20. data/examples/button_style_changed.rb +7 -0
  21. data/examples/button_styles_default.rb +6 -0
  22. data/examples/check.rb +18 -0
  23. data/examples/clear_and_append.rb +24 -0
  24. data/examples/download_and_show_image.rb +28 -0
  25. data/examples/edit_box.rb +3 -5
  26. data/examples/fonts.rb +2 -2
  27. data/examples/gen.rb +8 -8
  28. data/examples/get_headers.rb +10 -0
  29. data/examples/highlander.rb +4 -2
  30. data/examples/legacy/README.md +6 -0
  31. data/examples/legacy/not_checked/shoes-contrib/basic/shoes-notes.rb +1 -1
  32. data/examples/legacy/not_checked/simple/anim-shapes.rb +1 -1
  33. data/examples/legacy/not_checked/speedometer_app.rb +55 -0
  34. data/examples/legacy/working/simple/image-icon.rb +3 -0
  35. data/examples/legacy/{not_checked → working}/simple/image.rb +1 -1
  36. data/examples/link.rb +2 -2
  37. data/examples/list_box_choose.rb +17 -0
  38. data/examples/local_assets/local_file_server.rb +82 -0
  39. data/examples/local_assets/sample.gif +0 -0
  40. data/examples/local_assets/sample.mp4 +0 -0
  41. data/examples/local_fonts.rb +4 -0
  42. data/examples/local_images.rb +3 -0
  43. data/examples/motion_events.rb +20 -0
  44. data/examples/para/para_text.rb +14 -0
  45. data/examples/parse_xl_funnies.rb +58 -0
  46. data/examples/progress.rb +31 -0
  47. data/examples/radio/radio.rb +16 -0
  48. data/examples/radio/radio_groups.rb +18 -0
  49. data/examples/radio/radio_same_slot.rb +6 -0
  50. data/examples/rect.rb +4 -0
  51. data/examples/rotate_shapes.rb +17 -0
  52. data/examples/ruby_racer.rb +13 -15
  53. data/examples/selfitude.rb +18 -0
  54. data/examples/shapes/shapes_fill.rb +4 -3
  55. data/examples/shoes_school.rb +2 -4
  56. data/examples/show_hide.rb +6 -0
  57. data/examples/simpler-menu.rb +21 -0
  58. data/examples/skip_ci/change_my_audio_source.rb +21 -0
  59. data/examples/skip_ci/guitar_fretboard.rb +137 -0
  60. data/examples/video.rb +10 -0
  61. data/exe/scarpe +43 -66
  62. data/fonts/Pacifico.ttf +0 -0
  63. data/lacci/Gemfile +24 -0
  64. data/lacci/Gemfile.lock +79 -0
  65. data/lacci/Rakefile +12 -0
  66. data/lacci/lacci.gemspec +37 -0
  67. data/lacci/lib/lacci/scarpe_cli.rb +71 -0
  68. data/lacci/lib/lacci/scarpe_core.rb +22 -0
  69. data/lacci/lib/lacci/version.rb +13 -0
  70. data/lacci/lib/scarpe/niente/app.rb +23 -0
  71. data/lacci/lib/scarpe/niente/display_service.rb +62 -0
  72. data/lacci/lib/scarpe/niente/drawable.rb +57 -0
  73. data/lacci/lib/scarpe/niente/logger.rb +29 -0
  74. data/lacci/lib/scarpe/niente/shoes_spec.rb +87 -0
  75. data/lacci/lib/scarpe/niente.rb +20 -0
  76. data/lacci/lib/shoes/app.rb +309 -0
  77. data/{lib/scarpe → lacci/lib/shoes}/background.rb +2 -2
  78. data/{lib/scarpe → lacci/lib/shoes}/border.rb +2 -2
  79. data/lacci/lib/shoes/builtins.rb +63 -0
  80. data/lacci/lib/shoes/changelog.rb +52 -0
  81. data/{lib/scarpe → lacci/lib/shoes}/colors.rb +3 -1
  82. data/lacci/lib/shoes/constants.rb +47 -0
  83. data/{lib/scarpe → lacci/lib/shoes}/display_service.rb +71 -53
  84. data/lacci/lib/shoes/download.rb +123 -0
  85. data/lacci/lib/shoes/drawable.rb +380 -0
  86. data/lacci/lib/shoes/drawables/arc.rb +49 -0
  87. data/lacci/lib/shoes/drawables/arrow.rb +41 -0
  88. data/lacci/lib/shoes/drawables/button.rb +73 -0
  89. data/lacci/lib/shoes/drawables/check.rb +29 -0
  90. data/lacci/lib/shoes/drawables/document_root.rb +20 -0
  91. data/lacci/lib/shoes/drawables/edit_box.rb +29 -0
  92. data/{lib/scarpe → lacci/lib/shoes/drawables}/edit_line.rb +6 -6
  93. data/lacci/lib/shoes/drawables/flow.rb +22 -0
  94. data/{lib/scarpe → lacci/lib/shoes/drawables}/image.rb +7 -11
  95. data/lacci/lib/shoes/drawables/line.rb +20 -0
  96. data/lacci/lib/shoes/drawables/link.rb +34 -0
  97. data/lacci/lib/shoes/drawables/list_box.rb +56 -0
  98. data/lacci/lib/shoes/drawables/para.rb +118 -0
  99. data/lacci/lib/shoes/drawables/progress.rb +14 -0
  100. data/lacci/lib/shoes/drawables/radio.rb +33 -0
  101. data/lacci/lib/shoes/drawables/rect.rb +17 -0
  102. data/lacci/lib/shoes/drawables/shape.rb +36 -0
  103. data/lacci/lib/shoes/drawables/slot.rb +87 -0
  104. data/{lib/scarpe → lacci/lib/shoes/drawables}/span.rb +8 -7
  105. data/lacci/lib/shoes/drawables/stack.rb +26 -0
  106. data/lacci/lib/shoes/drawables/star.rb +50 -0
  107. data/lacci/lib/shoes/drawables/subscription_item.rb +93 -0
  108. data/lacci/lib/shoes/drawables/text_drawable.rb +63 -0
  109. data/lacci/lib/shoes/drawables/video.rb +16 -0
  110. data/lacci/lib/shoes/drawables/widget.rb +69 -0
  111. data/lacci/lib/shoes/drawables.rb +31 -0
  112. data/lacci/lib/shoes/errors.rb +28 -0
  113. data/lacci/lib/shoes/log.rb +71 -0
  114. data/lacci/lib/shoes/ruby_extensions.rb +15 -0
  115. data/lacci/lib/shoes/spacing.rb +9 -0
  116. data/lacci/lib/shoes-spec.rb +93 -0
  117. data/lacci/lib/shoes.rb +147 -0
  118. data/lacci/test/test_colors.rb +39 -0
  119. data/lacci/test/test_helper.rb +63 -0
  120. data/lacci/test/test_lacci.rb +18 -0
  121. data/lacci/test/test_shoes_errors.rb +49 -0
  122. data/lib/scarpe/cats_cradle.rb +271 -0
  123. data/lib/scarpe/errors.rb +77 -0
  124. data/lib/scarpe/evented_assertions.rb +121 -0
  125. data/lib/scarpe/shoes_spec.rb +181 -0
  126. data/lib/scarpe/version.rb +2 -2
  127. data/lib/scarpe/wv/app.rb +45 -23
  128. data/lib/scarpe/wv/arc.rb +4 -48
  129. data/lib/scarpe/wv/arrow.rb +9 -0
  130. data/lib/scarpe/wv/button.rb +7 -33
  131. data/lib/scarpe/wv/check.rb +27 -0
  132. data/lib/scarpe/wv/control_interface.rb +32 -40
  133. data/lib/scarpe/wv/document_root.rb +66 -31
  134. data/lib/scarpe/wv/drawable.rb +273 -0
  135. data/lib/scarpe/wv/edit_box.rb +4 -19
  136. data/lib/scarpe/wv/edit_line.rb +4 -18
  137. data/lib/scarpe/wv/flow.rb +2 -28
  138. data/lib/scarpe/wv/image.rb +10 -25
  139. data/lib/scarpe/wv/line.rb +3 -28
  140. data/lib/scarpe/wv/link.rb +3 -15
  141. data/lib/scarpe/wv/list_box.rb +6 -29
  142. data/lib/scarpe/wv/para.rb +11 -28
  143. data/lib/scarpe/wv/progress.rb +19 -0
  144. data/lib/scarpe/wv/radio.rb +33 -0
  145. data/lib/scarpe/wv/rect.rb +13 -0
  146. data/lib/scarpe/wv/shape.rb +41 -10
  147. data/lib/scarpe/wv/slot.rb +64 -0
  148. data/lib/scarpe/wv/span.rb +3 -25
  149. data/lib/scarpe/wv/stack.rb +2 -38
  150. data/lib/scarpe/wv/star.rb +3 -54
  151. data/lib/scarpe/wv/subscription_item.rb +84 -0
  152. data/lib/scarpe/wv/text_drawable.rb +32 -0
  153. data/lib/scarpe/wv/video.rb +34 -0
  154. data/lib/scarpe/wv/web_wrangler.rb +449 -299
  155. data/lib/scarpe/wv/webview_local_display.rb +63 -26
  156. data/lib/scarpe/wv/webview_relay_display.rb +24 -125
  157. data/lib/scarpe/wv/webview_relay_util.rb +140 -0
  158. data/lib/scarpe/wv/wv_display_worker.rb +19 -6
  159. data/lib/scarpe/wv.rb +76 -14
  160. data/lib/scarpe/wv_local.rb +1 -1
  161. data/lib/scarpe/wv_relay.rb +1 -1
  162. data/lib/scarpe.rb +4 -32
  163. data/logger/debug_web_wrangler.json +1 -1
  164. data/logger/scarpe_wv_test.json +1 -1
  165. data/scarpe-components/.gitignore +1 -0
  166. data/scarpe-components/Gemfile +22 -0
  167. data/scarpe-components/Gemfile.lock +86 -0
  168. data/scarpe-components/README.md +35 -0
  169. data/scarpe-components/Rakefile +12 -0
  170. data/scarpe-components/lib/scarpe/components/base64.rb +25 -0
  171. data/scarpe-components/lib/scarpe/components/calzini/alert.rb +49 -0
  172. data/scarpe-components/lib/scarpe/components/calzini/art_widgets.rb +203 -0
  173. data/scarpe-components/lib/scarpe/components/calzini/button.rb +39 -0
  174. data/scarpe-components/lib/scarpe/components/calzini/misc.rb +146 -0
  175. data/scarpe-components/lib/scarpe/components/calzini/para.rb +35 -0
  176. data/scarpe-components/lib/scarpe/components/calzini/slots.rb +155 -0
  177. data/scarpe-components/lib/scarpe/components/calzini/text_widgets.rb +65 -0
  178. data/scarpe-components/lib/scarpe/components/calzini.rb +149 -0
  179. data/scarpe-components/lib/scarpe/components/errors.rb +20 -0
  180. data/scarpe-components/lib/scarpe/components/file_helpers.rb +66 -0
  181. data/scarpe-components/lib/scarpe/components/html.rb +131 -0
  182. data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +75 -0
  183. data/scarpe-components/lib/scarpe/components/minitest_import_runnable.rb +98 -0
  184. data/scarpe-components/lib/scarpe/components/minitest_result.rb +86 -0
  185. data/scarpe-components/lib/scarpe/components/modular_logger.rb +113 -0
  186. data/scarpe-components/lib/scarpe/components/print_logger.rb +47 -0
  187. data/{lib/scarpe → scarpe-components/lib/scarpe/components}/promises.rb +115 -48
  188. data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +189 -0
  189. data/scarpe-components/lib/scarpe/components/string_helpers.rb +10 -0
  190. data/scarpe-components/lib/scarpe/components/tiranti.rb +225 -0
  191. data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +257 -0
  192. data/scarpe-components/lib/scarpe/components/version.rb +7 -0
  193. data/scarpe-components/scarpe-components.gemspec +38 -0
  194. data/scarpe-components/test/calzini/test_calzini_alert.rb +30 -0
  195. data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +105 -0
  196. data/scarpe-components/test/calzini/test_calzini_button.rb +52 -0
  197. data/scarpe-components/test/calzini/test_calzini_misc.rb +115 -0
  198. data/scarpe-components/test/calzini/test_calzini_para.rb +37 -0
  199. data/scarpe-components/test/calzini/test_calzini_slots.rb +130 -0
  200. data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +41 -0
  201. data/scarpe-components/test/mtr_data/exception.json +1 -0
  202. data/scarpe-components/test/mtr_data/fail_with_message.json +1 -0
  203. data/scarpe-components/test/mtr_data/skipped_no_message.json +1 -0
  204. data/scarpe-components/test/mtr_data/skipped_w_msg.json +1 -0
  205. data/scarpe-components/test/mtr_data/succeed_2_asserts.json +1 -0
  206. data/scarpe-components/test/test_components.rb +9 -0
  207. data/scarpe-components/test/test_dimensions.rb +26 -0
  208. data/scarpe-components/test/test_helper.rb +43 -0
  209. data/scarpe-components/test/test_html.rb +65 -0
  210. data/scarpe-components/test/test_minitest_result.rb +61 -0
  211. data/scarpe-components/test/test_promises.rb +261 -0
  212. data/scarpe-components/test/test_segmented_app_files.rb +184 -0
  213. data/scarpegen.rb +14 -14
  214. data/sig/scarpe.rbs +1 -1
  215. data/{lib/scarpe → spikes}/glibui/widget.rb +2 -2
  216. data/{lib/scarpe → spikes}/glibui.rb +1 -1
  217. data/templates/basic_class_template.erb +13 -14
  218. data/templates/class_template_with_event_bind.erb +4 -4
  219. data/templates/class_template_with_shapes.erb +8 -17
  220. data/templates/example_template.erb +1 -1
  221. data/templates/module_template.erb +4 -4
  222. data/templates/webview_template.erb +3 -5
  223. metadata +236 -145
  224. data/examples/fill.rb +0 -25
  225. data/examples/legacy/not_checked/shoes-contrib/basic/class-book.yaml +0 -387
  226. data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
  227. data/examples/legacy/not_checked/shoes-contrib/good/good-clock.rb +0 -51
  228. data/examples/legacy/not_checked/shoes-contrib/good/good-follow.rb +0 -26
  229. data/examples/legacy/not_checked/shoes-contrib/good/good-reminder.rb +0 -174
  230. data/examples/legacy/not_checked/shoes-contrib/good/good-vjot.rb +0 -56
  231. data/examples/legacy/not_checked/shoes-contrib/simple/simple-timer.rb +0 -13
  232. data/examples/legacy/not_checked/shoes-dep-samples/good-clock.rb +0 -51
  233. data/examples/legacy/not_checked/shoes-dep-samples/good-follow.rb +0 -26
  234. data/examples/legacy/not_checked/shoes-dep-samples/good-reminder.rb +0 -174
  235. data/examples/legacy/not_checked/shoes-dep-samples/good-vjot.rb +0 -56
  236. data/examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb +0 -75
  237. data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-shapes.rb +0 -17
  238. data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-text.rb +0 -13
  239. data/examples/legacy/not_checked/shoes-dep-samples/simple-arc.rb +0 -23
  240. data/examples/legacy/not_checked/shoes-dep-samples/simple-bounce.rb +0 -24
  241. data/examples/legacy/not_checked/shoes-dep-samples/simple-calc.rb +0 -70
  242. data/examples/legacy/not_checked/shoes-dep-samples/simple-chipmunk.rb +0 -26
  243. data/examples/legacy/not_checked/shoes-dep-samples/simple-control-sizes.rb +0 -24
  244. data/examples/legacy/not_checked/shoes-dep-samples/simple-curve.rb +0 -26
  245. data/examples/legacy/not_checked/shoes-dep-samples/simple-dialogs.rb +0 -29
  246. data/examples/legacy/not_checked/shoes-dep-samples/simple-draw.rb +0 -13
  247. data/examples/legacy/not_checked/shoes-dep-samples/simple-editor.rb +0 -28
  248. data/examples/legacy/not_checked/shoes-dep-samples/simple-form.rb +0 -28
  249. data/examples/legacy/not_checked/shoes-dep-samples/simple-form.shy +0 -0
  250. data/examples/legacy/not_checked/shoes-dep-samples/simple-mask.rb +0 -21
  251. data/examples/legacy/not_checked/shoes-dep-samples/simple-menu.rb +0 -31
  252. data/examples/legacy/not_checked/shoes-dep-samples/simple-menu1.rb +0 -35
  253. data/examples/legacy/not_checked/shoes-dep-samples/simple-rubygems.rb +0 -29
  254. data/examples/legacy/not_checked/shoes-dep-samples/simple-slide.rb +0 -45
  255. data/examples/legacy/not_checked/shoes-dep-samples/simple-sphere.rb +0 -28
  256. data/examples/legacy/not_checked/shoes-dep-samples/simple-sqlite3.rb +0 -13
  257. data/examples/legacy/not_checked/shoes-dep-samples/simple-timer.rb +0 -13
  258. data/examples/legacy/not_checked/shoes-dep-samples/simple-video.rb +0 -13
  259. data/examples/legacy/not_checked/simple/anim-text.rb +0 -13
  260. data/examples/legacy/not_checked/simple/arc.rb +0 -23
  261. data/examples/legacy/not_checked/simple/bounce.rb +0 -24
  262. data/examples/legacy/not_checked/simple/chipmunk.rb +0 -26
  263. data/examples/legacy/not_checked/simple/curve.rb +0 -26
  264. data/examples/legacy/not_checked/simple/dialogs.rb +0 -29
  265. data/examples/legacy/not_checked/simple/downloader.rb +0 -40
  266. data/examples/legacy/not_checked/simple/draw.rb +0 -13
  267. data/examples/legacy/not_checked/simple/mask.rb +0 -21
  268. data/examples/legacy/not_checked/simple/slide.rb +0 -45
  269. data/examples/legacy/not_checked/simple/sphere.rb +0 -28
  270. data/lib/constants.rb +0 -5
  271. data/lib/scarpe/alert.rb +0 -19
  272. data/lib/scarpe/app.rb +0 -78
  273. data/lib/scarpe/arc.rb +0 -49
  274. data/lib/scarpe/button.rb +0 -35
  275. data/lib/scarpe/document_root.rb +0 -20
  276. data/lib/scarpe/edit_box.rb +0 -24
  277. data/lib/scarpe/fill.rb +0 -23
  278. data/lib/scarpe/flow.rb +0 -19
  279. data/lib/scarpe/line.rb +0 -25
  280. data/lib/scarpe/link.rb +0 -25
  281. data/lib/scarpe/list_box.rb +0 -25
  282. data/lib/scarpe/logger.rb +0 -155
  283. data/lib/scarpe/para.rb +0 -90
  284. data/lib/scarpe/shape.rb +0 -19
  285. data/lib/scarpe/spacing.rb +0 -9
  286. data/lib/scarpe/stack.rb +0 -70
  287. data/lib/scarpe/star.rb +0 -47
  288. data/lib/scarpe/text_widget.rb +0 -42
  289. data/lib/scarpe/unit_test_helpers.rb +0 -163
  290. data/lib/scarpe/widget.rb +0 -198
  291. data/lib/scarpe/widgets.rb +0 -30
  292. data/lib/scarpe/wv/alert.rb +0 -65
  293. data/lib/scarpe/wv/background.rb +0 -18
  294. data/lib/scarpe/wv/border.rb +0 -22
  295. data/lib/scarpe/wv/control_interface_test.rb +0 -253
  296. data/lib/scarpe/wv/dimensions.rb +0 -22
  297. data/lib/scarpe/wv/fill.rb +0 -30
  298. data/lib/scarpe/wv/html.rb +0 -107
  299. data/lib/scarpe/wv/shape_helper.rb +0 -44
  300. data/lib/scarpe/wv/spacing.rb +0 -41
  301. data/lib/scarpe/wv/text_widget.rb +0 -30
  302. data/lib/scarpe/wv/widget.rb +0 -181
  303. data/scarpe-0.2.0.gem +0 -0
  304. /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/definr.rb +0 -0
  305. /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/funnies.rb +0 -0
  306. /data/examples/legacy/not_checked/shoes-contrib/{elements → basic}/list_box-select-class.rb +0 -0
  307. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/basic-edit-box.rb +0 -0
  308. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/basic-fps.rb +0 -0
  309. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/border-cat.rb +0 -0
  310. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/check-mate.rb +0 -0
  311. /data/examples/legacy/{not_checked/shoes-contrib/manipulation → working/simple}/clear-slot.rb +0 -0
  312. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/clock.rb +0 -0
  313. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/gradient-shoes.rb +0 -0
  314. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/list_box-shape-report.rb +0 -0
  315. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/list_box.rb +0 -0
  316. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/phat-button.rb +0 -0
  317. /data/examples/legacy/{not_checked/shoes-contrib → working}/simple/simple-calc.rb +0 -0
  318. /data/examples/legacy/{not_checked/shoes-contrib/position → working/simple}/stack-width.rb +0 -0
  319. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/width-introspec.rb +0 -0
  320. /data/{lib/scarpe → spikes}/glibui/README.md +0 -0
  321. /data/{lib/scarpe → spikes}/glibui/alert.rb +0 -0
  322. /data/{lib/scarpe → spikes}/glibui/app.rb +0 -0
  323. /data/{lib/scarpe → spikes}/glibui/background.rb +0 -0
  324. /data/{lib/scarpe → spikes}/glibui/border.rb +0 -0
  325. /data/{lib/scarpe → spikes}/glibui/button.rb +0 -0
  326. /data/{lib/scarpe → spikes}/glibui/dimensions.rb +0 -0
  327. /data/{lib/scarpe → spikes}/glibui/document_root.rb +0 -0
  328. /data/{lib/scarpe → spikes}/glibui/edit_box.rb +0 -0
  329. /data/{lib/scarpe → spikes}/glibui/edit_line.rb +0 -0
  330. /data/{lib/scarpe → spikes}/glibui/flow.rb +0 -0
  331. /data/{lib/scarpe → spikes}/glibui/html.rb +0 -0
  332. /data/{lib/scarpe → spikes}/glibui/image.rb +0 -0
  333. /data/{lib/scarpe → spikes}/glibui/link.rb +0 -0
  334. /data/{lib/scarpe → spikes}/glibui/local_display.rb +0 -0
  335. /data/{lib/scarpe → spikes}/glibui/para.rb +0 -0
  336. /data/{lib/scarpe → spikes}/glibui/spacing.rb +0 -0
  337. /data/{lib/scarpe → spikes}/glibui/stack.rb +0 -0
  338. /data/{lib/scarpe → spikes}/glibui/text_widget.rb +0 -0
  339. /data/{lib/scarpe → spikes}/libui/alert.rb +0 -0
  340. /data/{lib/scarpe → spikes}/libui/button.rb +0 -0
  341. /data/{lib/scarpe → spikes}/libui/colors.rb +0 -0
  342. /data/{lib/scarpe → spikes}/libui/core.rb +0 -0
  343. /data/{lib/scarpe → spikes}/libui/flow.rb +0 -0
  344. /data/{lib/scarpe → spikes}/libui/libui.rb +0 -0
  345. /data/{lib/scarpe → spikes}/libui/notepad.md +0 -0
  346. /data/{lib/scarpe → spikes}/libui/para.rb +0 -0
  347. /data/{lib/scarpe → spikes}/libui/stack.rb +0 -0
data/lib/scarpe/wv/app.rb CHANGED
@@ -1,38 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- # Scarpe::WebviewApp must only be used from the main thread, due to GTK+ limitations.
5
- class WebviewApp < WebviewWidget
6
- attr_reader :debug
3
+ module Scarpe::Webview
4
+ # Scarpe::Webview::App must only be used from the main thread, due to GTK+ limitations.
5
+ class App < Drawable # App inherits from Drawable to set up linkable IDs and event methods
7
6
  attr_reader :control_interface
8
7
 
9
8
  attr_writer :shoes_linkable_id
10
9
 
11
10
  def initialize(properties)
12
- # Is this a thing? Do we care about this?
13
- # opts = @control_interface.app_opts_get_override(opts)
14
-
15
11
  super
16
12
 
17
- # It's possible to provide a Ruby script by setting
18
- # SCARPE_TEST_CONTROL to its file path. This can
19
- # allow pre-setting test options or otherwise
20
- # performing additional actions not written into
21
- # the Shoes app itself.
22
- #
23
- # The control interface is what lets these files see
24
- # events, specify overrides and so on.
13
+ # Scarpe's ControlInterface sets up event handlers
14
+ # for the display service that aren't sent to
15
+ # Lacci (Shoes). In general it's used for setup
16
+ # and additional control or testing, outside the
17
+ # Shoes app. This is how CatsCradle and Shoes-Spec
18
+ # set up testing, for instance.
25
19
  @control_interface = ControlInterface.new
26
- if ENV["SCARPE_TEST_CONTROL"]
27
- @control_interface.instance_eval File.read(ENV["SCARPE_TEST_CONTROL"])
28
- end
29
20
 
30
21
  # TODO: rename @view
31
- @view = Scarpe::WebWrangler.new title: @title,
22
+ @view = Scarpe::Webview::WebWrangler.new title: @title,
32
23
  width: @width,
33
24
  height: @height,
34
- resizable: @resizable,
35
- debug: @debug
25
+ resizable: @resizable
26
+
27
+ @callbacks = {}
36
28
 
37
29
  # The control interface has to exist to get callbacks like "override Scarpe app opts".
38
30
  # But the Scarpe App needs those options to be created. So we can't pass these to
@@ -50,11 +42,11 @@ class Scarpe
50
42
  scarpe_app = self
51
43
 
52
44
  @view.init_code("scarpeInit") do
53
- @document_root.request_redraw!
45
+ request_redraw!
54
46
  end
55
47
 
56
48
  @view.bind("scarpeHandler") do |*args|
57
- @document_root.handle_callback(*args)
49
+ handle_callback(*args)
58
50
  end
59
51
 
60
52
  @view.bind("scarpeExit") do
@@ -65,6 +57,8 @@ class Scarpe
65
57
  def run
66
58
  @control_interface.dispatch_event(:init)
67
59
 
60
+ @view.empty_page = empty_page_element
61
+
68
62
  # This takes control of the main thread and never returns. And it *must* be run from
69
63
  # the main thread. And it stops any Ruby background threads.
70
64
  # That's totally cool and normal, right?
@@ -81,5 +75,33 @@ class Scarpe
81
75
  @view = nil
82
76
  end
83
77
  end
78
+
79
+ # All JS callbacks to Scarpe drawables are dispatched
80
+ # via this handler
81
+ def handle_callback(name, *args)
82
+ if @callbacks.key?(name)
83
+ @callbacks[name].call(*args)
84
+ else
85
+ raise Scarpe::UnknownEventTypeError, "No such Webview callback: #{name.inspect}!"
86
+ end
87
+ end
88
+
89
+ # Bind a Scarpe callback name; see handle_callback above.
90
+ # See Scarpe::Drawable for how the naming is set up
91
+ def bind(name, &block)
92
+ @callbacks[name] = block
93
+ end
94
+
95
+ # Request a full redraw if Webview is running. Otherwise
96
+ # this is a no-op.
97
+ #
98
+ # @return [void]
99
+ def request_redraw!
100
+ wrangler = DisplayService.instance.wrangler
101
+ if wrangler.is_running
102
+ wrangler.replace(@document_root.to_html)
103
+ end
104
+ nil
105
+ end
84
106
  end
85
107
  end
data/lib/scarpe/wv/arc.rb CHANGED
@@ -1,57 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "shape_helper"
4
-
5
- class Scarpe
6
- class WebviewArc < Scarpe::WebviewWidget
7
- include ShapeHelper
3
+ module Scarpe::Webview
4
+ class Arc < Drawable
8
5
  def initialize(properties)
9
6
  super(properties)
10
7
  end
11
8
 
12
- def element(&block)
13
- HTML.render do |h|
14
- h.div(id: html_id, style: style) do
15
- h.svg(width: @width, height: @height) do
16
- h.path(d: arc_path)
17
- end
18
- block.call(h) if block_given?
19
- end
20
- end
21
- end
22
-
23
- private
24
-
25
- def style
26
- {
27
- left: "#{@left}px",
28
- top: "#{@top}px",
29
- width: "#{@width}px",
30
- height: "#{@height}px",
31
- }
32
- end
33
-
34
- def arc_path
35
- center_x = @width / 2
36
- center_y = @height / 2
37
- radius_x = @width / 2
38
- radius_y = @height / 2
39
- start_angle_degrees = radians_to_degrees(@angle1) % 360
40
- end_angle_degrees = radians_to_degrees(@angle2) % 360
41
- large_arc_flag = (end_angle_degrees - start_angle_degrees) % 360 > 180 ? 1 : 0
42
-
43
- "M#{center_x} #{center_y} L#{@width} #{center_y} " \
44
- "A#{radius_x} #{radius_y} 0 #{large_arc_flag} 0 " \
45
- "#{center_x + radius_x * Math.cos(degrees_to_radians(end_angle_degrees))} " \
46
- "#{center_y + radius_y * Math.sin(degrees_to_radians(end_angle_degrees))} Z"
47
- end
48
-
49
- def degrees_to_radians(degrees)
50
- degrees * Math::PI / 180
51
- end
52
-
53
- def radians_to_degrees(radians)
54
- radians * (180.0 / Math::PI)
9
+ def element
10
+ render("arc")
55
11
  end
56
12
  end
57
13
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Scarpe::Webview
4
+ class Arrow < Drawable
5
+ def element
6
+ render("arrow")
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- class WebviewButton < WebviewWidget
3
+ module Scarpe::Webview
4
+ class Button < Drawable
5
5
  def initialize(properties)
6
6
  super
7
7
 
@@ -10,41 +10,15 @@ class Scarpe
10
10
  # This will be sent to the bind_self_event in Button
11
11
  send_self_event(event_name: "click")
12
12
  end
13
- end
14
13
 
15
- def element
16
- HTML.render do |h|
17
- h.button(id: html_id, onclick: handler_js_code("click"), style: style) do
18
- @text
19
- end
14
+ bind("hover") do
15
+ # This will be sent to the bind_self_event in Button
16
+ send_self_event(event_name: "hover")
20
17
  end
21
18
  end
22
19
 
23
- private
24
-
25
- def style
26
- styles = {}
27
- styles["background-color"] = @color
28
- styles["padding-top"] = @padding_top
29
- styles["padding-bottom"] = @padding_bottom
30
- styles[:color] = @text_color
31
- styles[:width] = Dimensions.length(@width) if @width
32
- styles[:height] = Dimensions.length(@height) if @height
33
- styles["font-size"] = @font_size
34
-
35
- styles[:top] = Dimensions.length(@top) if @top
36
- styles[:left] = Dimensions.length(@left) if @left
37
- styles[:position] = "absolute" if @top || @left
38
- styles["font-size"] = Dimensions.length(font_size) if @size
39
- styles["font-family"] = @font if @font
40
- styles["color"] = rgb_to_hex(@stroke) if @stroke
41
- styles
42
- end
43
-
44
- def font_size
45
- font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
46
-
47
- Dimensions.length(font_size)
20
+ def element
21
+ render("button")
48
22
  end
49
23
  end
50
24
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Scarpe::Webview
4
+ class Check < Drawable
5
+ attr_reader :text
6
+
7
+ def initialize(properties)
8
+ super
9
+
10
+ bind("click") do
11
+ send_self_event(event_name: "click", target: shoes_linkable_id)
12
+ end
13
+ end
14
+
15
+ def properties_changed(changes)
16
+ checked = changes.delete("checked")
17
+
18
+ html_element.toggle_input_button(checked)
19
+
20
+ super
21
+ end
22
+
23
+ def element
24
+ render("check")
25
+ end
26
+ end
27
+ end
@@ -1,28 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # The ControlInterface is used for testing. It's a way to register interest
4
- # in important events like redraw, init and shutdown, and to override
5
- # test-relevant values like the options to Shoes.app(). Note that no part
6
- # of the Scarpe framework should ever *depend* on ControlInterface. It's
7
- # for testing, not normal operation. If no ControlInterface were ever
8
- # created or called, Scarpe apps should run fine with no modifications.
4
+ # in important events like redraw, init and shutdown, and to configure a
5
+ # Shoes app for testing. Note that no part of the Scarpe framework should
6
+ # ever *depend* on ControlInterface. It's for testing, not normal operation.
7
+ # If no ControlInterface were ever created or called, Scarpe apps should run
8
+ # fine with no modifications.
9
9
  #
10
10
  # And if you depend on this from the framework, I'll add a check-mode that
11
11
  # never dispatches any events to any handlers. Do NOT test me on this.
12
12
 
13
- class Scarpe
13
+ module Scarpe::Webview
14
14
  class ControlInterface
15
- include Scarpe::Log
15
+ include Shoes::Log
16
16
 
17
17
  SUBSCRIBE_EVENTS = [:init, :shutdown, :next_redraw, :every_redraw, :next_heartbeat, :every_heartbeat]
18
18
  DISPATCH_EVENTS = [:init, :shutdown, :redraw, :heartbeat]
19
+ INVALID_SYSTEM_COMPONENTS_MESSAGE = "Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
20
+ CONTROL_INTERFACE_INIT_MESSAGE = "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
21
+ "to make sure they have access to app, doc_root, wrangler, etc!"
19
22
 
20
23
  attr_writer :doc_root
21
24
  attr_reader :do_shutdown
22
25
 
23
26
  # The control interface needs to see major system components to hook into their events
24
27
  def initialize
25
- log_init("WV::ControlInterface")
28
+ log_init("Webview::ControlInterface")
26
29
 
27
30
  @do_shutdown = false
28
31
  @event_handlers = {}
@@ -33,13 +36,17 @@ class Scarpe
33
36
  "<#ControlInterface>"
34
37
  end
35
38
 
36
- # This should get called once, from Scarpe::App
39
+ # This should get called once, from Shoes::App
37
40
  def set_system_components(app:, doc_root:, wrangler:)
38
- unless app && wrangler
39
- @log.error("False app passed to set_system_components!") unless app
40
- @log.error("False wrangler passed to set_system_components!") unless wrangler
41
- raise "Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
41
+ unless app
42
+ @log.error("False app passed to set_system_components!")
43
+ raise Scarpe::MissingAppError, INVALID_SYSTEM_COMPONENTS_MESSAGE
42
44
  end
45
+ unless wrangler
46
+ @log.error("False wrangler passed to set_system_components!")
47
+ raise Scarpe::MissingWranglerError, INVALID_SYSTEM_COMPONENTS_MESSAGE
48
+ end
49
+
43
50
  @app = app
44
51
  @doc_root = doc_root # May be nil at this point
45
52
  @wrangler = wrangler
@@ -50,28 +57,19 @@ class Scarpe
50
57
  end
51
58
 
52
59
  def app
53
- unless @app
54
- raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
55
- "to make sure they have access to app, doc_root, wrangler, etc!"
56
- end
60
+ raise Scarpe::MissingAppError, CONTROL_INTERFACE_INIT_MESSAGE unless @app
57
61
 
58
62
  @app
59
63
  end
60
64
 
61
65
  def doc_root
62
- unless @doc_root
63
- raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
64
- "to make sure they have access to app, doc_root, wrangler, etc!"
65
- end
66
+ raise Scarpe::MissingDocRootError, CONTROL_INTERFACE_INIT_MESSAGE unless @doc_root
66
67
 
67
68
  @doc_root
68
69
  end
69
70
 
70
71
  def wrangler
71
- unless @wrangler
72
- raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
73
- "to make sure they have access to app, doc_root, wrangler, etc!"
74
- end
72
+ raise Scarpe::MissingWranglerError, CONTROL_INTERFACE_INIT_MESSAGE unless @wrangler
75
73
 
76
74
  @wrangler
77
75
  end
@@ -79,23 +77,17 @@ class Scarpe
79
77
  # The control interface has overrides for certain settings. If the override has been specified,
80
78
  # those settings will be overridden.
81
79
 
82
- # Override the Shoes app opts like "debug:" and "die_after:" with new ones.
83
- def override_app_opts(new_opts)
84
- @new_app_opts = new_opts
85
- end
86
-
87
- # Called by Scarpe::App to get the override options
88
- def app_opts_get_override(opts)
89
- @new_app_opts || opts
90
- end
91
-
92
80
  # On recognised events, this sets a handler for that event
93
81
  def on_event(event, &block)
94
82
  unless SUBSCRIBE_EVENTS.include?(event)
95
- raise "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
83
+ raise Scarpe::IllegalSubscribeEventError, "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
96
84
  end
97
85
 
98
- @event_handlers[event] << block
86
+ @unsub_id ||= 0
87
+ @unsub_id += 1
88
+
89
+ @event_handlers[event] << { handler: block, unsub: @unsub_id }
90
+ @unsub_id
99
91
  end
100
92
 
101
93
  # Send out the specified event
@@ -103,7 +95,7 @@ class Scarpe
103
95
  @log.debug("CTL event #{event.inspect} #{args.inspect} #{keywords.inspect}")
104
96
 
105
97
  unless DISPATCH_EVENTS.include?(event)
106
- raise "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
98
+ raise Scarpe::IllegalDispatchEventError, "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
107
99
  end
108
100
 
109
101
  if @do_shutdown
@@ -145,8 +137,8 @@ class Scarpe
145
137
  private
146
138
 
147
139
  def dumb_dispatch_event(event, *args, **keywords)
148
- @event_handlers[event].each do |handler|
149
- instance_eval(*args, **keywords, &handler)
140
+ @event_handlers[event].each do |data|
141
+ instance_eval(*args, **keywords, &data[:handler])
150
142
  end
151
143
  end
152
144
  end
@@ -1,50 +1,85 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- class WebviewDocumentRoot < Scarpe::WebviewWidget
5
- include Scarpe::WebviewBackground
6
-
3
+ module Scarpe::Webview
4
+ # A DocumentRoot is a {Scarpe::Webview::Flow}, with all the same properties
5
+ # and basic behavior. It also reserves space for Builtins like fonts, alerts,
6
+ # etc. which don't have individual {Shoes::Drawable} objects.
7
+ class DocumentRoot < Flow
7
8
  def initialize(properties)
8
- @callbacks = {}
9
-
10
9
  super
11
- end
12
10
 
13
- def element(&blck)
14
- HTML.render do |h|
15
- h.div(style: style.merge(height: "100%"), &blck)
11
+ @fonts = []
12
+ @alerts = []
13
+
14
+ bind_shoes_event(event_name: "builtin") do |cmd_name, args|
15
+ case cmd_name
16
+ when "font"
17
+ @fonts << args[0]
18
+ # Can't just create font_updater and alert_updater on initialize - not everything is set up
19
+ @font_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new("root-fonts")
20
+ @font_updater.inner_html = font_contents
21
+ when "alert"
22
+ bind_ok_event
23
+ @alerts << args[0]
24
+ @alert_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new("root-alerts")
25
+ @alert_updater.inner_html = alert_contents
26
+ else
27
+ raise Scarpe::UnknownBuiltinCommandError, "Unexpected builtin command: #{cmd_name.inspect}!"
28
+ end
16
29
  end
17
30
  end
18
31
 
19
- # Bind a Scarpe callback name; see Scarpe::Widget for how the naming is set up
20
- def bind(name, &block)
21
- @callbacks[name] = block
32
+ def element(&block)
33
+ contents = block ? block.call : ""
34
+ super do
35
+ contents + HTML.render do |h|
36
+ h.div(id: "root-fonts") do
37
+ font_contents
38
+ end
39
+ h.div(id: "root-alerts") do
40
+ alert_contents
41
+ end
42
+ end
43
+ end
22
44
  end
23
45
 
24
- # All JS callbacks to Scarpe widgets are dispatched
25
- # via this handler, which is set up in Scarpe::App
26
- def handle_callback(name, *args)
27
- @callbacks[name].call(*args)
28
- end
46
+ private
47
+
48
+ # This needs to occur after initialize() because the app isn't yet allocated initially,
49
+ # so we can't call bind() for app events yet.
50
+ def bind_ok_event
51
+ return if @ok_event_setup_done
29
52
 
30
- # The document root knows when a frame has finished. It registers end-of-frame callbacks and calls them
31
- # when requested. It also tracks when a redraw has been requested. Note that often frames will be
32
- # very rare if nothing is changing, with seconds or minutes passing in between them.
53
+ @ok_event_setup_done = true
33
54
 
34
- def request_redraw!
35
- wrangler = WebviewDisplayService.instance.wrangler
36
- if wrangler.is_running
37
- wrangler.replace(self.to_html)
55
+ # Done with the alert(s), delete them
56
+ bind("OK") do
57
+ @alerts = []
58
+ needs_update!
38
59
  end
39
60
  end
40
61
 
41
- # The document root manages the connection between widgets and the WebviewWrangler.
42
- # By centralising this and wrapping in API functions, we can keep from executing
43
- # random Javascript, mostly.
62
+ def font_contents
63
+ HTML.render do |h|
64
+ @fonts.each do |font|
65
+ h.link(href: font, rel: "stylesheet")
66
+ h.style do
67
+ font_name = File.basename(font, ".*")
68
+ <<~CSS
69
+ @font-face {
70
+ font-family: #{font_name};
71
+ src: url("data:font/truetype;base64,#{encode_file_to_base64(font)}") format('truetype');
72
+ }
73
+ CSS
74
+ end
75
+ end
76
+ end
77
+ end
44
78
 
45
- # A Widget can request one or more of these as insertion points in the DOM
46
- def get_element_wrangler(html_id)
47
- Scarpe::WebWrangler::ElementWrangler.new(html_id)
79
+ def alert_contents
80
+ @alerts.map do |alert_text|
81
+ render("alert", { "text" => alert_text, "event_name" => "OK" })
82
+ end.join + " "
48
83
  end
49
84
  end
50
85
  end