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
@@ -1,24 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- module WebviewBorder
5
- def style
6
- styles = (super if defined?(super)) || {}
7
- return styles unless @border_color
3
+ module Scarpe::Webview
4
+ class Border < Drawable
8
5
 
9
- border_color = case @border_color
10
- when Range
11
- { "border-image": "linear-gradient(45deg, #{@border_color.first}, #{@border_color.last})" }
12
- when Array
13
- { "border-color": "rgba(#{@border_color.join(", ")})" }
14
- else
15
- { "border-color": @border_color }
16
- end
17
- styles.merge(
18
- "border-style": "solid",
19
- "border-width": "#{@options[:strokewidth] || 1}px",
20
- "border-radius": "#{@options[:curve] || 0}px",
21
- ).merge(border_color)
6
+ def initialize(properties)
7
+ super(properties)
8
+ end
9
+
10
+ # If the drawable is intended to be overridable, add element and style to Calzini instead
11
+ def element
12
+ render('border')
22
13
  end
23
14
  end
24
15
  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,43 +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
- protected
24
-
25
- def style
26
- styles = super
27
-
28
- styles[:"background-color"] = @color
29
- styles[:"padding-top"] = @padding_top
30
- styles[:"padding-bottom"] = @padding_bottom
31
- styles[:color] = @text_color
32
- styles[:width] = Dimensions.length(@width) if @width
33
- styles[:height] = Dimensions.length(@height) if @height
34
- styles[:"font-size"] = @font_size
35
-
36
- styles[:top] = Dimensions.length(@top) if @top
37
- styles[:left] = Dimensions.length(@left) if @left
38
- styles[:position] = "absolute" if @top || @left
39
- styles[:"font-size"] = Dimensions.length(font_size) if @size
40
- styles[:"font-family"] = @font if @font
41
- styles[:color] = rgb_to_hex(@stroke) if @stroke
42
-
43
- styles
44
- end
45
-
46
- def font_size
47
- font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
48
-
49
- Dimensions.length(font_size)
20
+ def element
21
+ render("button")
50
22
  end
51
23
  end
52
24
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- class WebviewCheck < Scarpe::WebviewWidget
3
+ module Scarpe::Webview
4
+ class Check < Drawable
5
5
  attr_reader :text
6
6
 
7
7
  def initialize(properties)
@@ -21,9 +21,7 @@ class Scarpe
21
21
  end
22
22
 
23
23
  def element
24
- HTML.render do |h|
25
- h.input(type: :checkbox, id: html_id, onclick: handler_js_code("click"), value: "hmm #{text}", checked: @checked, style:)
26
- end
24
+ render("check")
27
25
  end
28
26
  end
29
27
  end
@@ -1,28 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
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 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
- #
10
- # And if you depend on this from the framework, I'll add a check-mode that
11
- # never dispatches any events to any handlers. Do NOT test me on this.
12
-
13
- class Scarpe
3
+ # The ControlInterface is used to coordinate events. It's a way to register interest
4
+ # in important events like redraw, init and shutdown. It's used extensively for testing.
5
+ module Scarpe::Webview
14
6
  class ControlInterface
15
7
  include Shoes::Log
16
8
 
17
9
  SUBSCRIBE_EVENTS = [:init, :shutdown, :next_redraw, :every_redraw, :next_heartbeat, :every_heartbeat]
18
10
  DISPATCH_EVENTS = [:init, :shutdown, :redraw, :heartbeat]
11
+ INVALID_SYSTEM_COMPONENTS_MESSAGE = "Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
12
+ CONTROL_INTERFACE_INIT_MESSAGE = "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
13
+ "to make sure they have access to app, doc_root, wrangler, etc!"
19
14
 
20
15
  attr_writer :doc_root
21
16
  attr_reader :do_shutdown
22
17
 
23
18
  # The control interface needs to see major system components to hook into their events
24
19
  def initialize
25
- log_init("WV::ControlInterface")
20
+ log_init("Webview::ControlInterface")
26
21
 
27
22
  @do_shutdown = false
28
23
  @event_handlers = {}
@@ -35,11 +30,15 @@ class Scarpe
35
30
 
36
31
  # This should get called once, from Shoes::App
37
32
  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!"
33
+ unless app
34
+ @log.error("False app passed to set_system_components!")
35
+ raise Scarpe::MissingAppError, INVALID_SYSTEM_COMPONENTS_MESSAGE
42
36
  end
37
+ unless wrangler
38
+ @log.error("False wrangler passed to set_system_components!")
39
+ raise Scarpe::MissingWranglerError, INVALID_SYSTEM_COMPONENTS_MESSAGE
40
+ end
41
+
43
42
  @app = app
44
43
  @doc_root = doc_root # May be nil at this point
45
44
  @wrangler = wrangler
@@ -50,28 +49,19 @@ class Scarpe
50
49
  end
51
50
 
52
51
  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
52
+ raise Scarpe::MissingAppError, CONTROL_INTERFACE_INIT_MESSAGE unless @app
57
53
 
58
54
  @app
59
55
  end
60
56
 
61
57
  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
58
+ raise Scarpe::MissingDocRootError, CONTROL_INTERFACE_INIT_MESSAGE unless @doc_root
66
59
 
67
60
  @doc_root
68
61
  end
69
62
 
70
63
  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
64
+ raise Scarpe::MissingWranglerError, CONTROL_INTERFACE_INIT_MESSAGE unless @wrangler
75
65
 
76
66
  @wrangler
77
67
  end
@@ -82,7 +72,7 @@ class Scarpe
82
72
  # On recognised events, this sets a handler for that event
83
73
  def on_event(event, &block)
84
74
  unless SUBSCRIBE_EVENTS.include?(event)
85
- raise "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
75
+ raise Scarpe::IllegalSubscribeEventError, "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
86
76
  end
87
77
 
88
78
  @unsub_id ||= 0
@@ -97,7 +87,7 @@ class Scarpe
97
87
  @log.debug("CTL event #{event.inspect} #{args.inspect} #{keywords.inspect}")
98
88
 
99
89
  unless DISPATCH_EVENTS.include?(event)
100
- raise "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
90
+ raise Scarpe::IllegalDispatchEventError, "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
101
91
  end
102
92
 
103
93
  if @do_shutdown
@@ -1,8 +1,85 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- # A WebviewDocumentRoot is a WebviewFlow, with all the same properties
5
- # and basic behavior.
6
- class WebviewDocumentRoot < Scarpe::WebviewFlow
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
8
+ def initialize(properties)
9
+ super
10
+
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(html_id: "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(html_id: "root-alerts")
25
+ @alert_updater.inner_html = alert_contents
26
+ else
27
+ raise Scarpe::UnknownBuiltinCommandError, "Unexpected builtin command: #{cmd_name.inspect}!"
28
+ end
29
+ end
30
+ end
31
+
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
44
+ end
45
+
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
52
+
53
+ @ok_event_setup_done = true
54
+
55
+ # Done with the alert(s), delete them
56
+ bind("OK") do
57
+ @alerts = []
58
+ needs_update!
59
+ end
60
+ end
61
+
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
78
+
79
+ def alert_contents
80
+ @alerts.map do |alert_text|
81
+ render("alert", { "text" => alert_text, "event_name" => "OK" })
82
+ end.join + " "
83
+ end
7
84
  end
8
85
  end
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- # The WebviewWidget parent class helps connect a Webview widget with
3
+ module Scarpe::Webview
4
+ # The Webview::Drawable parent class helps connect a Webview drawable with
5
5
  # its Shoes equivalent, render itself to the Webview DOM, handle
6
6
  # Javascript events and generally keep things working in Webview.
7
- class WebviewWidget < Shoes::Linkable
7
+ class Drawable < Shoes::Linkable
8
+ # This will pick up the log implementation from wv.rb
8
9
  include Shoes::Log
9
10
 
10
11
  class << self
@@ -12,55 +13,60 @@ class Scarpe
12
13
  def display_class_for(scarpe_class_name)
13
14
  scarpe_class = Shoes.const_get(scarpe_class_name)
14
15
  unless scarpe_class.ancestors.include?(Shoes::Linkable)
15
- raise "Scarpe Webview can only get display classes for Shoes " +
16
- "linkable widgets, not #{scarpe_class_name.inspect}!"
16
+ raise Scarpe::InvalidClassError, "Scarpe Webview can only get display classes for Shoes " +
17
+ "linkable drawables, not #{scarpe_class_name.inspect}!"
17
18
  end
18
19
 
19
- klass = Scarpe.const_get("Webview" + scarpe_class_name.split("::")[-1])
20
+ klass = Scarpe::Webview.const_get(scarpe_class_name.split("::")[-1])
20
21
  if klass.nil?
21
- raise "Couldn't find corresponding Scarpe Webview class for #{scarpe_class_name.inspect}!"
22
+ raise Scarpe::MissingClassError, "Couldn't find corresponding Scarpe Webview class for #{scarpe_class_name.inspect}!"
22
23
  end
23
24
 
24
25
  klass
25
26
  end
26
27
  end
27
28
 
28
- # The Shoes ID corresponding to the Shoes widget for this Webview widget
29
+ # The Shoes ID corresponding to the Shoes drawable for this Webview drawable
29
30
  attr_reader :shoes_linkable_id
30
31
 
31
- # The WebviewWidget parent of this widget
32
+ # The Webview::Drawable parent of this drawable
32
33
  attr_reader :parent
33
34
 
34
- # An array of WebviewWidget children (possibly empty) of this widget
35
+ # An array of Webview::Drawable children (possibly empty) of this drawable
35
36
  attr_reader :children
36
37
 
37
- # Set instance variables for the display properties of this widget. Bind Shoes
38
- # events for changes of parent widget and changes of property values.
38
+ # Set instance variables for the Shoes styles of this drawable. Bind Shoes
39
+ # events for changes of parent drawable and changes of property values.
39
40
  def initialize(properties)
40
- log_init("WV::Widget")
41
+ log_init("Webview::Drawable")
42
+
43
+ @shoes_style_names = properties.keys.map(&:to_s) - ["shoes_linkable_id"]
41
44
 
42
- # Call method, which looks up the parent
43
45
  @shoes_linkable_id = properties["shoes_linkable_id"] || properties[:shoes_linkable_id]
44
46
  unless @shoes_linkable_id
45
- raise "Could not find property shoes_linkable_id in #{properties.inspect}!"
47
+ raise Scarpe::MissingAttributeError, "Could not find property shoes_linkable_id in #{properties.inspect}!"
46
48
  end
47
49
 
48
- # Set the display properties
50
+ # Set the Shoes styles as instance variables
49
51
  properties.each do |k, v|
50
52
  next if k == "shoes_linkable_id"
51
53
 
52
54
  instance_variable_set("@" + k.to_s, v)
53
55
  end
54
56
 
55
- # The parent field is *almost* simple enough that a typed display property would handle it.
57
+ # Must call this before bind
58
+ super(linkable_id: @shoes_linkable_id)
59
+
60
+ # This will only be used if moving a drawable from one parent to another.
61
+ # Shoes doesn't normally do that.
56
62
  bind_shoes_event(event_name: "parent", target: shoes_linkable_id) do |new_parent_id|
57
- display_parent = WebviewDisplayService.instance.query_display_widget_for(new_parent_id)
63
+ display_parent = DisplayService.instance.query_display_drawable_for(new_parent_id)
58
64
  if @parent != display_parent
59
65
  set_parent(display_parent)
60
66
  end
61
67
  end
62
68
 
63
- # When Shoes widgets change properties, we get a change notification here
69
+ # When Shoes drawables change properties, we get a change notification here
64
70
  bind_shoes_event(event_name: "prop_change", target: shoes_linkable_id) do |prop_changes|
65
71
  prop_changes.each do |k, v|
66
72
  instance_variable_set("@" + k, v)
@@ -71,35 +77,41 @@ class Scarpe
71
77
  bind_shoes_event(event_name: "destroy", target: shoes_linkable_id) do
72
78
  destroy_self
73
79
  end
80
+ end
74
81
 
75
- super(linkable_id: @shoes_linkable_id)
82
+ def shoes_styles
83
+ p = {}
84
+ @shoes_style_names.each do |prop_name|
85
+ p[prop_name] = instance_variable_get("@#{prop_name}")
86
+ end
87
+ p
76
88
  end
77
89
 
78
90
  # Properties_changed will be called automatically when properties change.
79
- # The widget should delete any changes from the Hash that it knows how
91
+ # The drawable should delete any changes from the Hash that it knows how
80
92
  # to incrementally handle, and pass the rest to super. If any changes
81
93
  # go entirely un-handled, a full redraw will be scheduled.
82
94
  # This exists to be overridden by children watching for changes.
83
95
  #
84
96
  # @param changes [Hash] a Hash of new values for properties that have changed
85
97
  def properties_changed(changes)
86
- # If a widget does something really nonstandard with its html_id or element, it will
98
+ # If a drawable does something really nonstandard with its html_id or element, it will
87
99
  # need to override to prevent this from happening. That's easy enough, though.
88
100
  if changes.key?("hidden")
89
101
  hidden = changes.delete("hidden")
90
102
  if hidden
91
103
  html_element.set_style("display", "none")
92
104
  else
93
- new_style = style # Get current display CSS property, which may vary by subclass
94
- disp = new_style[:display]
95
- html_element.set_style("display", disp || "block")
105
+ # With Calzini we can't easily tell what the display property should be.
106
+ # Could be flex or inline, not only block or none. Re-render this drawable.
107
+ needs_update!
96
108
  end
97
109
  end
98
110
 
99
111
  needs_update! unless changes.empty?
100
112
  end
101
113
 
102
- # Give this widget a new parent, including managing the appropriate child lists for parent widgets.
114
+ # Give this drawable a new parent, including managing the appropriate child lists for parent drawables.
103
115
  def set_parent(new_parent)
104
116
  @parent&.remove_child(self)
105
117
  new_parent&.add_child(self)
@@ -108,7 +120,7 @@ class Scarpe
108
120
 
109
121
  # A shorter inspect text for prettier irb output
110
122
  def inspect
111
- "#<#{self.class}:#{self.object_id} @shoes_linkable_id=#{@shoes_linkable_id} @parent=#{@parent.inspect} @children=#{@children.inspect}>"
123
+ "#<#{self.class}:#{self.object_id} @shoes_linkable_id=#{@shoes_linkable_id} @children=#{@children.inspect}>"
112
124
  end
113
125
 
114
126
  protected
@@ -132,55 +144,24 @@ class Scarpe
132
144
  needs_update!
133
145
  end
134
146
 
135
- # Convert an [r, g, b, a] array to an HTML hex color code
136
- # Arrays support alpha. HTML hex does not. So premultiply.
137
- def rgb_to_hex(color)
138
- return color if color.nil?
139
-
140
- r, g, b, a = *color
141
- if r.is_a?(Float)
142
- a ||= 1.0
143
- r_float = r * a
144
- g_float = g * a
145
- b_float = b * a
146
- else
147
- a ||= 255
148
- a_float = (a / 255.0)
149
- r_float = (r.to_f / 255.0) * a_float
150
- g_float = (g.to_f / 255.0) * a_float
151
- b_float = (b.to_f / 255.0) * a_float
152
- end
153
-
154
- r_int = (r_float * 255.0).to_i.clamp(0, 255)
155
- g_int = (g_float * 255.0).to_i.clamp(0, 255)
156
- b_int = (b_float * 255.0).to_i.clamp(0, 255)
157
-
158
- "#%0.2X%0.2X%0.2X" % [r_int, g_int, b_int]
159
- end
160
-
161
- # CSS styles
162
- def style
163
- styles = {}
164
- if @hidden
165
- styles[:display] = "none"
166
- end
167
- styles
168
- end
169
-
170
147
  public
171
148
 
172
- # This gets a mini-webview for just this element and its children, if any.
173
- # It is normally called by the widget itself to do its DOM management.
149
+ # This gets an accessor for just this element's HTML ID.
150
+ # It is normally called by the drawable itself to do its DOM management.
151
+ # Drawables are required to use their html_id for their outermost element,
152
+ # to make sure that remove(), hidden() etc. affect every part of the drawable.
174
153
  #
175
154
  # @return [Scarpe::WebWrangler::ElementWrangler] a DOM object manager
176
155
  def html_element
177
- @elt_wrangler ||= Scarpe::WebWrangler::ElementWrangler.new(html_id)
156
+ @elt_wrangler ||= Scarpe::Webview::WebWrangler::ElementWrangler.new(html_id:)
178
157
  end
179
158
 
180
159
  # Return a promise that guarantees all currently-requested changes have completed
181
160
  #
182
161
  # @return [Scarpe::Promise] a promise that will be fulfilled when all pending changes have finished
183
162
  def promise_update
163
+ # Doesn't matter what ElementWrangler we use -- they all return an update promise
164
+ # that includes all pending updates, no matter who they're for.
184
165
  html_element.promise_update
185
166
  end
186
167
 
@@ -188,7 +169,7 @@ class Scarpe
188
169
  #
189
170
  # @return [String] the HTML ID
190
171
  def html_id
191
- object_id.to_s
172
+ @linkable_id.to_s
192
173
  end
193
174
 
194
175
  # to_html is intended to get the HTML DOM rendering of this object and its children.
@@ -198,50 +179,58 @@ class Scarpe
198
179
  def to_html
199
180
  @children ||= []
200
181
  child_markup = @children.map(&:to_html).join
201
- if respond_to?(:element)
202
- element { child_markup }
203
- else
204
- child_markup
205
- end
182
+ element { child_markup }
206
183
  end
207
184
 
208
185
  # This binds a Scarpe JS callback, handled via a single dispatch point in the app
209
186
  #
210
- # @param event [String] the Scarpe widget event name
187
+ # @param event [String] the Scarpe drawable event name
211
188
  # @yield the block to call when the event occurs
212
189
  def bind(event, &block)
213
- raise("Widget has no linkable_id! #{inspect}") unless linkable_id
190
+ raise(Scarpe::MissingAttributeError, "Drawable has no linkable_id! #{inspect}") unless linkable_id
214
191
 
215
- WebviewDisplayService.instance.app.bind("#{linkable_id}-#{event}", &block)
192
+ DisplayService.instance.app.bind("#{linkable_id}-#{event}", &block)
216
193
  end
217
194
 
218
- # Removes the element from both the Ruby Widget tree and the HTML DOM.
195
+ # Removes the element from both the Ruby Drawable tree and the HTML DOM.
196
+ # Unsubscribe from all Shoes events.
219
197
  # Return a promise for when that HTML change will be visible.
220
198
  #
221
199
  # @return [Scarpe::Promise] a promise that is fulfilled when the HTML change is complete
222
200
  def destroy_self
223
201
  @parent&.remove_child(self)
202
+ unsub_all_shoes_events
224
203
  html_element.remove
225
204
  end
226
205
 
227
- # Request a full redraw of all widgets.
206
+ # Request a full redraw of the entire window, including the entire tree of
207
+ # drawables and the outer "empty page" frame.
208
+ #
209
+ # @return [void]
210
+ def full_window_redraw!
211
+ DisplayService.instance.app.request_redraw!
212
+ end
213
+
214
+ # Request a full redraw of this drawable, including all its children.
215
+ # Can be overridden in drawable subclasses if needed. An override would normally
216
+ # only be needed if re-rendering the element with the given html_id
217
+ # wasn't enough (and then remove would also need to be overridden.)
228
218
  #
229
- # It's really hard to do dirty-tracking here because the redraws are fully asynchronous.
230
- # And so we can't easily cancel one "in flight," and we can't easily pick up the latest
231
- # changes... And we probably don't want to, because we may be halfway through a batch.
219
+ # This occurs by default if a property is changed and the drawable
220
+ # doesn't remove its change in property_changed.
232
221
  #
233
222
  # @return [void]
234
223
  def needs_update!
235
- WebviewDisplayService.instance.app.request_redraw!
224
+ html_element.outer_html = to_html
236
225
  end
237
226
 
238
- # Generate JS code to trigger a specific event name on this widget with the supplies arguments.
227
+ # Generate JS code to trigger a specific event name on this drawable with the supplies arguments.
239
228
  #
240
229
  # @param handler_function_name [String] the event name - @see #bind
241
230
  # @param args [Array] additional arguments that will be passed to the event in the generated JS
242
231
  # @return [String] the generated JS code
243
232
  def handler_js_code(handler_function_name, *args)
244
- raise("Widget has no linkable_id! #{inspect}") unless linkable_id
233
+ raise(Scarpe::MissingAttributeError, "Drawable has no linkable_id! #{inspect}") unless linkable_id
245
234
 
246
235
  js_args = ["'#{linkable_id}-#{handler_function_name}'", *args].join(", ")
247
236
  "scarpeHandler(#{js_args})"
@@ -1,16 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scarpe
4
- class WebviewEditBox < Scarpe::WebviewWidget
5
- attr_reader :text, :height, :width
3
+ module Scarpe::Webview
4
+ class EditBox < Drawable
5
+ attr_reader :text, :height, :width, :tooltip , :font
6
6
 
7
7
  def initialize(properties)
8
8
  super
9
9
 
10
- # The JS handler sends a "change" event, which we forward to the Shoes widget tree
10
+ # The JS handler sends a "change" event, which we forward to the Shoes drawable tree
11
11
  bind("change") do |new_text|
12
12
  send_self_event(new_text, event_name: "change")
13
13
  end
14
+ bind("hover") do
15
+ send_self_event(event_name: "hover")
16
+ end
14
17
  end
15
18
 
16
19
  def properties_changed(changes)
@@ -23,20 +26,7 @@ class Scarpe
23
26
  end
24
27
 
25
28
  def element
26
- oninput = handler_js_code("change", "this.value")
27
-
28
- HTML.render do |h|
29
- h.textarea(id: html_id, oninput: oninput, style: style) { text }
30
- end
31
- end
32
-
33
- protected
34
-
35
- def style
36
- super.merge({
37
- height: Dimensions.length(height),
38
- width: Dimensions.length(width),
39
- }.compact)
29
+ render("edit_box")
40
30
  end
41
31
  end
42
32
  end