glimmer-dsl-swt 4.18.1.1 → 4.18.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2aa85c5f6d4f5a71bbc9538f291fff86199d26219c7b919068b5be7f99fc4bfd
4
- data.tar.gz: 4db3a940c06f112c309e822ce73b0a1e98317f87ae808c183f261d49d357c490
3
+ metadata.gz: 9e12bb24a84b93822013eef2122021cd5e6a8f90f9e450ac83f7bd5b5f0b7b55
4
+ data.tar.gz: dfdba626253a34506b99971821378e8579eac7f21a955ddbd7bc0543f770ad51
5
5
  SHA512:
6
- metadata.gz: 96d95b883f011fc5d706382c4a8f1eea500ccd9ad15bf1fb3c82e9c7509348d0dcd16ef4c99ef963eb3bb4760e63aca217d0f4ab43d404ea6c8fa636bdfc8adc
7
- data.tar.gz: a5182246e7825790b8c63ed8b7506d0e35e93af1f5a2e60c8ad6e015cee6fb092357ef2ca842d6f4bcf432b9cc5676b8167ec2bb42ef6dde47d007e50e1c2ba0
6
+ metadata.gz: d489317bc86659858e1215aca4f35441aa123f59affb4f35fe9fce1ec04f220f3856f5d203d686a1091a7a1652b746a9453ce598eb684910b1ded8717fc1552b
7
+ data.tar.gz: 10c31c53aab7d5a8905c6448f66dcacb01c98b952c9934ae1e5236437e583d37aa607161f38946754938c9fc655c876064cc268a93d73d8746667d69d69f684b
@@ -1,5 +1,44 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.2.4
4
+
5
+ - Tetris scoring
6
+ - Tetris eliminated Line tracking
7
+ - Tetris level tracking and speed-ups
8
+ - Tetris preview upcoming tetromino shape
9
+ - Added parent_proxy to CustomWidget and CustomShell classes
10
+ - Update CustomShell#center and ShellProxy#center to center_within_display to avoid clash with `row_layout` center property
11
+ - Fixed issue with shell/dialog/custom-shell not maintaining parent when not passed
12
+ - Fix Tetris sideways edge detection
13
+
14
+ ### 4.18.2.3
15
+
16
+ - Added Tetris Elaborate Sample
17
+ - 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)
18
+
19
+ ### 4.18.2.2
20
+
21
+ - Fixed issue with processing shape color due to missing Color class package name
22
+
23
+ ### 4.18.2.1
24
+
25
+ - Ensure drawing image works in Shape DSL
26
+ - Support passing image as simply an image path or image proxy to Shape DSL image method
27
+
28
+ ### 4.18.2.0
29
+
30
+ - 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)
31
+ - Canvas animation stop method
32
+ - Canvas animation restart method (restarts from frame 1)
33
+ - Canvas animation started? # meaning it is animating
34
+ - Canvas animation stopped? # meaning it has stopped animating
35
+ - Canvas animation duration_limit option
36
+ - Make gradient/round rectangles in Shape DSL receive an option of `gradient: true` and `round: true` instead of prefix
37
+ - Canvas Shape DSL support for Background/Foreground Pattern (NOTE: not extensively tested yet)
38
+ - Canvas Shape DSL smart defaults for background/foreground depending on shape being drawn
39
+ - Canvas Shape DSL smart defaults for fill option depending on shape being drawn
40
+ - Added fallback font "Courier" for `code_text` widget when "Consolas" is not available.
41
+
3
42
  ### 4.18.1.1
4
43
 
5
44
  - Add smart defaults for round rectangle angles (defaults to 60 degrees angles)
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.1.1
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.4
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
- (The Original Glimmer Library Since 2007. Beware of Imitators!)
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. Not only does Glimmer provide a large set of GUI [widgets](#widgets), but 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/).
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
 
@@ -230,6 +226,11 @@ Glimmer App:
230
226
 
231
227
  [![Math Bowling App Screenshot](https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/Math-Bowling-Screenshot.png)](https://github.com/AndyObtiva/MathBowling)
232
228
 
229
+ **Note:** I offer Glimmer as an open-source project that represents my interests in Ruby Programming, Desktop GUI application development with SWT, Object Oriented Design, Design Patterns, and Software Architecture.
230
+ Additionally, I am sharing my professional experience and expertise in Eclipse SWT given that I am an [EclipseCon](http://andymaleh.blogspot.com/2007/03/eclipsecon-2007-day-3.html)/[EclipseWorld](http://andymaleh.blogspot.com/2008/11/eclipseworld-2008-highlights.html) presenter and have built professional applications in SWT/JFace/RCP for Obtiva and the Pampered Chef in the past. This is also done in the hopes that it would indirectly bring me work in a field I am extremely passionate about.
231
+ That said, please keep in mind that I myself am learning topics in Software Engineering too everyday, including newer editions of SWT and JRuby, which seem to pop up every quarter.
232
+ If you see anything that needs to be improved, please do not hesitate to contact me on [Gitter](https://gitter.im/AndyObtiva/glimmer) or submit [Issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues)/[Pull-Requests](https://github.com/AndyObtiva/glimmer-dsl-swt/pulls).
233
+
233
234
  ## Table of contents
234
235
 
235
236
  - [Glimmer (JRuby Desktop Development GUI Framework)](#jruby-desktop-development-gui-framework)
@@ -305,7 +306,7 @@ Glimmer App:
305
306
  - [Custom Widget API](#custom-widget-api)
306
307
  - [Content/Options Example](#contentoptions-example)
307
308
  - [Gotcha](#gotcha)
308
- - [Final Notes](#final-notes)
309
+ - [Custom Widget Final Notes](#custom-widget-final-notes)
309
310
  - [Custom Shells](#custom-shells)
310
311
  - [Drag and Drop](#drag-and-drop)
311
312
  - [Miscellaneous](#miscellaneous)
@@ -368,6 +369,7 @@ Glimmer App:
368
369
  - [Login](#login)
369
370
  - [Tic Tac Toe Sample](#tic-tac-toe-sample)
370
371
  - [Contact Manager Sample](#contact-manager-sample)
372
+ - [Tetris](#tetris)
371
373
  - [External Samples](#external-samples)
372
374
  - [Glimmer Calculator](#glimmer-calculator)
373
375
  - [Gladiator](#gladiator)
@@ -456,7 +458,7 @@ jgem install glimmer-dsl-swt
456
458
 
457
459
  Or this command if you want a specific version:
458
460
  ```
459
- jgem install glimmer-dsl-swt -v 4.18.1.1
461
+ jgem install glimmer-dsl-swt -v 4.18.2.4
460
462
 
461
463
 
462
464
  ```
@@ -476,7 +478,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
476
478
 
477
479
  Add the following to `Gemfile`:
478
480
  ```
479
- gem 'glimmer-dsl-swt', '~> 4.18.1.1
481
+ gem 'glimmer-dsl-swt', '~> 4.18.2.4
480
482
  '
481
483
  ```
482
484
 
@@ -535,7 +537,7 @@ bin/glimmer samples
535
537
  Below are the full usage instructions that come up when running `glimmer` without args.
536
538
 
537
539
  ```
538
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.1.1
540
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.2.4
539
541
 
540
542
 
541
543
 
@@ -1016,7 +1018,7 @@ Output:
1016
1018
 
1017
1019
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1018
1020
  Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1019
- Swt glimmer-dsl-swt 4.18.1.1
1021
+ Swt glimmer-dsl-swt 4.18.2.4
1020
1022
 
1021
1023
  AndyMaleh Glimmer DSL for SWT
1022
1024
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
@@ -1084,6 +1086,8 @@ With `glimmer-dsl-swt` installed, you may want to run `girb` instead of standard
1084
1086
  girb
1085
1087
  ```
1086
1088
 
1089
+ ![GIRB](images/glimmer-girb.png)
1090
+
1087
1091
  If you cloned [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) project locally, you may run `bin/girb` instead.
1088
1092
 
1089
1093
  ```
@@ -1349,7 +1353,8 @@ This is not an exaustive list, but should give you a good start in learning Glim
1349
1353
  **Event loop:**
1350
1354
  - `display`: featured in [Tic Tac Toe](#tic-tac-toe)
1351
1355
  - `async_exec`: featured in [Hello, Custom Widget!](#hello-custom-widget) / [Hello, Custom Shell!](#hello-custom-shell)
1352
-
1356
+ - `sync_exec`: executes a block on the event loop synchronously (usually from another thread)
1357
+ - `timer_exec`: executes a block after a delay of time has passed
1353
1358
 
1354
1359
  #### SWT Proxies
1355
1360
 
@@ -2294,68 +2299,79 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
2294
2299
 
2295
2300
  ### Canvas Shape DSL
2296
2301
 
2297
- (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.)
2298
-
2299
2302
  Glimmer supports drawing graphics directly on a `canvas` widget via SWT (or any widget for that matter though `canvas` is recommended for drawing).
2300
2303
 
2301
2304
  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.
2302
2305
 
2303
2306
  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):
2304
- - `arc​(x, y, width, height, startAngle, arcAngle, fill: false)`
2305
- - `focus​(x, y, width, height)`
2306
- - `image(image, x, y)`
2307
- - `line(x1, y1, x2, y2)`
2308
- - `oval(x, y, width, height, fill: false)`
2309
- - `point​(x, y)`
2310
- - `polygon(pointArray, fill: false)`
2311
- - `polyline(pointArray)`
2312
- - `rectangle(x, y, width, height, fill: false)`
2313
- - `round_rectangle(x, y, width, height, arcWidth = 60, arcHeight = 60, fill: false)`
2314
- - `gradient_rectangle​(x, y, width, height, vertical = true, fill: false)`
2315
- - `text(String string, x, y)`
2307
+ - `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)
2308
+ - `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)
2309
+ - `image(image, x, y)` [image](#image)
2310
+ - `line(x1, y1, x2, y2)` line
2311
+ - `oval(x, y, width, height, fill: false)` oval if width does not match heigh and circle if width matches height. Can be optionally filled.
2312
+ - `point​(x, y)` point
2313
+ - `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)
2314
+ - `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)
2315
+ - `rectangle(x, y, width, height, fill: false)` standard rectangle, which can be optionally filled
2316
+ - `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
2317
+ - `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
2318
+ - `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))
2316
2319
 
2317
2320
  Shape keywords that can be filled with color can take an keyword argument `fill: true` (defaults to false when not specified)
2318
2321
 
2319
2322
  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.
2320
2323
 
2321
2324
  Here is a list of supported attributes nestable within a block under shapes:
2322
- - `alpha` sets transparency (integer between 0 and 255)
2323
- - `antialias` enables antialiasing (SWT style value of :default, :off, :on whereby :default applies OS default)
2324
- - `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)
2325
- - `clipping​(x, y, width, height)` clips area of painting
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
- - `line_cap` sets line cap (SWT style value of :cap_flat, :cap_round, or :cap_square)
2329
- - `line_dash` line dash float values (automatically sets `line_style` to SWT style value of :line_custom)
2330
- - `line_join` line join style (SWT style value of :join_miter, :join_round, or :join_bevel)
2331
- - `line_style` line join style (SWT style value of :line_solid, :line_dash, :line_dot, :line_dashdot, or :line_dashdotdot)
2325
+ - `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.
2326
+ - `alpha` sets transparency (integer between `0` and `255`)
2327
+ - `antialias` enables antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2328
+ - `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)
2329
+ - `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)
2330
+ - `clipping` clips area of painting (​numeric values for `(x, y, width, height)`)
2331
+ - `fill_rule` sets filling rule (SWT style value of `:fill_even_odd` or `:fill_winding`)
2332
+ - `font` sets font (Hash of `:name`, `:height`, and `:style` just like standard widget font property, or Font/FontProxy object directly)
2333
+ - `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)
2334
+ - `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)
2335
+ - `interpolation` sets the interpolation value (SWT style value of `:default`, `:none`, `:low`, `:high`)
2336
+ - `line_cap` sets line cap (SWT style value of `:cap_flat`, `:cap_round`, or `:cap_square`)
2337
+ - `line_dash` line dash float values (automatically sets `line_style` to SWT style value of `:line_custom`)
2338
+ - `line_join` line join style (SWT style value of `:join_miter`, `:join_round`, or `:join_bevel`)
2339
+ - `line_style` line join style (SWT style value of `:line_solid`, `:line_dash`, `:line_dot`, `:line_dashdot`, or `:line_dashdotdot`)
2332
2340
  - `line_width` line width in integer (used in draw operations)
2333
- - `text_anti_alias` enables text antialiasing (SWT style value of :default, :off, :on whereby :default applies OS default)
2341
+ - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2334
2342
 
2335
2343
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2336
2344
 
2337
2345
  ```ruby
2338
2346
  include Glimmer
2339
2347
 
2348
+ # image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
2349
+ image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
2350
+
2340
2351
  shell {
2341
2352
  text 'Canvas Example'
2342
2353
  minimum_size 320, 400
2343
2354
 
2344
2355
  canvas {
2345
- background :yellow
2356
+ background :dark_yellow
2346
2357
  rectangle(0, 0, 220, 400, fill: true) {
2347
- background :red
2358
+ background :dark_red
2348
2359
  }
2349
- round_rectangle(50, 20, 300, 150, 30, 50, fill: true) {
2350
- background :magenta
2360
+ rectangle(50, 20, 300, 150, 30, 50, round: true, fill: true) {
2361
+ background :yellow
2351
2362
  }
2352
- gradient_rectangle(150, 200, 100, 70, true, fill: true) {
2353
- background :dark_magenta
2363
+ rectangle(150, 200, 100, 70, true, gradient: true) {
2364
+ background :dark_red
2354
2365
  foreground :yellow
2355
2366
  }
2367
+ text('Glimmer', 208, 83) {
2368
+ font height: 25, style: :bold
2369
+ }
2356
2370
  rectangle(200, 80, 108, 36) {
2357
- foreground color(:dark_blue)
2371
+ foreground :black
2372
+ line_width 3
2358
2373
  }
2374
+ image(image_object, 70, 50)
2359
2375
  }
2360
2376
  }.open
2361
2377
  ```
@@ -2366,6 +2382,43 @@ Screenshot:
2366
2382
 
2367
2383
  Learn more at the [Hello, Canvas! Sample](#hello-canvas).
2368
2384
 
2385
+ 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).
2386
+
2387
+ Example of manually doing the same things as in the above example without relying on the declarative Glimmer Shape DSL:
2388
+
2389
+ ```ruby
2390
+ include Glimmer
2391
+
2392
+ shell {
2393
+ text 'Canvas Manual Example'
2394
+ minimum_size 320, 400
2395
+
2396
+ canvas {
2397
+ background :yellow
2398
+
2399
+ on_paint_control { |event|
2400
+ event.gc.setBackground(color(:red).swt_color)
2401
+ event.gc.fillRectangle(0, 0, 220, 400)
2402
+
2403
+ event.gc.setBackground(color(:magenta).swt_color)
2404
+ event.gc.fillRoundRectangle(50, 20, 300, 150, 30, 50)
2405
+
2406
+ event.gc.setBackground(color(:dark_magenta).swt_color)
2407
+ event.gc.fillGradientRectangle(150, 200, 100, 70, true)
2408
+
2409
+ event.gc.setForeground(color(:dark_blue).swt_color)
2410
+ event.gc.drawRectangle(200, 80, 108, 36)
2411
+ }
2412
+ }
2413
+ }.open
2414
+ ```
2415
+
2416
+ 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](https://github.com/AndyObtiva/glimmer-dsl-swt/pulls).
2417
+
2418
+ #### Shapes inside a Widget
2419
+
2420
+ 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`.
2421
+
2369
2422
  ### Canvas Animation DSL
2370
2423
 
2371
2424
  (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.)
@@ -2374,7 +2427,7 @@ Glimmer additionally provides built-in support for animations via a declarative
2374
2427
 
2375
2428
  Animations take advantage of multi-threading, each animation runs in its own independent thread of execution while updating the GUI asynchronously.
2376
2429
 
2377
- This example says it all (it moves a tiny red square across a blue background):
2430
+ 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)):
2378
2431
 
2379
2432
  ```ruby
2380
2433
  include Glimmer
@@ -2411,12 +2464,23 @@ Keywords:
2411
2464
  - `frame_count` an optional frame count limit after which the animation stops
2412
2465
  - `started` a boolean indicating if the animation is started right away or stopped waiting for manual startup via `#start` method
2413
2466
 
2414
- API:
2415
- - `#start` starts animation as a method on the animation object (returned from `animation` keyword)
2416
- - `#stop` stops animation gracefully as a method on the animation object (returned from `animation` keyword)
2467
+ API of Animation Object (returned from `animation` keyword):
2468
+ - `#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.
2469
+ - `#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.
2470
+ - `#restart` restarts animation, restarting progress of `frame_count`, `cycle_count`, and `duration_limit` if set.
2471
+ - `#started?` returns whether animation started
2472
+ - `#stopped?` returns whether animation stopped
2473
+ - `#indefinite?` (alias `infinite?`) returns true if animation does not have `frame_count`, `cycle_count`, or `duration_limit`
2474
+ - `#finite?` returns true if animation has `frame_count`, `cycle_count` (with `cycle`), or `duration_limit`
2475
+ - `#frame_count_limited?` returns true if `frame_count` is specified
2476
+ - `#cycle_enabled?` returns true if `cycle` is specified
2477
+ - `#cycle_limited?` returns true if `cycle_count` is specified
2478
+ - `#duration_limited?` returns true if `duration_limit` is specified
2417
2479
 
2418
2480
  Learn more at the [Hello, Canvas Animation! Sample](#hello-canvas-animation).
2419
2481
 
2482
+ 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.
2483
+
2420
2484
  ### Data-Binding
2421
2485
 
2422
2486
  Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
@@ -2897,7 +2961,7 @@ If you need a better widget with the ability to customize the date format patter
2897
2961
 
2898
2962
  ### Observer
2899
2963
 
2900
- Glimmer comes with `Observer` module, which is used internally for data-binding, but can also be used externally for custom use of the Observer Pattern. It is hidden when observing widgets, and used explicitly when observing models.
2964
+ Glimmer comes with the `Observer` mixin module, which is used internally for data-binding, but can also be used externally for custom use of the Observer Pattern. It is hidden when observing widgets, and used explicitly when observing models. In bidirectional data-binding, `Observer` is automatically unregistered from models once a widget is disposed to avoid memory leaks and worrying about managing them yourself.
2901
2965
 
2902
2966
  #### Observing Widgets
2903
2967
 
@@ -3263,7 +3327,7 @@ body {
3263
3327
 
3264
3328
  The `text` method invoked in the custom widget body will call the one you defined above it. To avoid this gotcha, simply name the text property above something else, like `custom_text`.
3265
3329
 
3266
- #### Final Notes
3330
+ #### Custom Widget Final Notes
3267
3331
 
3268
3332
  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:
3269
3333
  [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)
@@ -4587,6 +4651,18 @@ Contact Manager - Edit Done
4587
4651
 
4588
4652
  ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
4589
4653
 
4654
+ #### Tetris
4655
+
4656
+ 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.
4657
+
4658
+ Code:
4659
+
4660
+ [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
4661
+
4662
+ ![Tetris](images/glimmer-tetris.png)
4663
+
4664
+ ![Tetris Game Over](images/glimmer-tetris-game-over.png)
4665
+
4590
4666
  ### External Samples
4591
4667
 
4592
4668
  #### Glimmer Calculator
@@ -4614,7 +4690,7 @@ Gladiator is a good demonstration of:
4614
4690
 
4615
4691
  #### Timer
4616
4692
 
4617
- [<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 (Sound) library integration in a desktop application.
4693
+ [<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.
4618
4694
 
4619
4695
  [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
4620
4696
 
@@ -4640,6 +4716,8 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
4640
4716
 
4641
4717
  Note: this section mostly applies to Mac and Windows. On Linux, you can just run `glimmer package:gem` and after installing the gem, you get an executable matching the name of the app/custom-shell-gem you are building (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem)
4642
4718
 
4719
+ Note 2: Glimmer packaging has a strong dependency on JDK8 at the moment. JDK9 & JDK10 might work, but JDK11 and onward definitely won't since they dropped javapackager, which later came back as jpackage in JDK14, but it's not ready for prime time yet. Just stick to JDK8 for now, strongly supported by Oracle for the next 6 years at least.
4720
+
4643
4721
  Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
4644
4722
 
4645
4723
  ```
@@ -4707,6 +4785,8 @@ require_relative '../app/my_application.rb'
4707
4785
 
4708
4786
  ### javapackager Extra Arguments
4709
4787
 
4788
+ (note: currently `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh)
4789
+
4710
4790
  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:
4711
4791
  - https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
4712
4792
  - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html
@@ -4815,6 +4895,16 @@ By the way, keep in mind that during normal operation, it does also indicate a f
4815
4895
  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
4816
4896
  ```
4817
4897
 
4898
+ 3. Zsh (Z Shell)
4899
+
4900
+ Currently, `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh.
4901
+
4902
+ You can get around that in zsh by running glimmer package commands with `bash -c` prefix:
4903
+
4904
+ ```
4905
+ bash -c 'glimmer package'
4906
+ ```
4907
+
4818
4908
  ## App Updates
4819
4909
 
4820
4910
  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.1
1
+ 4.18.2.4
@@ -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.1.1 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.2.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.18.1.1"
9
+ s.version = "4.18.2.4"
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-20"
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 while 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. 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
14
+ s.date = "2021-01-24"
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,14 @@ 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/game_over_dialog.rb",
141
+ "samples/elaborate/tetris/view/playfield.rb",
142
+ "samples/elaborate/tetris/view/score_lane.rb",
135
143
  "samples/elaborate/tic_tac_toe.rb",
136
144
  "samples/elaborate/tic_tac_toe/board.rb",
137
145
  "samples/elaborate/tic_tac_toe/cell.rb",