glimmer-dsl-swt 4.18.5.2 → 4.18.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +8 -10
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +93 -16
  6. data/docs/reference/GLIMMER_SAMPLES.md +32 -0
  7. data/glimmer-dsl-swt.gemspec +9 -3
  8. data/lib/glimmer/swt/custom/drawable.rb +8 -7
  9. data/lib/glimmer/swt/custom/shape.rb +416 -37
  10. data/lib/glimmer/swt/custom/shape/arc.rb +22 -4
  11. data/lib/glimmer/swt/custom/shape/cubic.rb +117 -0
  12. data/lib/glimmer/swt/custom/shape/image.rb +19 -6
  13. data/lib/glimmer/swt/custom/shape/line.rb +119 -1
  14. data/lib/glimmer/swt/custom/shape/oval.rb +3 -3
  15. data/lib/glimmer/swt/custom/shape/path.rb +211 -0
  16. data/lib/glimmer/swt/custom/shape/path_segment.rb +111 -0
  17. data/lib/glimmer/swt/custom/shape/point.rb +40 -4
  18. data/lib/glimmer/swt/custom/shape/polygon.rb +93 -3
  19. data/lib/glimmer/swt/custom/shape/polyline.rb +76 -4
  20. data/lib/glimmer/swt/custom/shape/quad.rb +113 -0
  21. data/lib/glimmer/swt/custom/shape/rectangle.rb +7 -2
  22. data/lib/glimmer/swt/custom/shape/text.rb +2 -4
  23. data/lib/glimmer/swt/dialog_proxy.rb +4 -0
  24. data/lib/glimmer/swt/proxy_properties.rb +1 -1
  25. data/lib/glimmer/swt/widget_proxy.rb +16 -0
  26. data/samples/elaborate/contact_manager.rb +2 -0
  27. data/samples/elaborate/login.rb +2 -0
  28. data/samples/elaborate/mandelbrot_fractal.rb +2 -1
  29. data/samples/elaborate/meta_sample.rb +1 -0
  30. data/samples/elaborate/stock_ticker.rb +229 -0
  31. data/samples/elaborate/tetris.rb +2 -1
  32. data/samples/elaborate/tic_tac_toe.rb +2 -0
  33. data/samples/elaborate/user_profile.rb +10 -8
  34. data/samples/hello/hello_browser.rb +2 -0
  35. data/samples/hello/hello_button.rb +2 -0
  36. data/samples/hello/hello_canvas.rb +40 -21
  37. data/samples/hello/hello_canvas_animation.rb +2 -0
  38. data/samples/hello/hello_canvas_path.rb +66 -0
  39. data/samples/hello/hello_canvas_transform.rb +2 -0
  40. data/samples/hello/hello_checkbox.rb +2 -0
  41. data/samples/hello/hello_checkbox_group.rb +2 -0
  42. data/samples/hello/hello_code_text.rb +2 -0
  43. data/samples/hello/hello_color_dialog.rb +2 -0
  44. data/samples/hello/hello_combo.rb +2 -0
  45. data/samples/hello/hello_computed.rb +2 -0
  46. data/samples/hello/hello_cursor.rb +2 -0
  47. data/samples/hello/hello_custom_shell.rb +1 -0
  48. data/samples/hello/hello_custom_widget.rb +2 -0
  49. data/samples/hello/hello_date_time.rb +2 -0
  50. data/samples/hello/hello_dialog.rb +2 -0
  51. data/samples/hello/hello_directory_dialog.rb +2 -0
  52. data/samples/hello/hello_drag_and_drop.rb +5 -3
  53. data/samples/hello/hello_expand_bar.rb +2 -0
  54. data/samples/hello/hello_file_dialog.rb +2 -0
  55. data/samples/hello/hello_font_dialog.rb +2 -0
  56. data/samples/hello/hello_group.rb +2 -0
  57. data/samples/hello/hello_link.rb +2 -0
  58. data/samples/hello/hello_list_multi_selection.rb +2 -0
  59. data/samples/hello/hello_list_single_selection.rb +2 -0
  60. data/samples/hello/hello_menu_bar.rb +2 -0
  61. data/samples/hello/hello_message_box.rb +2 -0
  62. data/samples/hello/hello_pop_up_context_menu.rb +2 -0
  63. data/samples/hello/hello_progress_bar.rb +2 -0
  64. data/samples/hello/hello_radio.rb +2 -0
  65. data/samples/hello/hello_radio_group.rb +2 -0
  66. data/samples/hello/hello_sash_form.rb +2 -0
  67. data/samples/hello/hello_spinner.rb +2 -0
  68. data/samples/hello/hello_styled_text.rb +19 -17
  69. data/samples/hello/hello_tab.rb +2 -0
  70. data/samples/hello/hello_table.rb +2 -0
  71. data/samples/hello/hello_world.rb +2 -0
  72. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03f0ab47e7617c3d595a737c755ddc05e877074fb9139cacca042c6c31f7999e
4
- data.tar.gz: f80117653d4ce70cfde372cbe660ab4d0a7ae181a24df76c79226fcb43c68549
3
+ metadata.gz: 6951b42a995fd393c82fcb406f5bb308aacf9330d75b85e0050104451044870c
4
+ data.tar.gz: 1de171314b2b6da4c80e295152a91697085e8bc7b00502fb0af88aef2890defc
5
5
  SHA512:
6
- metadata.gz: a543129ea30b6a18306341b9fad1f62a36f919d83cedc27ea5b6e62c18e13827b28e05cbb01c81e0d8639d5412aeb6ba2e81de60e4c7f0ba5052b474eb07b7f3
7
- data.tar.gz: 8d757538764f6018a381bcc68583b2d2660d23c9a2f8f1b15c90ad904b84316b1a4e61197f1f618a2bb42ad5d2114cc087e9aaebe1538514a24b330bdf8ce44f
6
+ metadata.gz: d996c3707e136ec0e059396a3a06d301953236acbde4012f428fdc85dab3e13843296ace25426d41fa6fe7d87031ab5990a40e62a2b572bfbd47b97759575892
7
+ data.tar.gz: 5c317cdc5e75597d03bf241436cad374cd05e64d4a91739d08945ed2b4a5464807128eb25f23b271a057fdb4dd7b79372eee3c68f6f336a4fd27af8448ce31a9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.6.1
4
+
5
+ - Fixed issues with Canvas Path DSL handling of connected vs non-connected path segments (including in geometry calculations)
6
+ - Optimized Canvas Path DSL redraw performance by removing extra redraws
7
+ - Fixed issues in the Hello, Canvas Path! sample and renamed to Stock Ticker
8
+ - Added a new simpler Hello, Canvas Path! sample
9
+
10
+ ### 4.18.6.0
11
+
12
+ - Canvas Path DSL support (Alpha) for `path` as drawn or filled (`fill: true`) to the Canvas Shape DSL, supporting `point`, `line` (first point is auto-derived from previous point if not specified)
13
+ - Hello, Canvas Path! sample showing a Stock Ticker with line curves for multiple company stocks, animated with randomly generated data, moving to the left out of screen second by second. Has multiple tabs demonstrating different types of paths for graphing/charting of different real world business applications: point, line, quad, cubic.
14
+ - Fix issue to allow invocation of `set_min_size` off of `scrolled_composite` proxy directly (not just swt_widget), thus taking advantage of implicit `auto_exec`
15
+ - Support `Shape#content {}` method just like `WidgetProxy#content` to enable reopening and adding nested shapes at runtime after initial construction
16
+ - Support a path containing a `quad` bezier curve with `point_array` property
17
+ - Support a path containing a `cubic` bezier curve with `point_array` property
18
+
19
+ ### 4.18.5.5
20
+
21
+ - Automatically recalculate default size (width/height) to accomodate nested shapes when changing x/y/width/height sticking out of parent from right or bottom.
22
+ - Support special case of centering a nested shape with default x/y within a parent with default width/height calculated from nested shape
23
+ - Consider Canvas Shape DSL support for LineAttributes `line_dash_offset` and `line_miter_limit`
24
+ - Canvas Shape DSL Polygon `include?` does an outer/inner check of edge detection only
25
+ - Ensure all Canvas Shape DSL properties are restored upon painting a shape to what they were prior to painting that shape
26
+ - Fix issue with bringing high score dialog up in Tetris caused by latest dialog changes for supporting the new `color_dialog` and `font_dialog`
27
+
28
+ ### 4.18.5.4
29
+
30
+ - Support passing width, height as :default (or nil or not passed in if they are the last args) in all shapes that include other shapes to indicate they are calculated automatically from nested shapes, text/string extent, or otherwise defaulting to 0, 0
31
+ - Support [:default, width_delta], [:default, height_delta] attributes for width and height, which add/subtract from defaults used for shape
32
+ - Switch from use of `:default` with x_delta/y_delta to passing `[:default, x_delta]` or `[:default, y_delta]` (e.g. `image(file, [:default, -30], :default)` for x = default - 30 and y = default + 0)
33
+ - Support a bounding box for all shapes, implementing `#bounds` (x, y, width, and height) and `#size` (width, height) for the ones that don't receive as parameters (like polygon)
34
+
35
+ ### 4.18.5.3
36
+
37
+ - Support nesting shapes within shapes, with relative positioning (meaning x, y coordinates are assumed relative to parent's x, y in nested shapes)
38
+ - Support passing x, y coordinates as :default (or nil or not passed in if they are the last args) in all shapes, meaning they are centered within parent taking their width and height into account
39
+ - Support default_x_delta, y_delta attributes, which add/subtract from defaults used for shape
40
+
3
41
  ### 4.18.5.2
4
42
 
5
43
  - Support checking if an `arc` shape accurately includes a point x,y coordinates within pie region only
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.18.5.2
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.18.6.0
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -8,17 +8,15 @@
8
8
 
9
9
  **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
10
10
 
11
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](docs/reference/GLIMMER_COMMAND.md#packaging) on [Linux](https://www.linux.org/).
12
-
13
- [Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
14
-
15
- Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
16
-
17
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) versions 4.18.x.y come with [SWT 4.18](https://download.eclipse.org/eclipse/downloads/drops4/R-4.18-202012021800/), which was released on December 2, 2020.
11
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for SWT is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](docs/reference/GLIMMER_COMMAND.md#packaging) on [Linux](https://www.linux.org/).
18
12
 
19
13
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
20
14
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
21
15
 
16
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.18.6.0 includes [SWT 4.18](https://download.eclipse.org/eclipse/downloads/drops4/R-4.18-202012021800/), which was released on December 2, 2020. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
17
+
18
+ [Glimmer DSL for SWT receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) with your Ruby desktop GUI development needs! [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) brings great ideas to the table, such as declarative programming via domain specific languages, currently under-utilized in the GUI domain. That said, it may not be feature complete enough for everybody's needs, so please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) even better by providing feedback and [contributing](#contributing) when possible. The project is very active, so any feature suggestions that are accepted could be implemented within weeks if not days. Also, you are welcome to [hire me](#hire-me) full-time if you want long-term development of [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) for your project needs.
19
+
22
20
  Glimmer DSL gems:
23
21
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
24
22
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
@@ -342,7 +340,7 @@ jgem install glimmer-dsl-swt
342
340
 
343
341
  Or this command if you want a specific version:
344
342
  ```
345
- jgem install glimmer-dsl-swt -v 4.18.5.2
343
+ jgem install glimmer-dsl-swt -v 4.18.6.0
346
344
  ```
347
345
 
348
346
  `jgem` is JRuby's version of `gem` command.
@@ -360,7 +358,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
360
358
 
361
359
  Add the following to `Gemfile`:
362
360
  ```
363
- gem 'glimmer-dsl-swt', '~> 4.18.5.2'
361
+ gem 'glimmer-dsl-swt', '~> 4.18.6.0'
364
362
  ```
365
363
 
366
364
  And, then run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.18.5.2
1
+ 4.18.6.1
@@ -36,10 +36,12 @@ This guide should help you get started with Glimmer DSL for SWT. For more advanc
36
36
  - [Layouts](#layouts)
37
37
  - [Layout Data](#layout-data)
38
38
  - [Canvas Shape DSL](#canvas-shape-dsl)
39
+ - [Shapes inside a Shape](#shapes-inside-a-shape)
39
40
  - [Shapes inside a Widget](#shapes-inside-a-widget)
40
41
  - [Shapes inside an Image](#shapes-inside-an-image)
41
42
  - [Canvas Shape API](#canvas-shape-api)
42
43
  - [Pixel Graphics](#pixel-graphics)
44
+ - [Canvas Path DSL](#canvas-path-dsl)
43
45
  - [Canvas Transform DSL](#canvas-transform-dsl)
44
46
  - [Top-Level Transform Fluent Interface](#top-level-transform-fluent-interface)
45
47
  - [Canvas Animation DSL](#canvas-animation-dsl)
@@ -1385,12 +1387,10 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
1385
1387
 
1386
1388
  **(ALPHA FEATURE)**
1387
1389
 
1388
- Glimmer supports drawing graphics directly on a `canvas` widget via SWT (or any widget for that matter though `canvas` is recommended for drawing).
1390
+ 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.
1389
1391
 
1390
1392
  `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)`)
1391
1393
 
1392
- This is accomplished via the Shape DSL a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax.
1393
-
1394
1394
  Shape keywords and their args (including defaults) are listed below (they basically match method names and arguments on [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) minus the `draw` or `fill` prefix in downcase):
1395
1395
  - `arc(x, y, width, height, startAngle, arcAngle, fill: false)` arc is part of a circle within an oval area, denoted by start angle (degrees) and end angle (degrees)
1396
1396
  - `focus(x, y, width, height)` this is just like rectangle but its foreground color is always that of the OS widget focus color (useful when capturing user interaction via a shape)
@@ -1405,7 +1405,7 @@ Shape keywords and their args (including defaults) are listed below (they basica
1405
1405
  - `rectangle(x, y, width, height, arcWidth = 60, arcHeight = 60, fill: false, round: true)` round rectangle, which can be optionally filled, and takes optional extra round angle arguments
1406
1406
  - `rectangle(x, y, width, height, vertical = true, fill: true, gradient: true)` gradient rectangle, which is always filled, and takes an optional extra argument to specify true for vertical gradient (default) and false for horizontal gradient
1407
1407
  - `text(string, x, y, is_transparent = true)` text with optional is_transparent to indicate if background is transparent (default is true)
1408
- - `text(string, x, y, flags)` text with optional flags (flag format is `swt(comma_separated_flags)` where flags can be :draw_delimiter (i.e. new lines), :draw_tab, :draw_mnemonic, and :draw_transparent as explained in [GC API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html))
1408
+ - `text(string, x, y, flags)` text with optional flags (flag format is `swt(comma_separated_flags)` where flags can be `:draw_delimiter` (i.e. new lines), `:draw_tab`, `:draw_mnemonic`, and `:draw_transparent` as explained in [GC API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html))
1409
1409
 
1410
1410
  Shape keywords that can be filled with color can take a keyword argument `fill: true`. Defaults to false when not specified unless background is set with no foreground (or foreground is set with no background), in which case a smart default is applied.
1411
1411
  Smart defaults can be applied to automatically infer `gradient: true` (rectangle with both foreground and background) and `round: true` (rectangle with more than 4 args, the extra args are numeric) as well.
@@ -1462,7 +1462,7 @@ shell {
1462
1462
  font height: 25, style: :bold
1463
1463
  }
1464
1464
  rectangle(200, 80, 108, 36) {
1465
- foreground :black
1465
+ foreground rgb(0, 0, 0)
1466
1466
  line_width 3
1467
1467
  }
1468
1468
  image(image_object, 70, 50)
@@ -1474,6 +1474,10 @@ Screenshot:
1474
1474
 
1475
1475
  ![Canvas Animation Example](/images/glimmer-example-canvas.png)
1476
1476
 
1477
+ 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`.
1478
+
1479
+ Note that you could shift a shape off its centered position within its parent `canvas` by using `x_delta` and `y_delta` instead of `x` and `y`
1480
+
1477
1481
  The round and gradient options could be dropped since Glimmer DSL for SWT supports auto-inference of them based on shape parameters.
1478
1482
 
1479
1483
  Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
@@ -1504,7 +1508,7 @@ shell {
1504
1508
  font height: 25, style: :bold
1505
1509
  }
1506
1510
  rectangle(200, 80, 108, 36) {
1507
- foreground :black
1511
+ foreground rgb(0, 0, 0)
1508
1512
  line_width 3
1509
1513
  }
1510
1514
  image(image_object, 70, 50)
@@ -1539,7 +1543,7 @@ shell {
1539
1543
  }
1540
1544
  rectangle {
1541
1545
  x 50
1542
- x 20
1546
+ y 20
1543
1547
  width 300
1544
1548
  height 150
1545
1549
  arc_width 30
@@ -1594,23 +1598,26 @@ shell {
1594
1598
  minimum_size 320, 400
1595
1599
 
1596
1600
  canvas {
1597
- background :yellow
1601
+ background :dark_yellow
1598
1602
 
1599
1603
  on_paint_control { |paint_event|
1600
1604
  gc = paint_event.gc
1601
- gc.background = color(:red).swt_color
1602
- gc.fill_rectangle(0, 0, 220, 400)
1603
1605
 
1604
- gc.background = color(:magenta).swt_color
1605
- gc.fill_roundRectangle(50, 20, 300, 150, 30, 50)
1606
+ gc.background = color(:dark_red).swt_color
1607
+ gc.fill_rectangle(0, 0, 220, 400)
1606
1608
 
1607
- gc.background = color(:dark_magenta).swt_color
1608
- gc.fill_gradientRectangle(150, 200, 100, 70, true)
1609
+ gc.background = color(:yellow).swt_color
1610
+ gc.fill_round_rectangle(50, 20, 300, 150, 30, 50)
1609
1611
 
1610
- gc.foreground = color(:dark_blue).swt_color
1611
- gc.draw_rectangle(200, 80, 108, 36)
1612
+ gc.background = color(:dark_red).swt_color
1613
+ gc.foreground = color(:yellow).swt_color
1614
+ gc.fill_gradient_rectangle(150, 200, 100, 70, true)
1612
1615
 
1616
+ gc.font = font(height: 25, style: :bold).swt_font
1613
1617
  gc.foreground = color(:black).swt_color
1618
+ gc.draw_text('Glimmer', 208, 83, true)
1619
+
1620
+ gc.foreground = rgb(0, 0, 0).swt_color
1614
1621
  gc.line_width = 3
1615
1622
  gc.draw_rectangle(200, 80, 108, 36)
1616
1623
 
@@ -1620,6 +1627,36 @@ shell {
1620
1627
  }.open
1621
1628
  ```
1622
1629
 
1630
+ #### Shapes inside a Shape
1631
+
1632
+ Shapes can be nested within each other. If you nest a shape within another, its coordinates are assumed to be relative to its parent.
1633
+
1634
+ As such, if you move the parent, it moves all its children with it.
1635
+
1636
+ 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 shape relatively.
1637
+
1638
+ Note that you could shift a shape off its centered position within its parent shape by using `x_delta` and `y_delta` instead of `x` and `y`
1639
+
1640
+ Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example that nests lines, points, a polyline, and an image within a drawn rectangle parent:
1641
+
1642
+ ```ruby
1643
+ rectangle(205, 50, 88, 96) {
1644
+ foreground :yellow
1645
+ 3.times { |n|
1646
+ line(45, 70 + n*10, 65 + n*10, 30 + n*10) {
1647
+ foreground :yellow
1648
+ }
1649
+ }
1650
+ 10.times {|n|
1651
+ point(15 + n*5, 50 + n*5) {
1652
+ foreground :yellow
1653
+ }
1654
+ }
1655
+ polyline(45, 60, 55, 20, 65, 60, 85, 80, 45, 60)
1656
+ image(@image_object, 0, 5)
1657
+ }
1658
+ ```
1659
+
1623
1660
  #### Shapes inside a Widget
1624
1661
 
1625
1662
  Keep in mind that the Shape DSL can be used inside any widget, not just `canvas`. Unlike shapes on a `canvas`, which are standalone graphics, when included in a widget, which already has its own look and feel, shapes are used as a decorative add-on that complements its look by getting painted on top of it. For example, shapes were used to decorate `composite` blocks in the [Tetris](GLIMMER_SAMPLES.md#tetris) sample to have a more bevel look. In summary, Shapes can be used in a hybrid approach (shapes inside a widget), not just standalone in a `canvas`.
@@ -1730,6 +1767,8 @@ They are implemented with the help of the highly robust Java built-in shape geom
1730
1767
  - `Shape#contain?(x, y)` : indicates if shape contains x, y point
1731
1768
  - `Shape#include?(x, y)` : indicates if shape includes x, y point on the edge if drawn or inside if filled (include uses contain for filled shapes)
1732
1769
  - `Shape#move_by(x_delta, y_delta)` : moves shape object at x, y location
1770
+ - `Shape#size` : calculated size for shape bounding box (e.g. a polygon with an irregular shape will have its bounding box width and height calculated)
1771
+ - `Shape#bounds` : calculated bounds (x, y, width, height) for shape bounding box (e.g. a polygon with an irregular shape will have its bounding box top-left x, y, width and height calculated)
1733
1772
 
1734
1773
  Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example.
1735
1774
 
@@ -1915,6 +1954,44 @@ shell {
1915
1954
 
1916
1955
  As they say, there are many ways to skin a cat! This is in line with the Ruby way of providing more ways than one. Pick and choose the right tool for the job just like true software engineers.
1917
1956
 
1957
+ ### Canvas Path DSL
1958
+
1959
+ **(ALPHA FEATURE)**
1960
+
1961
+ Unlike common imperative GUI graphing toolkits, Glimmer enables declarative rendering of paths with the new Canvas Path DSL (Early Alpha) via the new `path { }` keyword and by nesting one of the following path segment keywords underneath:
1962
+ - `point(x1, y1)`: renders a Point (Dot) as part of a path.
1963
+ - `line(x1, y1, x2=nil, y2=nil)`: renders a Line as part of a path. If you drop x2, y2, it joins to the previous point automatically. You may repeat for a series of lines forming a curve.
1964
+ - `quad(x1, y1, x2, y2, x3=nil, y3=nil)`: renders a Quadratic Bezier Curve. If you drop x3 and y3, it joins to the previous point automatically.
1965
+ - `cubic(x1, y1, x2, y2, x3, y3, x4=nil, y4=nil)`: renders a Cubic Bezier Curve. If you drop x4 and y4, it joins to the previous point automatically.
1966
+
1967
+ Example:
1968
+
1969
+ ```ruby
1970
+ include Glimmer
1971
+
1972
+ shell {
1973
+ text 'Canvas Path Example'
1974
+ minimum_size 300, 300
1975
+
1976
+ canvas {
1977
+ path {
1978
+ foreground :black
1979
+ point(0, 0)
1980
+ 250.times {|n|
1981
+ cubic(n + n%30, n+ n%50, 40, 40, 70, 70, n + 20 + n%30, n%30*-1 * n%50)
1982
+ }
1983
+ }
1984
+ }
1985
+
1986
+ }.open
1987
+ ```
1988
+
1989
+ ![Canvas Path Example](/images/glimmer-example-canvas-path.png)
1990
+
1991
+ Learn more at the [Hello, Canvas Path!](GLIMMER_SAMPLES.md#hello-canvas-path) and [Stock Ticker](GLIMMER_SAMPLES.md#stock-ticker) samples.
1992
+
1993
+ ![Stock Ticker](/images/glimmer-stock-ticker.gif)
1994
+
1918
1995
  ### Canvas Transform DSL
1919
1996
 
1920
1997
  **(ALPHA FEATURE)**
@@ -33,6 +33,7 @@
33
33
  - [Hello, Canvas!](#hello-canvas)
34
34
  - [Hello, Canvas Animation!](#hello-canvas-animation)
35
35
  - [Hello, Canvas Transform!](#hello-canvas-transform)
36
+ - [Hello, Canvas Path!](#hello-canvas-path)
36
37
  - [Hello, Cursor!](#hello-cursor)
37
38
  - [Hello, Progress Bar!](#hello-progress-bar)
38
39
  - [Hello, Tree!](#hello-tree)
@@ -45,6 +46,7 @@
45
46
  - [Contact Manager](#contact-manager)
46
47
  - [Glimmer Tetris](#glimmer-tetris)
47
48
  - [Mandelbrot Fractal](#mandelbrot-fractal)
49
+ - [Stock Ticker](#stock-ticker)
48
50
  - [External Samples](#external-samples)
49
51
  - [Glimmer Calculator](#glimmer-calculator)
50
52
  - [Gladiator](#gladiator)
@@ -564,6 +566,10 @@ Hello, Canvas!
564
566
 
565
567
  ![Hello Canvas](/images/glimmer-hello-canvas.png)
566
568
 
569
+ Hello, Canvas! Moving Shapes and Nested Shapes via Drag'n'Drop
570
+
571
+ ![Hello Canvas Moving Shapes](/images/glimmer-hello-canvas-moving-shapes.gif)
572
+
567
573
  Hello, Canvas! with Moved Shapes (via Drag'n'Drop)
568
574
 
569
575
  ![Hello Canvas Moved Shapes](/images/glimmer-hello-canvas-moved-shapes.png)
@@ -580,6 +586,10 @@ Hello, Canvas! Colors Changed
580
586
 
581
587
  ![Hello Canvas Colors Changed](/images/glimmer-hello-canvas-colors-changed.png)
582
588
 
589
+ Hello, Canvas! Data-Binding (changing a `text` shape `string` via data-binding changes from another thread)
590
+
591
+ ![Hello Canvas Data Binding](/images/glimmer-hello-canvas-data-binding.gif)
592
+
583
593
  #### Hello, Canvas Animation!
584
594
 
585
595
  This sample demonstrates the use of the `canvas` widget and [Animation DSL](#canvas-animation-dsl) in Glimmer.
@@ -608,6 +618,18 @@ Hello, Canvas Transform!
608
618
 
609
619
  ![Hello Canvas Transform](/images/glimmer-hello-canvas-transform.png)
610
620
 
621
+ #### Hello, Canvas Path!
622
+
623
+ This sample demonstrates the use of the `path`, `quad`, `cubic`, `line`, and `point` keywords as part of the [Canvas Path DSL](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-path-dsl) within the [Canvas Shape DSL](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl).
624
+
625
+ Code:
626
+
627
+ [samples/hello/hello_canvas_path.rb](/samples/hello/hello_canvas_path.rb)
628
+
629
+ Hello, Canvas Path!
630
+
631
+ ![Hello Canvas Path](/images/glimmer-hello-canvas-path.png)
632
+
611
633
  #### Hello, Cursor!
612
634
 
613
635
  This sample demonstrates the use of the `cursor` property keyword to change the mouse cursor.
@@ -804,6 +826,16 @@ Code:
804
826
 
805
827
  ![Mandelbrot Fractal Help Menu](/images/glimmer-mandelbrot-menu-help.png)
806
828
 
829
+ #### Stock Ticker
830
+
831
+ This sample demonstrates a Stock Ticker that generates random stock price data for 4 different stocks and provides 4 different tab views of the graphed data using the [Canvas Path DSL](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-path-dsl). It leverages a thread that runs in the background and ticks the stocks to generate random new stock prices before amending the graphed paths with them.
832
+
833
+ Code:
834
+
835
+ [samples/elaborate/stock_ticker.rb](/samples/elaborate/stock_ticker.rb)
836
+
837
+ ![Stock Ticker](/images/glimmer-stock-ticker.gif)
838
+
807
839
  ### External Samples
808
840
 
809
841
  #### Glimmer Calculator
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.18.5.2 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.6.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.18.5.2"
9
+ s.version = "4.18.6.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2021-02-24"
14
+ s.date = "2021-03-01"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -115,13 +115,17 @@ Gem::Specification.new do |s|
115
115
  "lib/glimmer/swt/custom/radio_group.rb",
116
116
  "lib/glimmer/swt/custom/shape.rb",
117
117
  "lib/glimmer/swt/custom/shape/arc.rb",
118
+ "lib/glimmer/swt/custom/shape/cubic.rb",
118
119
  "lib/glimmer/swt/custom/shape/focus.rb",
119
120
  "lib/glimmer/swt/custom/shape/image.rb",
120
121
  "lib/glimmer/swt/custom/shape/line.rb",
121
122
  "lib/glimmer/swt/custom/shape/oval.rb",
123
+ "lib/glimmer/swt/custom/shape/path.rb",
124
+ "lib/glimmer/swt/custom/shape/path_segment.rb",
122
125
  "lib/glimmer/swt/custom/shape/point.rb",
123
126
  "lib/glimmer/swt/custom/shape/polygon.rb",
124
127
  "lib/glimmer/swt/custom/shape/polyline.rb",
128
+ "lib/glimmer/swt/custom/shape/quad.rb",
125
129
  "lib/glimmer/swt/custom/shape/rectangle.rb",
126
130
  "lib/glimmer/swt/custom/shape/text.rb",
127
131
  "lib/glimmer/swt/date_time_proxy.rb",
@@ -162,6 +166,7 @@ Gem::Specification.new do |s|
162
166
  "samples/elaborate/login.rb",
163
167
  "samples/elaborate/mandelbrot_fractal.rb",
164
168
  "samples/elaborate/meta_sample.rb",
169
+ "samples/elaborate/stock_ticker.rb",
165
170
  "samples/elaborate/tetris.rb",
166
171
  "samples/elaborate/tetris/model/block.rb",
167
172
  "samples/elaborate/tetris/model/game.rb",
@@ -180,6 +185,7 @@ Gem::Specification.new do |s|
180
185
  "samples/hello/hello_button.rb",
181
186
  "samples/hello/hello_canvas.rb",
182
187
  "samples/hello/hello_canvas_animation.rb",
188
+ "samples/hello/hello_canvas_path.rb",
183
189
  "samples/hello/hello_canvas_transform.rb",
184
190
  "samples/hello/hello_checkbox.rb",
185
191
  "samples/hello/hello_checkbox_group.rb",
@@ -34,19 +34,20 @@ module Glimmer
34
34
  @shapes ||= []
35
35
  end
36
36
 
37
- def image_buffered_shapes
38
- @image_buffered_shapes ||= []
37
+ def expanded_shapes
38
+ @shapes.map do |shape|
39
+ [shape] + shape.expanded_shapes
40
+ end.flatten
39
41
  end
40
42
 
41
- # Returns shapes expanded with regards to nested shapes
42
- def expand_shapes(shapes)
43
- # TODO
43
+ def image_buffered_shapes
44
+ @image_buffered_shapes ||= []
44
45
  end
45
46
 
46
47
  # TODO add a method like shapes that specifies drawable_properties to be able to adjust properties like transform in between shapes
47
48
 
48
49
  def shape_at_location(x, y)
49
- shapes.reverse.detect {|shape| shape.include?(x, y)}
50
+ expanded_shapes.reverse.detect {|shape| shape.include?(x, y)}
50
51
  end
51
52
 
52
53
  def add_shape(shape)
@@ -139,7 +140,7 @@ module Glimmer
139
140
  @paint_listener_proxy = on_swt_paint(&shape_painter)
140
141
  end
141
142
  else
142
- redraw if @finished_add_content && !is_disposed
143
+ redraw if respond_to?(:redraw) && @finished_add_content && !is_disposed
143
144
  end
144
145
  end
145
146
  alias resetup_shape_painting setup_shape_painting