glimmer-dsl-swt 4.18.5.0 → 4.18.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/README.md +16 -11
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +179 -33
- data/docs/reference/GLIMMER_SAMPLES.md +58 -0
- data/glimmer-dsl-swt.gemspec +7 -7
- data/lib/glimmer/data_binding/widget_binding.rb +4 -1
- data/lib/glimmer/dsl/swt/dialog_expression.rb +18 -9
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shell_expression.rb +1 -1
- data/lib/glimmer/swt/custom/drawable.rb +10 -2
- data/lib/glimmer/swt/custom/shape.rb +458 -58
- data/lib/glimmer/swt/custom/shape/arc.rb +35 -0
- data/lib/glimmer/swt/custom/shape/focus.rb +2 -2
- data/lib/glimmer/swt/custom/shape/image.rb +35 -9
- data/lib/glimmer/swt/custom/shape/line.rb +88 -4
- data/lib/glimmer/swt/custom/shape/oval.rb +18 -0
- data/lib/glimmer/swt/custom/shape/point.rb +10 -5
- data/lib/glimmer/swt/custom/shape/polygon.rb +105 -15
- data/lib/glimmer/swt/custom/shape/polyline.rb +88 -15
- data/lib/glimmer/swt/custom/shape/rectangle.rb +19 -0
- data/lib/glimmer/swt/custom/shape/text.rb +13 -3
- data/lib/glimmer/swt/{directory_dialog_proxy.rb → dialog_proxy.rb} +36 -7
- data/lib/glimmer/swt/font_proxy.rb +12 -6
- data/lib/glimmer/swt/message_box_proxy.rb +1 -0
- data/lib/glimmer/swt/properties.rb +3 -0
- data/lib/glimmer/swt/proxy_properties.rb +145 -0
- data/lib/glimmer/swt/transform_proxy.rb +39 -35
- data/lib/glimmer/swt/widget_proxy.rb +32 -60
- data/samples/elaborate/contact_manager.rb +2 -0
- data/samples/elaborate/login.rb +2 -0
- data/samples/elaborate/mandelbrot_fractal.rb +1 -0
- data/samples/elaborate/meta_sample.rb +1 -0
- data/samples/elaborate/tetris.rb +2 -1
- data/samples/elaborate/tic_tac_toe.rb +2 -0
- data/samples/elaborate/user_profile.rb +10 -8
- data/samples/hello/hello_browser.rb +2 -0
- data/samples/hello/hello_button.rb +2 -0
- data/samples/hello/hello_canvas.rb +157 -77
- data/samples/hello/hello_canvas_animation.rb +2 -0
- data/samples/hello/hello_canvas_transform.rb +2 -0
- data/samples/hello/hello_checkbox.rb +2 -0
- data/samples/hello/hello_checkbox_group.rb +2 -0
- data/samples/hello/hello_code_text.rb +2 -0
- data/{lib/glimmer/dsl/swt/directory_dialog_expression.rb → samples/hello/hello_color_dialog.rb} +44 -24
- data/samples/hello/hello_combo.rb +2 -0
- data/samples/hello/hello_computed.rb +2 -0
- data/samples/hello/hello_cursor.rb +2 -0
- data/samples/hello/hello_custom_shell.rb +1 -0
- data/samples/hello/hello_custom_widget.rb +2 -0
- data/samples/hello/hello_date_time.rb +2 -0
- data/samples/hello/hello_dialog.rb +2 -0
- data/samples/hello/hello_directory_dialog.rb +2 -0
- data/samples/hello/hello_drag_and_drop.rb +5 -3
- data/samples/hello/hello_expand_bar.rb +2 -0
- data/samples/hello/hello_file_dialog.rb +2 -0
- data/samples/hello/hello_font_dialog.rb +84 -0
- data/samples/hello/hello_group.rb +2 -0
- data/samples/hello/hello_link.rb +2 -0
- data/samples/hello/hello_list_multi_selection.rb +2 -0
- data/samples/hello/hello_list_single_selection.rb +2 -0
- data/samples/hello/hello_menu_bar.rb +2 -0
- data/samples/hello/hello_message_box.rb +2 -0
- data/samples/hello/hello_pop_up_context_menu.rb +2 -0
- data/samples/hello/hello_progress_bar.rb +2 -0
- data/samples/hello/hello_radio.rb +2 -0
- data/samples/hello/hello_radio_group.rb +2 -0
- data/samples/hello/hello_sash_form.rb +2 -0
- data/samples/hello/hello_spinner.rb +2 -0
- data/samples/hello/hello_styled_text.rb +19 -17
- data/samples/hello/hello_tab.rb +2 -0
- data/samples/hello/hello_table.rb +2 -0
- data/samples/hello/hello_world.rb +2 -0
- metadata +6 -6
- data/lib/glimmer/dsl/swt/file_dialog_expression.rb +0 -48
- data/lib/glimmer/swt/file_dialog_proxy.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb342869be74c6e592466ad89d26798dde5cf8f3d6beb52b5bcf6a6e8f221f6
|
4
|
+
data.tar.gz: c75442b7c5aeac5d77878d52e969669ea677877c12a43c97081155c5412c9c4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e484674be4fa02ea232e1452a80c4fbb2f141bee407ef6ce922dd0f1e3616f6ee420fc57fdd3d9af6c9d993a88705d95e62d9a5573273e63638a5876bf53d9
|
7
|
+
data.tar.gz: 6a76ebd41db15abe32ae22b2c675199595e196251b03a84ddad99a3aa2b254b43b8e50e339579764de667e10e3673814fb4ab3886aa9f27a9f8c43a7ca16bdcd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,48 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.18.5.5
|
4
|
+
|
5
|
+
- Automatically recalculate default size (width/height) to accomodate nested shapes when changing x/y/width/height sticking out of parent from right or bottom.
|
6
|
+
- Support special case of centering a nested shape with default x/y within a parent with default width/height calculated from nested shape
|
7
|
+
- Consider Canvas Shape DSL support for LineAttributes `line_dash_offset` and `line_miter_limit`
|
8
|
+
- Canvas Shape DSL Polygon `include?` does an outer/inner check of edge detection only
|
9
|
+
- Ensure all Canvas Shape DSL properties are restored upon painting a shape to what they were prior to painting that shape
|
10
|
+
- Fix issue with bringing high score dialog up in Tetris caused by latest dialog changes for supporting the new `color_dialog` and `font_dialog`
|
11
|
+
|
12
|
+
### 4.18.5.4
|
13
|
+
|
14
|
+
- 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
|
15
|
+
- Support [:default, width_delta], [:default, height_delta] attributes for width and height, which add/subtract from defaults used for shape
|
16
|
+
- 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)
|
17
|
+
- 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)
|
18
|
+
|
19
|
+
### 4.18.5.3
|
20
|
+
|
21
|
+
- Support nesting shapes within shapes, with relative positioning (meaning x, y coordinates are assumed relative to parent's x, y in nested shapes)
|
22
|
+
- 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
|
23
|
+
- Support default_x_delta, y_delta attributes, which add/subtract from defaults used for shape
|
24
|
+
|
25
|
+
### 4.18.5.2
|
26
|
+
|
27
|
+
- Support checking if an `arc` shape accurately includes a point x,y coordinates within pie region only
|
28
|
+
- Support checking if an `oval` shape includes a point x,y coordinates in oval region only (not its rectangular region)
|
29
|
+
- Support checking if a `focus` shape includes a point x,y coordinates
|
30
|
+
- Support checking point inclusion differently in drawed vs filled Rectangle (only check the drawn border when not filled)
|
31
|
+
- Support checking point inclusion differently in drawed vs filled Oval (only check the drawn border when not filled)
|
32
|
+
- Support checking point inclusion differently in drawed vs filled Arc (only check the drawn border when not filled)
|
33
|
+
- Support `#include?(x, y)` and `#contain?(x, y)` methods in `text` shape
|
34
|
+
- Fix point inclusion check for polyline
|
35
|
+
- Fix issue with `polygon` check if it includes a point x,y coordinates (replace with available `java.awt` robust geometry algorithms)
|
36
|
+
- Fix issue with transforms not working after the latest changes
|
37
|
+
|
38
|
+
### 4.18.5.1
|
39
|
+
|
40
|
+
- Hello, Color Dialog! Sample
|
41
|
+
- Hello, Font Dialog! Sample
|
42
|
+
- Handle SWT RGB color data objects when setting colors on widgets (e.g. background)
|
43
|
+
- Enhance Hello, Canvas! with Color selector via right-click menu
|
44
|
+
- Fixed issue with tree multi selection throwing an exception
|
45
|
+
|
3
46
|
### 4.18.5.0
|
4
47
|
|
5
48
|
- Automatic `sync_exec` usage from threads other than the GUI thread, thus absolving software engineers from the need to use `sync_exec` explicitly anymore.
|
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.
|
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.5
|
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
|
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.5.5 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.
|
343
|
+
jgem install glimmer-dsl-swt -v 4.18.5.5
|
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.
|
361
|
+
gem 'glimmer-dsl-swt', '~> 4.18.5.5'
|
364
362
|
```
|
365
363
|
|
366
364
|
And, then run:
|
@@ -404,9 +402,16 @@ Glimmer configuration may be done via the `Glimmer::Config` module.
|
|
404
402
|
|
405
403
|
## Samples
|
406
404
|
|
405
|
+
See a listing of samples over here, including screenshots and explanations of what each sample demonstrates:
|
406
|
+
|
407
407
|
[docs/reference/GLIMMER_SAMPLES.md](docs/reference/GLIMMER_SAMPLES.md)
|
408
408
|
|
409
|
-
Check the [samples](samples) directory in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) for examples on how to write Glimmer applications. To run a sample, make sure to install the `glimmer-dsl-swt` gem first and then
|
409
|
+
Check the [samples](samples) directory in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) for examples on how to write Glimmer applications. To run a sample, make sure to install the `glimmer-dsl-swt` gem first and then run:
|
410
|
+
```
|
411
|
+
glimmer samples
|
412
|
+
```
|
413
|
+
|
414
|
+
(alternatively, you may clone the repo, follow [CONTRIBUTING.md](CONTRIBUTING.md) instructions, and run samples locally with development glimmer command: `bin/glimmer`)
|
410
415
|
|
411
416
|
![Glimmer Meta-Sample](/images/glimmer-meta-sample.png)
|
412
417
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.5.
|
1
|
+
4.18.5.5
|
@@ -36,6 +36,7 @@ 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)
|
@@ -432,7 +433,7 @@ Dialog is a variation on Shell. It is basically a shell that is modal (blocks wh
|
|
432
433
|
|
433
434
|
Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT.DIALOG_TRIM and SWT.APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
|
434
435
|
|
435
|
-
Check out [Hello, Dialog!](#hello-dialog) sample to learn more.
|
436
|
+
Check out [Hello, Dialog!](GLIMMER_SAMPLES.md#hello-dialog) sample to learn more.
|
436
437
|
|
437
438
|
##### message_box
|
438
439
|
|
@@ -895,7 +896,7 @@ shell {
|
|
895
896
|
}.open
|
896
897
|
```
|
897
898
|
|
898
|
-
You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
|
899
|
+
You may check out a more full-fledged example in [Hello, Sash Form!](GLIMMER_SAMPLES.md#hello-sash-form)
|
899
900
|
|
900
901
|
![Hello Sash Form](/images/glimmer-hello-sash-form.png)
|
901
902
|
|
@@ -1385,11 +1386,9 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
|
|
1385
1386
|
|
1386
1387
|
**(ALPHA FEATURE)**
|
1387
1388
|
|
1388
|
-
Glimmer
|
1389
|
+
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
1390
|
|
1390
|
-
`canvas` has the `:double_buffered` SWT style by default 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
|
-
|
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.
|
1391
|
+
`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)`)
|
1393
1392
|
|
1394
1393
|
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
1394
|
- `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)
|
@@ -1404,9 +1403,10 @@ Shape keywords and their args (including defaults) are listed below (they basica
|
|
1404
1403
|
- `rectangle(x, y, width, height, fill: false)` standard rectangle, which can be optionally filled
|
1405
1404
|
- `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
1405
|
- `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
|
-
- `text(string, x, y,
|
1406
|
+
- `text(string, x, y, is_transparent = true)` text with optional is_transparent to indicate if background is transparent (default is true)
|
1407
|
+
- `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
1408
|
|
1409
|
-
Shape keywords that can be filled with color can take
|
1409
|
+
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.
|
1410
1410
|
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.
|
1411
1411
|
|
1412
1412
|
Optionally, a shape keyword takes a block that can set any attributes from [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) (methods starting with `set`), which enable setting the `background` for filling and `foreground` for drawing.
|
@@ -1461,7 +1461,7 @@ shell {
|
|
1461
1461
|
font height: 25, style: :bold
|
1462
1462
|
}
|
1463
1463
|
rectangle(200, 80, 108, 36) {
|
1464
|
-
foreground
|
1464
|
+
foreground rgb(0, 0, 0)
|
1465
1465
|
line_width 3
|
1466
1466
|
}
|
1467
1467
|
image(image_object, 70, 50)
|
@@ -1473,7 +1473,115 @@ Screenshot:
|
|
1473
1473
|
|
1474
1474
|
![Canvas Animation Example](/images/glimmer-example-canvas.png)
|
1475
1475
|
|
1476
|
-
|
1476
|
+
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`.
|
1477
|
+
|
1478
|
+
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`
|
1479
|
+
|
1480
|
+
The round and gradient options could be dropped since Glimmer DSL for SWT supports auto-inference of them based on shape parameters.
|
1481
|
+
|
1482
|
+
Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1483
|
+
|
1484
|
+
```ruby
|
1485
|
+
include Glimmer
|
1486
|
+
|
1487
|
+
# image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
|
1488
|
+
image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
|
1489
|
+
|
1490
|
+
shell {
|
1491
|
+
text 'Canvas Example'
|
1492
|
+
minimum_size 320, 400
|
1493
|
+
|
1494
|
+
canvas {
|
1495
|
+
background :dark_yellow
|
1496
|
+
rectangle(0, 0, 220, 400) {
|
1497
|
+
background :dark_red
|
1498
|
+
}
|
1499
|
+
rectangle(50, 20, 300, 150, 30, 50) {
|
1500
|
+
background :yellow
|
1501
|
+
}
|
1502
|
+
rectangle(150, 200, 100, 70, true) {
|
1503
|
+
background :dark_red
|
1504
|
+
foreground :yellow
|
1505
|
+
}
|
1506
|
+
text('Glimmer', 208, 83) {
|
1507
|
+
font height: 25, style: :bold
|
1508
|
+
}
|
1509
|
+
rectangle(200, 80, 108, 36) {
|
1510
|
+
foreground rgb(0, 0, 0)
|
1511
|
+
line_width 3
|
1512
|
+
}
|
1513
|
+
image(image_object, 70, 50)
|
1514
|
+
}
|
1515
|
+
}.open
|
1516
|
+
```
|
1517
|
+
|
1518
|
+
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.
|
1519
|
+
|
1520
|
+
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)
|
1521
|
+
|
1522
|
+
Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1523
|
+
|
1524
|
+
```ruby
|
1525
|
+
include Glimmer
|
1526
|
+
|
1527
|
+
# image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
|
1528
|
+
image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
|
1529
|
+
|
1530
|
+
shell {
|
1531
|
+
text 'Canvas Example'
|
1532
|
+
minimum_size 320, 400
|
1533
|
+
|
1534
|
+
canvas {
|
1535
|
+
background :dark_yellow
|
1536
|
+
rectangle {
|
1537
|
+
x 0
|
1538
|
+
y 0
|
1539
|
+
width 220
|
1540
|
+
height 400
|
1541
|
+
background :dark_red
|
1542
|
+
}
|
1543
|
+
rectangle {
|
1544
|
+
x 50
|
1545
|
+
y 20
|
1546
|
+
width 300
|
1547
|
+
height 150
|
1548
|
+
arc_width 30
|
1549
|
+
arc_height 50
|
1550
|
+
background :yellow
|
1551
|
+
}
|
1552
|
+
rectangle {
|
1553
|
+
x 150
|
1554
|
+
y 200
|
1555
|
+
width 100
|
1556
|
+
height 70
|
1557
|
+
vertical true
|
1558
|
+
background :dark_red
|
1559
|
+
foreground :yellow
|
1560
|
+
}
|
1561
|
+
text {
|
1562
|
+
string 'Glimmer'
|
1563
|
+
x 208
|
1564
|
+
y 83
|
1565
|
+
font height: 25, style: :bold
|
1566
|
+
}
|
1567
|
+
rectangle {
|
1568
|
+
x 200
|
1569
|
+
y 80
|
1570
|
+
width 108
|
1571
|
+
height 36
|
1572
|
+
foreground :black
|
1573
|
+
line_width 3
|
1574
|
+
}
|
1575
|
+
image {
|
1576
|
+
image image_object
|
1577
|
+
x 70
|
1578
|
+
y 50
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
}.open
|
1582
|
+
```
|
1583
|
+
|
1584
|
+
Learn more at the [Hello, Canvas! Sample](GLIMMER_SAMPLES.md#hello-canvas).
|
1477
1585
|
|
1478
1586
|
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).
|
1479
1587
|
|
@@ -1489,23 +1597,26 @@ shell {
|
|
1489
1597
|
minimum_size 320, 400
|
1490
1598
|
|
1491
1599
|
canvas {
|
1492
|
-
background :
|
1600
|
+
background :dark_yellow
|
1493
1601
|
|
1494
1602
|
on_paint_control { |paint_event|
|
1495
1603
|
gc = paint_event.gc
|
1496
|
-
gc.background = color(:red).swt_color
|
1497
|
-
gc.fill_rectangle(0, 0, 220, 400)
|
1498
1604
|
|
1499
|
-
gc.background = color(:
|
1500
|
-
gc.
|
1605
|
+
gc.background = color(:dark_red).swt_color
|
1606
|
+
gc.fill_rectangle(0, 0, 220, 400)
|
1501
1607
|
|
1502
|
-
gc.background = color(:
|
1503
|
-
gc.
|
1608
|
+
gc.background = color(:yellow).swt_color
|
1609
|
+
gc.fill_round_rectangle(50, 20, 300, 150, 30, 50)
|
1504
1610
|
|
1505
|
-
gc.
|
1506
|
-
gc.
|
1611
|
+
gc.background = color(:dark_red).swt_color
|
1612
|
+
gc.foreground = color(:yellow).swt_color
|
1613
|
+
gc.fill_gradient_rectangle(150, 200, 100, 70, true)
|
1507
1614
|
|
1615
|
+
gc.font = font(height: 25, style: :bold).swt_font
|
1508
1616
|
gc.foreground = color(:black).swt_color
|
1617
|
+
gc.draw_text('Glimmer', 208, 83, true)
|
1618
|
+
|
1619
|
+
gc.foreground = rgb(0, 0, 0).swt_color
|
1509
1620
|
gc.line_width = 3
|
1510
1621
|
gc.draw_rectangle(200, 80, 108, 36)
|
1511
1622
|
|
@@ -1515,9 +1626,39 @@ shell {
|
|
1515
1626
|
}.open
|
1516
1627
|
```
|
1517
1628
|
|
1629
|
+
#### Shapes inside a Shape
|
1630
|
+
|
1631
|
+
Shapes can be nested within each other. If you nest a shape within another, its coordinates are assumed to be relative to its parent.
|
1632
|
+
|
1633
|
+
As such, if you move the parent, it moves all its children with it.
|
1634
|
+
|
1635
|
+
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.
|
1636
|
+
|
1637
|
+
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`
|
1638
|
+
|
1639
|
+
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:
|
1640
|
+
|
1641
|
+
```ruby
|
1642
|
+
rectangle(205, 50, 88, 96) {
|
1643
|
+
foreground :yellow
|
1644
|
+
3.times { |n|
|
1645
|
+
line(45, 70 + n*10, 65 + n*10, 30 + n*10) {
|
1646
|
+
foreground :yellow
|
1647
|
+
}
|
1648
|
+
}
|
1649
|
+
10.times {|n|
|
1650
|
+
point(15 + n*5, 50 + n*5) {
|
1651
|
+
foreground :yellow
|
1652
|
+
}
|
1653
|
+
}
|
1654
|
+
polyline(45, 60, 55, 20, 65, 60, 85, 80, 45, 60)
|
1655
|
+
image(@image_object, 0, 5)
|
1656
|
+
}
|
1657
|
+
```
|
1658
|
+
|
1518
1659
|
#### Shapes inside a Widget
|
1519
1660
|
|
1520
|
-
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](#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`.
|
1661
|
+
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`.
|
1521
1662
|
|
1522
1663
|
#### Shapes inside an Image
|
1523
1664
|
|
@@ -1619,9 +1760,14 @@ shell {
|
|
1619
1760
|
|
1620
1761
|
These Canvas Shape API methods help with manipulating shapes upon user interaction, such as mouse clicking a specific shape.
|
1621
1762
|
|
1763
|
+
They are implemented with the help of the highly robust Java built-in shape geometry algorithms.
|
1764
|
+
|
1622
1765
|
- `WidgetProxy#shape_at_location(x, y)` : returns shape object at x, y location from a widget proxy like canvas
|
1623
|
-
- `Shape#
|
1766
|
+
- `Shape#contain?(x, y)` : indicates if shape contains x, y point
|
1767
|
+
- `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)
|
1624
1768
|
- `Shape#move_by(x_delta, y_delta)` : moves shape object at x, y location
|
1769
|
+
- `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)
|
1770
|
+
- `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)
|
1625
1771
|
|
1626
1772
|
Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example.
|
1627
1773
|
|
@@ -1889,7 +2035,7 @@ transform(1, 1, 4, 2, 2, 4).
|
|
1889
2035
|
translate(3, 7)
|
1890
2036
|
```
|
1891
2037
|
|
1892
|
-
Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
|
2038
|
+
Learn more at the [Hello, Canvas Transform! Sample](GLIMMER_SAMPLES.md#hello-canvas-transform).
|
1893
2039
|
|
1894
2040
|
### Canvas Animation DSL
|
1895
2041
|
|
@@ -1955,7 +2101,7 @@ API of Animation Object (returned from `animation` keyword):
|
|
1955
2101
|
- `#cycle_limited?` returns true if `cycle_count` is specified
|
1956
2102
|
- `#duration_limited?` returns true if `duration_limit` is specified
|
1957
2103
|
|
1958
|
-
Learn more at the [Hello, Canvas Animation! Sample](#hello-canvas-animation).
|
2104
|
+
Learn more at the [Hello, Canvas Animation! Sample](GLIMMER_SAMPLES.md#hello-canvas-animation).
|
1959
2105
|
|
1960
2106
|
If there is anything missing you would like added to the Glimmer Animation DSL that you saw available in the SWT APIs, you may [report an issue](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) or implement yourself and [contribute](#contributing) via a Pull Request.
|
1961
2107
|
|
@@ -1963,7 +2109,7 @@ If there is anything missing you would like added to the Glimmer Animation DSL t
|
|
1963
2109
|
|
1964
2110
|
Animation could be alternatively implemented without the `animation` keyword through a loop that invokes model methods inside `sync_exec {}` (or `async_exec {}`), which indirectly cause updates to the GUI via data-binding.
|
1965
2111
|
|
1966
|
-
The [Glimmer Tetris](#
|
2112
|
+
The [Glimmer Tetris](GLIMMER_SAMPLES.md#tetris) sample provides a good example of that.
|
1967
2113
|
|
1968
2114
|
### Data-Binding
|
1969
2115
|
|
@@ -2324,7 +2470,7 @@ shell {
|
|
2324
2470
|
}
|
2325
2471
|
```
|
2326
2472
|
|
2327
|
-
Check out [Hello, Table!](#hello-table) for an actual example including table editors.
|
2473
|
+
Check out [Hello, Table!](GLIMMER_SAMPLES.md#hello-table) for an actual example including table editors.
|
2328
2474
|
|
2329
2475
|
[Are We There Yet?](#are-we-there-yet) is an actual production Glimmer application that takes full advantage of table capabilities, storing model data in a database via ActiveRecord. As such, it's an excellent demonstration of how to use Glimmer DSL for SWT with a database.
|
2330
2476
|
|
@@ -2332,7 +2478,7 @@ Check out [Hello, Table!](#hello-table) for an actual example including table ed
|
|
2332
2478
|
|
2333
2479
|
Glimmer automatically adds sorting support to the SWT `Table` widget.
|
2334
2480
|
|
2335
|
-
Check out the [Contact Manager](#contact-manager) sample for an example.
|
2481
|
+
Check out the [Contact Manager](GLIMMER_SAMPLES.md#contact-manager) sample for an example.
|
2336
2482
|
You may click on any column and it will sort by ascending order first and descending if you click again.
|
2337
2483
|
|
2338
2484
|
Glimmer automatic table sorting supports `String`, `Integer`, and `Float` columns out of the box as well as any column data that is comparable.
|
@@ -2454,7 +2600,7 @@ You can data-bind any of these properties:
|
|
2454
2600
|
- `minutes bind(model, :property)`: produces an integer
|
2455
2601
|
- `seconds bind(model, :property)`: produces an integer
|
2456
2602
|
|
2457
|
-
Learn more at the [Hello, Date Time!](#hello-date-time) sample.
|
2603
|
+
Learn more at the [Hello, Date Time!](GLIMMER_SAMPLES.md#hello-date-time) sample.
|
2458
2604
|
|
2459
2605
|
If you need a better widget with the ability to customize the date format pattern, check out the [Nebula CDateTime Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-cw-cdatetime-nebula)
|
2460
2606
|
|
@@ -2840,7 +2986,7 @@ The `checkboxes` property returns the list of nested `checkbox` widgets.
|
|
2840
2986
|
|
2841
2987
|
When data-binding `selection`, the model property should have a matching property with `_options` suffix (e.g. `activities_options` for `activities`) to provide an `Array` of `String` objects for `checkbox` buttons.
|
2842
2988
|
|
2843
|
-
You may see an example at the [Hello, Checkbox Group!](#hello-checkbox-group) sample.
|
2989
|
+
You may see an example at the [Hello, Checkbox Group!](GLIMMER_SAMPLES.md#hello-checkbox-group) sample.
|
2844
2990
|
|
2845
2991
|
![Hello Checkbox Group](/images/glimmer-hello-checkbox-group.png)
|
2846
2992
|
|
@@ -2875,7 +3021,7 @@ radio_group { |radio_group_proxy|
|
|
2875
3021
|
# ...
|
2876
3022
|
```
|
2877
3023
|
|
2878
|
-
You may see another example at the [Hello, Radio Group!](#hello-radio-group) sample.
|
3024
|
+
You may see another example at the [Hello, Radio Group!](GLIMMER_SAMPLES.md#hello-radio-group) sample.
|
2879
3025
|
|
2880
3026
|
##### Code Text Custom Widget
|
2881
3027
|
|
@@ -3147,7 +3293,7 @@ This adds some default keyboard shortcuts:
|
|
3147
3293
|
|
3148
3294
|
If you prefer it to be vanilla with no default key event listeners, then pass the `default_behavior: false` option.
|
3149
3295
|
|
3150
|
-
Learn more at [Hello, Code Text!](#hello-code-text)
|
3296
|
+
Learn more at [Hello, Code Text!](GLIMMER_SAMPLES.md#hello-code-text)
|
3151
3297
|
|
3152
3298
|
##### Video Custom Custom Widget
|
3153
3299
|
|
@@ -3162,7 +3308,7 @@ Simply install the [glimmer-cw-video](https://rubygems.org/gems/glimmer-cw-video
|
|
3162
3308
|
This [Eclipse guide](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm) for how to write custom SWT widgets is also applicable to Glimmer Custom Widgets written in Ruby. I recommend reading it:
|
3163
3309
|
[https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm)
|
3164
3310
|
|
3165
|
-
Also, you may check out [Hello, Custom Widget!](#hello-custom-widget) for another example.
|
3311
|
+
Also, you may check out [Hello, Custom Widget!](GLIMMER_SAMPLES.md#hello-custom-widget) for another example.
|
3166
3312
|
|
3167
3313
|
### Custom Shells
|
3168
3314
|
|
@@ -3233,7 +3379,7 @@ shell { |app_shell|
|
|
3233
3379
|
|
3234
3380
|
If you use a Custom Shell as the top-level app shell, you may invoke the class method `::launch` instead to avoid building an app class yourself or including Glimmer into the top-level namespace (e.g. `Tetris.launch` instead of `include Glimmer; tetris.open`)
|
3235
3381
|
|
3236
|
-
You may check out [Hello, Custom Shell!](#hello-custom-shell) for another example.
|
3382
|
+
You may check out [Hello, Custom Shell!](GLIMMER_SAMPLES.md#hello-custom-shell) for another example.
|
3237
3383
|
|
3238
3384
|
### Drag and Drop
|
3239
3385
|
|
@@ -3247,7 +3393,7 @@ To get started, simply follow these steps:
|
|
3247
3393
|
1. On the drop target widget, add `on_drop` [DropTargetListener](https://help.eclipse.org/2020-03/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DropTargetListener.html) event handler block at minimum (you may also add `on_drag_enter` [must set [`event.detail`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DropTargetEvent.html#detail) if added], `on_drag_over`, `on_drag_leave`, `on_drag_operation_changed` and `on_drop_accept` if needed)
|
3248
3394
|
1. Read `event.data` and consume it (e.g. change widget text) inside the `on_drop` event handler block.
|
3249
3395
|
|
3250
|
-
Example (taken from [samples/hello/hello_drag_and_drop.rb](#hello-drag-and-drop) / you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
3396
|
+
Example (taken from [samples/hello/hello_drag_and_drop.rb](GLIMMER_SAMPLES.md#hello-drag-and-drop) / you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
3251
3397
|
|
3252
3398
|
```ruby
|
3253
3399
|
class Location
|