glimmer-dsl-swt 4.22.1.1 → 4.22.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +15 -12
  5. data/RUBY_VERSION +1 -1
  6. data/VERSION +1 -1
  7. data/bin/girb +1 -1
  8. data/bin/girb_runner.rb +1 -1
  9. data/bin/glimmer +1 -1
  10. data/bin/glimmer-setup +1 -1
  11. data/docs/reference/GLIMMER_COMMAND.md +20 -6
  12. data/docs/reference/GLIMMER_CONFIGURATION.md +1 -1
  13. data/docs/reference/GLIMMER_GIRB.md +2 -2
  14. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +646 -94
  15. data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +13 -32
  16. data/docs/reference/GLIMMER_SAMPLES.md +25 -9
  17. data/docs/reference/GLIMMER_STYLE_GUIDE.md +6 -0
  18. data/glimmer-dsl-swt.gemspec +0 -0
  19. data/lib/ext/glimmer/config.rb +1 -1
  20. data/lib/ext/glimmer.rb +4 -4
  21. data/lib/ext/rouge/themes/glimmer.rb +21 -0
  22. data/lib/glimmer/Rakefile +6 -6
  23. data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
  24. data/lib/glimmer/data_binding/observable_widget.rb +1 -1
  25. data/lib/glimmer/data_binding/table_items_binding.rb +1 -1
  26. data/lib/glimmer/data_binding/tree_items_binding.rb +1 -1
  27. data/lib/glimmer/data_binding/widget_binding.rb +1 -1
  28. data/lib/glimmer/dsl/swt/animation_expression.rb +1 -1
  29. data/lib/glimmer/dsl/swt/async_exec_expression.rb +1 -1
  30. data/lib/glimmer/dsl/swt/auto_exec_expression.rb +1 -1
  31. data/lib/glimmer/dsl/swt/bind_expression.rb +1 -1
  32. data/lib/glimmer/dsl/swt/block_property_expression.rb +1 -1
  33. data/lib/glimmer/dsl/swt/c_tab_item_expression.rb +1 -1
  34. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +1 -1
  35. data/lib/glimmer/dsl/swt/color_expression.rb +1 -1
  36. data/lib/glimmer/dsl/swt/column_properties_expression.rb +1 -1
  37. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +1 -1
  38. data/lib/glimmer/dsl/swt/cursor_expression.rb +1 -1
  39. data/lib/glimmer/dsl/swt/custom_shape_expression.rb +1 -1
  40. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
  41. data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -1
  42. data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -1
  43. data/lib/glimmer/dsl/swt/display_expression.rb +1 -1
  44. data/lib/glimmer/dsl/swt/dnd_expression.rb +1 -1
  45. data/lib/glimmer/dsl/swt/dsl.rb +2 -2
  46. data/lib/glimmer/dsl/swt/exec_expression.rb +2 -3
  47. data/lib/glimmer/dsl/swt/expand_item_expression.rb +1 -1
  48. data/lib/glimmer/dsl/swt/font_expression.rb +1 -1
  49. data/lib/glimmer/dsl/swt/image_expression.rb +1 -1
  50. data/lib/glimmer/dsl/swt/layout_data_expression.rb +1 -1
  51. data/lib/glimmer/dsl/swt/layout_expression.rb +1 -1
  52. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +1 -1
  53. data/lib/glimmer/dsl/swt/listener_expression.rb +1 -1
  54. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +1 -1
  55. data/lib/glimmer/dsl/swt/menu_expression.rb +1 -1
  56. data/lib/glimmer/dsl/swt/message_box_expression.rb +1 -1
  57. data/lib/glimmer/dsl/swt/multiply_expression.rb +1 -1
  58. data/lib/glimmer/dsl/swt/observe_expression.rb +1 -1
  59. data/lib/glimmer/dsl/swt/pixel_expression.rb +1 -1
  60. data/lib/glimmer/dsl/swt/property_expression.rb +1 -1
  61. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
  62. data/lib/glimmer/dsl/swt/rgb_expression.rb +1 -1
  63. data/lib/glimmer/dsl/swt/rgba_expression.rb +1 -1
  64. data/lib/glimmer/dsl/swt/shape_expression.rb +2 -1
  65. data/lib/glimmer/dsl/swt/shell_expression.rb +1 -1
  66. data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +4 -9
  67. data/lib/glimmer/dsl/swt/swt_expression.rb +1 -1
  68. data/lib/glimmer/dsl/swt/sync_call_expression.rb +1 -1
  69. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +1 -1
  70. data/lib/glimmer/dsl/swt/tab_item_expression.rb +1 -1
  71. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +1 -1
  72. data/lib/glimmer/dsl/swt/timer_exec_expression.rb +1 -1
  73. data/lib/glimmer/dsl/swt/transform_expression.rb +1 -1
  74. data/lib/glimmer/dsl/swt/tray_expression.rb +1 -1
  75. data/lib/glimmer/dsl/swt/tray_item_expression.rb +1 -1
  76. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +1 -1
  77. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +1 -1
  78. data/lib/glimmer/dsl/swt/widget_expression.rb +1 -1
  79. data/lib/glimmer/launcher.rb +2 -2
  80. data/lib/glimmer/rake_task/list.rb +1 -1
  81. data/lib/glimmer/rake_task/package.rb +1 -1
  82. data/lib/glimmer/rake_task/scaffold.rb +2 -3
  83. data/lib/glimmer/rake_task.rb +1 -1
  84. data/lib/glimmer/swt/c_tab_item_proxy.rb +1 -1
  85. data/lib/glimmer/swt/color_proxy.rb +1 -1
  86. data/lib/glimmer/swt/combo_proxy.rb +1 -1
  87. data/lib/glimmer/swt/cursor_proxy.rb +1 -1
  88. data/lib/glimmer/swt/custom/animation.rb +1 -1
  89. data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
  90. data/lib/glimmer/swt/custom/code_text.rb +1 -1
  91. data/lib/glimmer/swt/custom/drawable.rb +1 -1
  92. data/lib/glimmer/swt/custom/radio_group.rb +1 -1
  93. data/lib/glimmer/swt/custom/shape/arc.rb +1 -1
  94. data/lib/glimmer/swt/custom/shape/cubic.rb +1 -1
  95. data/lib/glimmer/swt/custom/shape/focus.rb +1 -1
  96. data/lib/glimmer/swt/custom/shape/image.rb +1 -1
  97. data/lib/glimmer/swt/custom/shape/line.rb +1 -1
  98. data/lib/glimmer/swt/custom/shape/oval.rb +1 -1
  99. data/lib/glimmer/swt/custom/shape/path.rb +1 -1
  100. data/lib/glimmer/swt/custom/shape/path_segment.rb +1 -1
  101. data/lib/glimmer/swt/custom/shape/point.rb +1 -1
  102. data/lib/glimmer/swt/custom/shape/polygon.rb +1 -1
  103. data/lib/glimmer/swt/custom/shape/polyline.rb +1 -1
  104. data/lib/glimmer/swt/custom/shape/quad.rb +1 -1
  105. data/lib/glimmer/swt/custom/shape/rectangle.rb +1 -1
  106. data/lib/glimmer/swt/custom/shape/text.rb +1 -1
  107. data/lib/glimmer/swt/custom/shape.rb +2 -1
  108. data/lib/glimmer/swt/date_time_proxy.rb +1 -1
  109. data/lib/glimmer/swt/dialog_proxy.rb +1 -1
  110. data/lib/glimmer/swt/display_proxy.rb +1 -1
  111. data/lib/glimmer/swt/dnd_proxy.rb +1 -1
  112. data/lib/glimmer/swt/expand_item_proxy.rb +1 -1
  113. data/lib/glimmer/swt/font_proxy.rb +1 -1
  114. data/lib/glimmer/swt/image_proxy.rb +1 -1
  115. data/lib/glimmer/swt/layout_data_proxy.rb +1 -1
  116. data/lib/glimmer/swt/layout_proxy.rb +1 -1
  117. data/lib/glimmer/swt/menu_proxy.rb +1 -1
  118. data/lib/glimmer/swt/message_box_proxy.rb +1 -1
  119. data/lib/glimmer/swt/packages.rb +1 -1
  120. data/lib/glimmer/swt/properties.rb +1 -1
  121. data/lib/glimmer/swt/proxy_properties.rb +1 -1
  122. data/lib/glimmer/swt/sash_form_proxy.rb +1 -1
  123. data/lib/glimmer/swt/scrolled_composite_proxy.rb +1 -1
  124. data/lib/glimmer/swt/shape_listener_proxy.rb +1 -1
  125. data/lib/glimmer/swt/shell_proxy.rb +2 -1
  126. data/lib/glimmer/swt/style_constantizable.rb +1 -1
  127. data/lib/glimmer/swt/styled_text_proxy.rb +1 -1
  128. data/lib/glimmer/swt/swt_proxy.rb +1 -1
  129. data/lib/glimmer/swt/tab_folder_proxy.rb +1 -1
  130. data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
  131. data/lib/glimmer/swt/table_column_proxy.rb +1 -1
  132. data/lib/glimmer/swt/table_proxy.rb +1 -1
  133. data/lib/glimmer/swt/tool_bar_proxy.rb +1 -1
  134. data/lib/glimmer/swt/transform_proxy.rb +1 -1
  135. data/lib/glimmer/swt/tray_item_proxy.rb +1 -1
  136. data/lib/glimmer/swt/tray_proxy.rb +1 -1
  137. data/lib/glimmer/swt/tree_proxy.rb +1 -1
  138. data/lib/glimmer/swt/widget_listener_proxy.rb +1 -1
  139. data/lib/glimmer/swt/widget_proxy.rb +1 -1
  140. data/lib/glimmer/ui/custom_shape.rb +1 -1
  141. data/lib/glimmer/ui/custom_shell.rb +1 -1
  142. data/lib/glimmer/ui/custom_widget.rb +1 -1
  143. data/lib/glimmer/ui.rb +21 -0
  144. data/lib/glimmer/util/proc_tracker.rb +4 -4
  145. data/lib/glimmer-dsl-swt.rb +1 -1
  146. data/samples/elaborate/battleship/model/cell.rb +1 -1
  147. data/samples/elaborate/battleship/model/game.rb +1 -1
  148. data/samples/elaborate/battleship/model/grid.rb +1 -1
  149. data/samples/elaborate/battleship/model/ship.rb +1 -1
  150. data/samples/elaborate/battleship/model/ship_collection.rb +1 -1
  151. data/samples/elaborate/battleship/view/action_panel.rb +1 -1
  152. data/samples/elaborate/battleship/view/cell.rb +1 -1
  153. data/samples/elaborate/battleship/view/grid.rb +1 -1
  154. data/samples/elaborate/battleship/view/ship.rb +1 -1
  155. data/samples/elaborate/battleship/view/ship_collection.rb +1 -1
  156. data/samples/elaborate/battleship.rb +1 -1
  157. data/samples/elaborate/calculator.rb +1 -1
  158. data/samples/elaborate/clock.rb +1 -1
  159. data/samples/elaborate/connect4/model/grid.rb +1 -1
  160. data/samples/elaborate/connect4/model/slot.rb +1 -1
  161. data/samples/elaborate/connect4.rb +1 -1
  162. data/samples/elaborate/contact_manager/contact.rb +1 -1
  163. data/samples/elaborate/contact_manager/contact_manager_presenter.rb +1 -1
  164. data/samples/elaborate/contact_manager/contact_repository.rb +1 -1
  165. data/samples/elaborate/contact_manager.rb +1 -1
  166. data/samples/elaborate/game_of_life/model/cell.rb +1 -1
  167. data/samples/elaborate/game_of_life/model/grid.rb +1 -1
  168. data/samples/elaborate/game_of_life.rb +1 -1
  169. data/samples/elaborate/login.rb +1 -1
  170. data/samples/elaborate/mandelbrot_fractal.rb +1 -1
  171. data/samples/elaborate/meta_sample.rb +1 -1
  172. data/samples/elaborate/metronome.rb +1 -1
  173. data/samples/elaborate/parking/model/parking_floor.rb +1 -1
  174. data/samples/elaborate/parking/model/parking_presenter.rb +1 -1
  175. data/samples/elaborate/parking/model/parking_spot.rb +1 -1
  176. data/samples/elaborate/parking.rb +1 -1
  177. data/samples/elaborate/quarto/model/game.rb +1 -1
  178. data/samples/elaborate/quarto/model/piece/cube.rb +1 -1
  179. data/samples/elaborate/quarto/model/piece/cylinder.rb +1 -1
  180. data/samples/elaborate/quarto/model/piece.rb +1 -1
  181. data/samples/elaborate/quarto/view/available_pieces_area.rb +1 -1
  182. data/samples/elaborate/quarto/view/board.rb +1 -1
  183. data/samples/elaborate/quarto/view/cell.rb +1 -1
  184. data/samples/elaborate/quarto/view/cube.rb +1 -1
  185. data/samples/elaborate/quarto/view/cylinder.rb +1 -1
  186. data/samples/elaborate/quarto/view/message_box_panel.rb +1 -1
  187. data/samples/elaborate/quarto/view/piece.rb +1 -1
  188. data/samples/elaborate/quarto/view/selected_piece_area.rb +1 -1
  189. data/samples/elaborate/quarto.rb +1 -3
  190. data/samples/elaborate/snake/model/apple.rb +33 -0
  191. data/samples/elaborate/snake/model/game.rb +68 -0
  192. data/samples/elaborate/snake/model/snake.rb +95 -0
  193. data/samples/elaborate/snake/model/vertebra.rb +22 -0
  194. data/samples/elaborate/snake/presenter/cell.rb +27 -0
  195. data/samples/elaborate/snake/presenter/grid.rb +49 -0
  196. data/samples/elaborate/snake.rb +103 -0
  197. data/samples/elaborate/stock_ticker.rb +1 -1
  198. data/samples/elaborate/tetris/model/block.rb +1 -1
  199. data/samples/elaborate/tetris/model/game.rb +1 -1
  200. data/samples/elaborate/tetris/model/past_game.rb +1 -1
  201. data/samples/elaborate/tetris/model/tetromino.rb +1 -1
  202. data/samples/elaborate/tetris/view/bevel.rb +1 -1
  203. data/samples/elaborate/tetris/view/block.rb +1 -1
  204. data/samples/elaborate/tetris/view/high_score_dialog.rb +1 -1
  205. data/samples/elaborate/tetris/view/playfield.rb +1 -1
  206. data/samples/elaborate/tetris/view/score_lane.rb +1 -1
  207. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +1 -1
  208. data/samples/elaborate/tetris.rb +8 -8
  209. data/samples/elaborate/tic_tac_toe/board.rb +1 -1
  210. data/samples/elaborate/tic_tac_toe/cell.rb +1 -1
  211. data/samples/elaborate/tic_tac_toe.rb +1 -1
  212. data/samples/elaborate/timer.rb +1 -1
  213. data/samples/elaborate/user_profile.rb +1 -1
  214. data/samples/elaborate/weather.rb +1 -1
  215. data/samples/hello/hello_arrow.rb +1 -1
  216. data/samples/hello/hello_browser.rb +1 -1
  217. data/samples/hello/hello_button.rb +1 -1
  218. data/samples/hello/hello_c_combo.rb +1 -1
  219. data/samples/hello/hello_c_tab.rb +1 -1
  220. data/samples/hello/hello_canvas.rb +1 -1
  221. data/samples/hello/hello_canvas_animation.rb +1 -1
  222. data/samples/hello/hello_canvas_animation_multi.rb +1 -1
  223. data/samples/hello/hello_canvas_data_binding.rb +8 -8
  224. data/samples/hello/hello_canvas_path.rb +1 -1
  225. data/samples/hello/hello_canvas_shape_listeners.rb +1 -1
  226. data/samples/hello/hello_checkbox.rb +1 -1
  227. data/samples/hello/hello_checkbox_group.rb +1 -1
  228. data/samples/hello/hello_code_text.rb +1 -1
  229. data/samples/hello/hello_color_dialog.rb +1 -1
  230. data/samples/hello/hello_combo.rb +1 -1
  231. data/samples/hello/hello_composite.rb +1 -1
  232. data/samples/hello/hello_computed.rb +1 -1
  233. data/samples/hello/hello_cool_bar.rb +1 -1
  234. data/samples/hello/hello_cursor.rb +1 -1
  235. data/samples/hello/hello_custom_shape.rb +1 -1
  236. data/samples/hello/hello_custom_shell.rb +1 -1
  237. data/samples/hello/hello_custom_widget.rb +1 -1
  238. data/samples/hello/hello_date_time.rb +1 -1
  239. data/samples/hello/hello_dialog.rb +1 -1
  240. data/samples/hello/hello_directory_dialog.rb +1 -1
  241. data/samples/hello/hello_drag_and_drop.rb +1 -1
  242. data/samples/hello/hello_expand_bar.rb +1 -1
  243. data/samples/hello/hello_file_dialog.rb +1 -1
  244. data/samples/hello/hello_font_dialog.rb +1 -1
  245. data/samples/hello/hello_group.rb +1 -1
  246. data/samples/hello/hello_label.rb +1 -1
  247. data/samples/hello/hello_layout.rb +1 -1
  248. data/samples/hello/hello_link.rb +1 -1
  249. data/samples/hello/hello_list_multi_selection.rb +1 -1
  250. data/samples/hello/hello_list_single_selection.rb +1 -1
  251. data/samples/hello/hello_menu_bar.rb +1 -1
  252. data/samples/hello/hello_message_box.rb +1 -1
  253. data/samples/hello/hello_pop_up_context_menu.rb +1 -1
  254. data/samples/hello/hello_print.rb +1 -1
  255. data/samples/hello/hello_print_dialog.rb +1 -1
  256. data/samples/hello/hello_progress_bar.rb +1 -1
  257. data/samples/hello/hello_radio.rb +1 -1
  258. data/samples/hello/hello_radio_group.rb +1 -1
  259. data/samples/hello/hello_sash_form.rb +1 -1
  260. data/samples/hello/hello_scale.rb +1 -1
  261. data/samples/hello/hello_scrolled_composite.rb +1 -1
  262. data/samples/hello/hello_shape.rb +1 -1
  263. data/samples/hello/hello_shell.rb +1 -1
  264. data/samples/hello/hello_slider.rb +1 -1
  265. data/samples/hello/hello_spinner.rb +1 -1
  266. data/samples/hello/hello_styled_text.rb +1 -1
  267. data/samples/hello/hello_tab.rb +1 -1
  268. data/samples/hello/hello_table.rb +1 -1
  269. data/samples/hello/hello_text.rb +1 -1
  270. data/samples/hello/hello_toggle.rb +1 -1
  271. data/samples/hello/hello_tool_bar.rb +1 -1
  272. data/samples/hello/hello_tray_item.rb +1 -1
  273. data/samples/hello/hello_tree.rb +1 -1
  274. data/samples/hello/hello_world.rb +1 -1
  275. metadata +27 -33
@@ -1593,7 +1593,15 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
1593
1593
 
1594
1594
  **(BETA FEATURE)**
1595
1595
 
1596
- While other GUI toolkits only offer a way to draw graphics imperatively (e.g. fill_rectangle, draw_point, etc...), Glimmer DSL for SWT breaks away from the mold by enabling software engineers to draw graphics declaratively. Simply declare all the shapes you want to see with their attributes, like background/foreground colors, and Glimmer DSL for SWT takes care of the rest, painting graphics on a blank `canvas` widget or amending/decorating an existing widget. This is accomplished through the Canvas Shape DSL, a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax. Still, for the rare cases where imperative logic is needed, Glimmer DSL for SWT supports imperative painting of graphics through direct usage of SWT.
1596
+ While other GUI toolkits only offer a way to draw graphics imperatively (e.g. draw_arc, draw_rectangle, move_to, line_to, etc...), Glimmer DSL for SWT breaks away from the mold by enabling software engineers to draw graphics declaratively. Simply declare all the shapes you want to see with their attributes, like background/foreground colors, and Glimmer DSL for SWT takes care of the rest, painting graphics on a blank `canvas` widget or amending/decorating an existing widget. This is accomplished through the Canvas Shape DSL, a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax. Still, for the rare cases where imperative logic is needed, Glimmer DSL for SWT supports imperative painting of graphics through direct usage of SWT.
1597
+
1598
+ ![Canvas Shape DSL Line](/images/glimmer-canvas-shape-dsl-line.png)
1599
+ ![Canvas Shape DSL Rectangle](/images/glimmer-canvas-shape-dsl-rectangle.png)
1600
+ ![Canvas Shape DSL Oval](/images/glimmer-canvas-shape-dsl-oval.png)
1601
+ ![Canvas Shape DSL Arc](/images/glimmer-canvas-shape-dsl-arc.png)
1602
+ ![Canvas Shape DSL Polyline](/images/glimmer-canvas-shape-dsl-polyline.png)
1603
+ ![Canvas Shape DSL Polygon](/images/glimmer-canvas-shape-dsl-polygon.png)
1604
+ ![Canvas Shape DSL Text](/images/glimmer-canvas-shape-dsl-text.png)
1597
1605
 
1598
1606
  `canvas` has the `:double_buffered` SWT style by default on platforms that need it (Windows & Linux) to ensure flicker-free rendering. If you need to disable it for whatever reason, just pass the `:none` SWT style instead (e.g. `canvas(:none)`)
1599
1607
 
@@ -1630,171 +1638,713 @@ Here is a list of supported attributes nestable within a block under shapes:
1630
1638
  - `foreground` sets draw color for drawable shapes (standard color symbol (e.g. `:red`), `rgb(red_integer, green_integer, blue_integer)` color, or Color/ColorProxy object directly)
1631
1639
  - `foreground_pattern` sets foreground gradient/image pattern for drawable shape lines (takes the same arguments as the SWT [Pattern](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Pattern.html) class [e.g. `foreground_pattern 2.3, 4.2, 5.4, 7.2, :red, :blue`] / note: this feature isn't extensively tested yet)
1632
1640
  - `interpolation` sets the interpolation value (SWT style value of `:default`, `:none`, `:low`, `:high`)
1633
- - `line_cap` sets line cap (SWT style value of `:cap_flat`, `:cap_round`, or `:cap_square`)
1641
+ - `line_cap` sets line cap (SWT style value of `:flat`, `:round`, or `:square`, with aliases `:cap_flat`, `:cap_round`, and `:cap_square`)
1634
1642
  - `line_dash` line dash float values (automatically sets `line_style` to SWT style value of `:line_custom`)
1635
- - `line_join` line join style (SWT style value of `:join_miter`, `:join_round`, or `:join_bevel`)
1643
+ - `line_join` line join style (SWT style value of `:miter`, `:round`, and `:bevel`, with aliases `:join_miter`, `:join_round`, or `:join_bevel`)
1636
1644
  - `line_style` line join style (SWT style value of `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`, or `:custom` while requiring `line_dash` attribute (or alternatively with `line_` prefix as per official SWT docs like `:line_solid` for `:solid`)
1637
1645
  - `line_width` line width in integer (used in draw operations)
1638
1646
  - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
1639
1647
  - `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
1640
1648
 
1649
+ If you specify the x and y coordinates as `:default`, `nil`, or leave them out, they get calculated automatically by centering the shape within its parent `canvas`.
1650
+
1651
+ If you specify the `width` and `height` parameters as `:max`, they get calculated from the parent's size, filling the parent maximally (and they are auto-calculated on parent resize).
1652
+
1653
+ Note that you could shift a shape off its centered position within its parent `canvas` by setting `x` to `[:default, x_delta]` and `y` to `[:default, y_delta]`
1654
+
1641
1655
  Keep in mind that ordering of shapes matters as it is followed in painting. For example, it is recommended you paint filled shapes first and then drawn ones.
1642
1656
 
1643
- Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1657
+ Example of `line` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1644
1658
 
1645
1659
  ```ruby
1646
- include Glimmer
1660
+ require 'glimmer-dsl-swt'
1647
1661
 
1648
- # image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
1649
- image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
1662
+ include Glimmer
1650
1663
 
1651
1664
  shell {
1652
- text 'Canvas Example'
1653
- minimum_size 320, 400
1654
-
1665
+ text 'Canvas Shape DSL'
1666
+ minimum_size 200, 220
1667
+
1655
1668
  canvas {
1656
- background :dark_yellow
1657
- rectangle(0, 0, 220, 400) {
1658
- background :dark_red
1669
+ background :white
1670
+
1671
+ line(30, 30, 170, 170) {
1672
+ foreground :red
1673
+ line_width 3
1659
1674
  }
1660
- rectangle(50, 20, 300, 150, 30, 50, round: true) {
1675
+ }
1676
+ }.open
1677
+ ```
1678
+
1679
+ ![Canvas Shape DSL Line](/images/glimmer-canvas-shape-dsl-line.png)
1680
+
1681
+ Example of `rectangle` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1682
+
1683
+ ```ruby
1684
+ require 'glimmer-dsl-swt'
1685
+
1686
+ include Glimmer
1687
+
1688
+ shell {
1689
+ text 'Canvas Shape DSL'
1690
+ minimum_size 200, 220
1691
+
1692
+ canvas {
1693
+ background :white
1694
+
1695
+ rectangle(30, 50, 140, 100) {
1661
1696
  background :yellow
1662
1697
  }
1663
- rectangle(150, 200, 100, 70, true, gradient: true) {
1664
- background :dark_red
1665
- foreground :yellow
1698
+
1699
+ rectangle(30, 50, 140, 100) {
1700
+ foreground :red
1701
+ line_width 3
1666
1702
  }
1667
- text('Glimmer', 208, 83) {
1668
- font height: 25, style: :bold
1703
+ }
1704
+ }.open
1705
+ ```
1706
+
1707
+ ![Canvas Shape DSL Rectangle](/images/glimmer-canvas-shape-dsl-rectangle.png)
1708
+
1709
+ Example of `rectangle` with round corners having 60 degree angles by default (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1710
+
1711
+ ```ruby
1712
+ require 'glimmer-dsl-swt'
1713
+
1714
+ include Glimmer
1715
+
1716
+ shell {
1717
+ text 'Canvas Shape DSL'
1718
+ minimum_size 200, 220
1719
+
1720
+ canvas {
1721
+ background :white
1722
+
1723
+ rectangle(30, 50, 140, 100, round: true) {
1724
+ background :yellow
1669
1725
  }
1670
- rectangle(200, 80, 108, 36) {
1671
- foreground rgb(0, 0, 0)
1726
+
1727
+ rectangle(30, 50, 140, 100, round: true) {
1728
+ foreground :red
1672
1729
  line_width 3
1673
1730
  }
1674
- image(image_object, 70, 50)
1675
1731
  }
1676
1732
  }.open
1677
1733
  ```
1678
1734
 
1679
- Screenshot:
1735
+ ![Canvas Shape DSL Rectangle Round](/images/glimmer-canvas-shape-dsl-rectangle-round.png)
1680
1736
 
1681
- ![Canvas Animation Example](/images/glimmer-example-canvas.png)
1737
+ Example of `rectangle` with round corners having different horizontal and vertical angles (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1682
1738
 
1683
- If you specify the x and y coordinates as `:default`, `nil`, or leave them out, they get calculated automatically by centering the shape within its parent `canvas`.
1739
+ ```ruby
1740
+ require 'glimmer-dsl-swt'
1684
1741
 
1685
- If you specify the `width` and `height` parameters as `:max`, they get calculated from the parent's size, filling the parent maximally (and they are auto-calculated on parent resize).
1742
+ include Glimmer
1686
1743
 
1687
- Note that you could shift a shape off its centered position within its parent `canvas` by setting `x` to `[:default, x_delta]` and `y` to `[:default, y_delta]`
1744
+ shell {
1745
+ text 'Canvas Shape DSL'
1746
+ minimum_size 200, 220
1747
+
1748
+ canvas {
1749
+ background :white
1750
+
1751
+ rectangle(30, 50, 140, 100, 40, 80) {
1752
+ background :yellow
1753
+ }
1754
+
1755
+ rectangle(30, 50, 140, 100, 40, 80) {
1756
+ foreground :red
1757
+ line_width 3
1758
+ }
1759
+ }
1760
+ }.open
1761
+ ```
1688
1762
 
1689
- The round and gradient options could be dropped since Glimmer DSL for SWT supports auto-inference of them based on shape parameters.
1763
+ ![Canvas Shape DSL Rectangle Round Angles](/images/glimmer-canvas-shape-dsl-rectangle-round-angles.png)
1690
1764
 
1691
- Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1765
+ Example of `oval` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1692
1766
 
1693
1767
  ```ruby
1694
- include Glimmer
1768
+ require 'glimmer-dsl-swt'
1695
1769
 
1696
- # image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
1697
- image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
1770
+ include Glimmer
1698
1771
 
1699
1772
  shell {
1700
- text 'Canvas Example'
1701
- minimum_size 320, 400
1702
-
1773
+ text 'Canvas Shape DSL'
1774
+ minimum_size 200, 220
1775
+
1703
1776
  canvas {
1704
- background :dark_yellow
1705
- rectangle(0, 0, 220, 400) {
1706
- background :dark_red
1777
+ background :white
1778
+
1779
+ oval(30, 50, 140, 100) {
1780
+ background :yellow
1707
1781
  }
1708
- rectangle(50, 20, 300, 150, 30, 50) {
1782
+
1783
+ oval(30, 50, 140, 100) {
1784
+ foreground :red
1785
+ line_width 3
1786
+ }
1787
+ }
1788
+ }.open
1789
+ ```
1790
+
1791
+ ![Canvas Shape DSL Oval](/images/glimmer-canvas-shape-dsl-oval.png)
1792
+
1793
+ Example of `arc` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1794
+
1795
+ ```ruby
1796
+ require 'glimmer-dsl-swt'
1797
+
1798
+ include Glimmer
1799
+
1800
+ shell {
1801
+ text 'Canvas Shape DSL'
1802
+ minimum_size 200, 220
1803
+
1804
+ canvas {
1805
+ background :white
1806
+
1807
+ arc(30, 30, 140, 140, 0, 270) {
1709
1808
  background :yellow
1710
1809
  }
1711
- rectangle(150, 200, 100, 70, true) {
1712
- background :dark_red
1713
- foreground :yellow
1810
+
1811
+ arc(30, 30, 140, 140, 0, 270) {
1812
+ foreground :red
1813
+ line_width 3
1814
+ }
1815
+ }
1816
+ }.open
1817
+ ```
1818
+
1819
+ ![Canvas Shape DSL Arc](/images/glimmer-canvas-shape-dsl-arc.png)
1820
+
1821
+ Example of `polyline` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1822
+
1823
+ ```ruby
1824
+ require 'glimmer-dsl-swt'
1825
+
1826
+ include Glimmer
1827
+
1828
+ shell {
1829
+ text 'Canvas Shape DSL'
1830
+ minimum_size 200, 220
1831
+
1832
+ canvas {
1833
+ background :white
1834
+
1835
+ polyline(30, 50, 50, 170, 70, 120, 90, 150, 110, 30, 130, 100, 150, 50, 170, 135) {
1836
+ foreground :red
1837
+ line_width 3
1714
1838
  }
1715
- text('Glimmer', 208, 83) {
1716
- font height: 25, style: :bold
1839
+ }
1840
+ }.open
1841
+ ```
1842
+
1843
+ ![Canvas Shape DSL Polyline](/images/glimmer-canvas-shape-dsl-polyline.png)
1844
+
1845
+ Example of `polygon` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1846
+
1847
+ ```ruby
1848
+ require 'glimmer-dsl-swt'
1849
+
1850
+ include Glimmer
1851
+
1852
+ shell {
1853
+ text 'Canvas Shape DSL'
1854
+ minimum_size 200, 220
1855
+
1856
+ canvas {
1857
+ background :white
1858
+
1859
+ polygon(30, 90, 80, 20, 130, 40, 170, 90, 130, 140, 80, 170, 40, 160) {
1860
+ background :yellow
1717
1861
  }
1718
- rectangle(200, 80, 108, 36) {
1719
- foreground rgb(0, 0, 0)
1862
+
1863
+ polygon(30, 90, 80, 20, 130, 40, 170, 90, 130, 140, 80, 170, 40, 160) {
1864
+ foreground :red
1720
1865
  line_width 3
1721
1866
  }
1722
- image(image_object, 70, 50)
1723
1867
  }
1724
1868
  }.open
1725
1869
  ```
1726
1870
 
1727
- Notice how the shape declaration parameters perfectly match the method parameters in the [SWT org.eclipse.swt.graphics.GC API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html). This is useful for developers coming to Glimmer DSL for SWT from SWT.
1871
+ ![Canvas Shape DSL Polygon](/images/glimmer-canvas-shape-dsl-polygon.png)
1728
1872
 
1729
- Of course, Glimmer DSL for SWT still supports an alternative syntax that is more declarative and consistent with the rest of the Glimmer GUI DSL syntax. This syntax in fact offers the extra-benefit of data-binding for shape parameter values (meaning you could use `bind(...)` syntax with them instead of setting values directly)
1873
+ Example of `text` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1730
1874
 
1731
- Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1875
+ ```ruby
1876
+ require 'glimmer-dsl-swt'
1877
+
1878
+ include Glimmer
1879
+
1880
+ shell {
1881
+ text 'Canvas Shape DSL'
1882
+ minimum_size 200, 220
1883
+
1884
+ canvas {
1885
+ background :white
1886
+
1887
+ text(" This is \n rendered text ", 30, 50) {
1888
+ background :yellow
1889
+ foreground :red
1890
+ font height: 25, style: :italic
1891
+
1892
+ rectangle { # automatically scales to match text extent
1893
+ foreground :red
1894
+ line_width 3
1895
+ }
1896
+ }
1897
+ }
1898
+ }.open
1899
+ ```
1900
+
1901
+ ![Canvas Shape DSL Text](/images/glimmer-canvas-shape-dsl-text.png)
1902
+
1903
+ Example of `image` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1732
1904
 
1733
1905
  ```ruby
1906
+ require 'glimmer-dsl-swt'
1907
+
1734
1908
  include Glimmer
1735
1909
 
1736
- # image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
1737
- image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
1910
+ shell {
1911
+ text 'Canvas Shape DSL'
1912
+ minimum_size 512, 542
1913
+
1914
+ canvas {
1915
+ background :white
1916
+
1917
+ image(File.expand_path('icons/scaffold_app.png', __dir__), 0, 5)
1918
+ }
1919
+ }.open
1920
+ ```
1921
+
1922
+ ![Canvas Shape DSL Image](/images/glimmer-canvas-shape-dsl-image.png)
1923
+
1924
+ Example of `image` pre-built with a smaller height (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1925
+
1926
+ ```ruby
1927
+ require 'glimmer-dsl-swt'
1928
+
1929
+ include Glimmer
1930
+
1931
+ @image_object = image(File.expand_path('icons/scaffold_app.png', __dir__), height: 200)
1738
1932
 
1739
1933
  shell {
1740
- text 'Canvas Example'
1741
- minimum_size 320, 400
1934
+ text 'Canvas Shape DSL'
1935
+ minimum_size 200, 230
1936
+
1937
+ canvas {
1938
+ background :white
1939
+
1940
+ image(@image_object, 0, 5)
1941
+ }
1942
+ }.open
1943
+ ```
1742
1944
 
1945
+ ![Canvas Shape DSL Image](/images/glimmer-canvas-shape-dsl-image-shrunk.png)
1946
+
1947
+ Example of setting `background_pattern` attribute to a horizontal gradient (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1948
+
1949
+ ```ruby
1950
+ require 'glimmer-dsl-swt'
1951
+
1952
+ include Glimmer
1953
+
1954
+ shell {
1955
+ text 'Canvas Shape DSL'
1956
+ minimum_size 200, 220
1957
+
1743
1958
  canvas {
1744
- background :dark_yellow
1745
- rectangle {
1746
- x 0
1747
- y 0
1748
- width 220
1749
- height 400
1750
- background :dark_red
1959
+ background :white
1960
+
1961
+ oval(30, 30, 140, 140) {
1962
+ background_pattern 0, 0, 200, 0, rgb(255, 255, 0), rgb(255, 0, 0)
1751
1963
  }
1752
- rectangle {
1753
- x 50
1754
- y 20
1755
- width 300
1756
- height 150
1757
- arc_width 30
1758
- arc_height 50
1964
+ }
1965
+ }.open
1966
+ ```
1967
+
1968
+ ![Canvas Shape DSL Oval Background Pattern Gradient](/images/glimmer-canvas-shape-dsl-oval-background-pattern-gradient.png)
1969
+
1970
+ Example of setting `foreground_pattern` attribute to a vertical gradient (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1971
+
1972
+ ```ruby
1973
+ require 'glimmer-dsl-swt'
1974
+
1975
+ include Glimmer
1976
+
1977
+ shell {
1978
+ text 'Canvas Shape DSL'
1979
+ minimum_size 200, 220
1980
+
1981
+ canvas {
1982
+ background :white
1983
+
1984
+ oval(30, 30, 140, 140) {
1985
+ foreground_pattern 0, 0, 0, 200, :blue, :green
1986
+ line_width 10
1987
+ }
1988
+ }
1989
+ }.open
1990
+ ```
1991
+
1992
+ ![Canvas Shape DSL Oval Foreground Pattern Gradient](/images/glimmer-canvas-shape-dsl-oval-foreground-pattern-gradient.png)
1993
+
1994
+ Example of setting `line_style` attribute to `:dashdot` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1995
+
1996
+ ```ruby
1997
+ require 'glimmer-dsl-swt'
1998
+
1999
+ include Glimmer
2000
+
2001
+ shell {
2002
+ text 'Canvas Shape DSL'
2003
+ minimum_size 200, 220
2004
+
2005
+ canvas {
2006
+ background :white
2007
+
2008
+ oval(30, 50, 140, 100) {
1759
2009
  background :yellow
1760
2010
  }
1761
- rectangle {
1762
- x 150
1763
- y 200
1764
- width 100
1765
- height 70
1766
- vertical true
1767
- background :dark_red
1768
- foreground :yellow
2011
+
2012
+ oval(30, 50, 140, 100) {
2013
+ foreground :red
2014
+ line_width 3
2015
+ line_style :dashdot
1769
2016
  }
1770
- text {
1771
- string 'Glimmer'
1772
- x 208
1773
- y 83
1774
- font height: 25, style: :bold
2017
+ }
2018
+ }.open
2019
+ ```
2020
+
2021
+ ![Canvas Shape DSL Oval](/images/glimmer-canvas-shape-dsl-oval-line-style-dashdot.png)
2022
+
2023
+ Example of setting `line_width` attribute to `10`, `line_join` attribute to `:miter` (default) and `line_cap` attribute to `:flat` (default) (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2024
+
2025
+ ```ruby
2026
+ require 'glimmer-dsl-swt'
2027
+
2028
+ include Glimmer
2029
+
2030
+ shell {
2031
+ text 'Canvas Shape DSL'
2032
+ minimum_size 200, 220
2033
+
2034
+ canvas {
2035
+ background :white
2036
+
2037
+ polyline(30, 50, 50, 170, 70, 120, 90, 150, 110, 30, 130, 100, 150, 50, 170, 135) {
2038
+ foreground :red
2039
+ line_width 10
2040
+ line_join :miter
2041
+ line_cap :flat
1775
2042
  }
2043
+ }
2044
+ }.open
2045
+ ```
2046
+
2047
+ ![Canvas Shape DSL Polyline Line Join Miter Line Cap Flat](/images/glimmer-canvas-shape-dsl-polyline-line-join-miter-line-cap-flat.png)
2048
+
2049
+ Example of setting `line_width` attribute to `10`, `line_join` attribute to `:round` and `line_cap` attribute to `:round` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2050
+
2051
+ ```ruby
2052
+ require 'glimmer-dsl-swt'
2053
+
2054
+ include Glimmer
2055
+
2056
+ shell {
2057
+ text 'Canvas Shape DSL'
2058
+ minimum_size 200, 220
2059
+
2060
+ canvas {
2061
+ background :white
2062
+
2063
+ polyline(30, 50, 50, 170, 70, 120, 90, 150, 110, 30, 130, 100, 150, 50, 170, 135) {
2064
+ foreground :red
2065
+ line_width 10
2066
+ line_join :round
2067
+ line_cap :round
2068
+ }
2069
+ }
2070
+ }.open
2071
+ ```
2072
+
2073
+ ![Canvas Shape DSL Polyline Line Join Round Line Cap Round](/images/glimmer-canvas-shape-dsl-polyline-line-join-round-line-cap-round.png)
2074
+
2075
+ Example of setting `line_width` attribute to `10`, `line_join` attribute to `:bevel` and `line_cap` attribute to `:square` (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2076
+
2077
+ ```ruby
2078
+ require 'glimmer-dsl-swt'
2079
+
2080
+ include Glimmer
2081
+
2082
+ shell {
2083
+ text 'Canvas Shape DSL'
2084
+ minimum_size 200, 220
2085
+
2086
+ canvas {
2087
+ background :white
2088
+
2089
+ polyline(30, 50, 50, 170, 70, 120, 90, 150, 110, 30, 130, 100, 150, 50, 170, 135) {
2090
+ foreground :red
2091
+ line_width 10
2092
+ line_join :bevel
2093
+ line_cap :square
2094
+ }
2095
+ }
2096
+ }.open
2097
+ ```
2098
+
2099
+ ![Canvas Shape DSL Polyline Line Join Miter Line Cap Flat](/images/glimmer-canvas-shape-dsl-polyline-line-join-bevel-line-cap-square.png)
2100
+
2101
+ Shape declaration parameters perfectly match the method parameters in the [SWT org.eclipse.swt.graphics.GC API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html). This is useful for developers coming to Glimmer DSL for SWT from SWT.
2102
+
2103
+ Glimmer DSL for SWT also supports an alternative syntax for specifying shape parameters by nesting underneath the shape instead of passing as args. This syntax in fact offers the extra-benefit of [data-binding](#data-binding) for shape parameter values (meaning you could use `<=` syntax with them instead of setting values directly)
2104
+
2105
+ Example of alternative syntax for specifying shape parameters (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2106
+
2107
+ ```ruby
2108
+ require 'glimmer-dsl-swt'
2109
+
2110
+ include Glimmer
2111
+
2112
+ shell {
2113
+ text 'Canvas Shape DSL'
2114
+ minimum_size 200, 220
2115
+
2116
+ canvas {
2117
+ background :white
2118
+
1776
2119
  rectangle {
1777
- x 200
1778
- y 80
1779
- width 108
1780
- height 36
1781
- foreground :black
1782
- line_width 3
2120
+ x 30
2121
+ y 50
2122
+ width 140
2123
+ height 100
2124
+ arc_width 40
2125
+ arc_height 80
2126
+ background :yellow
1783
2127
  }
1784
- image {
1785
- image image_object
1786
- x 70
2128
+
2129
+ rectangle {
2130
+ x 30
1787
2131
  y 50
2132
+ width 140
2133
+ height 100
2134
+ arc_width 40
2135
+ arc_height 80
2136
+ foreground :red
2137
+ line_width 3
1788
2138
  }
1789
2139
  }
1790
2140
  }.open
1791
2141
  ```
1792
2142
 
1793
- Learn more at the [Hello, Canvas! Sample](/docs/reference/GLIMMER_SAMPLES.md#hello-canvas).
2143
+ ![Canvas Shape DSL Rectangle Round Angles](/images/glimmer-canvas-shape-dsl-rectangle-round-angles.png)
1794
2144
 
1795
- If you ever have special needs or optimizations, you could always default to direct SWT painting via [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) instead. Learn more at the [SWT Graphics Guide](https://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html) and [SWT Image Guide](https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html#Saving%20Images).
2145
+ Example of canvas shape parameter data-binding (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1796
2146
 
1797
- Example of manually doing the same things as in the previous example without relying on the declarative Glimmer Shape DSL (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2147
+ ```ruby
2148
+ require 'glimmer-dsl-swt'
2149
+
2150
+ class HelloCanvasDataBinding
2151
+ include Glimmer::GUI::CustomWindow # alias for Glimmer::UI::CustomShell
2152
+
2153
+ CANVAS_WIDTH = 300
2154
+ CANVAS_HEIGHT = 300
2155
+
2156
+ attr_accessor :x1_value, :y1_value, :x2_value, :y2_value, :foreground_red, :foreground_green, :foreground_blue, :line_width_value, :line_style_value
2157
+
2158
+ def foreground_value
2159
+ rgb(foreground_red, foreground_green, foreground_blue)
2160
+ end
2161
+
2162
+ def line_style_value_options
2163
+ [:solid, :dash, :dot, :dashdot, :dashdotdot]
2164
+ end
2165
+
2166
+ before_body do
2167
+ self.x1_value = 0
2168
+ self.y1_value = 0
2169
+ self.x2_value = CANVAS_WIDTH
2170
+ self.y2_value = CANVAS_HEIGHT
2171
+ self.foreground_red = 28
2172
+ self.foreground_green = 128
2173
+ self.foreground_blue = 228
2174
+ self.line_width_value = 3
2175
+ self.line_style_value = :dot
2176
+ end
2177
+
2178
+ body {
2179
+ shell {
2180
+ text 'Hello, Canvas Data-Binding!'
2181
+
2182
+ tab_folder {
2183
+ tab_item {
2184
+ grid_layout(6, true) {
2185
+ margin_width 0
2186
+ margin_height 0
2187
+ horizontal_spacing 0
2188
+ vertical_spacing 0
2189
+ }
2190
+ text 'line'
2191
+
2192
+ label {
2193
+ layout_data(:fill, :center, false, false) {
2194
+ horizontal_span 3
2195
+ }
2196
+ text 'x1'
2197
+ }
2198
+ label {
2199
+ layout_data(:fill, :center, false, false) {
2200
+ horizontal_span 3
2201
+ }
2202
+ text 'y1'
2203
+ }
2204
+ spinner {
2205
+ layout_data(:fill, :center, false, false) {
2206
+ horizontal_span 3
2207
+ }
2208
+ maximum CANVAS_WIDTH
2209
+ increment 3
2210
+ selection <=> [self, :x1_value]
2211
+ }
2212
+ spinner {
2213
+ layout_data(:fill, :center, false, false) {
2214
+ horizontal_span 3
2215
+ }
2216
+ maximum CANVAS_HEIGHT
2217
+ increment 3
2218
+ selection <=> [self, :y1_value]
2219
+ }
2220
+ label {
2221
+ layout_data(:fill, :center, false, false) {
2222
+ horizontal_span 3
2223
+ }
2224
+ text 'x2'
2225
+ }
2226
+ label {
2227
+ layout_data(:fill, :center, false, false) {
2228
+ horizontal_span 3
2229
+ }
2230
+ text 'y2'
2231
+ }
2232
+ spinner {
2233
+ layout_data(:fill, :center, false, false) {
2234
+ horizontal_span 3
2235
+ }
2236
+ maximum CANVAS_WIDTH
2237
+ increment 3
2238
+ selection <=> [self, :x2_value]
2239
+ }
2240
+ spinner {
2241
+ layout_data(:fill, :center, false, false) {
2242
+ horizontal_span 3
2243
+ }
2244
+ maximum CANVAS_HEIGHT
2245
+ increment 3
2246
+ selection <=> [self, :y2_value]
2247
+ }
2248
+ label {
2249
+ layout_data(:fill, :center, false, false) {
2250
+ horizontal_span 2
2251
+ }
2252
+ text 'foreground red'
2253
+ }
2254
+ label {
2255
+ layout_data(:fill, :center, false, false) {
2256
+ horizontal_span 2
2257
+ }
2258
+ text 'foreground green'
2259
+ }
2260
+ label {
2261
+ layout_data(:fill, :center, false, false) {
2262
+ horizontal_span 2
2263
+ }
2264
+ text 'foreground blue'
2265
+ }
2266
+ spinner {
2267
+ layout_data(:fill, :center, false, false) {
2268
+ horizontal_span 2
2269
+ }
2270
+ maximum 255
2271
+ increment 10
2272
+ selection <=> [self, :foreground_red]
2273
+ }
2274
+ spinner {
2275
+ layout_data(:fill, :center, false, false) {
2276
+ horizontal_span 2
2277
+ }
2278
+ maximum 255
2279
+ increment 10
2280
+ selection <=> [self, :foreground_green]
2281
+ }
2282
+ spinner {
2283
+ layout_data(:fill, :center, false, false) {
2284
+ horizontal_span 2
2285
+ }
2286
+ maximum 255
2287
+ increment 10
2288
+ selection <=> [self, :foreground_blue]
2289
+ }
2290
+ label {
2291
+ layout_data(:fill, :center, false, false) {
2292
+ horizontal_span 3
2293
+ }
2294
+ text 'line width'
2295
+ }
2296
+ label {
2297
+ layout_data(:fill, :center, false, false) {
2298
+ horizontal_span 3
2299
+ }
2300
+ text 'line style'
2301
+ }
2302
+ spinner {
2303
+ layout_data(:fill, :center, false, false) {
2304
+ horizontal_span 3
2305
+ }
2306
+ maximum 255
2307
+ selection <=> [self, :line_width_value]
2308
+ }
2309
+ combo(:read_only) {
2310
+ layout_data(:fill, :center, false, false) {
2311
+ horizontal_span 3
2312
+ }
2313
+ selection <=> [self, :line_style_value]
2314
+ }
2315
+ canvas {
2316
+ layout_data(:center, :center, false, false) {
2317
+ horizontal_span 6
2318
+ width_hint CANVAS_WIDTH
2319
+ height_hint CANVAS_WIDTH
2320
+ }
2321
+ background :white
2322
+
2323
+ line {
2324
+ x1 <= [self, :x1_value]
2325
+ y1 <= [self, :y1_value]
2326
+ x2 <= [self, :x2_value]
2327
+ y2 <= [self, :y2_value]
2328
+ foreground <= [self, :foreground_value, computed_by: [:foreground_red, :foreground_green, :foreground_blue]]
2329
+ line_width <= [self, :line_width_value]
2330
+ line_style <= [self, :line_style_value]
2331
+ }
2332
+ }
2333
+ }
2334
+ }
2335
+ }
2336
+ }
2337
+
2338
+ end
2339
+
2340
+ HelloCanvasDataBinding.launch
2341
+ ```
2342
+
2343
+ ![Glimmer Example Canvas Data-Binding Line Changed](/images/glimmer-hello-canvas-data-binding-line-changed.png)
2344
+
2345
+ If you ever have special needs for optimization, you could always default to direct SWT painting via [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) instead. Learn more at the [SWT Graphics Guide](https://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html) and [SWT Image Guide](https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html#Saving%20Images).
2346
+
2347
+ Example of manual drawing without relying on the declarative Glimmer Shape DSL (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
1798
2348
 
1799
2349
  ```ruby
1800
2350
  include Glimmer
@@ -1835,6 +2385,8 @@ shell {
1835
2385
  }.open
1836
2386
  ```
1837
2387
 
2388
+ ![Glimmer Example Canvas](/images/glimmer-example-canvas.png)
2389
+
1838
2390
  #### Shapes inside a Shape
1839
2391
 
1840
2392
  Shapes can be nested within each other. If you nest a shape within another, its coordinates are assumed to be relative to its parent.
@@ -4142,4 +4694,4 @@ Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby
4142
4694
 
4143
4695
  [MIT](LICENSE.txt)
4144
4696
 
4145
- Copyright (c) 2007-2021 - Andy Maleh.
4697
+ Copyright (c) 2007-2022 - Andy Maleh.