glimmer-dsl-swt 4.18.5.1 → 4.18.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/README.md +15 -12
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +205 -24
- data/docs/reference/GLIMMER_SAMPLES.md +8 -0
- data/glimmer-dsl-swt.gemspec +8 -3
- data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
- data/lib/glimmer/swt/custom/drawable.rb +10 -2
- data/lib/glimmer/swt/custom/shape.rb +449 -54
- data/lib/glimmer/swt/custom/shape/arc.rb +35 -0
- data/lib/glimmer/swt/custom/shape/cubic.rb +108 -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 +121 -4
- data/lib/glimmer/swt/custom/shape/oval.rb +18 -0
- data/lib/glimmer/swt/custom/shape/path.rb +197 -0
- data/lib/glimmer/swt/custom/shape/path_segment.rb +86 -0
- data/lib/glimmer/swt/custom/shape/point.rb +42 -4
- 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/quad.rb +104 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +19 -0
- data/lib/glimmer/swt/custom/shape/text.rb +13 -3
- data/lib/glimmer/swt/dialog_proxy.rb +4 -0
- data/lib/glimmer/swt/proxy_properties.rb +1 -1
- data/lib/glimmer/swt/transform_proxy.rb +20 -4
- data/lib/glimmer/swt/widget_proxy.rb +17 -1
- data/samples/elaborate/contact_manager.rb +2 -0
- data/samples/elaborate/login.rb +2 -0
- data/samples/elaborate/mandelbrot_fractal.rb +2 -1
- 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 +40 -23
- data/samples/hello/hello_canvas_animation.rb +2 -0
- data/samples/hello/hello_canvas_path.rb +223 -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/samples/hello/hello_color_dialog.rb +2 -0
- 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 +2 -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 +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b3fe4c65726425f091b0660bbf4dd4c55543c5c515bed56487aacb7e1458b7e
|
4
|
+
data.tar.gz: 71580957a753685f1eac22fb60ea13c2e2f289bb47017293980d4d06d78d5eec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 974be0abde39dbacdabe5d560c319a049907791e280f03aa6192e945b64057f814cbc57346f51cead9627ee98db52276367f4ca1f8f497b2882846d280a7f103
|
7
|
+
data.tar.gz: 7b9c169a4705c8bfa390ef440e31100e40560eabca4f204d18d8e5197174d9834827fd9f76907384c2d8e3873f968c11b94f6a985c3a43eda0bbf9b8fc7b8bc9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.18.6.0
|
4
|
+
|
5
|
+
- 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)
|
6
|
+
- 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.
|
7
|
+
- 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`
|
8
|
+
- Support `Shape#content {}` method just like `WidgetProxy#content` to enable reopening and adding nested shapes at runtime after initial construction
|
9
|
+
- Support a path containing a `quad` bezier curve with `point_array` property
|
10
|
+
- Support a path containing a `cubic` bezier curve with `point_array` property
|
11
|
+
|
12
|
+
### 4.18.5.5
|
13
|
+
|
14
|
+
- Automatically recalculate default size (width/height) to accomodate nested shapes when changing x/y/width/height sticking out of parent from right or bottom.
|
15
|
+
- Support special case of centering a nested shape with default x/y within a parent with default width/height calculated from nested shape
|
16
|
+
- Consider Canvas Shape DSL support for LineAttributes `line_dash_offset` and `line_miter_limit`
|
17
|
+
- Canvas Shape DSL Polygon `include?` does an outer/inner check of edge detection only
|
18
|
+
- Ensure all Canvas Shape DSL properties are restored upon painting a shape to what they were prior to painting that shape
|
19
|
+
- Fix issue with bringing high score dialog up in Tetris caused by latest dialog changes for supporting the new `color_dialog` and `font_dialog`
|
20
|
+
|
21
|
+
### 4.18.5.4
|
22
|
+
|
23
|
+
- 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
|
24
|
+
- Support [:default, width_delta], [:default, height_delta] attributes for width and height, which add/subtract from defaults used for shape
|
25
|
+
- 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)
|
26
|
+
- 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)
|
27
|
+
|
28
|
+
### 4.18.5.3
|
29
|
+
|
30
|
+
- Support nesting shapes within shapes, with relative positioning (meaning x, y coordinates are assumed relative to parent's x, y in nested shapes)
|
31
|
+
- 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
|
32
|
+
- Support default_x_delta, y_delta attributes, which add/subtract from defaults used for shape
|
33
|
+
|
34
|
+
### 4.18.5.2
|
35
|
+
|
36
|
+
- Support checking if an `arc` shape accurately includes a point x,y coordinates within pie region only
|
37
|
+
- Support checking if an `oval` shape includes a point x,y coordinates in oval region only (not its rectangular region)
|
38
|
+
- Support checking if a `focus` shape includes a point x,y coordinates
|
39
|
+
- Support checking point inclusion differently in drawed vs filled Rectangle (only check the drawn border when not filled)
|
40
|
+
- Support checking point inclusion differently in drawed vs filled Oval (only check the drawn border when not filled)
|
41
|
+
- Support checking point inclusion differently in drawed vs filled Arc (only check the drawn border when not filled)
|
42
|
+
- Support `#include?(x, y)` and `#contain?(x, y)` methods in `text` shape
|
43
|
+
- Fix point inclusion check for polyline
|
44
|
+
- Fix issue with `polygon` check if it includes a point x,y coordinates (replace with available `java.awt` robust geometry algorithms)
|
45
|
+
- Fix issue with transforms not working after the latest changes
|
46
|
+
|
3
47
|
### 4.18.5.1
|
4
48
|
|
5
49
|
- Hello, Color Dialog! Sample
|
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.
|
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
|
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.
|
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.
|
361
|
+
gem 'glimmer-dsl-swt', '~> 4.18.6.0'
|
364
362
|
```
|
365
363
|
|
366
364
|
And, then run:
|
@@ -404,11 +402,16 @@ Glimmer configuration may be done via the `Glimmer::Config` module.
|
|
404
402
|
|
405
403
|
## Samples
|
406
404
|
|
407
|
-
See a listing of
|
405
|
+
See a listing of samples over here, including screenshots and explanations of what each sample demonstrates:
|
408
406
|
|
409
407
|
[docs/reference/GLIMMER_SAMPLES.md](docs/reference/GLIMMER_SAMPLES.md)
|
410
408
|
|
411
|
-
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`)
|
412
415
|
|
413
416
|
![Glimmer Meta-Sample](/images/glimmer-meta-sample.png)
|
414
417
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.
|
1
|
+
4.18.6.0
|
@@ -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,11 +1387,9 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
|
|
1385
1387
|
|
1386
1388
|
**(ALPHA FEATURE)**
|
1387
1389
|
|
1388
|
-
Glimmer
|
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
|
-
`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.
|
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)`)
|
1393
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)
|
@@ -1404,9 +1404,10 @@ Shape keywords and their args (including defaults) are listed below (they basica
|
|
1404
1404
|
- `rectangle(x, y, width, height, fill: false)` standard rectangle, which can be optionally filled
|
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
|
-
- `text(string, x, y,
|
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
1409
|
|
1409
|
-
Shape keywords that can be filled with color can take
|
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.
|
1410
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.
|
1411
1412
|
|
1412
1413
|
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 +1462,7 @@ shell {
|
|
1461
1462
|
font height: 25, style: :bold
|
1462
1463
|
}
|
1463
1464
|
rectangle(200, 80, 108, 36) {
|
1464
|
-
foreground
|
1465
|
+
foreground rgb(0, 0, 0)
|
1465
1466
|
line_width 3
|
1466
1467
|
}
|
1467
1468
|
image(image_object, 70, 50)
|
@@ -1473,6 +1474,114 @@ Screenshot:
|
|
1473
1474
|
|
1474
1475
|
![Canvas Animation Example](/images/glimmer-example-canvas.png)
|
1475
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
|
+
|
1481
|
+
The round and gradient options could be dropped since Glimmer DSL for SWT supports auto-inference of them based on shape parameters.
|
1482
|
+
|
1483
|
+
Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1484
|
+
|
1485
|
+
```ruby
|
1486
|
+
include Glimmer
|
1487
|
+
|
1488
|
+
# image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
|
1489
|
+
image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
|
1490
|
+
|
1491
|
+
shell {
|
1492
|
+
text 'Canvas Example'
|
1493
|
+
minimum_size 320, 400
|
1494
|
+
|
1495
|
+
canvas {
|
1496
|
+
background :dark_yellow
|
1497
|
+
rectangle(0, 0, 220, 400) {
|
1498
|
+
background :dark_red
|
1499
|
+
}
|
1500
|
+
rectangle(50, 20, 300, 150, 30, 50) {
|
1501
|
+
background :yellow
|
1502
|
+
}
|
1503
|
+
rectangle(150, 200, 100, 70, true) {
|
1504
|
+
background :dark_red
|
1505
|
+
foreground :yellow
|
1506
|
+
}
|
1507
|
+
text('Glimmer', 208, 83) {
|
1508
|
+
font height: 25, style: :bold
|
1509
|
+
}
|
1510
|
+
rectangle(200, 80, 108, 36) {
|
1511
|
+
foreground rgb(0, 0, 0)
|
1512
|
+
line_width 3
|
1513
|
+
}
|
1514
|
+
image(image_object, 70, 50)
|
1515
|
+
}
|
1516
|
+
}.open
|
1517
|
+
```
|
1518
|
+
|
1519
|
+
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.
|
1520
|
+
|
1521
|
+
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)
|
1522
|
+
|
1523
|
+
Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1524
|
+
|
1525
|
+
```ruby
|
1526
|
+
include Glimmer
|
1527
|
+
|
1528
|
+
# image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
|
1529
|
+
image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
|
1530
|
+
|
1531
|
+
shell {
|
1532
|
+
text 'Canvas Example'
|
1533
|
+
minimum_size 320, 400
|
1534
|
+
|
1535
|
+
canvas {
|
1536
|
+
background :dark_yellow
|
1537
|
+
rectangle {
|
1538
|
+
x 0
|
1539
|
+
y 0
|
1540
|
+
width 220
|
1541
|
+
height 400
|
1542
|
+
background :dark_red
|
1543
|
+
}
|
1544
|
+
rectangle {
|
1545
|
+
x 50
|
1546
|
+
y 20
|
1547
|
+
width 300
|
1548
|
+
height 150
|
1549
|
+
arc_width 30
|
1550
|
+
arc_height 50
|
1551
|
+
background :yellow
|
1552
|
+
}
|
1553
|
+
rectangle {
|
1554
|
+
x 150
|
1555
|
+
y 200
|
1556
|
+
width 100
|
1557
|
+
height 70
|
1558
|
+
vertical true
|
1559
|
+
background :dark_red
|
1560
|
+
foreground :yellow
|
1561
|
+
}
|
1562
|
+
text {
|
1563
|
+
string 'Glimmer'
|
1564
|
+
x 208
|
1565
|
+
y 83
|
1566
|
+
font height: 25, style: :bold
|
1567
|
+
}
|
1568
|
+
rectangle {
|
1569
|
+
x 200
|
1570
|
+
y 80
|
1571
|
+
width 108
|
1572
|
+
height 36
|
1573
|
+
foreground :black
|
1574
|
+
line_width 3
|
1575
|
+
}
|
1576
|
+
image {
|
1577
|
+
image image_object
|
1578
|
+
x 70
|
1579
|
+
y 50
|
1580
|
+
}
|
1581
|
+
}
|
1582
|
+
}.open
|
1583
|
+
```
|
1584
|
+
|
1476
1585
|
Learn more at the [Hello, Canvas! Sample](GLIMMER_SAMPLES.md#hello-canvas).
|
1477
1586
|
|
1478
1587
|
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).
|
@@ -1489,23 +1598,26 @@ shell {
|
|
1489
1598
|
minimum_size 320, 400
|
1490
1599
|
|
1491
1600
|
canvas {
|
1492
|
-
background :
|
1601
|
+
background :dark_yellow
|
1493
1602
|
|
1494
1603
|
on_paint_control { |paint_event|
|
1495
1604
|
gc = paint_event.gc
|
1496
|
-
gc.background = color(:red).swt_color
|
1497
|
-
gc.fill_rectangle(0, 0, 220, 400)
|
1498
1605
|
|
1499
|
-
gc.background = color(:
|
1500
|
-
gc.
|
1606
|
+
gc.background = color(:dark_red).swt_color
|
1607
|
+
gc.fill_rectangle(0, 0, 220, 400)
|
1501
1608
|
|
1502
|
-
gc.background = color(:
|
1503
|
-
gc.
|
1609
|
+
gc.background = color(:yellow).swt_color
|
1610
|
+
gc.fill_round_rectangle(50, 20, 300, 150, 30, 50)
|
1504
1611
|
|
1505
|
-
gc.
|
1506
|
-
gc.
|
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)
|
1507
1615
|
|
1616
|
+
gc.font = font(height: 25, style: :bold).swt_font
|
1508
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
|
1509
1621
|
gc.line_width = 3
|
1510
1622
|
gc.draw_rectangle(200, 80, 108, 36)
|
1511
1623
|
|
@@ -1515,6 +1627,36 @@ shell {
|
|
1515
1627
|
}.open
|
1516
1628
|
```
|
1517
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
|
+
|
1518
1660
|
#### Shapes inside a Widget
|
1519
1661
|
|
1520
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`.
|
@@ -1619,9 +1761,14 @@ shell {
|
|
1619
1761
|
|
1620
1762
|
These Canvas Shape API methods help with manipulating shapes upon user interaction, such as mouse clicking a specific shape.
|
1621
1763
|
|
1764
|
+
They are implemented with the help of the highly robust Java built-in shape geometry algorithms.
|
1765
|
+
|
1622
1766
|
- `WidgetProxy#shape_at_location(x, y)` : returns shape object at x, y location from a widget proxy like canvas
|
1623
|
-
- `Shape#
|
1767
|
+
- `Shape#contain?(x, y)` : indicates if shape contains x, y point
|
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)
|
1624
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)
|
1625
1772
|
|
1626
1773
|
Check [Hello, Canvas!](GLIMMER_SAMPLES.md#hello-canvas) for an example.
|
1627
1774
|
|
@@ -1807,6 +1954,40 @@ shell {
|
|
1807
1954
|
|
1808
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.
|
1809
1956
|
|
1957
|
+
### Canvas Path DSL
|
1958
|
+
|
1959
|
+
**(EARLY ALPHA FEATURE)**
|
1960
|
+
|
1961
|
+
Unlike common imperative GUI charting 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 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
|
+
shell {
|
1971
|
+
text 'Canvas Path DSL Example'
|
1972
|
+
minimum_size 300, 300
|
1973
|
+
|
1974
|
+
canvas {
|
1975
|
+
path {
|
1976
|
+
foreground :black
|
1977
|
+
point(0, 0)
|
1978
|
+
250.times {|n|
|
1979
|
+
cubic(n + n%30, n+ n%50, 40, 40, 70, 70, n + 20 + n%30, n%30*-1 * n%50)
|
1980
|
+
}
|
1981
|
+
}
|
1982
|
+
}
|
1983
|
+
|
1984
|
+
}.open
|
1985
|
+
```
|
1986
|
+
|
1987
|
+
Learn more at the [Hello, Canvas Path! Sample](/samples/hello/hello_canvas_path.rb).
|
1988
|
+
|
1989
|
+
![Hello Canvas Path Sample](/images/glimmer-hello-canvas-path.gif)
|
1990
|
+
|
1810
1991
|
### Canvas Transform DSL
|
1811
1992
|
|
1812
1993
|
**(ALPHA FEATURE)**
|
@@ -1963,7 +2144,7 @@ If there is anything missing you would like added to the Glimmer Animation DSL t
|
|
1963
2144
|
|
1964
2145
|
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
2146
|
|
1966
|
-
The [Glimmer Tetris](#tetris) sample provides a good example of that.
|
2147
|
+
The [Glimmer Tetris](GLIMMER_SAMPLES.md#tetris) sample provides a good example of that.
|
1967
2148
|
|
1968
2149
|
### Data-Binding
|
1969
2150
|
|
@@ -2324,7 +2505,7 @@ shell {
|
|
2324
2505
|
}
|
2325
2506
|
```
|
2326
2507
|
|
2327
|
-
Check out [Hello, Table!](#hello-table) for an actual example including table editors.
|
2508
|
+
Check out [Hello, Table!](GLIMMER_SAMPLES.md#hello-table) for an actual example including table editors.
|
2328
2509
|
|
2329
2510
|
[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
2511
|
|
@@ -2332,7 +2513,7 @@ Check out [Hello, Table!](#hello-table) for an actual example including table ed
|
|
2332
2513
|
|
2333
2514
|
Glimmer automatically adds sorting support to the SWT `Table` widget.
|
2334
2515
|
|
2335
|
-
Check out the [Contact Manager](#contact-manager) sample for an example.
|
2516
|
+
Check out the [Contact Manager](GLIMMER_SAMPLES.md#contact-manager) sample for an example.
|
2336
2517
|
You may click on any column and it will sort by ascending order first and descending if you click again.
|
2337
2518
|
|
2338
2519
|
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 +2635,7 @@ You can data-bind any of these properties:
|
|
2454
2635
|
- `minutes bind(model, :property)`: produces an integer
|
2455
2636
|
- `seconds bind(model, :property)`: produces an integer
|
2456
2637
|
|
2457
|
-
Learn more at the [Hello, Date Time!](#hello-date-time) sample.
|
2638
|
+
Learn more at the [Hello, Date Time!](GLIMMER_SAMPLES.md#hello-date-time) sample.
|
2458
2639
|
|
2459
2640
|
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
2641
|
|
@@ -2840,7 +3021,7 @@ The `checkboxes` property returns the list of nested `checkbox` widgets.
|
|
2840
3021
|
|
2841
3022
|
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
3023
|
|
2843
|
-
You may see an example at the [Hello, Checkbox Group!](#hello-checkbox-group) sample.
|
3024
|
+
You may see an example at the [Hello, Checkbox Group!](GLIMMER_SAMPLES.md#hello-checkbox-group) sample.
|
2844
3025
|
|
2845
3026
|
![Hello Checkbox Group](/images/glimmer-hello-checkbox-group.png)
|
2846
3027
|
|
@@ -2875,7 +3056,7 @@ radio_group { |radio_group_proxy|
|
|
2875
3056
|
# ...
|
2876
3057
|
```
|
2877
3058
|
|
2878
|
-
You may see another example at the [Hello, Radio Group!](#hello-radio-group) sample.
|
3059
|
+
You may see another example at the [Hello, Radio Group!](GLIMMER_SAMPLES.md#hello-radio-group) sample.
|
2879
3060
|
|
2880
3061
|
##### Code Text Custom Widget
|
2881
3062
|
|
@@ -3147,7 +3328,7 @@ This adds some default keyboard shortcuts:
|
|
3147
3328
|
|
3148
3329
|
If you prefer it to be vanilla with no default key event listeners, then pass the `default_behavior: false` option.
|
3149
3330
|
|
3150
|
-
Learn more at [Hello, Code Text!](#hello-code-text)
|
3331
|
+
Learn more at [Hello, Code Text!](GLIMMER_SAMPLES.md#hello-code-text)
|
3151
3332
|
|
3152
3333
|
##### Video Custom Custom Widget
|
3153
3334
|
|