glimmer-dsl-swt 4.22.1.1 → 4.22.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3026e50ed964fa1fb5f64eda607a4e867d31148c0bdf85a22a5c72797d5b7d64
4
- data.tar.gz: a95b41151a1c7805d7906e5d60771ef0281c202c29d7c5bdd38f4143c1f5bb6d
3
+ metadata.gz: b7f1a29590af7f987c7f766f38be9db3b963043e8be7b7c47396bf43002e7cab
4
+ data.tar.gz: 03e3578b2ec589a710bc097a21447722d11893b10dabdbb71961caa73877bb02
5
5
  SHA512:
6
- metadata.gz: 9a8e7851957f56c3625e7160b3432b22e970a406f7f9e2a0774da98dced348e0e3d9c6d2059c5bcef1ca714e058a9a23be37f4506d6a259996d3efae78b97790
7
- data.tar.gz: 510f9209d45b3debb9879996da87f86764b9a5e80bda1545de2217a81620b6e5c3d27bbb23ae2d79144294b51a203e3b15f5d50b643628ccf0477788afce6721
6
+ metadata.gz: 0705f8be12c4c40a82dc0db53d89c2c25054322952d8ab2ad0ffae4309564099fd05393e0132ac9f1b3fce0f0c03e4ba873b5c67cecd3bf063ba1b1233520f88
7
+ data.tar.gz: 6f90add738eed715917269fc17b57f363456f2e92571af298cd9df2d1cb95c3c96df059699397d79dc33d19f98b619a0fde1f832180853813856e50f2f8b7f27
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.22.1.2
4
+
5
+ - Fix support for ARM64 on Mac
6
+ - Upgrade to glimmer v2.5.5, reusing newly added Glimmer::DSL::ShineDataBindingExpression
7
+ - Include .gladiator-scratchpad in scaffolded app/gem .gitignore
8
+ - `ShellProxy#center_in_display` as alias to `#center_within_display`
9
+
3
10
  ## 4.22.1.1
4
11
 
5
12
  - Fix minor issue with Shape listener disposal
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.22.1.1
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.22.1.2
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)
@@ -17,7 +17,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
17
17
 
18
18
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
19
19
 
20
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.1.1 includes [SWT 4.22](https://download.eclipse.org/eclipse/downloads/drops4/R-4.22-202111241800/), which was released on November 24, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
20
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.1.2 includes [SWT 4.22](https://download.eclipse.org/eclipse/downloads/drops4/R-4.22-202111241800/), which was released on November 24, 2021. 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. Note that SWT now supports AARCH64/ARM64 on Mac and Linux!
21
21
 
22
22
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword.
23
23
 
@@ -25,8 +25,8 @@ Please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt
25
25
 
26
26
  Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interested in:
27
27
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
28
- - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
29
28
  - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
29
+ - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
30
30
  - [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)
31
31
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
32
32
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
@@ -147,9 +147,9 @@ shell {
147
147
  font height: 14
148
148
  enabled <= [BaseballGame, :selected_game]
149
149
 
150
- on_widget_selected {
150
+ on_widget_selected do
151
151
  book_selected_game
152
- }
152
+ end
153
153
  }
154
154
  }
155
155
  ```
@@ -296,7 +296,7 @@ https://www.eclipse.org/swt/faq.php
296
296
  - JDK 17 (17.0.1) (find at https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html / Ensure PATH includes Java bin directory for `jpackage` command to work when packaging Glimmer applications)
297
297
  - [RVM](http://rvm.io) on Mac & Linux (not available on Windows)
298
298
  - JRuby 9.3.1.0 (supporting Ruby 2.6.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.3.1.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download))
299
- - SWT 4.22 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem). Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested with Glimmer DSL for SWT yet, so it is considered experimental until declared otherwise.
299
+ - SWT 4.22 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem). Note that SWT now supports AARCH64/ARM64 on Mac and Linux!
300
300
  - Git (comes with Mac and Linux. Install on Windows: https://git-scm.com/download/win )
301
301
 
302
302
  Glimmer might still work on other versions of Java, JRuby and SWT, but there are no guarantees, so it is best to stick to the pre-requisites outlined above.
@@ -325,7 +325,7 @@ jgem install glimmer-dsl-swt
325
325
 
326
326
  Or this command if you want a specific version:
327
327
  ```
328
- jgem install glimmer-dsl-swt -v 4.22.1.1
328
+ jgem install glimmer-dsl-swt -v 4.22.1.2
329
329
  ```
330
330
 
331
331
  `jgem` is JRuby's version of `gem` command.
@@ -353,7 +353,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
353
353
 
354
354
  Add the following to `Gemfile`:
355
355
  ```
356
- gem 'glimmer-dsl-swt', '~> 4.22.1.1'
356
+ gem 'glimmer-dsl-swt', '~> 4.22.1.2'
357
357
  ```
358
358
 
359
359
  And, then run:
@@ -376,7 +376,7 @@ glimmer
376
376
  ```
377
377
 
378
378
  ```
379
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.1.1
379
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.1.2
380
380
 
381
381
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
382
382
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.22.1.1
1
+ 4.22.1.2
@@ -1,6 +1,6 @@
1
1
  ## Glimmer Command
2
2
 
3
- The `glimmer` command allows you to run, scaffold, package, and list Glimmer applications/gems.
3
+ The `glimmer` command allows you to run, scaffold, package, and list Glimmer applications/gems more conveniently.
4
4
 
5
5
  You can bring up usage instructions by running the `glimmer` command without arguments:
6
6
 
@@ -18,6 +18,8 @@ Note: If you encounter an issue running the `glimmer` command, run `bundle exec
18
18
 
19
19
  ### Basic Usage
20
20
 
21
+ You can run any Glimmer app with `jruby` directly, which is the most lightweight way of running Glimmer DSL for SWT applications. However, if you wrote an app that does not explicitly `require 'glimmer-dsl-swt'`, then you may use the `glimmer` command for convenience instead since it automatically loads `glimmer-dsl-swt`.
22
+
21
23
  ```
22
24
  glimmer application.rb
23
25
  ```
@@ -207,7 +209,7 @@ And, here is the Windows version of the boilerplate Preferences dialog.
207
209
 
208
210
  ![Glimmer Scaffold App Windows Preferences](/images/glimmer-scaffolding-app-windows-preferences.png)
209
211
 
210
- In order to run the app after making changes, you must run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.
212
+ In order to run the app after making changes, you can run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.
211
213
 
212
214
  ```
213
215
  glimmer run
@@ -216,7 +218,13 @@ glimmer run
216
218
  Alternatively, to manually run the app, you may type:
217
219
 
218
220
  ```
219
- glimmer run[bin/greeter]
221
+ jruby bin/greeter
222
+ ```
223
+
224
+ or:
225
+
226
+ ```
227
+ bin/greeter
220
228
  ```
221
229
 
222
230
  or:
@@ -225,6 +233,12 @@ or:
225
233
  glimmer bin/greeter
226
234
  ```
227
235
 
236
+ or:
237
+
238
+ ```
239
+ glimmer run[bin/greeter]
240
+ ```
241
+
228
242
  #### Desktopify
229
243
 
230
244
  Desktopify basically turns a website into a desktop application by wrapping the website within a [Browser Widget](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#browser-widget).
@@ -302,7 +316,7 @@ Desktopified App on Linux
302
316
 
303
317
  ![Glimmer Scaffold App](/images/glimmer-scaffolding-desktopify-linux.png)
304
318
 
305
- In order to run the app after making changes, you must run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.
319
+ In order to run the app after making changes, you can run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.
306
320
 
307
321
  ```
308
322
  glimmer run
@@ -18,7 +18,7 @@ Watch out for hands-on examples in this README indicated by "you may copy/paste
18
18
 
19
19
  Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt/samples](https://github.com/AndyObtiva/glimmer-dsl-swt/samples)
20
20
 
21
- If you need a more GUI interactive option to experiement with Glimmer GUI DSL Syntax, you may try:
21
+ If you need a more GUI interactive option to experiment with Glimmer GUI DSL Syntax, you may try:
22
22
  - [Glimmer Meta-Sample (The Sample of Samples)](#samples): allows launching Glimmer samples and viewing/editing code to learn/experiment too.
23
23
  - ["Ugliest Editor Ever"](https://github.com/AndyObtiva/glimmer-cs-gladiator)
24
24
  - Just build your own GUI editor using the [Glimmer DSL for SWT Ruby Gem](https://rubygems.org/gems/glimmer-dsl-swt).
@@ -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.
@@ -84,6 +84,7 @@
84
84
  - [Gladiator](#gladiator)
85
85
  - [Timer](#timer)
86
86
  - [Glimmer Klondike Solitaire](#glimmer-klondike-solitaire)
87
+ - [Glimmer Metronome](#glimmer-metronome)
87
88
  - [License](#license)
88
89
 
89
90
  ## Samples
@@ -1054,14 +1055,6 @@ Hello, Tool Bar!
1054
1055
 
1055
1056
  ![Hello Tool Bar](/images/glimmer-hello-tool-bar.png)
1056
1057
 
1057
- ![Hello Tool Bar Cut](/images/glimmer-hello-tool-bar-cut.png)
1058
-
1059
- ![Hello Tool Bar Copy](/images/glimmer-hello-tool-bar-copy.png)
1060
-
1061
- ![Hello Tool Bar Paste](/images/glimmer-hello-tool-bar-paste.png)
1062
-
1063
- ![Hello Tool Bar Font Size](/images/glimmer-hello-tool-bar-font-size.png)
1064
-
1065
1058
  #### Hello, Cool Bar!
1066
1059
 
1067
1060
  This sample demonstrates the use of `cool_bar` that can contain multiple reorganizable `tool_bar` widgets
@@ -1421,6 +1414,14 @@ This is a souped up version of the Klondike Solitaire elaborate sample, which is
1421
1414
 
1422
1415
  ![Glimmer Klondike Solitaire](https://raw.githubusercontent.com/AndyObtiva/glimmer_klondike_solitaire/master/images/glimmer-klondike-solitaire.png)
1423
1416
 
1417
+ #### Glimmer Metronome
1418
+
1419
+ This is an external enhanced version of [Metronome](#metronome) that can be packaged as an independent native executable.
1420
+
1421
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer_metronome/master/icons/linux/Glimmer%20Metronome.png" height=40 /> Glimmer Metronome](https://github.com/AndyObtiva/glimmer_metronome)
1422
+
1423
+ ![Metronome](https://raw.githubusercontent.com/AndyObtiva/glimmer_metronome/master/screenshots/glimmer-metronome.png)
1424
+
1424
1425
  ## License
1425
1426
 
1426
1427
  [MIT](LICENSE.txt)
Binary file
@@ -20,7 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/launcher'
23
- require ENV['SWT_JAR_FILE_PATH'] || "#{Glimmer::Launcher.swt_jar_file}#{Glimmer::Launcher.special_cpu_architecture_suffix}"
23
+ require ENV['SWT_JAR_FILE_PATH'] || "#{Glimmer::Launcher.swt_jar_file}"
24
24
  require 'glimmer/dsl/engine'
25
25
  Dir[File.expand_path('../*_expression.rb', __FILE__)].each {|f| require f}
26
26
 
@@ -32,6 +32,7 @@ module Glimmer
32
32
  include ParentExpression
33
33
 
34
34
  def can_interpret?(parent, keyword, *args, &block)
35
+ # TODO support CustomShape parent as well
35
36
  (parent.is_a?(Glimmer::SWT::Custom::Drawable) or parent.is_a?(Glimmer::SWT::Custom::Shape)) and
36
37
  Glimmer::SWT::Custom::Shape.valid?(parent, keyword, *args, &block)
37
38
  end
@@ -19,7 +19,7 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- require 'glimmer/dsl/expression'
22
+ require 'glimmer/dsl/shine_data_binding_expression'
23
23
  require 'glimmer/data_binding/model_binding'
24
24
  require 'glimmer/data_binding/widget_binding'
25
25
  require 'glimmer/swt/display_proxy'
@@ -28,22 +28,17 @@ require 'glimmer/data_binding/shine'
28
28
  module Glimmer
29
29
  module DSL
30
30
  module SWT
31
- class ShineDataBindingExpression < Expression
31
+ class ShineDataBindingExpression < Glimmer::DSL::ShineDataBindingExpression
32
32
  include_package 'org.eclipse.swt.widgets'
33
33
 
34
34
  def can_interpret?(parent, keyword, *args, &block)
35
- args.size == 0 and
36
- block.nil? and
35
+ super and
37
36
  (
38
37
  (parent.respond_to?(:has_attribute?) and parent.has_attribute?(keyword)) or
39
38
  (parent.respond_to?(:swt_widget) and (parent.swt_widget.is_a?(Table) or parent.swt_widget.is_a?(Tree)))
40
39
  ) and
41
40
  !(parent.respond_to?(:swt_widget) && parent.swt_widget.class == org.eclipse.swt.widgets.Canvas && keyword == 'image')
42
41
  end
43
-
44
- def interpret(parent, keyword, *args, &block)
45
- Glimmer::DataBinding::Shine.new(parent, keyword)
46
- end
47
42
  end
48
43
  end
49
44
  end
@@ -79,7 +79,7 @@ module Glimmer
79
79
  end
80
80
 
81
81
  def swt_jar_file
82
- @swt_jar_file ||= File.expand_path(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os, 'swt.jar'))
82
+ @swt_jar_file ||= File.expand_path(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os + special_cpu_architecture_suffix, 'swt.jar'))
83
83
  end
84
84
 
85
85
  def jruby_os_specific_options
@@ -99,6 +99,7 @@ module Glimmer
99
99
 
100
100
  # Gladiator (Glimmer Editor)
101
101
  .gladiator
102
+ .gladiator-scratchpad
102
103
 
103
104
  # Glimmer
104
105
  /dist/
@@ -116,12 +117,12 @@ module Glimmer
116
117
  GEMFILE_APP_MIDFIX = <<~MULTI_LINE_STRING
117
118
 
118
119
  gem 'glimmer-dsl-swt', '~> #{VERSION}'
119
- gem 'psych', '3.3.2' # Fixed temporarily because installing latest on JDK16 was causing issues
120
+ gem 'psych', '3.3.2' # Fixed temporarily because installing latest on JDK16+ was causing issues
120
121
  MULTI_LINE_STRING
121
122
  GEMFILE_GEM_MIDFIX = <<~MULTI_LINE_STRING
122
123
 
123
124
  gem 'glimmer-dsl-swt', '~> #{VERSION.split('.')[0...2].join('.')}'
124
- gem 'psych', '3.3.2' # Fixed temporarily because installing latest on JDK16 was causing issues
125
+ gem 'psych', '3.3.2' # Fixed temporarily because installing latest on JDK16+ was causing issues
125
126
  MULTI_LINE_STRING
126
127
  GEMFILE_SUFFIX = <<~MULTI_LINE_STRING
127
128
 
@@ -268,6 +268,7 @@ module Glimmer
268
268
  inverse_transform = TransformProxy.new(DisplayProxy.instance.swt_display, *transform_array.to_a)
269
269
  inverse_transform_array = [1,2,3,4,5,6].to_java(:float) # just placeholder data that gets overwritten with getElements
270
270
  inverse_transform.getElements(inverse_transform_array)
271
+ # TODO avoid Matrix usage directly by relying on SWT Transform#invert method instead (much simpler)
271
272
  matrix = Matrix[[inverse_transform_array[0], inverse_transform_array[1]], [inverse_transform_array[2], inverse_transform_array[3]]]
272
273
  result = matrix * Matrix.column_vector([x, y])
273
274
  x, y = result.to_a.flatten
@@ -105,6 +105,7 @@ module Glimmer
105
105
  @swt_widget.setLocation(location_x, location_y)
106
106
  end
107
107
  end
108
+ alias center_in_display center_within_display
108
109
 
109
110
  # Opens shell and starts SWT's UI thread event loop
110
111
  def open
@@ -46,8 +46,6 @@ class Quarto
46
46
  COLOR_AREA = rgb(206, 188, 170)
47
47
  COLOR_LIGHT_WOOD = rgb(254, 187, 120)
48
48
  COLOR_DARK_WOOD = rgb(204, 108, 58)
49
- MESSAGE_BOX_PANEL_WIDTH = 300
50
- MESSAGE_BOX_PANEL_HEIGHT = 100
51
49
  FILE_QUARTO_CONFIG = File.join(Dir.home, '.quarto')
52
50
 
53
51
  before_body do
@@ -195,13 +195,13 @@ class HelloCanvasDataBinding
195
195
  background :white
196
196
 
197
197
  line {
198
- x1 <=> [self, :x1_value]
199
- y1 <=> [self, :y1_value]
200
- x2 <=> [self, :x2_value]
201
- y2 <=> [self, :y2_value]
202
- foreground <=> [self, :foreground_value, computed_by: [:foreground_red, :foreground_green, :foreground_blue]]
203
- line_width <=> [self, :line_width_value]
204
- line_style <=> [self, :line_style_value]
198
+ x1 <= [self, :x1_value]
199
+ y1 <= [self, :y1_value]
200
+ x2 <= [self, :x2_value]
201
+ y2 <= [self, :y2_value]
202
+ foreground <= [self, :foreground_value, computed_by: [:foreground_red, :foreground_green, :foreground_blue]]
203
+ line_width <= [self, :line_width_value]
204
+ line_style <= [self, :line_style_value]
205
205
  }
206
206
  }
207
207
  }
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.22.1.1
4
+ version: 4.22.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 2.5.4
18
+ version: 2.5.5
19
19
  name: glimmer
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.5.4
26
+ version: 2.5.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -344,21 +344,22 @@ dependencies:
344
344
  version: 0.7.0
345
345
  description: Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI
346
346
  cross-platform desktop development library written in JRuby, an OS-threaded faster
347
- JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables
348
- productive and efficient authoring of desktop application user-interfaces by relying
349
- on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in
350
- data-binding support, which greatly facilitates synchronizing the GUI with domain
351
- models, thus achieving true decoupling of object oriented components and enabling
352
- developers to solve business problems (test-first) without worrying about GUI concerns,
353
- or alternatively drive development GUI-first, and then write clean business models
354
- (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets,
355
- but it also supports drawing Canvas Graphics like Shapes and Animations. To get
356
- started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets.
357
- Glimmer also includes native-executable packaging support, sorely lacking in other
358
- libraries, thus enabling the delivery of desktop apps written in Ruby as truly native
359
- DMG/PKG/APP files on the Mac, MSI/EXE files on Windows, and DEB/RPM files on Linux.
360
- Glimmer was the first Ruby gem to bring SWT (Standard Widget Toolkit) to Ruby, thanks
361
- to creator Andy Maleh, EclipseCon/EclipseWorld/RubyConf speaker.
347
+ JVM version of Ruby. It includes SWT 4.22 (released November 24, 2021). Glimmer's
348
+ main innovation is a declarative Ruby DSL that enables productive and efficient
349
+ authoring of desktop application user-interfaces by relying on the robust Eclipse
350
+ SWT library. Glimmer additionally innovates by having built-in data-binding support,
351
+ which greatly facilitates synchronizing the GUI with domain models, thus achieving
352
+ true decoupling of object oriented components and enabling developers to solve business
353
+ problems (test-first) without worrying about GUI concerns, or alternatively drive
354
+ development GUI-first, and then write clean business models (test-first) afterwards.
355
+ Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing
356
+ Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers
357
+ scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable
358
+ packaging support, sorely lacking in other libraries, thus enabling the delivery
359
+ of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac, MSI/EXE
360
+ files on Windows, and DEB/RPM files on Linux. Glimmer was the first Ruby gem to
361
+ bring SWT (Standard Widget Toolkit) to Ruby, thanks to creator Andy Maleh, EclipseCon/EclipseWorld/RubyConf
362
+ speaker.
362
363
  email: andy.am@gmail.com
363
364
  executables:
364
365
  - glimmer