glimmer-dsl-swt 4.18.1.0 → 4.18.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -0
- data/README.md +136 -46
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +10 -4
- data/lib/glimmer/dsl/swt/display_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/property_expression.rb +2 -1
- data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
- data/lib/glimmer/rake_task/list.rb +5 -5
- data/lib/glimmer/rake_task/package.rb +9 -9
- data/lib/glimmer/rake_task/scaffold.rb +36 -36
- data/lib/glimmer/swt/custom/animation.rb +163 -36
- data/lib/glimmer/swt/custom/code_text.rb +2 -1
- data/lib/glimmer/swt/custom/shape.rb +83 -18
- data/lib/glimmer/swt/display_proxy.rb +2 -1
- data/lib/glimmer/swt/widget_proxy.rb +4 -6
- data/lib/glimmer/ui/custom_shell.rb +13 -0
- data/samples/elaborate/meta_sample.rb +22 -1
- data/samples/elaborate/tetris.rb +102 -0
- data/samples/elaborate/tetris/model/block.rb +48 -0
- data/samples/elaborate/tetris/model/game.rb +116 -0
- data/samples/elaborate/tetris/model/tetromino.rb +228 -0
- data/samples/elaborate/tetris/view/block.rb +45 -0
- data/samples/elaborate/tetris/view/playfield.rb +49 -0
- data/samples/hello/hello_canvas.rb +7 -6
- data/samples/hello/hello_canvas_animation.rb +1 -1
- metadata +22 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813f7cef0d25c94aa62c0cd57d3445a3eb13acb229bdd59264f7d4a0268f1ed3
|
4
|
+
data.tar.gz: dccf84bac2d2ca037df0b4157335fd7451fc2701d90a79df18abc61971725df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9702ce2c81c56ddf6c56e590c7f30509149d75fbd6ee8e01da4bb5e0405381fae39da688ec30ab0686ff987cdc4eee06992d7c4b365a32f8bc2d773ea23e3b05
|
7
|
+
data.tar.gz: 4d1a2dfa58fffa6dd037ef07463056ccc70d09261bb0720f238332c07284347993c94e96ef5d18bb9a7f1f75d71b72ed2fdfe72202320f8de489624ac9084edc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,50 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.18.2.3
|
4
|
+
|
5
|
+
- Added Tetris Elaborate Sample
|
6
|
+
- Added support for CustomShell `::launch` and `::shutdown` class methods to treat a top-level custom shell as a self contained launchable app (saving you from writing boilerplate code for launching Glimmer applications)
|
7
|
+
|
8
|
+
### 4.18.2.2
|
9
|
+
|
10
|
+
- Fixed issue with processing shape color due to missing Color class package name
|
11
|
+
|
12
|
+
### 4.18.2.1
|
13
|
+
|
14
|
+
- Ensure drawing image works in Shape DSL
|
15
|
+
- Support passing image as simply an image path or image proxy to Shape DSL image method
|
16
|
+
|
17
|
+
### 4.18.2.0
|
18
|
+
|
19
|
+
- Canvas animation start method (useful if animation had a frame count limit or cycle count limit and needed to be started again after it stopped)
|
20
|
+
- Canvas animation stop method
|
21
|
+
- Canvas animation restart method (restarts from frame 1)
|
22
|
+
- Canvas animation started? # meaning it is animating
|
23
|
+
- Canvas animation stopped? # meaning it has stopped animating
|
24
|
+
- Canvas animation duration_limit option
|
25
|
+
- Make gradient/round rectangles in Shape DSL receive an option of `gradient: true` and `round: true` instead of prefix
|
26
|
+
- Canvas Shape DSL support for Background/Foreground Pattern (NOTE: not extensively tested yet)
|
27
|
+
- Canvas Shape DSL smart defaults for background/foreground depending on shape being drawn
|
28
|
+
- Canvas Shape DSL smart defaults for fill option depending on shape being drawn
|
29
|
+
- Added fallback font "Courier" for `code_text` widget when "Consolas" is not available.
|
30
|
+
|
31
|
+
### 4.18.1.1
|
32
|
+
|
33
|
+
- Add smart defaults for round rectangle angles (defaults to 60 degrees angles)
|
34
|
+
- Add smart default for gradient rectangle vertical option
|
35
|
+
- Small update to Hello, Canvas! Sample
|
36
|
+
- Convert SWT style symbol to SWT style integer if method takes integer but receives a symbol (or string)
|
37
|
+
- Make polygon not require [] for its array args
|
38
|
+
- Allow cycle to receive splatted array as varargs
|
39
|
+
- Change references to `Display.setAppName` and `Display.setAppVersion` to `Display.app_name =` and `Display.app_version =`
|
40
|
+
- Default Glimmer app name to "Glimmer" (instead of previous "SWT") unless `Display.app_name = "Somename"` is set by consumer before instantiating first display
|
41
|
+
- Set default background to system widget background default for fill shapes
|
42
|
+
- Set default foreground to black for draw shapes
|
43
|
+
- Fix issue with shapes always requiring a block (even an empty one) to render
|
44
|
+
- Fix issue with animation requiring changes to canvas directly in addition to shapes
|
45
|
+
- Fix issue with `glimmer list:gems:dsl` command
|
46
|
+
- Fix issue with scaffolding still depending on git-glimmer despite being merged back to git gem
|
47
|
+
|
3
48
|
### 4.18.1.0
|
4
49
|
|
5
50
|
- Canvas Shape DSL
|
data/README.md
CHANGED
@@ -1,6 +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.
|
2
|
-
|
3
|
-
|
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.2.3
|
4
2
|
## JRuby Desktop Development GUI Framework
|
5
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
6
4
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
@@ -10,9 +8,7 @@
|
|
10
8
|
|
11
9
|
**[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
|
12
10
|
|
13
|
-
(
|
14
|
-
|
15
|
-
[Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces while 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](#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. To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) 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](#custom-shell-gem) on [Linux](https://www.linux.org/).
|
11
|
+
[Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#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](#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](#widgets), but it also supports drawing Canvas Graphics like [Shapes](#canvas-shape-dsl) and [Animations](#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) 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](#custom-shell-gem) on [Linux](https://www.linux.org/).
|
16
12
|
|
17
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.
|
18
14
|
|
@@ -368,6 +364,7 @@ Glimmer App:
|
|
368
364
|
- [Login](#login)
|
369
365
|
- [Tic Tac Toe Sample](#tic-tac-toe-sample)
|
370
366
|
- [Contact Manager Sample](#contact-manager-sample)
|
367
|
+
- [Tetris](#tetris)
|
371
368
|
- [External Samples](#external-samples)
|
372
369
|
- [Glimmer Calculator](#glimmer-calculator)
|
373
370
|
- [Gladiator](#gladiator)
|
@@ -456,7 +453,7 @@ jgem install glimmer-dsl-swt
|
|
456
453
|
|
457
454
|
Or this command if you want a specific version:
|
458
455
|
```
|
459
|
-
jgem install glimmer-dsl-swt -v 4.18.
|
456
|
+
jgem install glimmer-dsl-swt -v 4.18.2.3
|
460
457
|
|
461
458
|
|
462
459
|
```
|
@@ -476,7 +473,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
476
473
|
|
477
474
|
Add the following to `Gemfile`:
|
478
475
|
```
|
479
|
-
gem 'glimmer-dsl-swt', '~> 4.18.
|
476
|
+
gem 'glimmer-dsl-swt', '~> 4.18.2.3
|
480
477
|
'
|
481
478
|
```
|
482
479
|
|
@@ -535,7 +532,7 @@ bin/glimmer samples
|
|
535
532
|
Below are the full usage instructions that come up when running `glimmer` without args.
|
536
533
|
|
537
534
|
```
|
538
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.
|
535
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.2.3
|
539
536
|
|
540
537
|
|
541
538
|
|
@@ -593,6 +590,8 @@ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
|
|
593
590
|
|
594
591
|
Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
|
595
592
|
|
593
|
+
Note: under Zsh (Z Shell), glimmer can only be used in its advanced TUI mode (e.g. `glimmer` and then selecting a task) not the primitive rake task mode (e.g. `glimmer scaffold[app]`)
|
594
|
+
|
596
595
|
### Glimmer Samples
|
597
596
|
|
598
597
|
You can list available Glimmer samples by running:
|
@@ -1013,8 +1012,8 @@ Output:
|
|
1013
1012
|
Name Gem Version Author Description
|
1014
1013
|
|
1015
1014
|
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
|
1016
|
-
Opal glimmer-dsl-opal 0.
|
1017
|
-
Swt glimmer-dsl-swt 4.18.
|
1015
|
+
Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
|
1016
|
+
Swt glimmer-dsl-swt 4.18.2.3
|
1018
1017
|
|
1019
1018
|
AndyMaleh Glimmer DSL for SWT
|
1020
1019
|
Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
|
@@ -1082,6 +1081,8 @@ With `glimmer-dsl-swt` installed, you may want to run `girb` instead of standard
|
|
1082
1081
|
girb
|
1083
1082
|
```
|
1084
1083
|
|
1084
|
+
![GIRB](images/glimmer-girb.png)
|
1085
|
+
|
1085
1086
|
If you cloned [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) project locally, you may run `bin/girb` instead.
|
1086
1087
|
|
1087
1088
|
```
|
@@ -1347,7 +1348,8 @@ This is not an exaustive list, but should give you a good start in learning Glim
|
|
1347
1348
|
**Event loop:**
|
1348
1349
|
- `display`: featured in [Tic Tac Toe](#tic-tac-toe)
|
1349
1350
|
- `async_exec`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell)
|
1350
|
-
|
1351
|
+
- `sync_exec`: executes a block on the event loop synchronously (usually from another thread)
|
1352
|
+
- `timer_exec`: executes a block after a delay of time has passed
|
1351
1353
|
|
1352
1354
|
#### SWT Proxies
|
1353
1355
|
|
@@ -2292,37 +2294,54 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
|
|
2292
2294
|
|
2293
2295
|
### Canvas Shape DSL
|
2294
2296
|
|
2295
|
-
(note: this is a very new feature of Glimmer. It may change a bit while getting battle tested. As always, you could default to basic SWT usage if needed.)
|
2296
|
-
|
2297
2297
|
Glimmer supports drawing graphics directly on a `canvas` widget via SWT (or any widget for that matter though `canvas` is recommended for drawing).
|
2298
2298
|
|
2299
2299
|
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.
|
2300
2300
|
|
2301
|
-
Shape keywords 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):
|
2302
|
-
- `arc(
|
2303
|
-
- `focus(
|
2304
|
-
- `image(
|
2305
|
-
- `line(
|
2306
|
-
- `oval(
|
2307
|
-
- `point(
|
2308
|
-
- `polygon(
|
2309
|
-
- `polyline(
|
2310
|
-
- `rectangle(
|
2311
|
-
- `
|
2312
|
-
- `
|
2313
|
-
- `text(
|
2314
|
-
|
2315
|
-
Shape keywords that can be filled with color can take an
|
2301
|
+
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):
|
2302
|
+
- `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)
|
2303
|
+
- `focus(x, y, width, height)` this is just like rectangle but its foreground color is always that of the OS widget focus color (useful when capturing user interaction via a shape)
|
2304
|
+
- `image(image, x, y)` [image](#image)
|
2305
|
+
- `line(x1, y1, x2, y2)` line
|
2306
|
+
- `oval(x, y, width, height, fill: false)` oval if width does not match heigh and circle if width matches height. Can be optionally filled.
|
2307
|
+
- `point(x, y)` point
|
2308
|
+
- `polygon(pointArray, fill: false)` polygon consisting of points, which close automatically to form a shape that can be optionally filled (when points only form a line, it does not show up as filled)
|
2309
|
+
- `polyline(pointArray)` polyline is just like a polygon, but it does not close up to form a shape, remaining open (unless the points close themselves by having the last point or an intermediate point match the first)
|
2310
|
+
- `rectangle(x, y, width, height, fill: false)` standard rectangle, which can be optionally filled
|
2311
|
+
- `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
|
2312
|
+
- `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
|
2313
|
+
- `text(string, x, y, flags = nil)` 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))
|
2314
|
+
|
2315
|
+
Shape keywords that can be filled with color can take an keyword argument `fill: true` (defaults to false when not specified)
|
2316
2316
|
|
2317
2317
|
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.
|
2318
2318
|
|
2319
|
+
Here is a list of supported attributes nestable within a block under shapes:
|
2320
|
+
- `advanced` enables advanced graphics subsystem (boolean value). Typically gets enabled automatically when setting alpha, antialias, patterns, interpolation, clipping. Rendering sometimes differs between advanced and non-advanced mode for basic graphics too, so you could enable manually if you prefer its look even for basic graphics.
|
2321
|
+
- `alpha` sets transparency (integer between `0` and `255`)
|
2322
|
+
- `antialias` enables antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
|
2323
|
+
- `background` sets fill color for fillable shapes (standard color symbol (e.g. `:red`), `rgb(red_integer, green_integer, blue_integer)` color, or Color/ColorProxy object directly)
|
2324
|
+
- `background_pattern` sets fill gradient/image pattern for fillable shape background (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. `background_pattern 2.3, 4.2, 5.4, 7.2, :red, :blue`] / note: this feature isn't extensively tested yet)
|
2325
|
+
- `clipping` clips area of painting (numeric values for `(x, y, width, height)`)
|
2326
|
+
- `fill_rule` sets filling rule (SWT style value of `:fill_even_odd` or `:fill_winding`)
|
2327
|
+
- `font` sets font (Hash of `:name`, `:height`, and `:style` just like standard widget font property, or Font/FontProxy object directly)
|
2328
|
+
- `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)
|
2329
|
+
- `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)
|
2330
|
+
- `interpolation` sets the interpolation value (SWT style value of `:default`, `:none`, `:low`, `:high`)
|
2331
|
+
- `line_cap` sets line cap (SWT style value of `:cap_flat`, `:cap_round`, or `:cap_square`)
|
2332
|
+
- `line_dash` line dash float values (automatically sets `line_style` to SWT style value of `:line_custom`)
|
2333
|
+
- `line_join` line join style (SWT style value of `:join_miter`, `:join_round`, or `:join_bevel`)
|
2334
|
+
- `line_style` line join style (SWT style value of `:line_solid`, `:line_dash`, `:line_dot`, `:line_dashdot`, or `:line_dashdotdot`)
|
2335
|
+
- `line_width` line width in integer (used in draw operations)
|
2336
|
+
- `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
|
2337
|
+
|
2319
2338
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2320
2339
|
|
2321
2340
|
```ruby
|
2322
2341
|
include Glimmer
|
2323
2342
|
|
2324
2343
|
shell {
|
2325
|
-
text 'Canvas Example
|
2344
|
+
text 'Canvas Example'
|
2326
2345
|
minimum_size 320, 400
|
2327
2346
|
|
2328
2347
|
canvas {
|
@@ -2330,10 +2349,10 @@ shell {
|
|
2330
2349
|
rectangle(0, 0, 220, 400, fill: true) {
|
2331
2350
|
background :red
|
2332
2351
|
}
|
2333
|
-
|
2352
|
+
rectangle(50, 20, 300, 150, 30, 50, round: true, fill: true) {
|
2334
2353
|
background :magenta
|
2335
2354
|
}
|
2336
|
-
|
2355
|
+
rectangle(150, 200, 100, 70, true, gradient: true) {
|
2337
2356
|
background :dark_magenta
|
2338
2357
|
foreground :yellow
|
2339
2358
|
}
|
@@ -2344,8 +2363,45 @@ shell {
|
|
2344
2363
|
}.open
|
2345
2364
|
```
|
2346
2365
|
|
2366
|
+
Screenshot:
|
2367
|
+
|
2368
|
+
![Canvas Animation Example](images/glimmer-example-canvas.png)
|
2369
|
+
|
2347
2370
|
Learn more at the [Hello, Canvas! Sample](#hello-canvas).
|
2348
2371
|
|
2372
|
+
If you get extremely stuck, remember that you could always default to direct [SWT GC usage]([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) and 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).
|
2373
|
+
|
2374
|
+
Example of manually doing the same things as in the above example without relying on the declarative Glimmer Shape DSL:
|
2375
|
+
|
2376
|
+
```ruby
|
2377
|
+
include Glimmer
|
2378
|
+
|
2379
|
+
shell {
|
2380
|
+
text 'Canvas Manual Example'
|
2381
|
+
minimum_size 320, 400
|
2382
|
+
|
2383
|
+
canvas {
|
2384
|
+
background :yellow
|
2385
|
+
|
2386
|
+
on_paint_control { |event|
|
2387
|
+
event.gc.setBackground(color(:red).swt_color)
|
2388
|
+
event.gc.fillRectangle(0, 0, 220, 400)
|
2389
|
+
|
2390
|
+
event.gc.setBackground(color(:magenta).swt_color)
|
2391
|
+
event.gc.fillRoundRectangle(50, 20, 300, 150, 30, 50)
|
2392
|
+
|
2393
|
+
event.gc.setBackground(color(:dark_magenta).swt_color)
|
2394
|
+
event.gc.fillGradientRectangle(150, 200, 100, 70, true)
|
2395
|
+
|
2396
|
+
event.gc.setForeground(color(:dark_blue).swt_color)
|
2397
|
+
event.gc.drawRectangle(200, 80, 108, 36)
|
2398
|
+
}
|
2399
|
+
}
|
2400
|
+
}.open
|
2401
|
+
```
|
2402
|
+
|
2403
|
+
In any case, if there is anything missing you would like added to the Glimmer Shape 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.
|
2404
|
+
|
2349
2405
|
### Canvas Animation DSL
|
2350
2406
|
|
2351
2407
|
(note: this is a very new feature of Glimmer. It may change a bit while getting battle tested. As always, you could default to basic SWT usage if needed.)
|
@@ -2354,13 +2410,13 @@ Glimmer additionally provides built-in support for animations via a declarative
|
|
2354
2410
|
|
2355
2411
|
Animations take advantage of multi-threading, each animation runs in its own independent thread of execution while updating the GUI asynchronously.
|
2356
2412
|
|
2357
|
-
This example says it all (it moves a tiny red square across a blue background):
|
2413
|
+
This example says it all (it moves a tiny red square across a blue background) (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2358
2414
|
|
2359
2415
|
```ruby
|
2360
2416
|
include Glimmer
|
2361
2417
|
|
2362
2418
|
shell {
|
2363
|
-
text 'Canvas Animation Example
|
2419
|
+
text 'Canvas Animation Example'
|
2364
2420
|
minimum_size 400, 400
|
2365
2421
|
|
2366
2422
|
canvas {
|
@@ -2378,8 +2434,12 @@ shell {
|
|
2378
2434
|
}.open
|
2379
2435
|
```
|
2380
2436
|
|
2381
|
-
|
2382
|
-
|
2437
|
+
Screenshot:
|
2438
|
+
|
2439
|
+
![Canvas Animation Example](images/glimmer-example-canvas-animation.png)
|
2440
|
+
|
2441
|
+
Keywords:
|
2442
|
+
- `animation` declares an animation under a canvas, which renders frames using a frame block indefinitely or finitely depending on (cycle_count/frame_count) properties
|
2383
2443
|
- `every` specifies delay in seconds between every two frame renders
|
2384
2444
|
- `frame` a block that can contain Shape DSL syntax that is rendered dynamically with variables calculated on the fly
|
2385
2445
|
- `cycle` a property that takes an array to cycle into a second variable for the `frame` block
|
@@ -2387,15 +2447,23 @@ Keywords involved:
|
|
2387
2447
|
- `frame_count` an optional frame count limit after which the animation stops
|
2388
2448
|
- `started` a boolean indicating if the animation is started right away or stopped waiting for manual startup via `#start` method
|
2389
2449
|
|
2390
|
-
API:
|
2391
|
-
- `#start` starts animation
|
2392
|
-
- `#stop` stops animation
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2450
|
+
API of Animation Object (returned from `animation` keyword):
|
2451
|
+
- `#start` starts an animation that is indefinite or has never been started before (i.e. having `started: false` option). Otherwise, resumes a stopped animation that has not been completed.
|
2452
|
+
- `#stop` stops animation. Maintains progress when `frame_count`, `cycle_count`, or `duration_limit` are set and haven't finished. That way, if `#start` is called, animation resumes from where it stopped exactly to completion.
|
2453
|
+
- `#restart` restarts animation, restarting progress of `frame_count`, `cycle_count`, and `duration_limit` if set.
|
2454
|
+
- `#started?` returns whether animation started
|
2455
|
+
- `#stopped?` returns whether animation stopped
|
2456
|
+
- `#indefinite?` (alias `infinite?`) returns true if animation does not have `frame_count`, `cycle_count`, or `duration_limit`
|
2457
|
+
- `#finite?` returns true if animation has `frame_count`, `cycle_count` (with `cycle`), or `duration_limit`
|
2458
|
+
- `#frame_count_limited?` returns true if `frame_count` is specified
|
2459
|
+
- `#cycle_enabled?` returns true if `cycle` is specified
|
2460
|
+
- `#cycle_limited?` returns true if `cycle_count` is specified
|
2461
|
+
- `#duration_limited?` returns true if `duration_limit` is specified
|
2396
2462
|
|
2397
2463
|
Learn more at the [Hello, Canvas Animation! Sample](#hello-canvas-animation).
|
2398
2464
|
|
2465
|
+
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.
|
2466
|
+
|
2399
2467
|
### Data-Binding
|
2400
2468
|
|
2401
2469
|
Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
|
@@ -3579,12 +3647,12 @@ Example.new
|
|
3579
3647
|
|
3580
3648
|
Application name (shows up on the Mac in top menu bar) and version may be specified upon [packaging](#packaging--distribution) by specifying "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
|
3581
3649
|
|
3582
|
-
Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT Display.
|
3650
|
+
Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT `Display.app_name=` method before any Display object has been instantiated (i.e. before any Glimmer widget like shell has been declared).
|
3583
3651
|
|
3584
3652
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
3585
3653
|
|
3586
3654
|
```ruby
|
3587
|
-
Display.
|
3655
|
+
Display.app_name = 'Glimmer Demo'
|
3588
3656
|
|
3589
3657
|
shell(:no_resize) {
|
3590
3658
|
text "Glimmer"
|
@@ -3594,7 +3662,7 @@ shell(:no_resize) {
|
|
3594
3662
|
}.open
|
3595
3663
|
```
|
3596
3664
|
|
3597
|
-
Also, you may invoke `Display.
|
3665
|
+
Also, you may invoke `Display.app_version = '1.0.0'` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
|
3598
3666
|
|
3599
3667
|
#### Checkbox Group Widget
|
3600
3668
|
|
@@ -4566,6 +4634,16 @@ Contact Manager - Edit Done
|
|
4566
4634
|
|
4567
4635
|
![Contact Manager](images/glimmer-contact-manager-edit-done.png)
|
4568
4636
|
|
4637
|
+
#### Tetris
|
4638
|
+
|
4639
|
+
This sample demonstrates how to build an interactive animated game with MVC architecture, custom-shell/custom-widgets, multi-threading, asynchronous programming, data-binding, canvas shape graphic decorations, and keyboard events.
|
4640
|
+
|
4641
|
+
Code:
|
4642
|
+
|
4643
|
+
[samples/elaborate/tic_tac_toe.rb](samples/elaborate/tetris.rb)
|
4644
|
+
|
4645
|
+
![Tetris](images/glimmer-tetris.png)
|
4646
|
+
|
4569
4647
|
### External Samples
|
4570
4648
|
|
4571
4649
|
#### Glimmer Calculator
|
@@ -4593,7 +4671,7 @@ Gladiator is a good demonstration of:
|
|
4593
4671
|
|
4594
4672
|
#### Timer
|
4595
4673
|
|
4596
|
-
[<img alt="Glimmer Timer Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=40 /> Timer](https://github.com/AndyObtiva/glimmer-cs-timer) is a sample app demonstrating data-binding, multi-threading, and Java
|
4674
|
+
[<img alt="Glimmer Timer Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=40 /> Timer](https://github.com/AndyObtiva/glimmer-cs-timer) is a sample app demonstrating data-binding, multi-threading, and JSound (Java Sound) library integration in a desktop application.
|
4597
4675
|
|
4598
4676
|
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
|
4599
4677
|
|
@@ -4686,6 +4764,8 @@ require_relative '../app/my_application.rb'
|
|
4686
4764
|
|
4687
4765
|
### javapackager Extra Arguments
|
4688
4766
|
|
4767
|
+
(note: currently `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh)
|
4768
|
+
|
4689
4769
|
In order to explicitly configure javapackager, Mac package attributes, or sign your Mac app to distribute on the App Store, you can follow more advanced instructions for `javapackager` here:
|
4690
4770
|
- https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
|
4691
4771
|
- https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html
|
@@ -4794,6 +4874,16 @@ By the way, keep in mind that during normal operation, it does also indicate a f
|
|
4794
4874
|
Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1sw__tx6mjdgyh3mky7vydc0000gp/T/fxbundler4076750801763032201/images/MathBowling/.VolumeIcon.icns] in unspecified directory
|
4795
4875
|
```
|
4796
4876
|
|
4877
|
+
3. Zsh (Z Shell)
|
4878
|
+
|
4879
|
+
Currently, `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh.
|
4880
|
+
|
4881
|
+
You can get around that in zsh by running glimmer package commands with `bash -c` prefix:
|
4882
|
+
|
4883
|
+
```
|
4884
|
+
bash -c 'glimmer package'
|
4885
|
+
```
|
4886
|
+
|
4797
4887
|
## App Updates
|
4798
4888
|
|
4799
4889
|
Glimmer already supports automatic (and manual) app updates via the Mac App Store for Mac apps. Simply run the `glimmer package` command with the Mac App Store keys configured as per [Mac Application Distribution](mac-application-distribution) instructions and you get automatic (and manual) app update support courtesy of the Mac App Store.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.
|
1
|
+
4.18.2.3
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-dsl-swt 4.18.
|
5
|
+
# stub: glimmer-dsl-swt 4.18.2.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.18.
|
9
|
+
s.version = "4.18.2.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["AndyMaleh".freeze]
|
14
|
-
s.date = "2021-01-
|
15
|
-
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces
|
14
|
+
s.date = "2021-01-23"
|
15
|
+
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.executables = ["glimmer".freeze, "girb".freeze]
|
18
18
|
s.extra_rdoc_files = [
|
@@ -132,6 +132,12 @@ Gem::Specification.new do |s|
|
|
132
132
|
"samples/elaborate/contact_manager/contact_repository.rb",
|
133
133
|
"samples/elaborate/login.rb",
|
134
134
|
"samples/elaborate/meta_sample.rb",
|
135
|
+
"samples/elaborate/tetris.rb",
|
136
|
+
"samples/elaborate/tetris/model/block.rb",
|
137
|
+
"samples/elaborate/tetris/model/game.rb",
|
138
|
+
"samples/elaborate/tetris/model/tetromino.rb",
|
139
|
+
"samples/elaborate/tetris/view/block.rb",
|
140
|
+
"samples/elaborate/tetris/view/playfield.rb",
|
135
141
|
"samples/elaborate/tic_tac_toe.rb",
|
136
142
|
"samples/elaborate/tic_tac_toe/board.rb",
|
137
143
|
"samples/elaborate/tic_tac_toe/cell.rb",
|