glimmer-dsl-swt 4.18.3.0 → 4.18.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -0
  3. data/README.md +440 -18
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +11 -7
  6. data/lib/ext/glimmer/config.rb +24 -7
  7. data/lib/ext/rouge/themes/glimmer.rb +29 -0
  8. data/lib/glimmer-dsl-swt.rb +0 -1
  9. data/lib/glimmer/data_binding/table_items_binding.rb +8 -5
  10. data/lib/glimmer/data_binding/widget_binding.rb +22 -4
  11. data/lib/glimmer/dsl/swt/image_expression.rb +14 -6
  12. data/lib/glimmer/dsl/swt/layout_data_expression.rb +4 -4
  13. data/lib/glimmer/dsl/swt/layout_expression.rb +5 -3
  14. data/lib/glimmer/swt/custom/code_text.rb +132 -37
  15. data/lib/glimmer/swt/custom/drawable.rb +3 -2
  16. data/lib/glimmer/swt/custom/shape.rb +25 -11
  17. data/lib/glimmer/swt/date_time_proxy.rb +1 -3
  18. data/lib/glimmer/swt/directory_dialog_proxy.rb +3 -3
  19. data/lib/glimmer/swt/display_proxy.rb +26 -5
  20. data/lib/glimmer/swt/file_dialog_proxy.rb +3 -3
  21. data/lib/glimmer/swt/font_proxy.rb +1 -0
  22. data/lib/glimmer/swt/image_proxy.rb +68 -1
  23. data/lib/glimmer/swt/shell_proxy.rb +23 -3
  24. data/lib/glimmer/swt/table_proxy.rb +43 -15
  25. data/lib/glimmer/swt/widget_listener_proxy.rb +14 -5
  26. data/lib/glimmer/swt/widget_proxy.rb +7 -3
  27. data/lib/glimmer/ui/custom_shell.rb +11 -9
  28. data/lib/glimmer/ui/custom_widget.rb +32 -17
  29. data/samples/elaborate/meta_sample.rb +81 -24
  30. data/samples/elaborate/tetris.rb +146 -42
  31. data/samples/elaborate/tetris/model/game.rb +259 -137
  32. data/samples/elaborate/tetris/{view/game_over_dialog.rb → model/past_game.rb} +11 -44
  33. data/samples/elaborate/tetris/model/tetromino.rb +45 -29
  34. data/samples/elaborate/tetris/view/block.rb +8 -13
  35. data/samples/elaborate/tetris/view/high_score_dialog.rb +131 -0
  36. data/samples/elaborate/tetris/view/playfield.rb +1 -1
  37. data/samples/elaborate/tetris/view/score_lane.rb +11 -11
  38. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +139 -0
  39. data/samples/elaborate/tic_tac_toe.rb +4 -4
  40. data/samples/hello/hello_canvas.rb +4 -4
  41. data/samples/hello/hello_canvas_animation.rb +3 -3
  42. data/samples/hello/hello_canvas_transform.rb +1 -1
  43. data/samples/hello/hello_code_text.rb +84 -0
  44. data/samples/hello/hello_link.rb +1 -1
  45. metadata +9 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1323fa9209cf80b8c8333bcefb49a4ea682494a63aab2a594d7c7325e5f07833
4
- data.tar.gz: 8d190e9c23540f238d23ffee220da4abd751499a7c8f230a86deb93e11f742d1
3
+ metadata.gz: 9d3b93ed7e1bfaddf902080def3c370528f1f7d199f470e504cab6c60cc78934
4
+ data.tar.gz: 5cd60a864c6b5ba100ba5293632e7eb85411da636ef87338d4f8ef090190b726
5
5
  SHA512:
6
- metadata.gz: d7f842d5fc21e75a1edbf6b07f470ee4b85aa6c462c60f0611143db7fa7ba0c5d2606d70fffd96d5abed5d3cef993b190d9e87bbb731278b7ad466d44c606abb
7
- data.tar.gz: e02f1e221a4473975fcbd5afc57e5fb7ab99fe45905f88d6be6547f8f8434959ba7ab0d44518ef90873182170a5c5867f9fe075bef8bebbc94fa528b7aef939e
6
+ metadata.gz: a53eea373c988e58a5a5e021eeb8ba5e0be74254a53e7a50c7ab1bf716df6db9fc9ce0fed70169d88b3f6ffa54cdb39bd4ba9cdc415ae1f9feeb3980c84c9538
7
+ data.tar.gz: 5965bb2ba7ebda9858228a06dddc74309032f435b13426c9fe4922d646f2698d77f045f4025d04085775e36fc1ea5e3529b77d309776579ef084009ebfbfca1a
@@ -1,5 +1,64 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.3.5
4
+
5
+ - Add `write_on_cancel: true` option for TableProxy#edit_table_item to make cancel behave just like save for special cases where you cannot cancel except the edit mode itself
6
+ - Make code_text custom widget support multiple code languages via `language: 'java'` option
7
+ - Make code_text custom widget support multiple themes via `theme: 'github'` option
8
+ - Hello, Code Text! Sample
9
+ - Fix issue with High Score Dialog in Tetris Sample not sorting by scores correctly (string compare instead of numeric compare) until first game is completed
10
+ - Fix issue with setting date geting rejected in `date_time` for month or day being incompatible with the year/month/day combo
11
+
12
+ ### 4.18.3.4
13
+
14
+ - Support building Image objects with the Glimmer Canvas Shape DSL
15
+ - Tetris build icon image in-game by nesting Glimmer Shape DSL syntax
16
+ - Canvas Make shapes auto-fill if you specify a background only (no need to say fill: true) or not fill if you specify a foreground only
17
+ - Tetris option to switch Up Arrow between Instant Down, Rotate Right, and Rotate Left
18
+
19
+ ### 4.18.3.3
20
+
21
+ - Support Table data binding read_only_sort: true option to allow visual sorting without affecting model data
22
+ - on_quit to
23
+ - Tetris Add lines and level to High Score Dialog
24
+ - Tetris Immediate Drop on Arrow Up
25
+ - Tetris Pause on showing High Score Dialog
26
+ - Tetris Make High Scores -> Show a check menu item
27
+ - Tetris Disable pause button upon showing High Score Dialog
28
+ - Fix Quit Tetris CMD+Q shortcut by adding on_quit event to display
29
+ - Tetris Fix escape button upon entering high score name
30
+ - If WidgetBinding encounters a disposed widget, it deregisters all observables that it is observing
31
+
32
+ ### 4.18.3.2
33
+
34
+ - Tetris High Scores
35
+ - Tetris Modify High Score Player Name
36
+ - Tetris Show High Scores (Menu Item + Accelerator)
37
+ - Tetris add a menu item with beep enablement option
38
+ - Tetris Clear High Scores
39
+ - 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.
40
+ - Fix issues relating to setting parenthood with custom widgets before building their body (instead of after)
41
+ - Fix issues relating to not respecting arity of passed in table editing callbacks: before_write, after_write, and after_cancel
42
+
43
+ ### 4.18.3.1
44
+
45
+ - 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.
46
+ - Have CustomShell::launch method take options to pass to custom shell keyword invocation
47
+ - Update Glimmer Meta-Sample to load entire gem into user directory (since some new samples rely on images)
48
+ - Update Glimmer Meta-Sample to display errors in a `dialog` instead of a `message_box` to allow scrolling
49
+ - Removed newly added CustomShell::shutdown as unnecessary (could just do CustomShell::launchd_custom_shell.close)
50
+ - Supporting deregistering Display listeners just like standard listeners via deregister
51
+ - Enhance performance of excluded keyword check
52
+ - Remove CustomWidget support for multiple before_body/after_body blocks instead of one each since it is not needed.
53
+ - Add new :fill_screen style for `shell` to start app filling the screen size (not full screen mode though)
54
+ - Tetris Menu Bar with Game Menu -> Start, Pause, Restart, and Exit
55
+ - Tetris refactor mutation methods to end with bangs
56
+ - Tetris Stop game if user does not play again in the end (instead of closing it)
57
+ - End Tetris Thread loop gracefully if game over is encountered
58
+ - Tetris use more observers instead of callbacks to Game
59
+ - Turn Tetris::Model::Game class from a singleton class to a standard class supporting instances
60
+ - Fix issue of `tetris` keyword not found when run from meta-sample app
61
+
3
62
  ### 4.18.3.0
4
63
 
5
64
  - Canvas Transform DSL (DSL declared Transform objects are auto-disposed after getting used by their parent shape)
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.3.0
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.5
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) 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/).
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/).
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
 
@@ -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)
@@ -407,6 +408,38 @@ If you see anything that needs to be improved, please do not hesitate to contact
407
408
 
408
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.
409
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.
442
+
410
443
  ## Platform Support
411
444
 
412
445
  Glimmer runs on the following platforms:
@@ -460,7 +493,7 @@ jgem install glimmer-dsl-swt
460
493
 
461
494
  Or this command if you want a specific version:
462
495
  ```
463
- jgem install glimmer-dsl-swt -v 4.18.3.0
496
+ jgem install glimmer-dsl-swt -v 4.18.3.5
464
497
 
465
498
 
466
499
  ```
@@ -480,7 +513,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
480
513
 
481
514
  Add the following to `Gemfile`:
482
515
  ```
483
- gem 'glimmer-dsl-swt', '~> 4.18.3.0
516
+ gem 'glimmer-dsl-swt', '~> 4.18.3.5
484
517
  '
485
518
  ```
486
519
 
@@ -539,7 +572,7 @@ bin/glimmer samples
539
572
  Below are the full usage instructions that come up when running `glimmer` without args.
540
573
 
541
574
  ```
542
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.0
575
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.3.5
543
576
 
544
577
 
545
578
 
@@ -815,7 +848,7 @@ glimmer run
815
848
 
816
849
  #### Custom Shell
817
850
 
818
- 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:
819
852
 
820
853
  ```
821
854
  glimmer scaffold:customshell[name]
@@ -829,7 +862,7 @@ glimmer scaffold:cs[name]
829
862
 
830
863
  #### Custom Widget
831
864
 
832
- 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:
833
866
 
834
867
  ```
835
868
  glimmer scaffold:customwidget[name]
@@ -843,7 +876,7 @@ glimmer scaffold:cw[name]
843
876
 
844
877
  #### Custom Shell Gem
845
878
 
846
- 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).
847
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.
848
881
  Unlike scaffolded Glimmer apps, custom shell gem content lives under the `lib` directory (not `app`).
849
882
  They can be packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
@@ -878,7 +911,7 @@ Examples:
878
911
 
879
912
  #### Custom Widget Gem
880
913
 
881
- 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:
882
915
 
883
916
  ```
884
917
  glimmer scaffold:gem:customwidget[name,namespace]
@@ -904,7 +937,7 @@ Examples:
904
937
 
905
938
  ### Gem Listing
906
939
 
907
- 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).
908
941
 
909
942
  #### Listing Custom Shell Gems
910
943
 
@@ -1020,7 +1053,7 @@ Output:
1020
1053
 
1021
1054
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1022
1055
  Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1023
- Swt glimmer-dsl-swt 4.18.3.0
1056
+ Swt glimmer-dsl-swt 4.18.3.5
1024
1057
 
1025
1058
  AndyMaleh Glimmer DSL for SWT
1026
1059
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
@@ -1098,9 +1131,12 @@ bin/girb
1098
1131
 
1099
1132
  Watch out for hands-on examples in this README indicated by "you may copy/paste in [`girb`](#girb-glimmer-irb-command)"
1100
1133
 
1101
- 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)
1102
1135
 
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).
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).
1104
1140
 
1105
1141
  ## Glimmer GUI DSL Syntax
1106
1142
 
@@ -2321,7 +2357,7 @@ Shape keywords and their args (including defaults) are listed below (they basica
2321
2357
  - `rectangle​(x, y, width, height, vertical = true, fill: true, gradient: true)` gradient rectangle, which is always filled, and takes an optional extra argument to specify true for vertical gradient (default) and false for horizontal gradient
2322
2358
  - `text(string, x, y, flags = nil)` text with optional flags (flag format is `swt(comma_separated_flags)` where flags can be :draw_delimiter (i.e. new lines), :draw_tab, :draw_mnemonic, and :draw_transparent as explained in [GC API](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html))
2323
2359
 
2324
- Shape keywords that can be filled with color can take an keyword argument `fill: true` (defaults to false when not specified)
2360
+ Shape keywords that can be filled with color can take an keyword argument `fill: true`. Defaults to false when not specified unless background is set with no foreground (or foreground is set with no background), in which case a smart default is applied.
2325
2361
 
2326
2362
  Optionally, a shape keyword takes a block that can set any attributes from [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) (methods starting with `set`), which enable setting the `background` for filling and `foreground` for drawing.
2327
2363
 
@@ -2359,10 +2395,10 @@ shell {
2359
2395
 
2360
2396
  canvas {
2361
2397
  background :dark_yellow
2362
- rectangle(0, 0, 220, 400, fill: true) {
2398
+ rectangle(0, 0, 220, 400) {
2363
2399
  background :dark_red
2364
2400
  }
2365
- rectangle(50, 20, 300, 150, 30, 50, round: true, fill: true) {
2401
+ rectangle(50, 20, 300, 150, 30, 50, round: true) {
2366
2402
  background :yellow
2367
2403
  }
2368
2404
  rectangle(150, 200, 100, 70, true, gradient: true) {
@@ -2432,6 +2468,103 @@ In any case, if there is anything missing you would like added to the Glimmer Sh
2432
2468
 
2433
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`.
2434
2470
 
2471
+ #### Shapes inside an Image
2472
+
2473
+ You can build an image using the Canvas Shape DSL (including setting the icon of the application).
2474
+
2475
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2476
+
2477
+ ```
2478
+ include Glimmer
2479
+
2480
+ shell {
2481
+ text 'Image Shape DSL Example'
2482
+ label {
2483
+ bevel_constant = 20
2484
+ icon_block_size = 64
2485
+ icon_bevel_size = icon_block_size.to_f / 25.to_f
2486
+ icon_bevel_pixel_size = 0.16*icon_block_size.to_f
2487
+ icon_size = 8
2488
+ icon_pixel_size = icon_block_size * icon_size
2489
+ image(icon_pixel_size, icon_pixel_size) {
2490
+ icon_size.times { |row|
2491
+ icon_size.times { |column|
2492
+ colored = row >= 1 && column.between?(1, 6)
2493
+ color = colored ? color([:white, :red, :blue, :green, :yellow, :magenta, :cyan, :dark_blue].sample) : color(:white)
2494
+ x = column * icon_block_size
2495
+ y = row * icon_block_size
2496
+ rectangle(x, y, icon_block_size, icon_block_size) {
2497
+ background color
2498
+ }
2499
+ polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2500
+ background rgb(color.red + 4*bevel_constant, color.green + 4*bevel_constant, color.blue + 4*bevel_constant)
2501
+ }
2502
+ polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size) {
2503
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2504
+ }
2505
+ polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size) {
2506
+ background rgb(color.red - 2*bevel_constant, color.green - 2*bevel_constant, color.blue - 2*bevel_constant)
2507
+ }
2508
+ polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2509
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2510
+ }
2511
+ }
2512
+ }
2513
+ }
2514
+ }
2515
+ }.open
2516
+ ```
2517
+
2518
+ ![Image Shape DSL](images/glimmer-example-image-shape-dsl.png)
2519
+
2520
+ Example setting the icon of the application (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2521
+
2522
+ ```
2523
+ include Glimmer
2524
+
2525
+ shell {
2526
+ text 'Image Shape DSL Example'
2527
+ label {
2528
+ text 'Image Shape DSL Example'
2529
+ font height: 30
2530
+ }
2531
+ bevel_constant = 20
2532
+ icon_block_size = 64
2533
+ icon_bevel_size = icon_block_size.to_f / 25.to_f
2534
+ icon_bevel_pixel_size = 0.16*icon_block_size.to_f
2535
+ icon_size = 8
2536
+ icon_pixel_size = icon_block_size * icon_size
2537
+ image(icon_pixel_size, icon_pixel_size) {
2538
+ icon_size.times { |row|
2539
+ icon_size.times { |column|
2540
+ colored = row >= 1 && column.between?(1, 6)
2541
+ color = colored ? color([:white, :red, :blue, :green, :yellow, :magenta, :cyan, :dark_blue].sample) : color(:white)
2542
+ x = column * icon_block_size
2543
+ y = row * icon_block_size
2544
+ rectangle(x, y, icon_block_size, icon_block_size) {
2545
+ background color
2546
+ }
2547
+ polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2548
+ background rgb(color.red + 4*bevel_constant, color.green + 4*bevel_constant, color.blue + 4*bevel_constant)
2549
+ }
2550
+ polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size) {
2551
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2552
+ }
2553
+ polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size) {
2554
+ background rgb(color.red - 2*bevel_constant, color.green - 2*bevel_constant, color.blue - 2*bevel_constant)
2555
+ }
2556
+ polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
2557
+ background rgb(color.red - bevel_constant, color.green - bevel_constant, color.blue - bevel_constant)
2558
+ }
2559
+ }
2560
+ }
2561
+ }
2562
+ }.open
2563
+ ```
2564
+
2565
+ ![Image Shape DSL](images/glimmer-example-image-shape-dsl-app-switcher-icon.png)
2566
+
2567
+
2435
2568
  ### Canvas Transform DSL
2436
2569
 
2437
2570
  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.
@@ -2500,6 +2633,8 @@ When using a transform at the top-level (outside of shell), you get a fluent int
2500
2633
  Example:
2501
2634
 
2502
2635
  ```ruby
2636
+ include Glimmer # make sure it is included in your class/module before using the fluent interface
2637
+
2503
2638
  transform(1, 1, 4, 2, 2, 4).
2504
2639
  multiply(1, 2, 3, 4,3,4).
2505
2640
  scale(1, 2, 3, 4, 5, 6).
@@ -2535,7 +2670,7 @@ shell {
2535
2670
 
2536
2671
  frame { |index|
2537
2672
  background rgb(index%100, index%100 + 100, index%55 + 200)
2538
- rectangle(index, index, 20, 20, fill: true) {
2673
+ rectangle(index, index, 20, 20) {
2539
2674
  background :red
2540
2675
  }
2541
2676
  }
@@ -2987,6 +3122,7 @@ Here is an explanation of the example above:
2987
3122
  - Task Start Date table column has a custom sort comparator block
2988
3123
  - Additional (secondary) sort properties are applied when sorting by Task, Project, or Duration in the order specified
2989
3124
 
3125
+ `bind(model, :property, read_only_sort: true)` could be used with items to make sorting not propagate sorting changes to model.
2990
3126
 
2991
3127
  #### Tree
2992
3128
 
@@ -3494,6 +3630,8 @@ shell { |app_shell|
3494
3630
  }.open
3495
3631
  ```
3496
3632
 
3633
+ 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`)
3634
+
3497
3635
  You may check out [Hello, Custom Shell!](#hello-custom-shell) for another example.
3498
3636
 
3499
3637
  ### Drag and Drop
@@ -3774,6 +3912,41 @@ shell(:no_resize) {
3774
3912
 
3775
3913
  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.
3776
3914
 
3915
+ #### Performance Profiling
3916
+
3917
+ 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:
3918
+
3919
+ `glimmer --profile path_to_glimmer_app.rb`
3920
+
3921
+ Additionally, add this code to monitor Glimmer app performance around its launch method:
3922
+
3923
+ ```ruby
3924
+ require 'jruby/profiler'
3925
+ profile_data = JRuby::Profiler.profile do
3926
+ SomeGlimmerApp.launch
3927
+ end
3928
+
3929
+ profile_printer = JRuby::Profiler::HtmlProfilePrinter.new(profile_data)
3930
+ ps = java.io.PrintStream.new(STDOUT.to_outputstream)
3931
+ ```
3932
+
3933
+ 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.
3934
+
3935
+ Example:
3936
+
3937
+ ```ruby
3938
+ shell {
3939
+ # some code
3940
+ on_swt_show {
3941
+ exit(0)
3942
+ }
3943
+ }
3944
+ ```
3945
+
3946
+ You may run `glimmer` with the `--profile.graph` instead for a more detailed output.
3947
+
3948
+ Learn more at the [JRuby Performance Profile WIKI page](https://github.com/jruby/jruby/wiki/Profiling-JRuby).
3949
+
3777
3950
  #### Checkbox Group Widget
3778
3951
 
3779
3952
  `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.
@@ -3844,6 +4017,225 @@ Glimmer Meta-Sample Code Example:
3844
4017
 
3845
4018
  To use, simply use `code_text` in place of the `text` or `styled_text` widget. If you set its `text` value to Ruby code, it automatically styles it with syntax highlighting.
3846
4019
 
4020
+ ##### Options
4021
+
4022
+ **theme**
4023
+ (default: 'glimmer')
4024
+
4025
+ Changes syntax color highlighting theme. Can be one of the following:
4026
+ - glimmer
4027
+ - github
4028
+ - pastie
4029
+
4030
+ **language**
4031
+ (default: `'ruby'`)
4032
+
4033
+ Sets the code language, which can be one of the following supported rouge gem languages:
4034
+ - abap
4035
+ - actionscript
4036
+ - ada
4037
+ - apache
4038
+ - apex
4039
+ - apiblueprint
4040
+ - apple_script
4041
+ - armasm
4042
+ - augeas
4043
+ - awk
4044
+ - batchfile
4045
+ - bbcbasic
4046
+ - bibtex
4047
+ - biml
4048
+ - bpf
4049
+ - brainfuck
4050
+ - brightscript
4051
+ - bsl
4052
+ - c
4053
+ - ceylon
4054
+ - cfscript
4055
+ - clean
4056
+ - clojure
4057
+ - cmake
4058
+ - cmhg
4059
+ - coffeescript
4060
+ - common_lisp
4061
+ - conf
4062
+ - console
4063
+ - coq
4064
+ - cpp
4065
+ - crystal
4066
+ - csharp
4067
+ - css
4068
+ - csvs
4069
+ - cuda
4070
+ - cypher
4071
+ - cython
4072
+ - d
4073
+ - dart
4074
+ - datastudio
4075
+ - diff
4076
+ - digdag
4077
+ - docker
4078
+ - dot
4079
+ - ecl
4080
+ - eex
4081
+ - eiffel
4082
+ - elixir
4083
+ - elm
4084
+ - email
4085
+ - epp
4086
+ - erb
4087
+ - erlang
4088
+ - escape
4089
+ - factor
4090
+ - fortran
4091
+ - freefem
4092
+ - fsharp
4093
+ - gdscript
4094
+ - ghc_cmm
4095
+ - ghc_core
4096
+ - gherkin
4097
+ - glsl
4098
+ - go
4099
+ - gradle
4100
+ - graphql
4101
+ - groovy
4102
+ - hack
4103
+ - haml
4104
+ - handlebars
4105
+ - haskell
4106
+ - haxe
4107
+ - hcl
4108
+ - hlsl
4109
+ - hocon
4110
+ - hql
4111
+ - html
4112
+ - http
4113
+ - hylang
4114
+ - idlang
4115
+ - igorpro
4116
+ - ini
4117
+ - io
4118
+ - irb
4119
+ - isbl
4120
+ - j
4121
+ - janet
4122
+ - java
4123
+ - javascript
4124
+ - jinja
4125
+ - jsl
4126
+ - json
4127
+ - json_doc
4128
+ - jsonnet
4129
+ - jsp
4130
+ - jsx
4131
+ - julia
4132
+ - kotlin
4133
+ - lasso
4134
+ - liquid
4135
+ - literate_coffeescript
4136
+ - literate_haskell
4137
+ - livescript
4138
+ - llvm
4139
+ - lua
4140
+ - lustre
4141
+ - lutin
4142
+ - m68k
4143
+ - magik
4144
+ - make
4145
+ - markdown
4146
+ - mason
4147
+ - mathematica
4148
+ - matlab
4149
+ - minizinc
4150
+ - moonscript
4151
+ - mosel
4152
+ - msgtrans
4153
+ - mxml
4154
+ - nasm
4155
+ - nesasm
4156
+ - nginx
4157
+ - nim
4158
+ - nix
4159
+ - objective_c
4160
+ - objective_cpp
4161
+ - ocaml
4162
+ - ocl
4163
+ - openedge
4164
+ - opentype_feature_file
4165
+ - pascal
4166
+ - perl
4167
+ - php
4168
+ - plain_text
4169
+ - plist
4170
+ - pony
4171
+ - postscript
4172
+ - powershell
4173
+ - praat
4174
+ - prolog
4175
+ - prometheus
4176
+ - properties
4177
+ - protobuf
4178
+ - puppet
4179
+ - python
4180
+ - q
4181
+ - qml
4182
+ - r
4183
+ - racket
4184
+ - reasonml
4185
+ - rego
4186
+ - rescript
4187
+ - robot_framework
4188
+ - ruby
4189
+ - rust
4190
+ - sas
4191
+ - sass
4192
+ - scala
4193
+ - scheme
4194
+ - scss
4195
+ - sed
4196
+ - shell
4197
+ - sieve
4198
+ - slice
4199
+ - slim
4200
+ - smalltalk
4201
+ - smarty
4202
+ - sml
4203
+ - solidity
4204
+ - sparql
4205
+ - sqf
4206
+ - sql
4207
+ - ssh
4208
+ - supercollider
4209
+ - swift
4210
+ - systemd
4211
+ - tap
4212
+ - tcl
4213
+ - terraform
4214
+ - tex
4215
+ - toml
4216
+ - tsx
4217
+ - ttcn3
4218
+ - tulip
4219
+ - turtle
4220
+ - twig
4221
+ - typescript
4222
+ - vala
4223
+ - varnish
4224
+ - vb
4225
+ - velocity
4226
+ - verilog
4227
+ - vhdl
4228
+ - viml
4229
+ - vue
4230
+ - wollok
4231
+ - xml
4232
+ - xojo
4233
+ - xpath
4234
+ - xquery
4235
+ - yaml
4236
+ - yang
4237
+ - zig
4238
+
3847
4239
  #### Video Widget
3848
4240
 
3849
4241
  [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
@@ -4110,8 +4502,18 @@ end
4110
4502
 
4111
4503
  ### log_excluded_keywords
4112
4504
 
4505
+ (default = false)
4506
+
4113
4507
  This just tells Glimmer whether to log excluded keywords or not (at the debug level). It is off by default.
4114
4508
 
4509
+ ### auto_sync_exec
4510
+
4511
+ (default = false)
4512
+
4513
+ 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.
4514
+
4515
+ 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.
4516
+
4115
4517
  ## Glimmer Style Guide
4116
4518
 
4117
4519
  - Widgets are declared with underscored lowercase versions of their SWT names minus the SWT package name.
@@ -4187,6 +4589,12 @@ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](samples/elabora
4187
4589
 
4188
4590
  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.
4189
4591
 
4592
+ 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):
4593
+
4594
+ ```ruby
4595
+ bin/glimmer samples/hello/hello_canvas_transform.rb
4596
+ ```
4597
+
4190
4598
  ### Hello Samples
4191
4599
 
4192
4600
  For hello-type simple samples, check the following.
@@ -4759,16 +5167,30 @@ Contact Manager - Edit Done
4759
5167
 
4760
5168
  #### Tetris
4761
5169
 
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.
5170
+ 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, canvas shape icon image generation, and keyboard events/shortcuts.
4763
5171
 
4764
5172
  Code:
4765
5173
 
4766
5174
  [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
4767
5175
 
5176
+ ![Tetris Icon](images/glimmer-tetris-icon.png)
5177
+
4768
5178
  ![Tetris](images/glimmer-tetris.png)
4769
5179
 
4770
5180
  ![Tetris Game Over](images/glimmer-tetris-game-over.png)
4771
5181
 
5182
+ ![Tetris Game Over](images/glimmer-tetris-game-over-sorted-by-score.png)
5183
+
5184
+ ![Tetris High Scores](images/glimmer-tetris-high-score-dialog.png)
5185
+
5186
+ ![Tetris Game Menu](images/glimmer-tetris-game-menu.png)
5187
+
5188
+ ![Tetris View Menu](images/glimmer-tetris-view-menu.png)
5189
+
5190
+ ![Tetris Options Menu](images/glimmer-tetris-options-menu.png)
5191
+
5192
+ ![Tetris Help Menu](images/glimmer-tetris-help-menu.png)
5193
+
4772
5194
  ### External Samples
4773
5195
 
4774
5196
  #### Glimmer Calculator