glimmer-dsl-swt 4.18.2.2 → 4.18.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -0
  3. data/README.md +213 -32
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +19 -6
  6. data/lib/ext/glimmer/config.rb +24 -7
  7. data/lib/glimmer/data_binding/widget_binding.rb +14 -4
  8. data/lib/glimmer/dsl/swt/color_expression.rb +4 -4
  9. data/lib/glimmer/dsl/swt/data_binding_expression.rb +3 -3
  10. data/lib/glimmer/dsl/swt/display_expression.rb +3 -3
  11. data/lib/glimmer/dsl/swt/dsl.rb +1 -0
  12. data/lib/glimmer/dsl/swt/multiply_expression.rb +53 -0
  13. data/lib/glimmer/dsl/swt/property_expression.rb +4 -2
  14. data/lib/glimmer/dsl/swt/shape_expression.rb +2 -4
  15. data/lib/glimmer/dsl/swt/transform_expression.rb +55 -0
  16. data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
  17. data/lib/glimmer/rake_task/scaffold.rb +4 -3
  18. data/lib/glimmer/swt/color_proxy.rb +28 -6
  19. data/lib/glimmer/swt/custom/drawable.rb +8 -0
  20. data/lib/glimmer/swt/custom/shape.rb +66 -26
  21. data/lib/glimmer/swt/directory_dialog_proxy.rb +3 -3
  22. data/lib/glimmer/swt/display_proxy.rb +26 -5
  23. data/lib/glimmer/swt/file_dialog_proxy.rb +3 -3
  24. data/lib/glimmer/swt/layout_data_proxy.rb +3 -3
  25. data/lib/glimmer/swt/shell_proxy.rb +17 -5
  26. data/lib/glimmer/swt/transform_proxy.rb +109 -0
  27. data/lib/glimmer/swt/widget_listener_proxy.rb +14 -5
  28. data/lib/glimmer/swt/widget_proxy.rb +35 -26
  29. data/lib/glimmer/ui/custom_shell.rb +17 -3
  30. data/lib/glimmer/ui/custom_widget.rb +66 -45
  31. data/samples/elaborate/meta_sample.rb +102 -24
  32. data/samples/elaborate/tetris.rb +137 -0
  33. data/samples/elaborate/tetris/model/block.rb +48 -0
  34. data/samples/elaborate/tetris/model/game.rb +226 -0
  35. data/samples/elaborate/tetris/model/tetromino.rb +316 -0
  36. data/samples/elaborate/tetris/view/block.rb +70 -0
  37. data/samples/elaborate/tetris/view/game_over_dialog.rb +68 -0
  38. data/samples/elaborate/tetris/view/playfield.rb +56 -0
  39. data/samples/elaborate/tetris/view/score_lane.rb +87 -0
  40. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +72 -0
  41. data/samples/elaborate/tic_tac_toe.rb +4 -4
  42. data/samples/hello/hello_canvas_transform.rb +40 -0
  43. data/samples/hello/hello_link.rb +1 -1
  44. metadata +17 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86c6cb24dde4db7916e8af3e1c2e61c8146d1be0893ff9d59f3546867438032d
4
- data.tar.gz: 63a055522af49c34e2bf1fad56f2fa54fab9842129c99816561bc60081b3373a
3
+ metadata.gz: 0d88ee3cdf02d4610332fd450379b43ab5231e0a2e5e9941c746ea7b65bcad00
4
+ data.tar.gz: db869412b61dd6c45002cd11ebf7cdb046d02b4de9b74769ec8cd90122eafbd9
5
5
  SHA512:
6
- metadata.gz: 132c53c40c35a0e05a3f44953651b1418b453b6cf8d9bd8cd2f5d90bfa1ce1254b816f5bfb0c26fa7222e924818817dbf8260f4107f92c54816de2c42545e21d
7
- data.tar.gz: cd8c874d5549295a0466944a2a3257405f3f670417dce6cade8c80202a5016d3b86a1cf7393479694c9fd0e2ea080a9fd4e965c57d653ae62653140883d612fc
6
+ metadata.gz: 520388927363b967965f3afbbafdd753daf3c399547b87e5c60535620b12ffc694b05e14b5176b600fd1dcf7eecb4ee9c00ca41f4cbdda79ad138d2e593c836a
7
+ data.tar.gz: 5d52780657cac19b47ccec883b163b56fd1823f1701abef6e01e8b9b3109479648999506eb3dea2cb831826ab88eb562faf1c1a961f8d9c85620cfc956da7432
@@ -1,5 +1,58 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.3.1
4
+
5
+ - Provide an auto_sync_exec all data-binding config option to automatically sync_exec GUI calls from other threads instead of requiring users to use sync_exec on model attribute-change logic. Default value to false.
6
+ - Have CustomShell::launch method take options to pass to custom shell keyword invocation
7
+ - Update Glimmer Meta-Sample to load entire gem into user directory (since some new samples rely on images)
8
+ - Update Glimmer Meta-Sample to display errors in a `dialog` instead of a `message_box` to allow scrolling
9
+ - Removed newly added CustomShell::shutdown as unnecessary (could just do CustomShell::launchd_custom_shell.close)
10
+ - Supporting deregistering Display listeners just like standard listeners via deregister
11
+ - Enhance performance of excluded keyword check
12
+ - Remove CustomWidget support for multiple before_body/after_body blocks instead of one each since it is not needed.
13
+ - Tetris Menu Bar with Game Menu -> Start, Pause, Restart, and Exit
14
+ - Tetris refactor mutation methods to end with bangs
15
+ - Add new :fill_screen style for `shell` to start app filling the screen size (not full screen mode though)
16
+ - Tetris Stop game if user does not play again in the end (instead of closing it)
17
+ - End Tetris Thread loop gracefully if game over is encountered
18
+ - Tetris use more observers instead of callbacks to Game
19
+ - Turn Tetris::Model::Game class from a singleton class to a standard class supporting instances
20
+ - Fix issue of `tetris` keyword not found when run from meta-sample app
21
+
22
+ ### 4.18.3.0
23
+
24
+ - Canvas Transform DSL (DSL declared Transform objects are auto-disposed after getting used by their parent shape)
25
+ - 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))
26
+ - Hello, Canvas Transformation!
27
+
28
+ ### 4.18.2.5
29
+
30
+ - ColorProxy args now are automatically fit into 0..255 bounds upon use of the `color`/`rgb`/`rgba` keywords
31
+ - Canvas Shape DSL (Property) Data-Binding support (No Argument Data-Binding support yet)
32
+ - Add a more bevel 3D look to Tetris blocks
33
+ - Use flyweight pattern with colors
34
+ - Use flyweight pattern with widget classes
35
+ - Use flyweight pattern with custom widget classes
36
+ - Optimized performance of Canvas Shape DSL
37
+ - Optimized performance of Tetris game
38
+ - Fixed issue with top-level sync_exec/async_exec use randomly bombing
39
+
40
+ ### 4.18.2.4
41
+
42
+ - Tetris scoring
43
+ - Tetris eliminated Line tracking
44
+ - Tetris level tracking and speed-ups
45
+ - Tetris preview upcoming tetromino shape
46
+ - Added parent_proxy to CustomWidget and CustomShell classes
47
+ - Update CustomShell#center and ShellProxy#center to center_within_display to avoid clash with `row_layout` center property
48
+ - Fixed issue with shell/dialog/custom-shell not maintaining parent when not passed
49
+ - Fix Tetris sideways edge detection
50
+
51
+ ### 4.18.2.3
52
+
53
+ - Added Tetris Elaborate Sample
54
+ - 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)
55
+
3
56
  ### 4.18.2.2
4
57
 
5
58
  - Fixed issue with processing shape color due to missing Color class package name
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.2
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.1
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.2
463
+ jgem install glimmer-dsl-swt -v 4.18.3.1
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.2
483
+ gem 'glimmer-dsl-swt', '~> 4.18.3.1
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.2
542
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.1
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.2
1023
+ Swt glimmer-dsl-swt 4.18.3.1
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,115 @@ 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)
2412
+
2413
+ event.gc.set_background(color(:dark_magenta).swt_color)
2414
+ event.gc.fill_gradientRectangle(150, 200, 100, 70, true)
2388
2415
 
2389
- event.gc.setBackground(color(:magenta).swt_color)
2390
- event.gc.fillRoundRectangle(50, 20, 300, 150, 30, 50)
2416
+ event.gc.set_foreground(color(:dark_blue).swt_color)
2417
+ event.gc.draw_rectangle(200, 80, 108, 36)
2391
2418
 
2392
- event.gc.setBackground(color(:dark_magenta).swt_color)
2393
- event.gc.fillGradientRectangle(150, 200, 100, 70, true)
2419
+ event.gc.set_foreground(color(:black).swt_color)
2420
+ event.gc.set_lineWidth(3)
2421
+ event.gc.draw_rectangle(200, 80, 108, 36)
2394
2422
 
2395
- event.gc.setForeground(color(:dark_blue).swt_color)
2396
- event.gc.drawRectangle(200, 80, 108, 36)
2423
+ event.gc.draw_image(image_object.swt_image, 70, 50)
2397
2424
  }
2398
2425
  }
2399
2426
  }.open
2400
2427
  ```
2401
2428
 
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.
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
+ }
2489
+ }
2490
+ }
2491
+ }.open
2492
+ ```
2493
+
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
+ include Glimmer # make sure it is included in your class/module before using the fluent interface
2504
+
2505
+ transform(1, 1, 4, 2, 2, 4).
2506
+ multiply(1, 2, 3, 4,3,4).
2507
+ scale(1, 2, 3, 4, 5, 6).
2508
+ rotate(45).
2509
+ scale(2, 4).
2510
+ invert.
2511
+ shear(2, 4).
2512
+ translate(3, 7)
2513
+ ```
2514
+
2515
+ Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
2403
2516
 
2404
2517
  ### Canvas Animation DSL
2405
2518
 
@@ -2825,7 +2938,7 @@ Glimmer automatic table sorting supports `String`, `Integer`, and `Float` column
2825
2938
 
2826
2939
  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
2940
 
2828
- Should you have a special data type that could not be compared automatically, Glimmer offers the following 3 alternatives for custom sorting:
2941
+ Should you have a special data type that could not be compared automatically, Glimmer s the following 3 alternatives for custom sorting:
2829
2942
  - `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
2943
  - `sort_by(&block)`: this works just like Ruby `Enumerable` `sort_by`. The block receives the table column data as argument.
2831
2944
  - `sort(&comparator)`: this works just like Ruby `Enumerable` `sort`. The comparator block receives two objects from the table column data.
@@ -2920,7 +3033,7 @@ a text widget to the user to change the selected or passed tree item text into s
2920
3033
 
2921
3034
  `date_time` represents the SWT DateTime widget.
2922
3035
 
2923
- Glimmer offers the following alias keywords for it for convenience:
3036
+ Glimmer s the following alias keywords for it for convenience:
2924
3037
  - `date`: `date_time(:date)`
2925
3038
  - `date_drop_down`: `date_time(:date, :drop_down)`
2926
3039
  - `time`: `date_time(:time)`
@@ -2943,7 +3056,7 @@ If you need a better widget with the ability to customize the date format patter
2943
3056
 
2944
3057
  ### Observer
2945
3058
 
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.
3059
+ 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
3060
 
2948
3061
  #### Observing Widgets
2949
3062
 
@@ -3125,7 +3238,7 @@ Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer
3125
3238
 
3126
3239
  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
3240
 
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.
3241
+ 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
3242
 
3130
3243
  #### Simple Example
3131
3244
 
@@ -3309,7 +3422,7 @@ body {
3309
3422
 
3310
3423
  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
3424
 
3312
- #### Final Notes
3425
+ #### Custom Widget Final Notes
3313
3426
 
3314
3427
  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
3428
  [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 +3500,7 @@ You may check out [Hello, Custom Shell!](#hello-custom-shell) for another exampl
3387
3500
 
3388
3501
  ### Drag and Drop
3389
3502
 
3390
- Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
3503
+ Glimmer s Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
3391
3504
 
3392
3505
  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
3506
 
@@ -3663,6 +3776,41 @@ shell(:no_resize) {
3663
3776
 
3664
3777
  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.
3665
3778
 
3779
+ #### Performance Profiling
3780
+
3781
+ JRuby comes with built-in support for performance profiling via the `--profile` option (with some code shown below), which can be accepted by the `glimmer` command too:
3782
+
3783
+ `glimmer --profile path_to_glimmer_app.rb`
3784
+
3785
+ Additionally, add this code to monitor Glimmer app performance around its launch method:
3786
+
3787
+ ```ruby
3788
+ require 'jruby/profiler'
3789
+ profile_data = JRuby::Profiler.profile do
3790
+ SomeGlimmerApp.launch
3791
+ end
3792
+
3793
+ profile_printer = JRuby::Profiler::HtmlProfilePrinter.new(profile_data)
3794
+ ps = java.io.PrintStream.new(STDOUT.to_outputstream)
3795
+ ```
3796
+
3797
+ When monitoring app startup time performance, make sure to add a hook to the top-level `shell` `on_swt_show` event that exits the app as soon as the shell shows up to end performance profiling and get the results.
3798
+
3799
+ Example:
3800
+
3801
+ ```ruby
3802
+ shell {
3803
+ # some code
3804
+ on_swt_show {
3805
+ exit(0)
3806
+ }
3807
+ }
3808
+ ```
3809
+
3810
+ You may run `glimmer` with the `--profile.graph` instead for a more detailed output.
3811
+
3812
+ Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby/jruby/wiki/Profiling-JRuby).
3813
+
3666
3814
  #### Checkbox Group Widget
3667
3815
 
3668
3816
  `checkbox_group` (or alias `check_group`) is a Glimmer built-in custom widget that displays a list of `checkbox` buttons (`button(:check)`) based on its `items` property.
@@ -4076,6 +4224,12 @@ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](samples/elabora
4076
4224
 
4077
4225
  You may edit the code of any sample before launching it by clicking on the "Launch" button. This helps you learn by experimenting with Glimmer GUI DSL syntax. To go back to original code, simply hit the "Reset" button.
4078
4226
 
4227
+ Note that if you fail to run any sample through the Glimmer Meta-Sample for whatever reason, you could always run directly by cloning the project, running `bundle`, and then this command (drop the "bin" if you install the glimmer-dsl-swt gem instead):
4228
+
4229
+ ```ruby
4230
+ bin/glimmer samples/hello/hello_canvas_transform.rb
4231
+ ```
4232
+
4079
4233
  ### Hello Samples
4080
4234
 
4081
4235
  For hello-type simple samples, check the following.
@@ -4563,6 +4717,19 @@ Hello, Canvas Animation Another Frame!
4563
4717
 
4564
4718
  ![Hello Canvas Animation Frame 2](images/glimmer-hello-canvas-animation-frame2.png)
4565
4719
 
4720
+ #### Hello, Canvas Transform!
4721
+
4722
+ 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).
4723
+
4724
+ Code:
4725
+
4726
+ [samples/hello/hello_canvas_transform.rb](samples/hello/hello_canvas_transform.rb)
4727
+
4728
+ Hello, Canvas Transform!
4729
+
4730
+ ![Hello Canvas Transform](images/glimmer-hello-canvas-transform.png)
4731
+
4732
+
4566
4733
  ### Elaborate Samples
4567
4734
 
4568
4735
  For more elaborate samples, check the following:
@@ -4633,6 +4800,18 @@ Contact Manager - Edit Done
4633
4800
 
4634
4801
  ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
4635
4802
 
4803
+ #### Tetris
4804
+
4805
+ 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.
4806
+
4807
+ Code:
4808
+
4809
+ [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
4810
+
4811
+ ![Tetris](images/glimmer-tetris.png)
4812
+
4813
+ ![Tetris Game Over](images/glimmer-tetris-game-over.png)
4814
+
4636
4815
  ### External Samples
4637
4816
 
4638
4817
  #### Glimmer Calculator
@@ -4686,6 +4865,8 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
4686
4865
 
4687
4866
  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
4867
 
4868
+ 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.
4869
+
4689
4870
  Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
4690
4871
 
4691
4872
  ```
@@ -4792,7 +4973,7 @@ Pass `-v` to javapackager in `Glimmer::RakeTask::Package.javapackager_extra_args
4792
4973
 
4793
4974
  ### Windows Application Packaging
4794
4975
 
4795
- Windows offers two options for setup packaging:
4976
+ Windows s two options for setup packaging:
4796
4977
  - `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
4978
  - `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
4979