scarpe 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. checksums.yaml +4 -4
  2. data/.cursor/rules/commit-style-preferences.mdc +72 -0
  3. data/.cursor/rules/component_context.mdc +82 -0
  4. data/.cursor/rules/debug-failed-tests.mdc +100 -0
  5. data/.cursor/rules/display_service_context.mdc +80 -0
  6. data/.cursor/rules/event_handling_context.mdc +100 -0
  7. data/.cursor/rules/git-pager-handling.mdc +64 -0
  8. data/.cursor/rules/lacci-context.mdc +52 -0
  9. data/.cursor/rules/scarpe_design_context.mdc +46 -0
  10. data/.cursor/rules/shoes_compatibility_context.mdc +75 -0
  11. data/.cursor/rules/timeout_context.mdc +78 -0
  12. data/.cursor/rules/update_lacci_and_wv.mdc +8 -0
  13. data/.cursor/rules/what_is_scarpe.mdc +22 -0
  14. data/.cursor/rules/writing-new-rules.mdc +73 -0
  15. data/CHANGELOG.md +46 -5
  16. data/CLAUDE.md +223 -0
  17. data/Gemfile +2 -2
  18. data/Gemfile.lock +85 -55
  19. data/LICENSE.txt +7 -1
  20. data/README.md +80 -20
  21. data/Rakefile +73 -14
  22. data/docs/SCARPE_FEATURES.md +38 -0
  23. data/docs/_config.yml +13 -0
  24. data/docs/calzini_components_and_updates.md +78 -0
  25. data/docs/display_service_separation.md +39 -0
  26. data/docs/documentation.md +43 -0
  27. data/docs/event_loops.md +66 -0
  28. data/docs/image.png +0 -0
  29. data/docs/index.md +118 -0
  30. data/docs/lacci.md +121 -0
  31. data/docs/scarpe_shoes_incompatibilities.md +71 -0
  32. data/docs/shoes_and_display_events.md +55 -0
  33. data/docs/shoes_implementations.md +79 -0
  34. data/docs/static/manual.md +5 -0
  35. data/docs/static/scarpe-logo.png +0 -0
  36. data/docs/timeouts_and_handlers.md +66 -0
  37. data/docs/web_archaeology.md +76 -0
  38. data/examples/Edit_box_Styles.rb +8 -0
  39. data/examples/Kerning.rb +7 -0
  40. data/examples/background_with_image.rb +14 -5
  41. data/examples/bloopsaphone/working/feepogram.rb +1 -1
  42. data/examples/bloopsaphone/working/le_dance_des_rubis.rb +135 -0
  43. data/examples/bloopsaphone/working/pixel_dreams_in_ruby.rb +131 -0
  44. data/examples/bloopsaphone/working/type_rebellion.rb +157 -0
  45. data/examples/border.rb +11 -0
  46. data/examples/check.rb +2 -0
  47. data/examples/download_and_show_image.rb +3 -0
  48. data/examples/flags/finland.rb +15 -0
  49. data/examples/flags/italy.rb +11 -0
  50. data/examples/flags/mauritius.rb +14 -0
  51. data/examples/font_family.rb +17 -0
  52. data/examples/font_shorthand.rb +9 -0
  53. data/examples/gen.rb +4 -0
  54. data/examples/internal_link_navigation.rb +19 -0
  55. data/examples/legacy/not_checked/shoes-manual/append.rb +10 -0
  56. data/examples/legacy/not_checked/shoes-manual/background_change.rb +12 -0
  57. data/examples/legacy/not_checked/shoes-manual/background_pattern.rb +5 -0
  58. data/examples/legacy/not_checked/shoes-manual/basic_app.rb +8 -0
  59. data/examples/legacy/not_checked/shoes-manual/border.rb +9 -0
  60. data/examples/legacy/not_checked/shoes-manual/builtins/FONTS.rb +5 -0
  61. data/examples/legacy/not_checked/shoes-manual/builtins/ask.rb +2 -0
  62. data/examples/legacy/not_checked/shoes-manual/builtins/ask_color.rb +5 -0
  63. data/examples/legacy/not_checked/shoes-manual/builtins/ask_open_file.rb +5 -0
  64. data/examples/legacy/not_checked/shoes-manual/builtins/ask_save_folder.rb +2 -0
  65. data/examples/legacy/not_checked/shoes-manual/builtins/confirm.rb +4 -0
  66. data/examples/legacy/not_checked/shoes-manual/builtins/debug.rb +2 -0
  67. data/examples/legacy/not_checked/shoes-manual/builtins/info.rb +3 -0
  68. data/examples/legacy/not_checked/shoes-manual/button.rb +9 -0
  69. data/examples/legacy/not_checked/shoes-manual/clear.rb +7 -0
  70. data/examples/legacy/not_checked/shoes-manual/custom_header.rb +13 -0
  71. data/examples/legacy/not_checked/shoes-manual/displace.rb +14 -0
  72. data/examples/legacy/not_checked/shoes-manual/edit_box.rb +8 -0
  73. data/examples/legacy/not_checked/shoes-manual/fill_pattern.rb +5 -0
  74. data/examples/legacy/not_checked/shoes-manual/fonts.rb +7 -0
  75. data/examples/legacy/not_checked/shoes-manual/gutter.rb +6 -0
  76. data/examples/legacy/not_checked/shoes-manual/image_web.rb +4 -0
  77. data/examples/legacy/not_checked/shoes-manual/keypress.rb +7 -0
  78. data/examples/legacy/not_checked/shoes-manual/list_box.rb +10 -0
  79. data/examples/legacy/not_checked/shoes-manual/motion.rb +10 -0
  80. data/examples/legacy/not_checked/shoes-manual/mouse.rb +8 -0
  81. data/examples/legacy/not_checked/shoes-manual/move.rb +14 -0
  82. data/examples/legacy/not_checked/shoes-manual/nested_ovals.rb +8 -0
  83. data/examples/legacy/not_checked/shoes-manual/oval.rb +7 -0
  84. data/examples/legacy/not_checked/shoes-manual/ovals.rb +6 -0
  85. data/examples/legacy/not_checked/shoes-manual/ovals_image.rb +8 -0
  86. data/examples/legacy/not_checked/shoes-manual/prepend.rb +7 -0
  87. data/examples/legacy/not_checked/shoes-manual/progress_bar.rb +10 -0
  88. data/examples/legacy/not_checked/shoes-manual/radio.rb +18 -0
  89. data/examples/legacy/not_checked/shoes-manual/radio_alternative_1.rb +7 -0
  90. data/examples/legacy/not_checked/shoes-manual/radio_alternative_2.rb +9 -0
  91. data/examples/legacy/not_checked/shoes-manual/rotate_rectangle.rb +6 -0
  92. data/examples/legacy/not_checked/shoes-manual/shape.rb +11 -0
  93. data/examples/legacy/not_checked/shoes-manual/static/avatar.png +0 -0
  94. data/examples/legacy/not_checked/shoes-manual/stroke.rb +5 -0
  95. data/examples/legacy/not_checked/shoes-manual/style.rb +3 -0
  96. data/examples/legacy/not_checked/shoes-manual/style_alternative_1.rb +4 -0
  97. data/examples/legacy/not_checked/shoes-manual/style_alternative_2.rb +5 -0
  98. data/examples/legacy/not_checked/shoes-manual/style_length.rb +5 -0
  99. data/examples/legacy/not_checked/shoes-manual/timer.rb +6 -0
  100. data/examples/legacy/not_checked/shoes-manual/trigger_window.rb +8 -0
  101. data/examples/legacy/not_checked/shoes-manual/window_owner.rb +8 -0
  102. data/examples/legacy/working/shoes_manual/alert_button.rb +2 -0
  103. data/examples/legacy/working/shoes_manual/animate.rb +7 -0
  104. data/examples/legacy/working/shoes_manual/background_para.rb +4 -0
  105. data/examples/legacy/working/shoes_manual/button_alternative.rb +7 -0
  106. data/examples/legacy/working/shoes_manual/checkbox.rb +17 -0
  107. data/examples/legacy/working/shoes_manual/download.rb +12 -0
  108. data/examples/legacy/working/shoes_manual/edit_box.rb +6 -0
  109. data/examples/legacy/working/shoes_manual/editline.rb +7 -0
  110. data/examples/legacy/working/shoes_manual/fixed_height.rb +8 -0
  111. data/examples/legacy/working/shoes_manual/fixed_width.rb +12 -0
  112. data/examples/legacy/working/shoes_manual/image.rb +5 -0
  113. data/examples/legacy/working/shoes_manual/instance_variable_check.rb +10 -0
  114. data/examples/legacy/working/shoes_manual/message.rb +18 -0
  115. data/examples/legacy/working/shoes_manual/rectangle.rb +6 -0
  116. data/examples/legacy/working/shoes_manual/save_download.rb +12 -0
  117. data/examples/legacy/working/shoes_manual/self_check.rb +10 -0
  118. data/examples/legacy/working/shoes_manual/stack.rb +7 -0
  119. data/examples/legacy/working/shoes_manual/style_info.rb +8 -0
  120. data/examples/legacy/working/shoes_manual/utf8_support.rb +8 -0
  121. data/examples/legacy/working/shoes_manual/width.rb +4 -0
  122. data/examples/local_assets/multi_image.rb +5 -0
  123. data/examples/local_assets/small.png +0 -0
  124. data/examples/local_fonts.rb +3 -0
  125. data/examples/margin.rb +13 -0
  126. data/examples/margin_check.rb +27 -0
  127. data/examples/oval-with-kwargs.rb +3 -0
  128. data/examples/oval.rb +26 -0
  129. data/examples/page_navigation_single_app.rb +42 -0
  130. data/examples/para_font_styles.rb +17 -0
  131. data/examples/para_font_variant.rb +6 -0
  132. data/examples/para_fontweight.rb +13 -0
  133. data/examples/parse_xl_funnies.rb +3 -0
  134. data/examples/rect.rb +1 -1
  135. data/examples/scarpe_ext.rb +3 -0
  136. data/examples/shapes/star.rb +1 -3
  137. data/examples/shoes_subclass_app.rb +25 -0
  138. data/examples/spacing.rb +1 -1
  139. data/examples/span.rb +4 -2
  140. data/examples/url_routing_example.rb +67 -0
  141. data/lacci/Gemfile +0 -2
  142. data/lacci/Gemfile.lock +4 -32
  143. data/lacci/lacci.gemspec +3 -3
  144. data/lacci/lib/lacci/scarpe_cli.rb +0 -1
  145. data/lacci/lib/lacci/version.rb +1 -1
  146. data/lacci/lib/scarpe/niente/app.rb +12 -1
  147. data/lacci/lib/scarpe/niente/display_service.rb +5 -1
  148. data/lacci/lib/scarpe/niente/drawable.rb +2 -0
  149. data/lacci/lib/scarpe/niente/shoes_spec.rb +10 -5
  150. data/lacci/lib/scarpe/niente.rb +15 -2
  151. data/lacci/lib/shoes/app.rb +204 -105
  152. data/lacci/lib/shoes/constants.rb +24 -2
  153. data/lacci/lib/shoes/display_service.rb +43 -4
  154. data/lacci/lib/shoes/drawable.rb +326 -36
  155. data/lacci/lib/shoes/drawables/arc.rb +4 -26
  156. data/lacci/lib/shoes/drawables/arrow.rb +3 -23
  157. data/lacci/lib/shoes/drawables/border.rb +28 -0
  158. data/lacci/lib/shoes/drawables/button.rb +5 -21
  159. data/lacci/lib/shoes/drawables/check.rb +7 -3
  160. data/lacci/lib/shoes/drawables/document_root.rb +4 -4
  161. data/lacci/lib/shoes/drawables/edit_box.rb +6 -5
  162. data/lacci/lib/shoes/drawables/edit_line.rb +5 -4
  163. data/lacci/lib/shoes/drawables/flow.rb +4 -6
  164. data/lacci/lib/shoes/drawables/font_helper.rb +62 -0
  165. data/lacci/lib/shoes/drawables/image.rb +2 -2
  166. data/lacci/lib/shoes/drawables/line.rb +3 -6
  167. data/lacci/lib/shoes/drawables/link.rb +16 -9
  168. data/lacci/lib/shoes/drawables/list_box.rb +8 -5
  169. data/lacci/lib/shoes/drawables/oval.rb +48 -0
  170. data/lacci/lib/shoes/drawables/para.rb +106 -18
  171. data/lacci/lib/shoes/drawables/progress.rb +2 -1
  172. data/lacci/lib/shoes/drawables/radio.rb +5 -3
  173. data/lacci/lib/shoes/drawables/rect.rb +7 -6
  174. data/lacci/lib/shoes/drawables/shape.rb +4 -3
  175. data/lacci/lib/shoes/drawables/slot.rb +102 -9
  176. data/lacci/lib/shoes/drawables/stack.rb +7 -12
  177. data/lacci/lib/shoes/drawables/star.rb +9 -31
  178. data/lacci/lib/shoes/drawables/text_drawable.rb +93 -34
  179. data/lacci/lib/shoes/drawables/video.rb +3 -2
  180. data/lacci/lib/shoes/drawables/widget.rb +9 -4
  181. data/lacci/lib/shoes/drawables.rb +2 -1
  182. data/lacci/lib/shoes/errors.rb +13 -3
  183. data/lacci/lib/shoes/margin_helper.rb +79 -0
  184. data/lacci/lib/shoes.rb +98 -20
  185. data/lacci/test/.gitignore +1 -0
  186. data/lacci/test/test_draw_context.rb +167 -0
  187. data/lacci/test/test_font_helper.rb +57 -0
  188. data/lacci/test/test_helper.rb +31 -4
  189. data/lacci/test/test_lacci.rb +93 -6
  190. data/lacci/test/test_margin_helper.rb +82 -0
  191. data/lacci/test/test_niente_test_infra.rb +40 -0
  192. data/lacci/test/test_oval.rb +82 -0
  193. data/lacci/test/test_parenting.rb +140 -0
  194. data/lacci/test/test_shoes_errors.rb +15 -13
  195. data/lacci/test/test_text_drawables.rb +23 -0
  196. data/lib/scarpe/assets.rb +19 -0
  197. data/lib/scarpe/cats_cradle.rb +57 -98
  198. data/lib/scarpe/shoes_spec.rb +24 -44
  199. data/lib/scarpe/version.rb +1 -1
  200. data/lib/scarpe/wv/app.rb +1 -0
  201. data/lib/scarpe/wv/arc.rb +0 -4
  202. data/lib/scarpe/wv/border.rb +15 -0
  203. data/lib/scarpe/wv/control_interface.rb +2 -10
  204. data/lib/scarpe/wv/document_root.rb +2 -2
  205. data/lib/scarpe/wv/drawable.rb +6 -40
  206. data/lib/scarpe/wv/edit_box.rb +4 -1
  207. data/lib/scarpe/wv/edit_line.rb +4 -1
  208. data/lib/scarpe/wv/image.rb +2 -5
  209. data/lib/scarpe/wv/link.rb +4 -2
  210. data/lib/scarpe/wv/oval.rb +13 -0
  211. data/lib/scarpe/wv/para.rb +1 -0
  212. data/lib/scarpe/wv/scarpe_extensions.rb +8 -0
  213. data/lib/scarpe/wv/shape.rb +10 -5
  214. data/lib/scarpe/wv/text_drawable.rb +72 -14
  215. data/lib/scarpe/wv/web_wrangler.rb +33 -11
  216. data/lib/scarpe/wv/webview_local_display.rb +6 -2
  217. data/lib/scarpe/wv.rb +16 -2
  218. data/scarpe-components/Gemfile +4 -3
  219. data/scarpe-components/Gemfile.lock +6 -37
  220. data/scarpe-components/README.md +2 -2
  221. data/scarpe-components/assets/bootstrap-themes/bootstrap-cerulean.css +12229 -0
  222. data/scarpe-components/assets/bootstrap-themes/bootstrap-cosmo.css +11810 -0
  223. data/scarpe-components/assets/bootstrap-themes/bootstrap-cyborg.css +12210 -0
  224. data/scarpe-components/assets/bootstrap-themes/bootstrap-darkly.css +12153 -0
  225. data/scarpe-components/assets/bootstrap-themes/bootstrap-flatly.css +12126 -0
  226. data/scarpe-components/assets/bootstrap-themes/bootstrap-icons.min.css +5 -0
  227. data/scarpe-components/assets/bootstrap-themes/bootstrap-journal.css +12099 -0
  228. data/scarpe-components/assets/bootstrap-themes/bootstrap-litera.css +12211 -0
  229. data/scarpe-components/assets/bootstrap-themes/bootstrap-lumen.css +12369 -0
  230. data/scarpe-components/assets/bootstrap-themes/bootstrap-lux.css +11928 -0
  231. data/scarpe-components/assets/bootstrap-themes/bootstrap-materia.css +13184 -0
  232. data/scarpe-components/assets/bootstrap-themes/bootstrap-minty.css +12177 -0
  233. data/scarpe-components/assets/bootstrap-themes/bootstrap-morph.css +12750 -0
  234. data/scarpe-components/assets/bootstrap-themes/bootstrap-pulse.css +11890 -0
  235. data/scarpe-components/assets/bootstrap-themes/bootstrap-quartz.css +12622 -0
  236. data/scarpe-components/assets/bootstrap-themes/bootstrap-sandstone.css +12201 -0
  237. data/scarpe-components/assets/bootstrap-themes/bootstrap-simplex.css +12186 -0
  238. data/scarpe-components/assets/bootstrap-themes/bootstrap-sketchy.css +12451 -0
  239. data/scarpe-components/assets/bootstrap-themes/bootstrap-slate.css +12492 -0
  240. data/scarpe-components/assets/bootstrap-themes/bootstrap-solar.css +12149 -0
  241. data/scarpe-components/assets/bootstrap-themes/bootstrap-spacelab.css +12266 -0
  242. data/scarpe-components/assets/bootstrap-themes/bootstrap-superhero.css +12216 -0
  243. data/scarpe-components/assets/bootstrap-themes/bootstrap-united.css +12077 -0
  244. data/scarpe-components/assets/bootstrap-themes/bootstrap-vapor.css +12549 -0
  245. data/scarpe-components/assets/bootstrap-themes/bootstrap-yeti.css +12325 -0
  246. data/scarpe-components/assets/bootstrap-themes/bootstrap-zephyr.css +12283 -0
  247. data/scarpe-components/assets/bootstrap-themes/bootstrap.bundle.min.js +7 -0
  248. data/scarpe-components/lib/scarpe/components/asset_server.rb +219 -0
  249. data/scarpe-components/lib/scarpe/components/base64.rb +22 -0
  250. data/scarpe-components/lib/scarpe/components/calzini/{art_widgets.rb → art_drawables.rb} +42 -18
  251. data/scarpe-components/lib/scarpe/components/calzini/border.rb +38 -0
  252. data/scarpe-components/lib/scarpe/components/calzini/button.rb +6 -8
  253. data/scarpe-components/lib/scarpe/components/calzini/misc.rb +14 -16
  254. data/scarpe-components/lib/scarpe/components/calzini/para.rb +218 -11
  255. data/scarpe-components/lib/scarpe/components/calzini/slots.rb +16 -60
  256. data/scarpe-components/lib/scarpe/components/calzini.rb +88 -1
  257. data/scarpe-components/lib/scarpe/components/errors.rb +4 -0
  258. data/scarpe-components/lib/scarpe/components/html.rb +4 -1
  259. data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +11 -3
  260. data/scarpe-components/lib/scarpe/components/minitest_result.rb +41 -0
  261. data/scarpe-components/lib/scarpe/components/port_helpers.rb +30 -0
  262. data/scarpe-components/lib/scarpe/components/print_logger.rb +17 -2
  263. data/scarpe-components/lib/scarpe/components/process_helpers.rb +37 -0
  264. data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +1 -1
  265. data/scarpe-components/lib/scarpe/components/tiranti.rb +42 -100
  266. data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +3 -1
  267. data/scarpe-components/lib/scarpe/components/version.rb +1 -1
  268. data/scarpe-components/scarpe-components.gemspec +1 -1
  269. data/scarpe-components/test/assets/big-image.png +0 -0
  270. data/scarpe-components/test/assets/big-stylesheet.css +497 -0
  271. data/scarpe-components/test/assets/little-image.png +0 -0
  272. data/scarpe-components/test/assets/little-stylesheet.css +1 -0
  273. data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +7 -7
  274. data/scarpe-components/test/calzini/test_calzini_button.rb +7 -5
  275. data/scarpe-components/test/calzini/test_calzini_misc.rb +9 -9
  276. data/scarpe-components/test/calzini/test_calzini_para.rb +6 -9
  277. data/scarpe-components/test/calzini/test_calzini_slots.rb +12 -57
  278. data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +83 -18
  279. data/scarpe-components/test/calzini/test_various.rb +133 -0
  280. data/scarpe-components/test/test_asset_server.rb +72 -0
  281. data/scarpe-components/test/test_components.rb +31 -2
  282. data/scarpe-components/test/test_helper.rb +0 -1
  283. data/scarpe-components/test/test_minitest_result.rb +7 -0
  284. data/scarpe-components/test/test_port_helpers.rb +12 -0
  285. data/scarpe-components/test/test_segmented_app_files.rb +2 -0
  286. data/tasks/check_html_fixtures.rb +140 -0
  287. data/tasks/regenerate_html_fixtures.rb +104 -0
  288. data/templates/class_template_with_shapes.erb +0 -11
  289. metadata +225 -39
  290. data/.rubocop.yml +0 -88
  291. data/lacci/lib/scarpe/niente/logger.rb +0 -29
  292. data/lacci/lib/shoes/drawables/span.rb +0 -27
  293. data/lacci/lib/shoes/spacing.rb +0 -9
  294. data/lib/scarpe/evented_assertions.rb +0 -121
  295. data/lib/scarpe/wv/span.rb +0 -44
  296. data/scarpe-components/lib/scarpe/components/calzini/text_widgets.rb +0 -65
  297. /data/examples/legacy/{not_checked → working}/shoes3-tests/editline/editline.rb +0 -0
@@ -5,17 +5,21 @@ class Shoes
5
5
  shoes_styles :checked
6
6
  shoes_events :click
7
7
 
8
- def initialize(checked = nil, &block)
8
+ init_args
9
+ opt_init_args :checked
10
+ def initialize(*args, **kwargs, &block)
9
11
  @block = block
10
12
  super
11
13
 
12
- bind_self_event("click") { click }
14
+ bind_self_event("click") do
15
+ self.checked = !checked?
16
+ @block.call(self) if @block
17
+ end
13
18
  create_display_drawable
14
19
  end
15
20
 
16
21
  def click(&block)
17
22
  @block = block
18
- self.checked = !checked?
19
23
  end
20
24
 
21
25
  def checked?
@@ -4,11 +4,11 @@ class Shoes
4
4
  class DocumentRoot < Shoes::Flow
5
5
  shoes_events # No DocumentRoot-specific events yet
6
6
 
7
- def initialize
8
- @height = "100%"
9
- @width = @margin = @padding = nil
10
- @options = {}
7
+ Shoes::Drawable.drawable_default_styles[Shoes::DocumentRoot][:height] = "100%"
8
+ Shoes::Drawable.drawable_default_styles[Shoes::DocumentRoot][:width] = "100%"
11
9
 
10
+ init_args
11
+ def initialize(**kwargs, &block)
12
12
  super
13
13
  end
14
14
 
@@ -2,13 +2,14 @@
2
2
 
3
3
  class Shoes
4
4
  class EditBox < Shoes::Drawable
5
- shoes_styles :text, :height, :width
5
+ shoes_styles :text, :height, :width ,:tooltip, :font
6
6
  shoes_events :change
7
7
 
8
- def initialize(text = "", height: nil, width: nil, &block)
9
- super
10
- @text = text
8
+ init_args
9
+ opt_init_args :text
10
+ def initialize(*args, **kwargs, &block)
11
11
  @callback = block
12
+ super
12
13
 
13
14
  bind_self_event("change") do |new_text|
14
15
  self.text = new_text
@@ -23,7 +24,7 @@ class Shoes
23
24
  end
24
25
 
25
26
  def append(new_text)
26
- self.text = self.text + new_text
27
+ self.text = (self.text || "") + new_text
27
28
  end
28
29
  end
29
30
  end
@@ -2,13 +2,14 @@
2
2
 
3
3
  class Shoes
4
4
  class EditLine < Shoes::Drawable
5
- shoes_styles :text, :width
5
+ shoes_styles :text, :width, :font, :tooltip, :stroke, :secret
6
6
  shoes_events :change
7
7
 
8
- def initialize(text = "", width: nil, &block)
9
- super
8
+ init_args
9
+ opt_init_args :text
10
+ def initialize(*args, **kwargs, &block)
10
11
  @block = block
11
- @text = text
12
+ super
12
13
 
13
14
  bind_self_event("change") do |new_text|
14
15
  self.text = new_text
@@ -3,20 +3,18 @@
3
3
  class Shoes
4
4
  class Flow < Shoes::Slot
5
5
  include Shoes::Background
6
- include Shoes::Border
7
- include Shoes::Spacing
8
6
 
9
- shoes_styles :width, :height, :margin, :padding
7
+ Shoes::Drawable.drawable_default_styles[Shoes::Flow][:width] = "100%"
8
+
10
9
  shoes_events
11
10
 
12
- def initialize(width: "100%", height: nil, margin: nil, padding: nil, **options, &block)
11
+ def initialize(*args, **kwargs, &block)
13
12
  super
14
- @options = options
15
13
 
16
14
  # Create the display-side drawable *before* instance_eval, which will add child drawables with their display drawables
17
15
  create_display_drawable
18
16
 
19
- Shoes::App.instance.with_slot(self, &block) if block_given?
17
+ @app.with_slot(self, &block) if block_given?
20
18
  end
21
19
  end
22
20
  end
@@ -0,0 +1,62 @@
1
+ module FontHelper
2
+
3
+ def parse_font(font)
4
+
5
+ input = font
6
+ regex = /\s+(?=(?:[^']*'[^']*')*[^']*$)(?![^']*,[^']*')/
7
+ result = input.split(regex)
8
+
9
+ fs = nil
10
+ fv = nil
11
+ fw = nil
12
+ fss = nil
13
+ ff = ""
14
+
15
+ fos = ["italic", "oblique"]
16
+ fov = ["small-caps", "initial", "inherit"]
17
+ fow = ["bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
18
+ foss = ["xx-small", "x-small", "small","large", "x-large", "xx-large", "smaller", "larger"]
19
+
20
+ result.each do |i|
21
+ if fos.include?(i)
22
+ fs = i
23
+ next
24
+ elsif fov.include?(i)
25
+ fv = i
26
+ next
27
+ elsif fow.include?(i)
28
+ fw = i
29
+ next
30
+ elsif foss.include?(i)
31
+ fss = i
32
+ next
33
+ else
34
+ if contains_number?(i)
35
+
36
+ fss=i;
37
+
38
+ elsif i != "normal" && i != "medium" && i.strip != ""
39
+
40
+ if ff == "Arial"
41
+
42
+ ff = i
43
+
44
+ else
45
+
46
+ ff = ff+" "+i
47
+
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ [fs, fv , fw , fss , ff.strip]
55
+ end
56
+
57
+ def contains_number?(str)
58
+
59
+ !!(str =~ /\d/)
60
+
61
+ end
62
+ end
@@ -5,9 +5,9 @@ class Shoes
5
5
  shoes_styles :url, :width, :height, :top, :left, :click
6
6
  shoes_events # No Image-specific events yet
7
7
 
8
- def initialize(url, width: nil, height: nil, top: nil, left: nil, click: nil)
8
+ init_args :url
9
+ def initialize(*args, **kwargs)
9
10
  super
10
- @url = url
11
11
 
12
12
  # Get the image dimensions
13
13
  # @width, @height = size
@@ -5,14 +5,11 @@ class Shoes
5
5
  shoes_styles :left, :top, :x2, :y2, :draw_context
6
6
  shoes_events # No Line-specific events yet
7
7
 
8
- def initialize(left, top, x2, y2)
8
+ init_args :left, :top, :x2, :y2
9
+ def initialize(*args, **kwargs)
9
10
  super
10
11
 
11
- @left = left
12
- @top = top
13
- @x2 = x2
14
- @y2 = y2
15
- @draw_context = Shoes::App.instance.current_draw_context
12
+ @draw_context = @app.current_draw_context
16
13
 
17
14
  create_display_drawable
18
15
  end
@@ -5,22 +5,29 @@ class Shoes
5
5
  shoes_styles :text, :click, :has_block
6
6
  shoes_events :click
7
7
 
8
- def initialize(text, click: nil, &block)
9
- super
8
+ #Shoes::Drawable.drawable_default_styles[Shoes::Link][:click] = "#"
10
9
 
11
- @text = text
10
+ init_args # Empty by the time it reaches Drawable#initialize
11
+ def initialize(*args, **kwargs, &block)
12
12
  @block = block
13
+
14
+ # Check if click is an internal route (starts with /)
15
+ click_value = kwargs[:click]
16
+ @internal_route = click_value.is_a?(String) && click_value.start_with?("/")
17
+
13
18
  # We can't send a block to the display drawable, but we can send a boolean
14
- @has_block = !block.nil?
19
+ # Also set has_block if we have an internal route (so display uses onclick, not href)
20
+ @has_block = !block.nil? || @internal_route
15
21
 
16
- # The click property should be changed before it gets sent to the display drawable
17
- @click ||= "#"
22
+ super
18
23
 
19
24
  bind_self_event("click") do
25
+ if @internal_route
26
+ # Navigate to the internal route
27
+ app.visit(@click)
28
+ end
20
29
  @block&.call
21
30
  end
22
-
23
- create_display_drawable
24
31
  end
25
32
  end
26
33
 
@@ -28,7 +35,7 @@ class Shoes
28
35
  # hovered over. The functionality isn't present in Lacci yet.
29
36
  class LinkHover < Link
30
37
  def initialize
31
- raise "This class should never be instantiated! Use link, not link_hover!"
38
+ raise "This class should never be instantiated directly! Use link, not link_hover!"
32
39
  end
33
40
  end
34
41
  end
@@ -11,11 +11,14 @@ class Shoes
11
11
 
12
12
  shoes_events :change
13
13
 
14
- def initialize(**args, &block)
15
- super
16
-
17
- @items = args[:items] || []
18
- @chosen = args[:choose] || args[:items]&.first
14
+ init_args # No positional args
15
+ def initialize(**kwargs, &block)
16
+ # These aren't being set as styles -- remove them from kwargs before calling super
17
+ # TODO: set [] as default value for items?
18
+ @items = kwargs.delete(:items) || []
19
+ @chosen = kwargs.delete(:choose) || @items&.first
20
+
21
+ super(**kwargs, &block)
19
22
 
20
23
  bind_self_event("change") do |new_item|
21
24
  self.chosen = new_item
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ # Docs: https://github.com/scarpe-team/scarpe/blob/main/docs/static/manual.md#ovalleft-top-radius--shoesshape
5
+ class Oval < Shoes::Drawable
6
+ shoes_styles :center, :draw_context, :stroke, :fill
7
+
8
+ shoes_style(:left) { |val| convert_to_integer(val, "left") }
9
+ shoes_style(:top) { |val| convert_to_integer(val, "top") }
10
+ shoes_style(:radius) { |val| convert_to_integer(val, "radius") }
11
+ shoes_style(:height) { |val| convert_to_integer(val, "height") }
12
+ shoes_style(:width) { |val| convert_to_integer(val, "width") }
13
+ shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") }
14
+
15
+ Shoes::Drawable.drawable_default_styles[Shoes::Oval][:fill] = "black"
16
+ Shoes::Drawable.drawable_default_styles[Shoes::Oval][:stroke] = "black"
17
+
18
+ init_args :left, :top
19
+ opt_init_args :radius, :height
20
+ def initialize(*args, **options)
21
+ super # Parse any positional or keyword args
22
+
23
+ @draw_context = @app.current_draw_context
24
+
25
+ unless @left && @top && (@width || @height || @radius)
26
+ raise Shoes::Errors::InvalidAttributeValueError, "Oval requires left, top and one of (width, height, radius) to be specified!"
27
+ end
28
+
29
+ # Calzini expects "radius" to mean the x-axis-aligned radius, not y-axis-aligned.
30
+ # For an axis-aligned oval the two may be different.
31
+
32
+ # If we have no width, but a radius, default the width to be the radius * 2
33
+ @width ||= @radius * 2 if @radius
34
+
35
+ # We now know we have width or height, but maybe not both.
36
+
37
+ # Default to a circle - set height from width or vice-versa
38
+ @width ||= @height
39
+ @height ||= @width
40
+
41
+ # If we don't have radius yet, set it from width
42
+ @radius ||= @width / 2
43
+
44
+ create_display_drawable
45
+ end
46
+
47
+ end
48
+ end
@@ -1,24 +1,34 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require_relative 'font_helper.rb'
3
3
  class Shoes
4
- class Para < Shoes::Drawable
5
- shoes_styles :text_items, :size, :font, :html_attributes, :hidden
6
- shoes_style(:stroke) { |val| Shoes::Colors.to_rgb(val) }
4
+ class Para < Shoes::Drawable
5
+ include FontHelper
6
+ shoes_styles :text_items, :size, :family, :font_weight, :font, :font_variant, :emphasis, :kerning
7
+ shoes_style(:stroke) { |val, _name| Shoes::Colors.to_rgb(val) }
8
+ shoes_style(:fill) { |val, _name| Shoes::Colors.to_rgb(val) }
9
+
10
+ shoes_style(:align) do |val|
11
+ unless ["left", "center", "right"].include?(val)
12
+ raise(Shoes::Errors::InvalidAttributeValueError, "Align must be one of left, center or right!")
13
+ end
14
+ val
15
+ end
16
+
17
+ Shoes::Drawable.drawable_default_styles[Shoes::Para][:size] = :para
7
18
 
8
19
  shoes_events # No Para-specific events yet
9
20
 
10
- # Initializes a new instance of the `Para` widget.
21
+ # Initializes a new instance of the `Para` drawable. There are different
22
+ # methods to instantiate slightly different styles of Para, such as
23
+ # `tagline`, `caption` and `subtitle`. These will always be different
24
+ # sizes, but may be generally styled differently for some display services.
11
25
  #
12
26
  # @param args The text content of the paragraph.
13
- # @param stroke [String, nil] The color of the text stroke.
14
- # @param size [Symbol] The size of the paragraph text.
15
- # @param font [String, nil] The font of the paragraph text.
16
- # @param hidden [Boolean] Determines if the paragraph is initially hidden.
17
- # @param html_attributes [Hash] Additional HTML attributes for the paragraph.
27
+ # @param kwargs [Hash] the various Shoes styles for this paragraph.
18
28
  #
19
29
  # @example
20
30
  # Shoes.app do
21
- # p = para "Hello, This is at the top!", stroke: "red", size: :title, font: "Arial"
31
+ # p = para "Hello, This is at the top!", stroke: red, size: :title, font: "Arial"
22
32
  #
23
33
  # banner("Welcome to Shoes!")
24
34
  # title("Shoes Examples")
@@ -29,22 +39,60 @@ class Shoes
29
39
  #
30
40
  # p.replace "On top we'll switch to ", strong("bold"), "!"
31
41
  # end
32
- def initialize(*args, stroke: nil, size: :para, font: nil, **html_attributes)
33
- super
42
+
43
+ def initialize(*args, **kwargs)
44
+
45
+ if kwargs[:font]
46
+ arr= parse_font(kwargs[:font])
47
+
48
+ if arr[0] != nil
49
+
50
+ kwargs[:emphasis] = arr[0]
51
+
52
+ end
53
+
54
+ if arr[1] != nil
55
+
56
+ kwargs[:font_variant] = arr[1]
57
+
58
+ end
59
+
60
+ if arr[2] != nil
61
+
62
+ kwargs[:font_weight] = arr[2]
63
+
64
+ end
65
+
66
+ if arr[3] != nil
67
+
68
+ kwargs[:size] = arr[3]
69
+
70
+ end
34
71
 
72
+ if arr[4] != ""
73
+
74
+ kwargs[:family] = arr[4]
75
+
76
+ end
77
+
78
+ end
79
+
80
+ # Don't pass text_children args to Drawable#initialize
81
+ super(*[], **kwargs)
82
+
35
83
  # Text_children alternates strings and TextDrawables, so we can't just pass
36
84
  # it as a Shoes style. It won't serialize.
37
85
  update_text_children(args)
38
86
 
39
- @html_attributes = html_attributes || {}
40
-
41
87
  create_display_drawable
42
88
  end
43
89
 
90
+
91
+
44
92
  private
45
93
 
46
94
  def text_children_to_items(text_children)
47
- text_children.map { |arg| arg.is_a?(String) ? arg : arg.linkable_id }
95
+ text_children.map { |arg| arg.is_a?(TextDrawable) ? arg.linkable_id : arg.to_s }
48
96
  end
49
97
 
50
98
  public
@@ -67,10 +115,20 @@ class Shoes
67
115
  update_text_children(children)
68
116
  end
69
117
 
118
+ # Return the text, but not the styling, of the para's
119
+ # contents. For example, if the contents had strong
120
+ # and emphasized text, the bold and emphasized would
121
+ # be removed but the text would be returned.
122
+ #
123
+ # @return [String] the text from this para
70
124
  def text
71
125
  @text_children.map(&:to_s).join
72
126
  end
73
127
 
128
+ # Return the text but not styling from the para. This
129
+ # is the same as #text.
130
+ #
131
+ # @return [String] the text from this para
74
132
  def to_s
75
133
  self.text
76
134
  end
@@ -84,35 +142,65 @@ class Shoes
84
142
  # This should signal the display drawable to change
85
143
  self.text_items = text_children_to_items(@text_children)
86
144
  end
145
+
146
+
87
147
  end
88
148
  end
89
149
 
90
150
  class Shoes
91
151
  class Drawable
152
+ # Return a banner-sized para. This can use all the normal
153
+ # Para styles and arguments. See {Para#initialize} for
154
+ # details.
155
+ #
156
+ # @return [Shoes::Para] the new para drawable
92
157
  def banner(*args, **kwargs)
93
158
  para(*args, **{ size: :banner }.merge(kwargs))
94
159
  end
95
160
 
161
+ # Return a title-sized para. This can use all the normal
162
+ # Para styles and arguments. See {Para#initialize} for
163
+ # details.
164
+ #
165
+ # @return [Shoes::Para] the new para drawable
96
166
  def title(*args, **kwargs)
97
167
  para(*args, **{ size: :title }.merge(kwargs))
98
168
  end
99
169
 
170
+ # Return a subtitle-sized para. This can use all the normal
171
+ # Para styles and arguments. See {Para#initialize} for
172
+ # details.
173
+ #
174
+ # @return [Shoes::Para] the new para drawable
100
175
  def subtitle(*args, **kwargs)
101
176
  para(*args, **{ size: :subtitle }.merge(kwargs))
102
177
  end
103
178
 
179
+ # Return a tagline-sized para. This can use all the normal
180
+ # Para styles and arguments. See {Para#initialize} for
181
+ # details.
182
+ #
183
+ # @return [Shoes::Para] the new para drawable
104
184
  def tagline(*args, **kwargs)
105
185
  para(*args, **{ size: :tagline }.merge(kwargs))
106
186
  end
107
187
 
188
+ # Return a caption-sized para. This can use all the normal
189
+ # Para styles and arguments. See {Para#initialize} for
190
+ # details.
191
+ #
192
+ # @return [Shoes::Para] the new para drawable
108
193
  def caption(*args, **kwargs)
109
194
  para(*args, **{ size: :caption }.merge(kwargs))
110
195
  end
111
196
 
197
+ # Return an inscription-sized para. This can use all the normal
198
+ # Para styles and arguments. See {Para#initialize} for
199
+ # details.
200
+ #
201
+ # @return [Shoes::Para] the new para drawable
112
202
  def inscription(*args, **kwargs)
113
203
  para(*args, **{ size: :inscription }.merge(kwargs))
114
204
  end
115
-
116
- alias_method :ins, :inscription
117
205
  end
118
206
  end
@@ -5,7 +5,8 @@ class Shoes
5
5
  shoes_styles :fraction
6
6
  shoes_events # No Progress-specific events yet
7
7
 
8
- def initialize(fraction: nil)
8
+ init_args # No positional args
9
+ def initialize(**kwargs)
9
10
  super
10
11
 
11
12
  create_display_drawable
@@ -8,11 +8,13 @@ class Shoes
8
8
  shoes_styles :group, :checked
9
9
  shoes_events :click
10
10
 
11
- def initialize(group = nil, checked: nil, &block)
12
- super
13
- @group = group
11
+ init_args
12
+ opt_init_args :group
13
+ def initialize(*args, **kwargs, &block)
14
14
  @block = block
15
15
 
16
+ super
17
+
16
18
  bind_self_event("click") { click }
17
19
  create_display_drawable
18
20
  end
@@ -2,14 +2,15 @@
2
2
 
3
3
  class Shoes
4
4
  class Rect < Shoes::Drawable
5
- shoes_styles :left, :top, :width, :height, :draw_context, :curve
6
- shoes_events # No Rect-specific events yet
7
-
8
- def initialize(*args)
9
- @draw_context = Shoes::App.instance.current_draw_context
5
+ shoes_styles :draw_context, :curve, :stroke, :fill
6
+ shoes_events # No Rect-specific events
10
7
 
8
+ init_args :left, :top, :width, :height
9
+ opt_init_args :curve
10
+ def initialize(*args, **kwargs)
11
11
  super
12
- self.left, self.top, self.width, self.height, self.curve = args
12
+
13
+ @draw_context = @app.current_draw_context
13
14
 
14
15
  create_display_drawable
15
16
  end
@@ -13,14 +13,15 @@ class Shoes
13
13
  shoes_styles :left, :top, :shape_commands, :draw_context
14
14
  shoes_events # No Shape-specific events yet
15
15
 
16
- def initialize(left: nil, top: nil, &block)
16
+ init_args # No positional args
17
+ def initialize(**kwargs, &block)
17
18
  @shape_commands = []
18
- @draw_context = Shoes::App.instance.current_draw_context
19
19
 
20
20
  super
21
+ @draw_context = @app.current_draw_context
21
22
  create_display_drawable
22
23
 
23
- Shoes::App.instance.with_slot(self, &block) if block_given?
24
+ @app.with_slot(self, &block) if block_given?
24
25
  end
25
26
 
26
27
  # The cmd should be an array of the form: