scarpe 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (378) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -1
  3. data/.yardopts +1 -0
  4. data/CHANGELOG.md +52 -6
  5. data/Gemfile +2 -1
  6. data/Gemfile.lock +20 -6
  7. data/LICENSE.txt +7 -1
  8. data/README.md +100 -21
  9. data/Rakefile +68 -1
  10. data/examples/Edit_box_Styles.rb +8 -0
  11. data/examples/Kerning.rb +7 -0
  12. data/examples/animate.rb +20 -0
  13. data/examples/arrow.rb +10 -0
  14. data/examples/border.rb +11 -0
  15. data/examples/btn_tooltip.rb +7 -0
  16. data/examples/button_style_changed.rb +7 -0
  17. data/examples/button_styles_default.rb +6 -0
  18. data/examples/check.rb +2 -0
  19. data/examples/download_and_show_image.rb +3 -0
  20. data/examples/flags/finland.rb +15 -0
  21. data/examples/flags/italy.rb +11 -0
  22. data/examples/flags/mauritius.rb +14 -0
  23. data/examples/font_family.rb +17 -0
  24. data/examples/font_shorthand.rb +9 -0
  25. data/examples/gen.rb +12 -8
  26. data/examples/highlander.rb +3 -3
  27. data/examples/legacy/README.md +6 -0
  28. data/examples/legacy/not_checked/shoes-contrib/basic/shoes-notes.rb +1 -1
  29. data/examples/legacy/not_checked/shoes-manual/append.rb +10 -0
  30. data/examples/legacy/not_checked/shoes-manual/background_change.rb +12 -0
  31. data/examples/legacy/not_checked/shoes-manual/background_pattern.rb +5 -0
  32. data/examples/legacy/not_checked/shoes-manual/basic_app.rb +8 -0
  33. data/examples/legacy/not_checked/shoes-manual/border.rb +9 -0
  34. data/examples/legacy/not_checked/shoes-manual/builtins/FONTS.rb +5 -0
  35. data/examples/legacy/not_checked/shoes-manual/builtins/ask.rb +2 -0
  36. data/examples/legacy/not_checked/shoes-manual/builtins/ask_color.rb +5 -0
  37. data/examples/legacy/not_checked/shoes-manual/builtins/ask_open_file.rb +5 -0
  38. data/examples/legacy/not_checked/shoes-manual/builtins/ask_save_folder.rb +2 -0
  39. data/examples/legacy/not_checked/shoes-manual/builtins/confirm.rb +4 -0
  40. data/examples/legacy/not_checked/shoes-manual/builtins/debug.rb +2 -0
  41. data/examples/legacy/not_checked/shoes-manual/builtins/info.rb +3 -0
  42. data/examples/legacy/not_checked/shoes-manual/button.rb +9 -0
  43. data/examples/legacy/not_checked/shoes-manual/clear.rb +7 -0
  44. data/examples/legacy/not_checked/shoes-manual/custom_header.rb +13 -0
  45. data/examples/legacy/not_checked/shoes-manual/displace.rb +14 -0
  46. data/examples/legacy/not_checked/shoes-manual/edit_box.rb +8 -0
  47. data/examples/legacy/not_checked/shoes-manual/fill_pattern.rb +5 -0
  48. data/examples/legacy/not_checked/shoes-manual/fonts.rb +7 -0
  49. data/examples/legacy/not_checked/shoes-manual/gutter.rb +6 -0
  50. data/examples/legacy/not_checked/shoes-manual/image_web.rb +4 -0
  51. data/examples/legacy/not_checked/shoes-manual/keypress.rb +7 -0
  52. data/examples/legacy/not_checked/shoes-manual/list_box.rb +10 -0
  53. data/examples/legacy/not_checked/shoes-manual/motion.rb +10 -0
  54. data/examples/legacy/not_checked/shoes-manual/mouse.rb +8 -0
  55. data/examples/legacy/not_checked/shoes-manual/move.rb +14 -0
  56. data/examples/legacy/not_checked/shoes-manual/nested_ovals.rb +8 -0
  57. data/examples/legacy/not_checked/shoes-manual/oval.rb +7 -0
  58. data/examples/legacy/not_checked/shoes-manual/ovals.rb +6 -0
  59. data/examples/legacy/not_checked/shoes-manual/ovals_image.rb +8 -0
  60. data/examples/legacy/not_checked/shoes-manual/prepend.rb +7 -0
  61. data/examples/legacy/not_checked/shoes-manual/progress_bar.rb +10 -0
  62. data/examples/legacy/not_checked/shoes-manual/radio.rb +18 -0
  63. data/examples/legacy/not_checked/shoes-manual/radio_alternative_1.rb +7 -0
  64. data/examples/legacy/not_checked/shoes-manual/radio_alternative_2.rb +9 -0
  65. data/examples/legacy/not_checked/shoes-manual/rotate_rectangle.rb +6 -0
  66. data/examples/legacy/not_checked/shoes-manual/shape.rb +11 -0
  67. data/examples/legacy/not_checked/shoes-manual/static/avatar.png +0 -0
  68. data/examples/legacy/not_checked/shoes-manual/stroke.rb +5 -0
  69. data/examples/legacy/not_checked/shoes-manual/style.rb +3 -0
  70. data/examples/legacy/not_checked/shoes-manual/style_alternative_1.rb +4 -0
  71. data/examples/legacy/not_checked/shoes-manual/style_alternative_2.rb +5 -0
  72. data/examples/legacy/not_checked/shoes-manual/style_length.rb +5 -0
  73. data/examples/legacy/not_checked/shoes-manual/timer.rb +6 -0
  74. data/examples/legacy/not_checked/shoes-manual/trigger_window.rb +8 -0
  75. data/examples/legacy/not_checked/shoes-manual/window_owner.rb +8 -0
  76. data/examples/legacy/not_checked/simple/anim-shapes.rb +1 -1
  77. data/examples/legacy/not_checked/speedometer_app.rb +55 -0
  78. data/examples/legacy/working/shoes_manual/alert_button.rb +2 -0
  79. data/examples/legacy/working/shoes_manual/animate.rb +7 -0
  80. data/examples/legacy/working/shoes_manual/background_para.rb +4 -0
  81. data/examples/legacy/working/shoes_manual/button_alternative.rb +7 -0
  82. data/examples/legacy/working/shoes_manual/checkbox.rb +17 -0
  83. data/examples/legacy/working/shoes_manual/download.rb +12 -0
  84. data/examples/legacy/working/shoes_manual/edit_box.rb +6 -0
  85. data/examples/legacy/working/shoes_manual/editline.rb +7 -0
  86. data/examples/legacy/working/shoes_manual/fixed_height.rb +8 -0
  87. data/examples/legacy/working/shoes_manual/fixed_width.rb +12 -0
  88. data/examples/legacy/working/shoes_manual/image.rb +5 -0
  89. data/examples/legacy/working/shoes_manual/instance_variable_check.rb +10 -0
  90. data/examples/legacy/working/shoes_manual/message.rb +18 -0
  91. data/examples/legacy/working/shoes_manual/rectangle.rb +6 -0
  92. data/examples/legacy/working/shoes_manual/save_download.rb +12 -0
  93. data/examples/legacy/working/shoes_manual/self_check.rb +10 -0
  94. data/examples/legacy/working/shoes_manual/stack.rb +7 -0
  95. data/examples/legacy/working/shoes_manual/style_info.rb +8 -0
  96. data/examples/legacy/working/shoes_manual/utf8_support.rb +8 -0
  97. data/examples/legacy/working/shoes_manual/width.rb +4 -0
  98. data/examples/legacy/working/simple/image-icon.rb +3 -0
  99. data/examples/legacy/{not_checked → working}/simple/image.rb +1 -1
  100. data/examples/list_box_choose.rb +17 -0
  101. data/examples/local_assets/local_file_server.rb +82 -0
  102. data/examples/local_assets/multi_image.rb +5 -0
  103. data/examples/local_assets/sample.gif +0 -0
  104. data/examples/local_assets/sample.mp4 +0 -0
  105. data/examples/local_assets/small.png +0 -0
  106. data/examples/local_fonts.rb +5 -2
  107. data/examples/local_images.rb +2 -3
  108. data/examples/margin.rb +13 -0
  109. data/examples/margin_check.rb +27 -0
  110. data/examples/oval-with-kwargs.rb +3 -0
  111. data/examples/oval.rb +26 -0
  112. data/examples/para/para_text.rb +14 -0
  113. data/examples/para_font_styles.rb +17 -0
  114. data/examples/para_font_variant.rb +6 -0
  115. data/examples/para_fontweight.rb +13 -0
  116. data/examples/parse_xl_funnies.rb +3 -0
  117. data/examples/progress.rb +31 -0
  118. data/examples/radio/radio_groups.rb +2 -2
  119. data/examples/rect.rb +4 -0
  120. data/examples/rotate_shapes.rb +17 -0
  121. data/examples/scarpe_ext.rb +3 -0
  122. data/examples/shapes/star.rb +1 -3
  123. data/examples/simpler-menu.rb +21 -0
  124. data/examples/spacing.rb +1 -1
  125. data/examples/span.rb +4 -2
  126. data/exe/scarpe +2 -1
  127. data/lacci/Gemfile +2 -0
  128. data/lacci/Gemfile.lock +8 -1
  129. data/lacci/lacci.gemspec +2 -2
  130. data/lacci/lib/lacci/scarpe_cli.rb +2 -2
  131. data/lacci/lib/lacci/scarpe_core.rb +2 -1
  132. data/lacci/lib/lacci/version.rb +1 -1
  133. data/lacci/lib/scarpe/niente/app.rb +23 -0
  134. data/lacci/lib/scarpe/niente/display_service.rb +66 -0
  135. data/lacci/lib/scarpe/niente/drawable.rb +59 -0
  136. data/lacci/lib/scarpe/niente/shoes_spec.rb +93 -0
  137. data/lacci/lib/scarpe/niente.rb +32 -0
  138. data/lacci/lib/shoes/app.rb +111 -72
  139. data/lacci/lib/shoes/background.rb +2 -2
  140. data/lacci/lib/shoes/border.rb +2 -2
  141. data/lacci/lib/shoes/builtins.rb +63 -0
  142. data/lacci/lib/shoes/changelog.rb +52 -0
  143. data/lacci/lib/shoes/colors.rb +3 -1
  144. data/lacci/lib/shoes/constants.rb +41 -2
  145. data/lacci/lib/shoes/display_service.rb +80 -18
  146. data/lacci/lib/shoes/download.rb +2 -2
  147. data/lacci/lib/shoes/drawable.rb +654 -0
  148. data/lacci/lib/shoes/drawables/arc.rb +27 -0
  149. data/lacci/lib/shoes/drawables/arrow.rb +21 -0
  150. data/lacci/lib/shoes/drawables/border.rb +28 -0
  151. data/lacci/lib/shoes/drawables/button.rb +57 -0
  152. data/lacci/lib/shoes/drawables/check.rb +33 -0
  153. data/lacci/lib/shoes/drawables/document_root.rb +20 -0
  154. data/lacci/lib/shoes/{widgets → drawables}/edit_box.rb +9 -8
  155. data/lacci/lib/shoes/{widgets → drawables}/edit_line.rb +8 -7
  156. data/lacci/lib/shoes/drawables/flow.rb +20 -0
  157. data/lacci/lib/shoes/drawables/font_helper.rb +62 -0
  158. data/lacci/lib/shoes/{widgets → drawables}/image.rb +7 -7
  159. data/lacci/lib/shoes/drawables/line.rb +17 -0
  160. data/lacci/lib/shoes/drawables/link.rb +31 -0
  161. data/lacci/lib/shoes/drawables/list_box.rb +59 -0
  162. data/lacci/lib/shoes/drawables/oval.rb +48 -0
  163. data/lacci/lib/shoes/drawables/para.rb +206 -0
  164. data/lacci/lib/shoes/drawables/progress.rb +15 -0
  165. data/lacci/lib/shoes/drawables/radio.rb +35 -0
  166. data/lacci/lib/shoes/drawables/rect.rb +18 -0
  167. data/lacci/lib/shoes/{widgets → drawables}/shape.rb +8 -8
  168. data/lacci/lib/shoes/drawables/slot.rb +178 -0
  169. data/lacci/lib/shoes/drawables/stack.rb +21 -0
  170. data/lacci/lib/shoes/drawables/star.rb +28 -0
  171. data/lacci/lib/shoes/drawables/subscription_item.rb +93 -0
  172. data/lacci/lib/shoes/drawables/text_drawable.rb +122 -0
  173. data/lacci/lib/shoes/drawables/video.rb +17 -0
  174. data/lacci/lib/shoes/drawables/widget.rb +74 -0
  175. data/lacci/lib/shoes/drawables.rb +32 -0
  176. data/lacci/lib/shoes/errors.rb +38 -0
  177. data/lacci/lib/shoes/log.rb +2 -2
  178. data/lacci/lib/shoes/margin_helper.rb +79 -0
  179. data/lacci/lib/shoes/ruby_extensions.rb +15 -0
  180. data/lacci/lib/shoes-spec.rb +93 -0
  181. data/lacci/lib/shoes.rb +31 -10
  182. data/lacci/test/.gitignore +1 -0
  183. data/lacci/test/test_draw_context.rb +167 -0
  184. data/lacci/test/test_font_helper.rb +57 -0
  185. data/lacci/test/test_helper.rb +81 -0
  186. data/lacci/test/test_lacci.rb +99 -3
  187. data/lacci/test/test_margin_helper.rb +82 -0
  188. data/lacci/test/test_niente_test_infra.rb +26 -0
  189. data/lacci/test/test_oval.rb +82 -0
  190. data/lacci/test/test_parenting.rb +140 -0
  191. data/lacci/test/test_shoes_errors.rb +49 -0
  192. data/lacci/test/test_text_drawables.rb +23 -0
  193. data/lib/scarpe/assets.rb +18 -0
  194. data/lib/scarpe/cats_cradle.rb +84 -103
  195. data/lib/scarpe/errors.rb +77 -0
  196. data/lib/scarpe/shoes_spec.rb +160 -0
  197. data/lib/scarpe/version.rb +2 -2
  198. data/lib/scarpe/wv/app.rb +21 -20
  199. data/lib/scarpe/wv/arc.rb +4 -51
  200. data/lib/scarpe/wv/arrow.rb +9 -0
  201. data/lib/scarpe/wv/border.rb +9 -18
  202. data/lib/scarpe/wv/button.rb +7 -35
  203. data/lib/scarpe/wv/check.rb +3 -5
  204. data/lib/scarpe/wv/control_interface.rb +20 -30
  205. data/lib/scarpe/wv/document_root.rb +81 -4
  206. data/lib/scarpe/wv/{widget.rb → drawable.rb} +71 -82
  207. data/lib/scarpe/wv/edit_box.rb +8 -18
  208. data/lib/scarpe/wv/edit_line.rb +9 -20
  209. data/lib/scarpe/wv/flow.rb +2 -18
  210. data/lib/scarpe/wv/image.rb +7 -30
  211. data/lib/scarpe/wv/line.rb +3 -25
  212. data/lib/scarpe/wv/link.rb +6 -17
  213. data/lib/scarpe/wv/list_box.rb +6 -29
  214. data/lib/scarpe/wv/oval.rb +13 -0
  215. data/lib/scarpe/wv/para.rb +12 -30
  216. data/lib/scarpe/wv/progress.rb +19 -0
  217. data/lib/scarpe/wv/radio.rb +9 -10
  218. data/lib/scarpe/wv/rect.rb +13 -0
  219. data/lib/scarpe/wv/scarpe_extensions.rb +8 -0
  220. data/lib/scarpe/wv/shape.rb +13 -13
  221. data/lib/scarpe/wv/slot.rb +8 -25
  222. data/lib/scarpe/wv/stack.rb +2 -18
  223. data/lib/scarpe/wv/star.rb +3 -53
  224. data/lib/scarpe/wv/subscription_item.rb +38 -4
  225. data/lib/scarpe/wv/text_drawable.rb +90 -0
  226. data/lib/scarpe/wv/video.rb +15 -15
  227. data/lib/scarpe/wv/web_wrangler.rb +320 -328
  228. data/lib/scarpe/wv/webview_local_display.rb +52 -33
  229. data/lib/scarpe/wv/webview_relay_display.rb +12 -12
  230. data/lib/scarpe/wv/webview_relay_util.rb +7 -10
  231. data/lib/scarpe/wv/wv_display_worker.rb +2 -2
  232. data/lib/scarpe/wv.rb +52 -12
  233. data/lib/scarpe/wv_local.rb +1 -1
  234. data/lib/scarpe/wv_relay.rb +1 -1
  235. data/lib/scarpe.rb +1 -0
  236. data/logger/debug_web_wrangler.json +1 -1
  237. data/logger/scarpe_wv_test.json +1 -1
  238. data/scarpe-components/Gemfile +4 -1
  239. data/scarpe-components/Gemfile.lock +85 -0
  240. data/scarpe-components/README.md +2 -2
  241. data/scarpe-components/assets/bootstrap-themes/bootstrap-cerulean.css +12229 -0
  242. data/scarpe-components/assets/bootstrap-themes/bootstrap-cosmo.css +11810 -0
  243. data/scarpe-components/assets/bootstrap-themes/bootstrap-cyborg.css +12210 -0
  244. data/scarpe-components/assets/bootstrap-themes/bootstrap-darkly.css +12153 -0
  245. data/scarpe-components/assets/bootstrap-themes/bootstrap-flatly.css +12126 -0
  246. data/scarpe-components/assets/bootstrap-themes/bootstrap-icons.min.css +5 -0
  247. data/scarpe-components/assets/bootstrap-themes/bootstrap-journal.css +12099 -0
  248. data/scarpe-components/assets/bootstrap-themes/bootstrap-litera.css +12211 -0
  249. data/scarpe-components/assets/bootstrap-themes/bootstrap-lumen.css +12369 -0
  250. data/scarpe-components/assets/bootstrap-themes/bootstrap-lux.css +11928 -0
  251. data/scarpe-components/assets/bootstrap-themes/bootstrap-materia.css +13184 -0
  252. data/scarpe-components/assets/bootstrap-themes/bootstrap-minty.css +12177 -0
  253. data/scarpe-components/assets/bootstrap-themes/bootstrap-morph.css +12750 -0
  254. data/scarpe-components/assets/bootstrap-themes/bootstrap-pulse.css +11890 -0
  255. data/scarpe-components/assets/bootstrap-themes/bootstrap-quartz.css +12622 -0
  256. data/scarpe-components/assets/bootstrap-themes/bootstrap-sandstone.css +12201 -0
  257. data/scarpe-components/assets/bootstrap-themes/bootstrap-simplex.css +12186 -0
  258. data/scarpe-components/assets/bootstrap-themes/bootstrap-sketchy.css +12451 -0
  259. data/scarpe-components/assets/bootstrap-themes/bootstrap-slate.css +12492 -0
  260. data/scarpe-components/assets/bootstrap-themes/bootstrap-solar.css +12149 -0
  261. data/scarpe-components/assets/bootstrap-themes/bootstrap-spacelab.css +12266 -0
  262. data/scarpe-components/assets/bootstrap-themes/bootstrap-superhero.css +12216 -0
  263. data/scarpe-components/assets/bootstrap-themes/bootstrap-united.css +12077 -0
  264. data/scarpe-components/assets/bootstrap-themes/bootstrap-vapor.css +12549 -0
  265. data/scarpe-components/assets/bootstrap-themes/bootstrap-yeti.css +12325 -0
  266. data/scarpe-components/assets/bootstrap-themes/bootstrap-zephyr.css +12283 -0
  267. data/scarpe-components/assets/bootstrap-themes/bootstrap.bundle.min.js +7 -0
  268. data/scarpe-components/lib/scarpe/components/asset_server.rb +219 -0
  269. data/scarpe-components/lib/scarpe/components/base64.rb +23 -5
  270. data/scarpe-components/lib/scarpe/components/calzini/alert.rb +49 -0
  271. data/scarpe-components/lib/scarpe/components/calzini/art_drawables.rb +227 -0
  272. data/scarpe-components/lib/scarpe/components/calzini/border.rb +38 -0
  273. data/scarpe-components/lib/scarpe/components/calzini/button.rb +37 -0
  274. data/scarpe-components/lib/scarpe/components/calzini/misc.rb +136 -0
  275. data/scarpe-components/lib/scarpe/components/calzini/para.rb +237 -0
  276. data/scarpe-components/lib/scarpe/components/calzini/slots.rb +109 -0
  277. data/scarpe-components/lib/scarpe/components/calzini.rb +236 -0
  278. data/scarpe-components/lib/scarpe/components/errors.rb +24 -0
  279. data/scarpe-components/lib/scarpe/components/file_helpers.rb +1 -0
  280. data/scarpe-components/lib/scarpe/components/html.rb +134 -0
  281. data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +83 -0
  282. data/scarpe-components/lib/scarpe/components/minitest_import_runnable.rb +98 -0
  283. data/scarpe-components/lib/scarpe/components/minitest_result.rb +127 -0
  284. data/scarpe-components/lib/scarpe/components/modular_logger.rb +5 -5
  285. data/scarpe-components/lib/scarpe/components/print_logger.rb +22 -3
  286. data/scarpe-components/lib/scarpe/components/process_helpers.rb +37 -0
  287. data/scarpe-components/lib/scarpe/components/promises.rb +14 -14
  288. data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +36 -17
  289. data/scarpe-components/lib/scarpe/components/string_helpers.rb +10 -0
  290. data/scarpe-components/lib/scarpe/components/tiranti.rb +167 -0
  291. data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +48 -6
  292. data/scarpe-components/lib/scarpe/components/version.rb +2 -2
  293. data/scarpe-components/test/assets/big-image.png +0 -0
  294. data/scarpe-components/test/assets/big-stylesheet.css +497 -0
  295. data/scarpe-components/test/assets/little-image.png +0 -0
  296. data/scarpe-components/test/assets/little-stylesheet.css +1 -0
  297. data/scarpe-components/test/calzini/test_calzini_alert.rb +30 -0
  298. data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +105 -0
  299. data/scarpe-components/test/calzini/test_calzini_button.rb +54 -0
  300. data/scarpe-components/test/calzini/test_calzini_misc.rb +115 -0
  301. data/scarpe-components/test/calzini/test_calzini_para.rb +34 -0
  302. data/scarpe-components/test/calzini/test_calzini_slots.rb +85 -0
  303. data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +106 -0
  304. data/scarpe-components/test/calzini/test_various.rb +133 -0
  305. data/scarpe-components/test/mtr_data/exception.json +1 -0
  306. data/scarpe-components/test/mtr_data/fail_with_message.json +1 -0
  307. data/scarpe-components/test/mtr_data/skipped_no_message.json +1 -0
  308. data/scarpe-components/test/mtr_data/skipped_w_msg.json +1 -0
  309. data/scarpe-components/test/mtr_data/succeed_2_asserts.json +1 -0
  310. data/scarpe-components/test/test_asset_server.rb +72 -0
  311. data/scarpe-components/test/test_components.rb +31 -2
  312. data/scarpe-components/test/test_dimensions.rb +26 -0
  313. data/scarpe-components/test/test_helper.rb +20 -1
  314. data/scarpe-components/test/test_html.rb +65 -0
  315. data/scarpe-components/test/test_minitest_result.rb +68 -0
  316. data/scarpe-components/test/test_promises.rb +5 -4
  317. data/scarpe-components/test/test_segmented_app_files.rb +10 -6
  318. data/scarpegen.rb +14 -14
  319. data/sig/scarpe.rbs +1 -1
  320. data/tasks/check_html_fixtures.rb +140 -0
  321. data/tasks/regenerate_html_fixtures.rb +104 -0
  322. data/templates/basic_class_template.erb +13 -14
  323. data/templates/class_template_with_event_bind.erb +4 -4
  324. data/templates/class_template_with_shapes.erb +8 -28
  325. data/templates/example_template.erb +1 -1
  326. data/templates/module_template.erb +4 -4
  327. data/templates/webview_template.erb +3 -2
  328. metadata +286 -80
  329. data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
  330. data/lacci/lib/shoes/spacing.rb +0 -9
  331. data/lacci/lib/shoes/widget.rb +0 -218
  332. data/lacci/lib/shoes/widgets/alert.rb +0 -19
  333. data/lacci/lib/shoes/widgets/arc.rb +0 -51
  334. data/lacci/lib/shoes/widgets/button.rb +0 -35
  335. data/lacci/lib/shoes/widgets/check.rb +0 -28
  336. data/lacci/lib/shoes/widgets/document_root.rb +0 -20
  337. data/lacci/lib/shoes/widgets/flow.rb +0 -22
  338. data/lacci/lib/shoes/widgets/font.rb +0 -14
  339. data/lacci/lib/shoes/widgets/line.rb +0 -18
  340. data/lacci/lib/shoes/widgets/link.rb +0 -25
  341. data/lacci/lib/shoes/widgets/list_box.rb +0 -25
  342. data/lacci/lib/shoes/widgets/para.rb +0 -68
  343. data/lacci/lib/shoes/widgets/radio.rb +0 -35
  344. data/lacci/lib/shoes/widgets/slot.rb +0 -75
  345. data/lacci/lib/shoes/widgets/span.rb +0 -26
  346. data/lacci/lib/shoes/widgets/stack.rb +0 -24
  347. data/lacci/lib/shoes/widgets/star.rb +0 -44
  348. data/lacci/lib/shoes/widgets/subscription_item.rb +0 -60
  349. data/lacci/lib/shoes/widgets/text_widget.rb +0 -51
  350. data/lacci/lib/shoes/widgets/video.rb +0 -15
  351. data/lacci/lib/shoes/widgets.rb +0 -29
  352. data/lib/scarpe/evented_assertions.rb +0 -88
  353. data/lib/scarpe/wv/alert.rb +0 -66
  354. data/lib/scarpe/wv/background.rb +0 -27
  355. data/lib/scarpe/wv/control_interface_test.rb +0 -238
  356. data/lib/scarpe/wv/dimensions.rb +0 -22
  357. data/lib/scarpe/wv/font.rb +0 -36
  358. data/lib/scarpe/wv/html.rb +0 -108
  359. data/lib/scarpe/wv/spacing.rb +0 -41
  360. data/lib/scarpe/wv/span.rb +0 -68
  361. data/lib/scarpe/wv/text_widget.rb +0 -30
  362. /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/definr.rb +0 -0
  363. /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/funnies.rb +0 -0
  364. /data/examples/legacy/not_checked/shoes-contrib/{elements → basic}/list_box-select-class.rb +0 -0
  365. /data/examples/legacy/{not_checked → working}/shoes3-tests/editline/editline.rb +0 -0
  366. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/basic-edit-box.rb +0 -0
  367. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/basic-fps.rb +0 -0
  368. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/border-cat.rb +0 -0
  369. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/check-mate.rb +0 -0
  370. /data/examples/legacy/{not_checked/shoes-contrib/manipulation → working/simple}/clear-slot.rb +0 -0
  371. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/clock.rb +0 -0
  372. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/gradient-shoes.rb +0 -0
  373. /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/list_box-shape-report.rb +0 -0
  374. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/list_box.rb +0 -0
  375. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/phat-button.rb +0 -0
  376. /data/examples/legacy/{not_checked/shoes-contrib → working}/simple/simple-calc.rb +0 -0
  377. /data/examples/legacy/{not_checked/shoes-contrib/position → working/simple}/stack-width.rb +0 -0
  378. /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/width-introspec.rb +0 -0
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Progress < Shoes::Drawable
5
+ shoes_styles :fraction
6
+ shoes_events # No Progress-specific events yet
7
+
8
+ init_args # No positional args
9
+ def initialize(**kwargs)
10
+ super
11
+
12
+ create_display_drawable
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ # A Radio button drawable. Only a single radio button may be checked in each
5
+ # group. If no group is specified, or the group is nil, default to all
6
+ # radio buttons in the same slot being treated as being in the same group.
7
+ class Radio < Shoes::Drawable
8
+ shoes_styles :group, :checked
9
+ shoes_events :click
10
+
11
+ init_args
12
+ opt_init_args :group
13
+ def initialize(*args, **kwargs, &block)
14
+ @block = block
15
+
16
+ super
17
+
18
+ bind_self_event("click") { click }
19
+ create_display_drawable
20
+ end
21
+
22
+ def click(&block)
23
+ @block = block
24
+ self.checked = !checked?
25
+ end
26
+
27
+ def checked?
28
+ @checked ? true : false
29
+ end
30
+
31
+ def checked(value)
32
+ self.checked = value
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Rect < Shoes::Drawable
5
+ shoes_styles :draw_context, :curve, :stroke, :fill
6
+ shoes_events # No Rect-specific events
7
+
8
+ init_args :left, :top, :width, :height
9
+ opt_init_args :curve
10
+ def initialize(*args, **kwargs)
11
+ @draw_context = Shoes::App.instance.current_draw_context
12
+
13
+ super
14
+
15
+ create_display_drawable
16
+ end
17
+ end
18
+ end
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Shoes
3
+ class Shoes
4
4
  # A Shape acts as a sort of union type for drawn shapes. In Shoes you can use it to merge multiple
5
5
  # ovals, arcs, stars, etc. into a single drawn shape.
6
6
  #
7
7
  # In Shoes3, a Shape isn't really a Slot. It's a kind of DSL with drawing commands that happen
8
- # to have the same name as the Art widgets like star, arc, etc. Here we're treating it as
9
- # a slot containing those widgets, which is wrong but not *too* wrong.
8
+ # to have the same name as the Art drawables like star, arc, etc. Here we're treating it as
9
+ # a slot containing those drawables, which is wrong but not *too* wrong.
10
10
  #
11
11
  # @incompatibility A Shoes3 Shape is *not* a slot; Scarpe does *not* do union shapes
12
12
  class Shape < Shoes::Slot
13
- display_properties :left, :top, :shape_commands, :draw_context
13
+ shoes_styles :left, :top, :shape_commands, :draw_context
14
+ shoes_events # No Shape-specific events yet
14
15
 
15
- def initialize(left: nil, top: nil, &block)
16
- @left = left
17
- @top = top
16
+ init_args # No positional args
17
+ def initialize(**kwargs, &block)
18
18
  @shape_commands = []
19
19
  @draw_context = Shoes::App.instance.current_draw_context
20
20
 
21
21
  super
22
- create_display_widget
22
+ create_display_drawable
23
23
 
24
24
  Shoes::App.instance.with_slot(self, &block) if block_given?
25
25
  end
@@ -0,0 +1,178 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes::Slot < Shoes::Drawable
4
+ # @incompatibility Shoes uses #content, not #children, for this. Scarpe does both.
5
+ attr_reader :children
6
+
7
+ shoes_events # No Slot-specific events
8
+
9
+ # This only shows this specific slot's settings, not its parent's.
10
+ # Use current_draw_context to allow inheritance.
11
+ attr_reader :draw_context
12
+
13
+
14
+ def initialize(...)
15
+ # The draw context tracks current settings like fill and stroke,
16
+ # plus potentially other current state that changes from drawable
17
+ # to drawable and slot to slot.
18
+ @draw_context = {
19
+ "fill" => nil,
20
+ "stroke" => nil,
21
+ "strokewidth" => nil,
22
+ "rotate" => nil,
23
+ # "transform" => nil, # "corner",
24
+ # "translate" => nil, # [0, 0],
25
+ }
26
+
27
+ super
28
+ end
29
+
30
+ # Do not call directly, use set_parent
31
+ def remove_child(child)
32
+ @children ||= []
33
+ unless @children.include?(child)
34
+ @log.warn("remove_child: no such child(#{child.inspect}) for parent(#{parent.inspect})!")
35
+ end
36
+ @children.delete(child)
37
+ end
38
+
39
+ # Do not call directly, use set_parent
40
+ def add_child(child)
41
+ @children ||= []
42
+ @children << child
43
+ end
44
+
45
+ # Get a list of child drawables
46
+ def contents
47
+ @children ||= []
48
+ @children.dup
49
+ end
50
+
51
+ # We use method_missing for drawable-creating methods like "button".
52
+ # The parent's method_missing will auto-create Shoes style getters and setters.
53
+ # This is similar to the method_missing in Shoes::App, but differs in where
54
+ # the new drawable will appear.
55
+ def method_missing(name, *args, **kwargs, &block)
56
+ klass = ::Shoes::Drawable.drawable_class_by_name(name)
57
+ return super unless klass
58
+
59
+ ::Shoes::Slot.define_method(name) do |*args, **kwargs, &block|
60
+ instance = nil
61
+
62
+ # Look up the Shoes drawable and create it. But first set
63
+ # this slot as the current one so that draw context
64
+ # is handled properly.
65
+ Shoes::App.instance.with_slot(self) do
66
+ instance = klass.new(*args, **kwargs, &block)
67
+ end
68
+
69
+ instance
70
+ end
71
+
72
+ send(name, *args, **kwargs, &block)
73
+ end
74
+
75
+ def respond_to_missing?(name, include_private = false)
76
+ return true if ::Shoes::Drawable.drawable_class_by_name(name.to_s)
77
+
78
+ false
79
+ end
80
+
81
+ # Draw context methods
82
+
83
+ # Set the default fill color in this slot and child slots.
84
+ # Pass nil for "no setting", so that it can inherit defaults.
85
+ #
86
+ # @param color [Nil,Color] a Shoes color for the fill color or nil to use parent setting
87
+ # @return [void]
88
+ def fill(color)
89
+ @draw_context["fill"] = color
90
+ end
91
+
92
+ # Set the default fill in this slot and child slots to transparent.
93
+ #
94
+ # @return [void]
95
+ def nofill
96
+ @draw_context["fill"] = rgb(0, 0, 0, 0)
97
+ end
98
+
99
+ # Set the default stroke color in this slot and child slots.
100
+ # Pass nil for "no setting" so it can inherit defaults.
101
+ #
102
+ # @param color [Nil,Color] a Shoes color for the stroke color or nil to use parent setting
103
+ # @return [void]
104
+ def stroke(color)
105
+ @draw_context["stroke"] = color
106
+ end
107
+
108
+ # Set the default strokewidth in this slot and child slots.
109
+ # Pass nil for "no setting".
110
+ #
111
+ # @param width [Numeric,Nil] the new width, or nil to use parent setting
112
+ # @return [void]
113
+ def strokewidth(width)
114
+ @draw_context["strokewidth"] = width
115
+ end
116
+
117
+ # Set the default stroke in this slot and child slots
118
+ # to transparent.
119
+ #
120
+ # @return [void]
121
+ def nostroke
122
+ @draw_context["stroke"] = rgb(0, 0, 0, 0)
123
+ end
124
+
125
+ # Set the current rotation in this slot and any child slots.
126
+ # Pass nil to reset the angle to default.
127
+ #
128
+ # @param angle [Numeric,Nil] the new default rotation for shapes or nil to use parent setting
129
+ # @return [void]
130
+ def rotate(angle)
131
+ @draw_context["rotate"] = angle
132
+ end
133
+
134
+ # Get the current draw context styles, based on this slot and its parent slots.
135
+ #
136
+ # @return [Hash] a hash of Shoes styles for the context
137
+ def current_draw_context
138
+ s = @parent ? @parent.current_draw_context : {}
139
+ @draw_context.each { |k, v| s[k] = v unless v.nil? }
140
+
141
+ s
142
+ end
143
+
144
+ # Methods to add or remove children
145
+
146
+ # Remove all children from this drawable. If a block
147
+ # is given, call the block to replace the children with
148
+ # new contents from that block.
149
+ #
150
+ # Should only be called on Slots, which can
151
+ # have children.
152
+ #
153
+ # @incompatibility Shoes Classic calls the clear block with current self, while Scarpe uses the Shoes::App as self
154
+ #
155
+ # @yield The block to call to replace the contents of the drawable (optional)
156
+ # @return [void]
157
+ def clear(&block)
158
+ @children ||= []
159
+ @children.dup.each(&:destroy)
160
+ append(&block) if block_given?
161
+ nil
162
+ end
163
+
164
+ # Call the block to append new children to a Slot.
165
+ #
166
+ # Should only be called on a Slot, since only Slots can have children.
167
+ #
168
+ # @incompatibility Shoes Classic calls the append block with current self, while Scarpe uses the Shoes::App as self
169
+ #
170
+ # @yield the block to call to replace children; will be called on the Shoes::App, appending to the called Slot as the current slot
171
+ # @return [void]
172
+ def append(&block)
173
+ raise(Shoes::Errors::InvalidAttributeValueError, "append requires a block!") unless block_given?
174
+ raise(Shoes::Errors::InvalidAttributeValueError, "Don't append to something that isn't a slot!") unless self.is_a?(Shoes::Slot)
175
+
176
+ Shoes::App.instance.with_slot(self, &block)
177
+ end
178
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Stack < Shoes::Slot
5
+ include Shoes::Background
6
+
7
+ shoes_styles :scroll
8
+
9
+ shoes_events # No Stack-specific events
10
+
11
+ def initialize(*args, **kwargs, &block)
12
+ super
13
+
14
+ create_display_drawable
15
+
16
+ # Create the display-side drawable *before* running the block.
17
+ # Then child drawables have a parent to add themselves to.
18
+ Shoes::App.instance.with_slot(self, &block) if block_given?
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Star < Shoes::Drawable
5
+ shoes_styles :left, :top, :draw_context
6
+
7
+ shoes_style(:points) { |val| convert_to_integer(val, "points") }
8
+ shoes_style(:outer) { |val| convert_to_float(val, "outer") }
9
+ shoes_style(:inner) { |val| convert_to_float(val, "inner") }
10
+
11
+ Shoes::Drawable.drawable_default_styles[Shoes::Star][:points] = 10
12
+ Shoes::Drawable.drawable_default_styles[Shoes::Star][:outer] = 100
13
+ Shoes::Drawable.drawable_default_styles[Shoes::Star][:inner] = 50
14
+
15
+ shoes_events # No Star-specific events
16
+
17
+ init_args :left, :top
18
+ opt_init_args :points, :outer, :inner
19
+ def initialize(*args, **kwargs)
20
+ super
21
+
22
+ @draw_context = Shoes::App.instance.current_draw_context
23
+
24
+ create_display_drawable
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Certain Shoes calls like motion and keydown are basically an
4
+ # event subscription, with no other visible presence. However,
5
+ # they have a place in the drawable tree and can be deleted.
6
+ #
7
+ # Depending on the display library they may not have any
8
+ # direct visual (or similar) presence there either.
9
+ #
10
+ # Inheriting from Drawable gives these a parent slot and a
11
+ # linkable_id automatically.
12
+ #
13
+ # Events not yet implemented: start, finish events for slots -
14
+ # start is first draw, finish is drawable destroyed
15
+ class Shoes::SubscriptionItem < Shoes::Drawable
16
+ shoes_styles :shoes_api_name, :args
17
+ shoes_events :animate, :every, :timer, :hover, :leave, :motion, :click, :release, :keypress
18
+
19
+ def initialize(args: [], shoes_api_name:, &block)
20
+ super
21
+
22
+ @callback = block
23
+
24
+ case shoes_api_name
25
+ when "animate"
26
+ @unsub_id = bind_self_event("animate") do |frame|
27
+ @callback.call(frame)
28
+ end
29
+ when "every"
30
+ @unsub_id = bind_self_event("every") do |count|
31
+ @callback.call(count)
32
+ end
33
+ when "timer"
34
+ @unsub_id = bind_self_event("timer") do
35
+ @callback.call
36
+ end
37
+ when "hover"
38
+ # Hover passes the Shoes drawable as the block param
39
+ @unsub_id = bind_self_event("hover") do
40
+ @callback&.call(self)
41
+ end
42
+ when "leave"
43
+ # Leave passes the Shoes drawable as the block param
44
+ @unsub_id = bind_self_event("leave") do
45
+ @callback&.call(self)
46
+ end
47
+ when "motion"
48
+ # Shoes sends back x, y, mods as the args.
49
+ # Shoes3 uses the strings "control" "shift" and
50
+ # "control_shift" as the mods arg.
51
+ @unsub_id = bind_self_event("motion") do |x, y, ctrl_key, shift_key, **_kwargs|
52
+ mods = [ctrl_key ? "control" : nil, shift_key ? "shift" : nil].compact.join("_")
53
+ @callback&.call(x, y, mods)
54
+ end
55
+ when "click"
56
+ # Click has block params button, left, top
57
+ # button is the button number, left and top are coords
58
+ @unsub_id = bind_self_event("click") do |button, x, y, **_kwargs|
59
+ @callback&.call(button, x, y)
60
+ end
61
+ when "release"
62
+ # Click has block params button, left, top
63
+ # button is the button number, left and top are coords
64
+ @unsub_id = bind_self_event("release") do |button, x, y, **_kwargs|
65
+ @callback&.call(button, x, y)
66
+ end
67
+ when "keypress"
68
+ # Keypress passes the key string or symbol to the handler
69
+ # Do anything special for serialisation here?
70
+ @unsub_id = bind_self_event("keypress") do |key|
71
+ @callback&.call(key)
72
+ end
73
+ else
74
+ raise "Unknown Shoes event #{shoes_api_name.inspect} passed to SubscriptionItem!"
75
+ end
76
+
77
+ @unsub_id = bind_self_event(shoes_api_name) do |*args|
78
+ @callback&.call(*args)
79
+ end
80
+
81
+ # This won't create a visible display drawable, but will turn into
82
+ # an invisible drawable and a stream of events.
83
+ create_display_drawable
84
+ end
85
+
86
+ def destroy
87
+ # TODO: we need a better way to do this automatically. See https://github.com/scarpe-team/scarpe/issues/291
88
+ unsub_shoes_event(@unsub_id) if @unsub_id
89
+ @unsub_id = nil
90
+
91
+ super
92
+ end
93
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ # TextDrawable is the parent class of various classes of
5
+ # text that can go inside a para. This includes normal
6
+ # text, but also links, italic text, bold text, etc.
7
+ #
8
+ # In Shoes3 this corresponds to cText, and it would
9
+ # have methods app, contents, children, parent,
10
+ # style, to_s, text, text= and replace.
11
+ #
12
+ # Much of what this does and how is similar to Para.
13
+ # It's a very similar API.
14
+ class TextDrawable < Shoes::Drawable
15
+ shoes_styles :text_items, :size, :stroke, :strokewidth, :fill, :undercolor, :font
16
+
17
+ STRIKETHROUGH_VALUES = [nil, "none", "single"]
18
+ shoes_style :strikethrough do |val, _name|
19
+ unless STRIKETHROUGH_VALUES.include?(val)
20
+ raise Shoes::Errors::InvalidAttributeValueError, "Strikethrough must be one of: #{STRIKETHROUGH_VALUES.inspect}!"
21
+ end
22
+ val
23
+ end
24
+
25
+ UNDERLINE_VALUES = [nil, "none", "single", "double", "low", "error"]
26
+ shoes_style :underline do |val, _name|
27
+ unless UNDERLINE_VALUES.include?(val)
28
+ raise Shoes::Errors::InvalidAttributeValueError, "Underline must be one of: #{UNDERLINE_VALUES.inspect}!"
29
+ end
30
+ val
31
+ end
32
+
33
+ shoes_events # No TextDrawable-specific events yet
34
+
35
+ def initialize(*args, **kwargs)
36
+ # Don't pass text_children args to Drawable#initialize
37
+ super(*[], **kwargs)
38
+
39
+ # Text_children alternates strings and TextDrawables, so we can't just pass
40
+ # it as a Shoes style. It won't serialize.
41
+ update_text_children(args)
42
+
43
+ create_display_drawable
44
+ end
45
+
46
+ def text_children_to_items(text_children)
47
+ text_children.map { |arg| arg.is_a?(TextDrawable) ? arg.linkable_id : arg.to_s }
48
+ end
49
+
50
+ # Sets the paragraph text to a new value, which can
51
+ # include {TextDrawable}s like em(), strong(), etc.
52
+ #
53
+ # @param children [Array] the arguments can be Strings and/or TextDrawables
54
+ # @return [void]
55
+ def replace(*children)
56
+ update_text_children(children)
57
+ end
58
+
59
+ # Set the paragraph text to a single String.
60
+ # To use bold, italics, etc. use {Para#replace} instead.
61
+ #
62
+ # @param child [String] the new text to use for this Para
63
+ # @return [void]
64
+ def text=(*children)
65
+ update_text_children(children)
66
+ end
67
+
68
+ # Return the text, but not the styling, of the para's
69
+ # contents. For example, if the contents had strong
70
+ # and emphasized text, the bold and emphasized would
71
+ # be removed but the text would be returned.
72
+ #
73
+ # @return [String] the text from this para
74
+ def text
75
+ @text_children.map(&:to_s).join
76
+ end
77
+
78
+ # Return the text but not styling from the para. This
79
+ # is the same as #text.
80
+ #
81
+ # @return [String] the text from this para
82
+ def to_s
83
+ self.text
84
+ end
85
+
86
+ private
87
+
88
+ # Text_children alternates strings and TextDrawables, so we can't just pass
89
+ # it as a Shoes style. It won't serialize.
90
+ def update_text_children(children)
91
+ @text_children = children.flatten
92
+ # This should signal the display drawable to change
93
+ self.text_items = text_children_to_items(@text_children)
94
+ end
95
+ end
96
+
97
+ class << self
98
+ def default_text_drawable_with(element)
99
+ class_name = element.capitalize
100
+
101
+ drawable_class = Class.new(Shoes::TextDrawable) do
102
+ shoes_events # No specific events
103
+
104
+ init_args # We're going to pass an empty array to super
105
+ end
106
+ Shoes.const_set class_name, drawable_class
107
+ end
108
+ end
109
+ end
110
+
111
+ Shoes.default_text_drawable_with(:code)
112
+ Shoes.default_text_drawable_with(:del)
113
+ Shoes.default_text_drawable_with(:em)
114
+ Shoes.default_text_drawable_with(:strong)
115
+ Shoes.default_text_drawable_with(:span)
116
+ Shoes.default_text_drawable_with(:sub)
117
+ Shoes.default_text_drawable_with(:sup)
118
+ Shoes.default_text_drawable_with(:ins) # in Shoes3, looks like "ins" is just underline
119
+
120
+ # Defaults must come *after* classes are defined
121
+
122
+ Shoes::Drawable.drawable_default_styles[Shoes::Ins][:underline] = "single"
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Video < Shoes::Drawable
5
+ shoes_styles :url
6
+ shoes_events # No specific events yet
7
+
8
+ init_args :url
9
+ def initialize(*args, **kwargs)
10
+ super
11
+
12
+ create_display_drawable
13
+ end
14
+
15
+ # other methods
16
+ end
17
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A Shoes::Widget is mostly a Slot (related to the
4
+ # old Shoes concepts of Canvas) that creates drawables
5
+ # inside itself. When a subclass of Widget is created,
6
+ # it adds a method to create new objects of that type
7
+ # on Shoes::App and all Shoes slots.
8
+ #
9
+ # The hardest part with a Shoes::Widget is that it
10
+ # should work fine even if initialize() doesn't call
11
+ # super, which would make it hard to set up a Shoes
12
+ # linkable_id, create a display widget, etc.
13
+ #
14
+ # It would be possible to add an extra method to set
15
+ # these up and call it on every created drawable
16
+ # in case a Widget's initialize method doesn't call
17
+ # super, which happens quite often. But then we wouldn't
18
+ # support automatic setting of styles (e.g. padding)
19
+ # for the widget object itself, which is mostly a Flow.
20
+ # We also couldn't support default styles -- I can't tell
21
+ # whether Shoes supports these things either.
22
+ #
23
+ # But there's another way to do all of this. When a
24
+ # subclass of Widget defines an initialize method,
25
+ # we can catch the method_added hook, save a copy of
26
+ # that initialize method, and substitute our own
27
+ # initialize that calls super. We have to be a little
28
+ # careful -- if the widget's initialize *does* call
29
+ # super that shouldn't be an error. But that's
30
+ # workable by defining an extra method with the
31
+ # copied-method name that does nothing.
32
+
33
+ ##### TODO: when this is subclassed, grab :initialize out
34
+ # of the subclass, put it into :initialize_widget, and
35
+ # replace with an initialize that creates the display
36
+ # widget propertly, sets the linkable_id, etc.
37
+
38
+ class Shoes::Widget < Shoes::Slot
39
+ include Shoes::Background
40
+
41
+ shoes_events
42
+
43
+ def self.inherited(subclass)
44
+ super
45
+
46
+ # Widgets are special - we can't know in advance what sort of initialize args they take
47
+ subclass.init_args :any
48
+ end
49
+
50
+ def self.method_added(name)
51
+ # We're only looking for the initialize() method, and only on subclasses
52
+ # of Shoes::Widget, not Shoes::Widget itself.
53
+ return if self == ::Shoes::Widget || name != :initialize
54
+
55
+ # Need to avoid infinite adding of initialize() if we're re-adding the default initialize
56
+ return if @midway_through_adding_initialize
57
+
58
+ # Take the user-provided initialize method and save a copy named __widget_initialize
59
+ alias_method :__widget_initialize, :initialize
60
+
61
+ # And add the default initialize back where it belongs
62
+ @midway_through_adding_initialize = true
63
+ define_method(:initialize) do |*args, **kwargs, &block|
64
+ super(*args, **kwargs, &block)
65
+ @options = kwargs # Get rid of options?
66
+ create_display_drawable
67
+ __widget_initialize(*args, **kwargs, &block)
68
+
69
+ # Do Widgets do this?
70
+ Shoes::App.instance.with_slot(self, &block) if block
71
+ end
72
+ @midway_through_adding_initialize = false
73
+ end
74
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shoes/drawables/slot"
4
+ require "shoes/drawables/stack"
5
+ require "shoes/drawables/flow"
6
+ require "shoes/drawables/widget"
7
+ require "shoes/drawables/document_root"
8
+
9
+ require "shoes/drawables/text_drawable"
10
+
11
+ require "shoes/drawables/subscription_item"
12
+
13
+ require "shoes/drawables/arc"
14
+ require "shoes/drawables/line"
15
+ require "shoes/drawables/rect"
16
+ require "shoes/drawables/shape"
17
+ require "shoes/drawables/star"
18
+ require "shoes/drawables/oval"
19
+ require "shoes/drawables/arrow"
20
+
21
+ require "shoes/drawables/button"
22
+ require "shoes/drawables/check"
23
+ require "shoes/drawables/edit_box"
24
+ require "shoes/drawables/edit_line"
25
+ require "shoes/drawables/image"
26
+ require "shoes/drawables/link"
27
+ require "shoes/drawables/list_box"
28
+ require "shoes/drawables/para"
29
+ require "shoes/drawables/radio"
30
+ require "shoes/drawables/video"
31
+ require "shoes/drawables/progress"
32
+ require "shoes/drawables/border"