glimmer-dsl-swt 4.18.2.4 → 4.18.3.3

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 +60 -0
  3. data/README.md +240 -30
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +13 -7
  6. data/lib/ext/glimmer/config.rb +24 -7
  7. data/lib/glimmer/data_binding/table_items_binding.rb +8 -5
  8. data/lib/glimmer/data_binding/widget_binding.rb +22 -4
  9. data/lib/glimmer/dsl/swt/color_expression.rb +4 -4
  10. data/lib/glimmer/dsl/swt/data_binding_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/{samples/elaborate/tetris/view/game_over_dialog.rb → lib/glimmer/dsl/swt/transform_expression.rb} +29 -46
  16. data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
  17. data/lib/glimmer/swt/color_proxy.rb +28 -6
  18. data/lib/glimmer/swt/custom/drawable.rb +8 -0
  19. data/lib/glimmer/swt/custom/shape.rb +66 -26
  20. data/lib/glimmer/swt/directory_dialog_proxy.rb +3 -3
  21. data/lib/glimmer/swt/display_proxy.rb +26 -5
  22. data/lib/glimmer/swt/file_dialog_proxy.rb +3 -3
  23. data/lib/glimmer/swt/shell_proxy.rb +24 -4
  24. data/lib/glimmer/swt/table_proxy.rb +31 -7
  25. data/lib/glimmer/swt/transform_proxy.rb +109 -0
  26. data/lib/glimmer/swt/widget_listener_proxy.rb +14 -5
  27. data/lib/glimmer/swt/widget_proxy.rb +35 -20
  28. data/lib/glimmer/ui/custom_shell.rb +11 -9
  29. data/lib/glimmer/ui/custom_widget.rb +65 -39
  30. data/samples/elaborate/meta_sample.rb +81 -24
  31. data/samples/elaborate/tetris.rb +105 -44
  32. data/samples/elaborate/tetris/model/block.rb +1 -1
  33. data/samples/elaborate/tetris/model/game.rb +233 -137
  34. data/samples/elaborate/tetris/model/past_game.rb +26 -0
  35. data/samples/elaborate/tetris/model/tetromino.rb +46 -30
  36. data/samples/elaborate/tetris/view/block.rb +33 -5
  37. data/samples/elaborate/tetris/view/high_score_dialog.rb +133 -0
  38. data/samples/elaborate/tetris/view/playfield.rb +1 -1
  39. data/samples/elaborate/tetris/view/score_lane.rb +11 -11
  40. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +121 -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 +11 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e12bb24a84b93822013eef2122021cd5e6a8f90f9e450ac83f7bd5b5f0b7b55
4
- data.tar.gz: dfdba626253a34506b99971821378e8579eac7f21a955ddbd7bc0543f770ad51
3
+ metadata.gz: 59c5aae689604e6024a5bffb1053cd50cc05c1598dca6fc3a01510f17371deab
4
+ data.tar.gz: 5fc97483b96bf334b1e25b30b8455ad41af3e6f56ae6f5310ac31504ce87c41d
5
5
  SHA512:
6
- metadata.gz: d489317bc86659858e1215aca4f35441aa123f59affb4f35fe9fce1ec04f220f3856f5d203d686a1091a7a1652b746a9453ce598eb684910b1ded8717fc1552b
7
- data.tar.gz: 10c31c53aab7d5a8905c6448f66dcacb01c98b952c9934ae1e5236437e583d37aa607161f38946754938c9fc655c876064cc268a93d73d8746667d69d69f684b
6
+ metadata.gz: fdf5681c5632aa64d15c9e2037757d4e7599fbcaeacc14acc1af1dd1669c205ca7a8730551277ae0a3cff5bb435a802dcbdb824e7dbc749f75471ba15079e999
7
+ data.tar.gz: 5f96f41c1bdd491da20ae87ad1b2a5f072eeaca78c6e8f15a1a942390c2cc23b07259465452b242e0d61111a6881954458b5fe5214d77bfd4f45dd365ae0eb14
@@ -1,5 +1,65 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.3.3
4
+
5
+ - Support Table data binding read_only_sort: true option to allow visual sorting without affecting model data
6
+ - Tetris Add lines and level to High Score Dialog
7
+ - Tetris Immediate Drop on Arrow Up
8
+ - Tetris Pause on showing High Score Dialog
9
+ - Tetris Make High Scores -> Show a check menu item
10
+ - Tetris Disable pause button upon showing High Score Dialog
11
+ - Fix Quit Tetris CMD+Q shortcut by adding on_quit event to display
12
+ - Tetris Fix escape button upon entering high score name
13
+ - If WidgetBinding encounters a disposed widget, it deregisters all observables that it is observing
14
+
15
+ ### 4.18.3.2
16
+
17
+ - Tetris High Scores
18
+ - Tetris Modify High Score Player Name
19
+ - Tetris Show High Scores (Menu Item + Accelerator)
20
+ - Tetris add a menu item with beep enablement option
21
+ - Tetris Clear High Scores
22
+ - Tetris Add left and right alt (option) buttons as alternative to shift for rotation. Use left ctrl as rotate left. Use a, s, d as left, down, right.
23
+ - Fix issues relating to setting parenthood with custom widgets before building their body (instead of after)
24
+ - Fix issues relating to not respecting arity of passed in table editing callbacks: before_write, after_write, and after_cancel
25
+
26
+ ### 4.18.3.1
27
+
28
+ - 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.
29
+ - Have CustomShell::launch method take options to pass to custom shell keyword invocation
30
+ - Update Glimmer Meta-Sample to load entire gem into user directory (since some new samples rely on images)
31
+ - Update Glimmer Meta-Sample to display errors in a `dialog` instead of a `message_box` to allow scrolling
32
+ - Removed newly added CustomShell::shutdown as unnecessary (could just do CustomShell::launchd_custom_shell.close)
33
+ - Supporting deregistering Display listeners just like standard listeners via deregister
34
+ - Enhance performance of excluded keyword check
35
+ - Remove CustomWidget support for multiple before_body/after_body blocks instead of one each since it is not needed.
36
+ - Add new :fill_screen style for `shell` to start app filling the screen size (not full screen mode though)
37
+ - Tetris Menu Bar with Game Menu -> Start, Pause, Restart, and Exit
38
+ - Tetris refactor mutation methods to end with bangs
39
+ - Tetris Stop game if user does not play again in the end (instead of closing it)
40
+ - End Tetris Thread loop gracefully if game over is encountered
41
+ - Tetris use more observers instead of callbacks to Game
42
+ - Turn Tetris::Model::Game class from a singleton class to a standard class supporting instances
43
+ - Fix issue of `tetris` keyword not found when run from meta-sample app
44
+
45
+ ### 4.18.3.0
46
+
47
+ - Canvas Transform DSL (DSL declared Transform objects are auto-disposed after getting used by their parent shape)
48
+ - 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))
49
+ - Hello, Canvas Transformation!
50
+
51
+ ### 4.18.2.5
52
+
53
+ - ColorProxy args now are automatically fit into 0..255 bounds upon use of the `color`/`rgb`/`rgba` keywords
54
+ - Canvas Shape DSL (Property) Data-Binding support (No Argument Data-Binding support yet)
55
+ - Add a more bevel 3D look to Tetris blocks
56
+ - Use flyweight pattern with colors
57
+ - Use flyweight pattern with widget classes
58
+ - Use flyweight pattern with custom widget classes
59
+ - Optimized performance of Canvas Shape DSL
60
+ - Optimized performance of Tetris game
61
+ - Fixed issue with top-level sync_exec/async_exec use randomly bombing
62
+
3
63
  ### 4.18.2.4
4
64
 
5
65
  - Tetris scoring
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.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.3.3
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,7 +226,7 @@ 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 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.
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
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
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
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).
@@ -241,6 +241,7 @@ If you see anything that needs to be improved, please do not hesitate to contact
241
241
  - [Desktop Apps Built with Glimmer DSL for SWT](#desktop-apps-built-with-glimmer-dsl-for-swt)
242
242
  - [Table of contents](#table-of-contents)
243
243
  - [Background](#background)
244
+ - [Software Architecture](#software-architecture)
244
245
  - [Platform Support](#platform-support)
245
246
  - [Pre-requisites](#pre-requisites)
246
247
  - [Setup](#setup)
@@ -288,6 +289,7 @@ If you see anything that needs to be improved, please do not hesitate to contact
288
289
  - [Layouts](#layouts)
289
290
  - [Layout Data](#layout-data)
290
291
  - [Canvas Shape DSL](#canvas-shape-dsl)
292
+ - [Canvas Transform DSL](#canvas-transform-dsl)
291
293
  - [Canvas Animation DSL](#canvas-animation-dsl)
292
294
  - [Data-Binding](#data-binding)
293
295
  - [General Examples](#general-examples)
@@ -364,6 +366,7 @@ If you see anything that needs to be improved, please do not hesitate to contact
364
366
  - [Hello, Dialog!](#hello-dialog)
365
367
  - [Hello, Canvas!](#hello-canvas)
366
368
  - [Hello, Canvas Animation!](#hello-canvas-animation)
369
+ - [Hello, Canvas Transform!](#hello-canvas-transform)
367
370
  - [Elaborate Samples](#elaborate-samples)
368
371
  - [User Profile](#user-profile)
369
372
  - [Login](#login)
@@ -403,7 +406,39 @@ If you see anything that needs to be improved, please do not hesitate to contact
403
406
 
404
407
  ## Background
405
408
 
406
- 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.
409
+ [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.
410
+
411
+ ## Software Architecture
412
+
413
+ There are several requirements for building enterprise-level/consumer-level desktop GUI applications:
414
+ - Cross-Platform Support (Mac, Windows, Linux) without compilation/recompilation
415
+ - OS Native Look & Feel
416
+ - High Performance
417
+ - Productivity
418
+ - Maintainability
419
+ - Extensibility
420
+ - Native Executable Packaging
421
+ - Multi-Threading / Parallel Programming
422
+ - Arbitrary Graphics Painting
423
+ - Audio Support
424
+
425
+ Glimmer provides cross-platform support that does not require Ruby compilation (like Tk does), thanks to JRuby, a JVM (Java Virtual Machine) faster OS-threaded version of Ruby.
426
+
427
+ Glimmer leverages SWT (Standard Widget Toolkit), which provides cross-platform widgets that automatically use the native GUI libraries under each operating system, such as Win32 on Windows, Cocoa on Mac, and GTK on Linux.
428
+
429
+ Furthermore, what is special about SWT regarding "High Performance" is that it does all the GUI painting natively outside of Java, thus producing GUI that runs at maximum performance even in Ruby. As such, you do not need to worry about Ruby dynamic typing getting in the way of GUI performance. It has ZERO effect on it and since SWT supports making asynchronous calls for GUI rendering, you could avoid blocking the GUI completely with any computations happening in Ruby no matter how complex, thus never affecting the responsiveness of GUI of applications while taking full advantage of the productivity benefits of Ruby dynamic typing.
430
+
431
+ Glimmer takes this further by providing a very programmer friendly DSL (Domain Specific Language) that visually maps lightweight Ruby syntax to the containment hierarchy of GUI widgets (meaning Ruby blocks nested within each other map to GUI widgets nested within each other). This provides maximum productivity and maintainability.
432
+
433
+ Extensibility has never been simpler in desktop GUI application development than with Glimmer, which provides the ability to support any new custom keywords through custom widgets and custom shells (windows). Basically, you map a keyword by declaring a view class matching its name by convention with a GUI body that simply consists of reusable Glimmer GUI syntax. They can be passive views or smart views with additional logic. This provides the ultimate realization of Object Oriented Programming and micro-level MVC pattern.
434
+
435
+ Thanks to Java and JRuby, Glimmer apps can be packaged as cross-platform JAR files (with JRuby Warbler) and native executables (with Java Packager) as Mac APP/DMG/PACKAGE or Windows EXE/MSI.
436
+
437
+ The Java Virtual Machine already supports OS-native threads, so Glimmer apps can have multiple things running in parallel with no problem.
438
+
439
+ SWT supports Canvas graphics drawing, and Glimmer takes that further by provding a Canvas Shape/Transform/Animation DSL, making it very simple to decorate any existing widgets or add new widgets with a completely custom look and feel if needed for branding or entertainment (gaming) purposes.
440
+
441
+ Audio is supported via the Java Sound library in a cross-platform approach and video is supported via a Glimmer custom widget, so any Glimmer app can be enhanced with audio and video where needed.
407
442
 
408
443
  ## Platform Support
409
444
 
@@ -458,7 +493,7 @@ jgem install glimmer-dsl-swt
458
493
 
459
494
  Or this command if you want a specific version:
460
495
  ```
461
- jgem install glimmer-dsl-swt -v 4.18.2.4
496
+ jgem install glimmer-dsl-swt -v 4.18.3.3
462
497
 
463
498
 
464
499
  ```
@@ -478,7 +513,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
478
513
 
479
514
  Add the following to `Gemfile`:
480
515
  ```
481
- gem 'glimmer-dsl-swt', '~> 4.18.2.4
516
+ gem 'glimmer-dsl-swt', '~> 4.18.3.3
482
517
  '
483
518
  ```
484
519
 
@@ -537,7 +572,7 @@ bin/glimmer samples
537
572
  Below are the full usage instructions that come up when running `glimmer` without args.
538
573
 
539
574
  ```
540
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.2.4
575
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.3
541
576
 
542
577
 
543
578
 
@@ -813,7 +848,7 @@ glimmer run
813
848
 
814
849
  #### Custom Shell
815
850
 
816
- To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
851
+ To scaffold a Glimmer [custom shell](#custom-shells) (full window view) for an existing Glimmer app, run the following command:
817
852
 
818
853
  ```
819
854
  glimmer scaffold:customshell[name]
@@ -827,7 +862,7 @@ glimmer scaffold:cs[name]
827
862
 
828
863
  #### Custom Widget
829
864
 
830
- To scaffold a Glimmer custom widget (part of a view) for an existing Glimmer app, run the following command:
865
+ To scaffold a Glimmer [custom widget](#custom-widgets) (part of a view) for an existing Glimmer app, run the following command:
831
866
 
832
867
  ```
833
868
  glimmer scaffold:customwidget[name]
@@ -841,7 +876,7 @@ glimmer scaffold:cw[name]
841
876
 
842
877
  #### Custom Shell Gem
843
878
 
844
- Custom shell gems are self-contained Glimmer apps as well as reusable custom shells.
879
+ Custom shell gems are self-contained Glimmer apps as well as reusable [custom shells](#custom-shells).
845
880
  They have everything scaffolded Glimmer apps come with in addition to gem content like a [Juwelier](https://rubygems.org/gems/juwelier) Rakefile that can build gemspec and release gems.
846
881
  Unlike scaffolded Glimmer apps, custom shell gem content lives under the `lib` directory (not `app`).
847
882
  They can be packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
@@ -876,7 +911,7 @@ Examples:
876
911
 
877
912
  #### Custom Widget Gem
878
913
 
879
- To scaffold a Glimmer custom widget gem (part of a view distributed as a Ruby gem), run the following command:
914
+ To scaffold a Glimmer [custom widget](#custom-widgets) gem (part of a view distributed as a Ruby gem), run the following command:
880
915
 
881
916
  ```
882
917
  glimmer scaffold:gem:customwidget[name,namespace]
@@ -902,7 +937,7 @@ Examples:
902
937
 
903
938
  ### Gem Listing
904
939
 
905
- The `glimmer` command comes with tasks for listing Glimmer related gems to make it easy to find Glimmer Custom Shells, Custom Widgets, and DSLs published by others in the Glimmer community on [rubygems.org](http://www.rubygems.org).
940
+ The `glimmer` command comes with tasks for listing Glimmer related gems to make it easy to find Glimmer [Custom Shells](#custom-shells), [Custom Widgets](#custom-widgets), and DSLs published by others in the Glimmer community on [rubygems.org](http://www.rubygems.org).
906
941
 
907
942
  #### Listing Custom Shell Gems
908
943
 
@@ -1018,7 +1053,7 @@ Output:
1018
1053
 
1019
1054
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1020
1055
  Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1021
- Swt glimmer-dsl-swt 4.18.2.4
1056
+ Swt glimmer-dsl-swt 4.18.3.3
1022
1057
 
1023
1058
  AndyMaleh Glimmer DSL for SWT
1024
1059
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
@@ -1096,7 +1131,12 @@ bin/girb
1096
1131
 
1097
1132
  Watch out for hands-on examples in this README indicated by "you may copy/paste in [`girb`](#girb-glimmer-irb-command)"
1098
1133
 
1099
- Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)
1134
+ Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt/samples](https://github.com/AndyObtiva/glimmer-dsl-swt/samples)
1135
+
1136
+ If you need a more GUI interactive option to experiement with Glimmer GUI DSL Syntax, you may try:
1137
+ - [Glimmer Meta-Sample (The Sample of Samples)](#samples): allows launching Glimmer samples and viewing/editing code to learn/experiment too.
1138
+ - ["Ugliest Editor Ever"](https://github.com/AndyObtiva/glimmer-cs-gladiator)
1139
+ - Just build your own GUI editor using the [Glimmer DSL for SWT Ruby Gem](https://rubygems.org/gems/glimmer-dsl-swt).
1100
1140
 
1101
1141
  ## Glimmer GUI DSL Syntax
1102
1142
 
@@ -1507,7 +1547,7 @@ Although SWT Display is not technically a widget, it has similar APIs and DSL su
1507
1547
 
1508
1548
  #### Multi-Threading
1509
1549
 
1510
- [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.
1550
+ [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.
1511
1551
 
1512
1552
  ##### async_exec
1513
1553
 
@@ -1938,7 +1978,7 @@ style = swt(:shell_trim, :max!) # creates a shell trim style without the maximiz
1938
1978
 
1939
1979
  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!)`.
1940
1980
 
1941
- Glimmer makes this easier by alternatively offering a `:no_resize` extra SWT style, added for convenience.
1981
+ Glimmer makes this easier by alternatively ing a `:no_resize` extra SWT style, added for convenience.
1942
1982
  This makes declaring a non-resizable window as easy as:
1943
1983
 
1944
1984
  ```ruby
@@ -2339,6 +2379,7 @@ Here is a list of supported attributes nestable within a block under shapes:
2339
2379
  - `line_style` line join style (SWT style value of `:line_solid`, `:line_dash`, `:line_dot`, `:line_dashdot`, or `:line_dashdotdot`)
2340
2380
  - `line_width` line width in integer (used in draw operations)
2341
2381
  - `text_anti_alias` enables text antialiasing (SWT style value of `:default`, `:off`, `:on` whereby `:default` applies OS default, which varies per OS)
2382
+ - `transform` sets transform object using [Canvas Transform DSL](#canvas-transform-dsl) syntax
2342
2383
 
2343
2384
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2344
2385
 
@@ -2387,6 +2428,8 @@ If you get extremely stuck, remember that you could always default to direct [SW
2387
2428
  Example of manually doing the same things as in the above example without relying on the declarative Glimmer Shape DSL:
2388
2429
 
2389
2430
  ```ruby
2431
+ image_object = image(File.expand_path('./icons/scaffold_app.png'), width: 100)
2432
+
2390
2433
  include Glimmer
2391
2434
 
2392
2435
  shell {
@@ -2397,17 +2440,23 @@ shell {
2397
2440
  background :yellow
2398
2441
 
2399
2442
  on_paint_control { |event|
2400
- event.gc.setBackground(color(:red).swt_color)
2401
- event.gc.fillRectangle(0, 0, 220, 400)
2443
+ event.gc.set_background(color(:red).swt_color)
2444
+ event.gc.fill_rectangle(0, 0, 220, 400)
2445
+
2446
+ event.gc.set_background(color(:magenta).swt_color)
2447
+ event.gc.fill_roundRectangle(50, 20, 300, 150, 30, 50)
2402
2448
 
2403
- event.gc.setBackground(color(:magenta).swt_color)
2404
- event.gc.fillRoundRectangle(50, 20, 300, 150, 30, 50)
2449
+ event.gc.set_background(color(:dark_magenta).swt_color)
2450
+ event.gc.fill_gradientRectangle(150, 200, 100, 70, true)
2405
2451
 
2406
- event.gc.setBackground(color(:dark_magenta).swt_color)
2407
- event.gc.fillGradientRectangle(150, 200, 100, 70, true)
2452
+ event.gc.set_foreground(color(:dark_blue).swt_color)
2453
+ event.gc.draw_rectangle(200, 80, 108, 36)
2408
2454
 
2409
- event.gc.setForeground(color(:dark_blue).swt_color)
2410
- event.gc.drawRectangle(200, 80, 108, 36)
2455
+ event.gc.set_foreground(color(:black).swt_color)
2456
+ event.gc.set_lineWidth(3)
2457
+ event.gc.draw_rectangle(200, 80, 108, 36)
2458
+
2459
+ event.gc.draw_image(image_object.swt_image, 70, 50)
2411
2460
  }
2412
2461
  }
2413
2462
  }.open
@@ -2419,6 +2468,88 @@ In any case, if there is anything missing you would like added to the Glimmer Sh
2419
2468
 
2420
2469
  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
2470
 
2471
+ ### Canvas Transform DSL
2472
+
2473
+ 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.
2474
+
2475
+ `transform` keyword builds a `Transform` object. It optionally takes the transformation matrix elements: (m11, m12, m21, m22, dx, dy)
2476
+
2477
+ 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
2478
+
2479
+ Additionally, Transform operation keywords may be nested within the `transform` keyword to set its properties:
2480
+ - `identity` resets transform to identity (no transformation)
2481
+ - `invert` inverts a transform
2482
+ - `multiply(&block)` multiplies by another transform (takes a block representing properties of another transform, no need for using the word transform again)
2483
+ - `rotate(angle)` rotates by angle degrees
2484
+ - `scale(x, y)` scales a shape (stretch)
2485
+ - `shear(x, y)` shear effect
2486
+ - `translate(x, y)` translate x and y coordinates (move)
2487
+ - `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)
2488
+
2489
+ Also, setting `transform` to `nil` after a previous `transform` has been set is like calling `identity`. It resets the transform.
2490
+
2491
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2492
+
2493
+ ```ruby
2494
+ include Glimmer
2495
+
2496
+ shell {
2497
+ text 'Canvas Transform Example'
2498
+ minimum_size 330, 352
2499
+
2500
+ canvas { |canvas_proxy|
2501
+ background :white
2502
+
2503
+ text('glimmer', 0, 0) {
2504
+ foreground :red
2505
+ transform {
2506
+ translate 220, 100
2507
+ scale 2.5, 2.5
2508
+ rotate 90
2509
+ }
2510
+ }
2511
+ text('glimmer', 0, 0) {
2512
+ foreground :dark_green
2513
+ transform {
2514
+ translate 0, 0
2515
+ shear 2, 3
2516
+ scale 2, 2
2517
+ }
2518
+ }
2519
+ text('glimmer', 0, 0) {
2520
+ foreground :blue
2521
+ transform {
2522
+ translate 0, 220
2523
+ scale 3, 3
2524
+ }
2525
+ }
2526
+ }
2527
+ }.open
2528
+ ```
2529
+
2530
+ ![Canvas Transform Example](images/glimmer-example-canvas-transform.png)
2531
+
2532
+ #### Top-Level Transform Fluent Interface
2533
+
2534
+ When using a transform at the top-level (outside of shell), you get a fluent interface to faciliate manual constructioni and use.
2535
+
2536
+ Example:
2537
+
2538
+ ```ruby
2539
+ include Glimmer # make sure it is included in your class/module before using the fluent interface
2540
+
2541
+ transform(1, 1, 4, 2, 2, 4).
2542
+ multiply(1, 2, 3, 4,3,4).
2543
+ scale(1, 2, 3, 4, 5, 6).
2544
+ rotate(45).
2545
+ scale(2, 4).
2546
+ invert.
2547
+ shear(2, 4).
2548
+ translate(3, 7)
2549
+ ```
2550
+
2551
+ Learn more at the [Hello, Canvas Transform! Sample](#hello-canvas-transform).
2552
+
2422
2553
  ### Canvas Animation DSL
2423
2554
 
2424
2555
  (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.)
@@ -2843,7 +2974,7 @@ Glimmer automatic table sorting supports `String`, `Integer`, and `Float` column
2843
2974
 
2844
2975
  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`.
2845
2976
 
2846
- Should you have a special data type that could not be compared automatically, Glimmer offers the following 3 alternatives for custom sorting:
2977
+ Should you have a special data type that could not be compared automatically, Glimmer s the following 3 alternatives for custom sorting:
2847
2978
  - `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`).
2848
2979
  - `sort_by(&block)`: this works just like Ruby `Enumerable` `sort_by`. The block receives the table column data as argument.
2849
2980
  - `sort(&comparator)`: this works just like Ruby `Enumerable` `sort`. The comparator block receives two objects from the table column data.
@@ -2894,6 +3025,7 @@ Here is an explanation of the example above:
2894
3025
  - Task Start Date table column has a custom sort comparator block
2895
3026
  - Additional (secondary) sort properties are applied when sorting by Task, Project, or Duration in the order specified
2896
3027
 
3028
+ `bind(model, :property, read_only_sort: true)` could be used with items to make sorting not propagate sorting changes to model.
2897
3029
 
2898
3030
  #### Tree
2899
3031
 
@@ -2938,7 +3070,7 @@ a text widget to the user to change the selected or passed tree item text into s
2938
3070
 
2939
3071
  `date_time` represents the SWT DateTime widget.
2940
3072
 
2941
- Glimmer offers the following alias keywords for it for convenience:
3073
+ Glimmer s the following alias keywords for it for convenience:
2942
3074
  - `date`: `date_time(:date)`
2943
3075
  - `date_drop_down`: `date_time(:date, :drop_down)`
2944
3076
  - `time`: `date_time(:time)`
@@ -3143,7 +3275,7 @@ Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer
3143
3275
 
3144
3276
  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.
3145
3277
 
3146
- 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.
3278
+ 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.
3147
3279
 
3148
3280
  #### Simple Example
3149
3281
 
@@ -3401,11 +3533,13 @@ shell { |app_shell|
3401
3533
  }.open
3402
3534
  ```
3403
3535
 
3536
+ If you use a Custom Shell as the top-level app shell, you may invoke the class method `::launch` instead to avoid building an app class yourself or including Glimmer into the top-level namespace (e.g. `Tetris.launch` instead of `include Glimmer; tetris.open`)
3537
+
3404
3538
  You may check out [Hello, Custom Shell!](#hello-custom-shell) for another example.
3405
3539
 
3406
3540
  ### Drag and Drop
3407
3541
 
3408
- Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
3542
+ Glimmer s Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
3409
3543
 
3410
3544
  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)
3411
3545
 
@@ -3681,6 +3815,41 @@ shell(:no_resize) {
3681
3815
 
3682
3816
  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.
3683
3817
 
3818
+ #### Performance Profiling
3819
+
3820
+ 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:
3821
+
3822
+ `glimmer --profile path_to_glimmer_app.rb`
3823
+
3824
+ Additionally, add this code to monitor Glimmer app performance around its launch method:
3825
+
3826
+ ```ruby
3827
+ require 'jruby/profiler'
3828
+ profile_data = JRuby::Profiler.profile do
3829
+ SomeGlimmerApp.launch
3830
+ end
3831
+
3832
+ profile_printer = JRuby::Profiler::HtmlProfilePrinter.new(profile_data)
3833
+ ps = java.io.PrintStream.new(STDOUT.to_outputstream)
3834
+ ```
3835
+
3836
+ 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.
3837
+
3838
+ Example:
3839
+
3840
+ ```ruby
3841
+ shell {
3842
+ # some code
3843
+ on_swt_show {
3844
+ exit(0)
3845
+ }
3846
+ }
3847
+ ```
3848
+
3849
+ You may run `glimmer` with the `--profile.graph` instead for a more detailed output.
3850
+
3851
+ Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby/jruby/wiki/Profiling-JRuby).
3852
+
3684
3853
  #### Checkbox Group Widget
3685
3854
 
3686
3855
  `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.
@@ -4017,8 +4186,18 @@ end
4017
4186
 
4018
4187
  ### log_excluded_keywords
4019
4188
 
4189
+ (default = false)
4190
+
4020
4191
  This just tells Glimmer whether to log excluded keywords or not (at the debug level). It is off by default.
4021
4192
 
4193
+ ### auto_sync_exec
4194
+
4195
+ (default = false)
4196
+
4197
+ This automatically uses sync_exec on GUI calls from threads other than the main GUI thread instead of requiring users to manually use sync_exec. Default value to false.
4198
+
4199
+ Keep in mind the caveat that it would force redraws on every minor changein the models instead of applying large scope changes all together, thus causing too much drawing/stutter in the GUI. As such, this is a good fit for simpler GUIs, not ones used with highly sophisticated 2D graphics. It may be mitigated in the future by introducing the idea of large-scale observation events that wrap around smaller events. Until then, keep the caveat in mind or just use sync_exec manually as usually done with Java SWT apps.
4200
+
4022
4201
  ## Glimmer Style Guide
4023
4202
 
4024
4203
  - Widgets are declared with underscored lowercase versions of their SWT names minus the SWT package name.
@@ -4094,6 +4273,12 @@ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](samples/elabora
4094
4273
 
4095
4274
  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.
4096
4275
 
4276
+ 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):
4277
+
4278
+ ```ruby
4279
+ bin/glimmer samples/hello/hello_canvas_transform.rb
4280
+ ```
4281
+
4097
4282
  ### Hello Samples
4098
4283
 
4099
4284
  For hello-type simple samples, check the following.
@@ -4581,6 +4766,19 @@ Hello, Canvas Animation Another Frame!
4581
4766
 
4582
4767
  ![Hello Canvas Animation Frame 2](images/glimmer-hello-canvas-animation-frame2.png)
4583
4768
 
4769
+ #### Hello, Canvas Transform!
4770
+
4771
+ 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).
4772
+
4773
+ Code:
4774
+
4775
+ [samples/hello/hello_canvas_transform.rb](samples/hello/hello_canvas_transform.rb)
4776
+
4777
+ Hello, Canvas Transform!
4778
+
4779
+ ![Hello Canvas Transform](images/glimmer-hello-canvas-transform.png)
4780
+
4781
+
4584
4782
  ### Elaborate Samples
4585
4783
 
4586
4784
  For more elaborate samples, check the following:
@@ -4663,6 +4861,18 @@ Code:
4663
4861
 
4664
4862
  ![Tetris Game Over](images/glimmer-tetris-game-over.png)
4665
4863
 
4864
+ ![Tetris Game Over](images/glimmer-tetris-game-over-sorted-by-score.png)
4865
+
4866
+ ![Tetris High Scores](images/glimmer-tetris-high-score-dialog.png)
4867
+
4868
+ ![Tetris Game Menu](images/glimmer-tetris-game-menu.png)
4869
+
4870
+ ![Tetris View Menu](images/glimmer-tetris-view-menu.png)
4871
+
4872
+ ![Tetris Options Menu](images/glimmer-tetris-options-menu.png)
4873
+
4874
+ ![Tetris Help Menu](images/glimmer-tetris-help-menu.png)
4875
+
4666
4876
  ### External Samples
4667
4877
 
4668
4878
  #### Glimmer Calculator
@@ -4824,7 +5034,7 @@ Pass `-v` to javapackager in `Glimmer::RakeTask::Package.javapackager_extra_args
4824
5034
 
4825
5035
  ### Windows Application Packaging
4826
5036
 
4827
- Windows offers two options for setup packaging:
5037
+ Windows s two options for setup packaging:
4828
5038
  - `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)).
4829
5039
  - `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.
4830
5040