glimmer-dsl-swt 4.18.2.1 → 4.18.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +175 -32
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +18 -6
  6. data/lib/glimmer/dsl/swt/color_expression.rb +4 -4
  7. data/lib/glimmer/dsl/swt/data_binding_expression.rb +3 -3
  8. data/lib/glimmer/dsl/swt/display_expression.rb +3 -3
  9. data/lib/glimmer/dsl/swt/dsl.rb +1 -0
  10. data/lib/glimmer/dsl/swt/multiply_expression.rb +53 -0
  11. data/lib/glimmer/dsl/swt/property_expression.rb +4 -2
  12. data/lib/glimmer/dsl/swt/shape_expression.rb +2 -4
  13. data/lib/glimmer/dsl/swt/transform_expression.rb +55 -0
  14. data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
  15. data/lib/glimmer/rake_task/scaffold.rb +4 -3
  16. data/lib/glimmer/swt/color_proxy.rb +28 -6
  17. data/lib/glimmer/swt/custom/drawable.rb +8 -0
  18. data/lib/glimmer/swt/custom/shape.rb +66 -26
  19. data/lib/glimmer/swt/display_proxy.rb +1 -1
  20. data/lib/glimmer/swt/layout_data_proxy.rb +3 -3
  21. data/lib/glimmer/swt/shell_proxy.rb +4 -3
  22. data/lib/glimmer/swt/transform_proxy.rb +109 -0
  23. data/lib/glimmer/swt/widget_proxy.rb +34 -25
  24. data/lib/glimmer/ui/custom_shell.rb +15 -2
  25. data/lib/glimmer/ui/custom_widget.rb +44 -31
  26. data/samples/elaborate/meta_sample.rb +21 -0
  27. data/samples/elaborate/tetris.rb +106 -0
  28. data/samples/elaborate/tetris/model/block.rb +48 -0
  29. data/samples/elaborate/tetris/model/game.rb +185 -0
  30. data/samples/elaborate/tetris/model/tetromino.rb +313 -0
  31. data/samples/elaborate/tetris/view/block.rb +70 -0
  32. data/samples/elaborate/tetris/view/game_over_dialog.rb +72 -0
  33. data/samples/elaborate/tetris/view/playfield.rb +56 -0
  34. data/samples/elaborate/tetris/view/score_lane.rb +87 -0
  35. data/samples/hello/hello_canvas_transform.rb +40 -0
  36. metadata +16 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd5449ef80c4ae38994b5ceb0fcf32b1cc843b7387523267920449dc9d4f5dd6
4
- data.tar.gz: d55dd2c0daeaf9cd3d388b4a53676d7e10f3c0adeca8591631ac857d2c69fd08
3
+ metadata.gz: 1323fa9209cf80b8c8333bcefb49a4ea682494a63aab2a594d7c7325e5f07833
4
+ data.tar.gz: 8d190e9c23540f238d23ffee220da4abd751499a7c8f230a86deb93e11f742d1
5
5
  SHA512:
6
- metadata.gz: 6dcd43c02e87bade7a8ab2fb81d6db5a47ac286c03a62e95b829f2c7aa65bb2b7e21fdcd88ead5cee4302cc743d4f09a15cc3b130dcd139c57bd3e5475d24d59
7
- data.tar.gz: dfa9233d6e1f4d0c8bcb0e33090b86d25280e5ccd5fa205e474b356522964149d9140225d632137ca49b288a554009be2ed827817c9ba076018b9dafead4881c
6
+ metadata.gz: d7f842d5fc21e75a1edbf6b07f470ee4b85aa6c462c60f0611143db7fa7ba0c5d2606d70fffd96d5abed5d3cef993b190d9e87bbb731278b7ad466d44c606abb
7
+ data.tar.gz: e02f1e221a4473975fcbd5afc57e5fb7ab99fe45905f88d6be6547f8f8434959ba7ab0d44518ef90873182170a5c5867f9fe075bef8bebbc94fa528b7aef939e
@@ -1,5 +1,43 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.3.0
4
+
5
+ - Canvas Transform DSL (DSL declared Transform objects are auto-disposed after getting used by their parent shape)
6
+ - Canvas support a top-level Transform DSL fluent interface for methods that use Transform arguments manually (e.g. tr1 = transform.rotate(90).translate(0, -100))
7
+ - Hello, Canvas Transformation!
8
+
9
+ ### 4.18.2.5
10
+
11
+ - ColorProxy args now are automatically fit into 0..255 bounds upon use of the `color`/`rgb`/`rgba` keywords
12
+ - Canvas Shape DSL (Property) Data-Binding support (No Argument Data-Binding support yet)
13
+ - Add a more bevel 3D look to Tetris blocks
14
+ - Use flyweight pattern with colors
15
+ - Use flyweight pattern with widget classes
16
+ - Use flyweight pattern with custom widget classes
17
+ - Optimized performance of Canvas Shape DSL
18
+ - Optimized performance of Tetris game
19
+ - Fixed issue with top-level sync_exec/async_exec use randomly bombing
20
+
21
+ ### 4.18.2.4
22
+
23
+ - Tetris scoring
24
+ - Tetris eliminated Line tracking
25
+ - Tetris level tracking and speed-ups
26
+ - Tetris preview upcoming tetromino shape
27
+ - Added parent_proxy to CustomWidget and CustomShell classes
28
+ - Update CustomShell#center and ShellProxy#center to center_within_display to avoid clash with `row_layout` center property
29
+ - Fixed issue with shell/dialog/custom-shell not maintaining parent when not passed
30
+ - Fix Tetris sideways edge detection
31
+
32
+ ### 4.18.2.3
33
+
34
+ - Added Tetris Elaborate Sample
35
+ - 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)
36
+
37
+ ### 4.18.2.2
38
+
39
+ - Fixed issue with processing shape color due to missing Color class package name
40
+
3
41
  ### 4.18.2.1
4
42
 
5
43
  - Ensure drawing image works in Shape DSL
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.2.1
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.18.3.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,7 +8,7 @@
8
8
 
9
9
  **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
10
10
 
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/).
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) s [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/).
12
12
 
13
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
14
 
@@ -24,7 +24,7 @@ Glimmer DSL gems:
24
24
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
25
25
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
26
26
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
27
- - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
27
+ - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
28
28
 
29
29
  ## Examples
30
30
 
@@ -226,6 +226,11 @@ Glimmer App:
226
226
 
227
227
  [![Math Bowling App Screenshot](https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/Math-Bowling-Screenshot.png)](https://github.com/AndyObtiva/MathBowling)
228
228
 
229
+ **Note:** I offer Glimmer DSL for SWT as a free and open-source [Ruby Gem](https://rubygems.org/gems/glimmer-dsl-swt) 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
+
229
234
  ## Table of contents
230
235
 
231
236
  - [Glimmer (JRuby Desktop Development GUI Framework)](#jruby-desktop-development-gui-framework)
@@ -283,6 +288,7 @@ Glimmer App:
283
288
  - [Layouts](#layouts)
284
289
  - [Layout Data](#layout-data)
285
290
  - [Canvas Shape DSL](#canvas-shape-dsl)
291
+ - [Canvas Transform DSL](#canvas-transform-dsl)
286
292
  - [Canvas Animation DSL](#canvas-animation-dsl)
287
293
  - [Data-Binding](#data-binding)
288
294
  - [General Examples](#general-examples)
@@ -301,7 +307,7 @@ Glimmer App:
301
307
  - [Custom Widget API](#custom-widget-api)
302
308
  - [Content/Options Example](#contentoptions-example)
303
309
  - [Gotcha](#gotcha)
304
- - [Final Notes](#final-notes)
310
+ - [Custom Widget Final Notes](#custom-widget-final-notes)
305
311
  - [Custom Shells](#custom-shells)
306
312
  - [Drag and Drop](#drag-and-drop)
307
313
  - [Miscellaneous](#miscellaneous)
@@ -359,11 +365,13 @@ Glimmer App:
359
365
  - [Hello, Dialog!](#hello-dialog)
360
366
  - [Hello, Canvas!](#hello-canvas)
361
367
  - [Hello, Canvas Animation!](#hello-canvas-animation)
368
+ - [Hello, Canvas Transform!](#hello-canvas-transform)
362
369
  - [Elaborate Samples](#elaborate-samples)
363
370
  - [User Profile](#user-profile)
364
371
  - [Login](#login)
365
372
  - [Tic Tac Toe Sample](#tic-tac-toe-sample)
366
373
  - [Contact Manager Sample](#contact-manager-sample)
374
+ - [Tetris](#tetris)
367
375
  - [External Samples](#external-samples)
368
376
  - [Glimmer Calculator](#glimmer-calculator)
369
377
  - [Gladiator](#gladiator)
@@ -397,7 +405,7 @@ Glimmer App:
397
405
 
398
406
  ## Background
399
407
 
400
- Ruby is a dynamically-typed object-oriented language, which provides great productivity gains due to its powerful expressive syntax and dynamic nature. While it is proven by the Ruby on Rails framework for web development, it currently lacks a robust platform-independent framework for building desktop applications. Given that Java libraries can now be utilized in Ruby code through JRuby, Eclipse technologies, such as SWT, JFace, and RCP can help fill the gap of desktop application development with Ruby.
408
+ [Ruby](https://www.ruby-lang.org) is a dynamically-typed object-oriented language, which provides great productivity gains due to its powerful expressive syntax and dynamic nature. While it is proven by the [Ruby](https://www.ruby-lang.org) on Rails framework for web development, it currently lacks a robust platform-independent framework for building desktop applications. Given that Java libraries can now be utilized in Ruby code through JRuby, Eclipse technologies, such as [SWT](https://www.eclipse.org/swt/), JFace, and RCP can help fill the gap of desktop application development with Ruby.
401
409
 
402
410
  ## Platform Support
403
411
 
@@ -452,7 +460,7 @@ jgem install glimmer-dsl-swt
452
460
 
453
461
  Or this command if you want a specific version:
454
462
  ```
455
- jgem install glimmer-dsl-swt -v 4.18.2.1
463
+ jgem install glimmer-dsl-swt -v 4.18.3.0
456
464
 
457
465
 
458
466
  ```
@@ -472,7 +480,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
472
480
 
473
481
  Add the following to `Gemfile`:
474
482
  ```
475
- gem 'glimmer-dsl-swt', '~> 4.18.2.1
483
+ gem 'glimmer-dsl-swt', '~> 4.18.3.0
476
484
  '
477
485
  ```
478
486
 
@@ -531,7 +539,7 @@ bin/glimmer samples
531
539
  Below are the full usage instructions that come up when running `glimmer` without args.
532
540
 
533
541
  ```
534
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.2.1
542
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.0
535
543
 
536
544
 
537
545
 
@@ -1012,7 +1020,7 @@ Output:
1012
1020
 
1013
1021
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1014
1022
  Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1015
- Swt glimmer-dsl-swt 4.18.2.1
1023
+ Swt glimmer-dsl-swt 4.18.3.0
1016
1024
 
1017
1025
  AndyMaleh Glimmer DSL for SWT
1018
1026
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
@@ -1092,6 +1100,8 @@ Watch out for hands-on examples in this README indicated by "you may copy/paste
1092
1100
 
1093
1101
  Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)
1094
1102
 
1103
+ If you need a more GUI interactive option to experiement with Glimmer GUI DSL Syntax, you may try the ["Ugliest Editor Ever"](https://github.com/AndyObtiva/glimmer-cs-gladiator) or just build your own using the [Glimmer DSL for SWT Ruby Gem](https://rubygems.org/gems/glimmer-dsl-swt).
1104
+
1095
1105
  ## Glimmer GUI DSL Syntax
1096
1106
 
1097
1107
  Glimmer's core is a GUI DSL with a lightweight visual syntax that makes it easy to visualize the nesting of widgets in the GUI hierarchy tree.
@@ -1501,7 +1511,7 @@ Although SWT Display is not technically a widget, it has similar APIs and DSL su
1501
1511
 
1502
1512
  #### Multi-Threading
1503
1513
 
1504
- [JRuby](https://www.jruby.org/) supports [truly parallel multi-threading](https://github.com/jruby/jruby/wiki/Concurrency-in-jruby) since it relies on the JVM (Java Virtual Machine). As such, it enables development of highly-interactive desktop applications that can do background work while the user is interacting with the GUI.
1514
+ [JRuby](https://www.jruby.org/) supports [truly parallel multi-threading](https://github.com/jruby/jruby/wiki/Concurrency-in-jruby) since it relies on the JVM (Java Virtual Machine). As such, it enables development of highly-interactive desktop applications that can do background work while the user is interacting with the GUI. However, any code that interacts with the GUI from a thread other than the main (first) GUI thread must do so only through sync_exec (if it is standard synchronous code) or async_exec.
1505
1515
 
1506
1516
  ##### async_exec
1507
1517
 
@@ -1932,7 +1942,7 @@ style = swt(:shell_trim, :max!) # creates a shell trim style without the maximiz
1932
1942
 
1933
1943
  SWT Shell widget by default is resizable. To make it non-resizable, one must pass a complicated style bit concoction like `swt(:shell_trim, :resize!, :max!)`.
1934
1944
 
1935
- Glimmer makes this easier by alternatively offering a `:no_resize` extra SWT style, added for convenience.
1945
+ Glimmer makes this easier by alternatively ing a `:no_resize` extra SWT style, added for convenience.
1936
1946
  This makes declaring a non-resizable window as easy as:
1937
1947
 
1938
1948
  ```ruby
@@ -2333,31 +2343,40 @@ Here is a list of supported attributes nestable within a block under shapes:
2333
2343
  - `line_style` line join style (SWT style value of `:line_solid`, `:line_dash`, `:line_dot`, `:line_dashdot`, or `:line_dashdotdot`)
2334
2344
  - `line_width` line width in integer (used in draw operations)
2335
2345
  - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2346
+ - `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
2336
2347
 
2337
2348
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2338
2349
 
2339
2350
  ```ruby
2340
2351
  include Glimmer
2341
2352
 
2353
+ # image object has to be declared outside the canvas and shell to avoid confusing with canvas image property
2354
+ image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
2355
+
2342
2356
  shell {
2343
2357
  text 'Canvas Example'
2344
2358
  minimum_size 320, 400
2345
2359
 
2346
2360
  canvas {
2347
- background :yellow
2361
+ background :dark_yellow
2348
2362
  rectangle(0, 0, 220, 400, fill: true) {
2349
- background :red
2363
+ background :dark_red
2350
2364
  }
2351
2365
  rectangle(50, 20, 300, 150, 30, 50, round: true, fill: true) {
2352
- background :magenta
2366
+ background :yellow
2353
2367
  }
2354
2368
  rectangle(150, 200, 100, 70, true, gradient: true) {
2355
- background :dark_magenta
2369
+ background :dark_red
2356
2370
  foreground :yellow
2357
2371
  }
2372
+ text('Glimmer', 208, 83) {
2373
+ font height: 25, style: :bold
2374
+ }
2358
2375
  rectangle(200, 80, 108, 36) {
2359
- foreground color(:dark_blue)
2376
+ foreground :black
2377
+ line_width 3
2360
2378
  }
2379
+ image(image_object, 70, 50)
2361
2380
  }
2362
2381
  }.open
2363
2382
  ```
@@ -2373,6 +2392,8 @@ If you get extremely stuck, remember that you could always default to direct [SW
2373
2392
  Example of manually doing the same things as in the above example without relying on the declarative Glimmer Shape DSL:
2374
2393
 
2375
2394
  ```ruby
2395
+ image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
2396
+
2376
2397
  include Glimmer
2377
2398
 
2378
2399
  shell {
@@ -2383,23 +2404,113 @@ shell {
2383
2404
  background :yellow
2384
2405
 
2385
2406
  on_paint_control { |event|
2386
- event.gc.setBackground(color(:red).swt_color)
2387
- event.gc.fillRectangle(0, 0, 220, 400)
2407
+ event.gc.set_background(color(:red).swt_color)
2408
+ event.gc.fill_rectangle(0, 0, 220, 400)
2409
+
2410
+ event.gc.set_background(color(:magenta).swt_color)
2411
+ event.gc.fill_roundRectangle(50, 20, 300, 150, 30, 50)
2388
2412
 
2389
- event.gc.setBackground(color(:magenta).swt_color)
2390
- event.gc.fillRoundRectangle(50, 20, 300, 150, 30, 50)
2413
+ event.gc.set_background(color(:dark_magenta).swt_color)
2414
+ event.gc.fill_gradientRectangle(150, 200, 100, 70, true)
2391
2415
 
2392
- event.gc.setBackground(color(:dark_magenta).swt_color)
2393
- event.gc.fillGradientRectangle(150, 200, 100, 70, true)
2416
+ event.gc.set_foreground(color(:dark_blue).swt_color)
2417
+ event.gc.draw_rectangle(200, 80, 108, 36)
2394
2418
 
2395
- event.gc.setForeground(color(:dark_blue).swt_color)
2396
- event.gc.drawRectangle(200, 80, 108, 36)
2419
+ event.gc.set_foreground(color(:black).swt_color)
2420
+ event.gc.set_lineWidth(3)
2421
+ event.gc.draw_rectangle(200, 80, 108, 36)
2422
+
2423
+ event.gc.draw_image(image_object.swt_image, 70, 50)
2424
+ }
2425
+ }
2426
+ }.open
2427
+ ```
2428
+
2429
+ 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).
2430
+
2431
+ #### Shapes inside a Widget
2432
+
2433
+ 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`.
2434
+
2435
+ ### Canvas Transform DSL
2436
+
2437
+ The transform DSL builds [org.eclipse.swt.graphics.Transform](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Transform.html) objects with a nice declarative syntax.
2438
+
2439
+ `transform` keyword builds a `Transform` object. It optionally takes the transformation matrix elements: (m11, m12, m21, m22, dx, dy)
2440
+
2441
+ The first 2 values represent the 1st row, the second 2 values represent the 2nd row, and the last 2 values represent translation on the x and y axes
2442
+
2443
+ Additionally, Transform operation keywords may be nested within the `transform` keyword to set its properties:
2444
+ - `identity` resets transform to identity (no transformation)
2445
+ - `invert` inverts a transform
2446
+ - `multiply(&block)` multiplies by another transform (takes a block representing properties of another transform, no need for using the word transform again)
2447
+ - `rotate(angle)` rotates by angle degrees
2448
+ - `scale(x, y)` scales a shape (stretch)
2449
+ - `shear(x, y)` shear effect
2450
+ - `translate(x, y)` translate x and y coordinates (move)
2451
+ - `elements(m11, m12, m21, m22, dx, dy)` resets all values of the transform matrix (first 2 values represent the 1st row, second 2 values represent the 2nd row, the last 2 values represent translation on x and y axes)
2452
+
2453
+ Also, setting `transform` to `nil` after a previous `transform` has been set is like calling `identity`. It resets the transform.
2454
+
2455
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2456
+
2457
+ ```ruby
2458
+ include Glimmer
2459
+
2460
+ shell {
2461
+ text 'Canvas Transform Example'
2462
+ minimum_size 330, 352
2463
+
2464
+ canvas { |canvas_proxy|
2465
+ background :white
2466
+
2467
+ text('glimmer', 0, 0) {
2468
+ foreground :red
2469
+ transform {
2470
+ translate 220, 100
2471
+ scale 2.5, 2.5
2472
+ rotate 90
2473
+ }
2474
+ }
2475
+ text('glimmer', 0, 0) {
2476
+ foreground :dark_green
2477
+ transform {
2478
+ translate 0, 0
2479
+ shear 2, 3
2480
+ scale 2, 2
2481
+ }
2482
+ }
2483
+ text('glimmer', 0, 0) {
2484
+ foreground :blue
2485
+ transform {
2486
+ translate 0, 220
2487
+ scale 3, 3
2488
+ }
2397
2489
  }
2398
2490
  }
2399
2491
  }.open
2400
2492
  ```
2401
2493
 
2402
- 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.
2494
+ ![Canvas Transform Example](images/glimmer-example-canvas-transform.png)
2495
+
2496
+ #### Top-Level Transform Fluent Interface
2497
+
2498
+ When using a transform at the top-level (outside of shell), you get a fluent interface to faciliate manual constructioni and use.
2499
+
2500
+ Example:
2501
+
2502
+ ```ruby
2503
+ transform(1, 1, 4, 2, 2, 4).
2504
+ multiply(1, 2, 3, 4,3,4).
2505
+ scale(1, 2, 3, 4, 5, 6).
2506
+ rotate(45).
2507
+ scale(2, 4).
2508
+ invert.
2509
+ shear(2, 4).
2510
+ translate(3, 7)
2511
+ ```
2512
+
2513
+ Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
2403
2514
 
2404
2515
  ### Canvas Animation DSL
2405
2516
 
@@ -2825,7 +2936,7 @@ Glimmer automatic table sorting supports `String`, `Integer`, and `Float` column
2825
2936
 
2826
2937
  In cases where data is nil, depending on the data-type, it is automatically converted to `Float` with `to_f`, `Integer` with `to_i`, or `String` with `to_s`.
2827
2938
 
2828
- Should you have a special data type that could not be compared automatically, Glimmer offers the following 3 alternatives for custom sorting:
2939
+ Should you have a special data type that could not be compared automatically, Glimmer s the following 3 alternatives for custom sorting:
2829
2940
  - `sort_property`: this may be set to an alternative property to the one data-bound to the table column. For example, a table column called 'adult', which returns `true` or `false` may be sorted with `sort_property :dob` instead. This also support multi-property (aka multi-column) sorting (e.g. `sort_property :dob, :name`).
2830
2941
  - `sort_by(&block)`: this works just like Ruby `Enumerable` `sort_by`. The block receives the table column data as argument.
2831
2942
  - `sort(&comparator)`: this works just like Ruby `Enumerable` `sort`. The comparator block receives two objects from the table column data.
@@ -2920,7 +3031,7 @@ a text widget to the user to change the selected or passed tree item text into s
2920
3031
 
2921
3032
  `date_time` represents the SWT DateTime widget.
2922
3033
 
2923
- Glimmer offers the following alias keywords for it for convenience:
3034
+ Glimmer s the following alias keywords for it for convenience:
2924
3035
  - `date`: `date_time(:date)`
2925
3036
  - `date_drop_down`: `date_time(:date, :drop_down)`
2926
3037
  - `time`: `date_time(:time)`
@@ -2943,7 +3054,7 @@ If you need a better widget with the ability to customize the date format patter
2943
3054
 
2944
3055
  ### Observer
2945
3056
 
2946
- 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.
3057
+ 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.
2947
3058
 
2948
3059
  #### Observing Widgets
2949
3060
 
@@ -3125,7 +3236,7 @@ Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer
3125
3236
 
3126
3237
  A developer might start with approach #1 to eliminate duplication in a view and later upgrade it to approach #2 when needing to export a custom widget to make it available in many views.
3127
3238
 
3128
- Class-based Custom Widgets offer a number of benefits over method-based custom widgets, such as built-in support for passing SWT style, nested block of extra widgets and properties, and `before_body`/`after_body` hooks.
3239
+ Class-based Custom Widgets a number of benefits over method-based custom widgets, such as built-in support for passing SWT style, nested block of extra widgets and properties, and `before_body`/`after_body` hooks.
3129
3240
 
3130
3241
  #### Simple Example
3131
3242
 
@@ -3309,7 +3420,7 @@ body {
3309
3420
 
3310
3421
  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`.
3311
3422
 
3312
- #### Final Notes
3423
+ #### Custom Widget Final Notes
3313
3424
 
3314
3425
  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:
3315
3426
  [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)
@@ -3387,7 +3498,7 @@ You may check out [Hello, Custom Shell!](#hello-custom-shell) for another exampl
3387
3498
 
3388
3499
  ### Drag and Drop
3389
3500
 
3390
- Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
3501
+ Glimmer s Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
3391
3502
 
3392
3503
  You may learn more about SWT Drag and Drop support over here: [https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html](https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html)
3393
3504
 
@@ -4563,6 +4674,19 @@ Hello, Canvas Animation Another Frame!
4563
4674
 
4564
4675
  ![Hello Canvas Animation Frame 2](images/glimmer-hello-canvas-animation-frame2.png)
4565
4676
 
4677
+ #### Hello, Canvas Transform!
4678
+
4679
+ This sample demonstrates the use of the `transform` keyword as part of the [Transform DSL](#canvas-transform-dsl) within the [Shape DSL](#canvas-shape-dsl).
4680
+
4681
+ Code:
4682
+
4683
+ [samples/hello/hello_canvas_transform.rb](samples/hello/hello_canvas_transform.rb)
4684
+
4685
+ Hello, Canvas Transform!
4686
+
4687
+ ![Hello Canvas Transform](images/glimmer-hello-canvas-transform.png)
4688
+
4689
+
4566
4690
  ### Elaborate Samples
4567
4691
 
4568
4692
  For more elaborate samples, check the following:
@@ -4633,6 +4757,18 @@ Contact Manager - Edit Done
4633
4757
 
4634
4758
  ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
4635
4759
 
4760
+ #### Tetris
4761
+
4762
+ 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.
4763
+
4764
+ Code:
4765
+
4766
+ [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
4767
+
4768
+ ![Tetris](images/glimmer-tetris.png)
4769
+
4770
+ ![Tetris Game Over](images/glimmer-tetris-game-over.png)
4771
+
4636
4772
  ### External Samples
4637
4773
 
4638
4774
  #### Glimmer Calculator
@@ -4686,6 +4822,8 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
4686
4822
 
4687
4823
  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)
4688
4824
 
4825
+ 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.
4826
+
4689
4827
  Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
4690
4828
 
4691
4829
  ```
@@ -4792,7 +4930,7 @@ Pass `-v` to javapackager in `Glimmer::RakeTask::Package.javapackager_extra_args
4792
4930
 
4793
4931
  ### Windows Application Packaging
4794
4932
 
4795
- Windows offers two options for setup packaging:
4933
+ Windows s two options for setup packaging:
4796
4934
  - `msi` (recommended): simpler packaging option. Requires [WiX Toolset](https://wixtoolset.org/) and [.NET Framework](https://dotnet.microsoft.com/download/dotnet-framework). Simply run `glimmer package[msi]` (or `glimmer package:native[msi]` if it's not your first time) and it will give you more details on the pre-requisites you need to install (e.g. [WiX Toolset](https://wixtoolset.org/) and [.NET Framework 3.5 SP1](https://dotnet.microsoft.com/download/dotnet-framework/net35-sp1)).
4797
4935
  - `exe`: more advanced packaging option. Requires [Inno Setup](https://jrsoftware.org/isinfo.php). Simply run `glimmer package[exe]` (or `glimmer package:native[exe]` if it's not your first time) and it will tell you what you need to install.
4798
4936
 
@@ -4867,6 +5005,11 @@ Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1
4867
5005
 
4868
5006
  Currently, `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh.
4869
5007
 
5008
+ You can get around that in zsh by running glimmer package commands with `bash -c` prefix:
5009
+
5010
+ ```
5011
+ bash -c 'glimmer package'
5012
+ ```
4870
5013
 
4871
5014
  ## App Updates
4872
5015