glimmer-dsl-swt 4.18.4.1 → 4.18.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -0
  3. data/README.md +84 -5072
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_COMMAND.md +591 -0
  6. data/docs/reference/GLIMMER_CONFIGURATION.md +183 -0
  7. data/docs/reference/GLIMMER_GIRB.md +30 -0
  8. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +3251 -0
  9. data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +202 -0
  10. data/docs/reference/GLIMMER_SAMPLES.md +676 -0
  11. data/docs/reference/GLIMMER_STYLE_GUIDE.md +14 -0
  12. data/glimmer-dsl-swt.gemspec +16 -7
  13. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +3 -3
  14. data/lib/glimmer/dsl/swt/exec_expression.rb +1 -1
  15. data/lib/glimmer/dsl/swt/observe_expression.rb +8 -5
  16. data/lib/glimmer/dsl/swt/pixel_expression.rb +38 -0
  17. data/lib/glimmer/dsl/swt/timer_exec_expression.rb +35 -0
  18. data/lib/glimmer/dsl/swt/widget_expression.rb +1 -0
  19. data/lib/glimmer/swt/custom/animation.rb +9 -8
  20. data/lib/glimmer/swt/custom/code_text.rb +26 -18
  21. data/lib/glimmer/swt/custom/drawable.rb +21 -5
  22. data/lib/glimmer/swt/custom/shape.rb +42 -37
  23. data/lib/glimmer/swt/display_proxy.rb +11 -10
  24. data/lib/glimmer/swt/properties.rb +35 -10
  25. data/lib/glimmer/swt/shell_proxy.rb +1 -1
  26. data/lib/glimmer/swt/table_proxy.rb +2 -2
  27. data/lib/glimmer/swt/widget_proxy.rb +21 -6
  28. data/lib/glimmer/ui/custom_widget.rb +17 -0
  29. data/samples/elaborate/mandelbrot_fractal.rb +103 -0
  30. data/samples/elaborate/meta_sample.rb +14 -6
  31. data/samples/elaborate/tetris.rb +14 -17
  32. data/samples/elaborate/tetris/model/game.rb +1 -2
  33. data/samples/elaborate/tetris/view/high_score_dialog.rb +0 -7
  34. data/samples/elaborate/tetris/view/playfield.rb +1 -1
  35. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +13 -11
  36. data/samples/hello/hello_canvas_transform.rb +1 -1
  37. data/samples/hello/hello_table.rb +1 -0
  38. metadata +14 -5
  39. data/samples/elaborate/meta_sample/meta_sample_logo.png +0 -0
@@ -0,0 +1,202 @@
1
+ ## Glimmer Packaging and Distribution
2
+
3
+ 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). On Windows, ensure system PATH includes Java bin directory like "C:\Program Files\Java\jdk1.8.0_241\bin" for javapackager command to work during packaging Glimmer applications.
4
+
5
+ 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.
6
+
7
+ Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
8
+
9
+ ```
10
+ glimmer package
11
+ ```
12
+
13
+ It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating all available packaging types on the current platform (e.g. `DMG`, `PKG`, `APP` on the Mac) and displaying a message indicating what pre-requisite setup tools are needed if not installed already (e.g. [Wix Toolset](https://wixtoolset.org/) to generate MSI files on Windows). If you install Wix, make sure it is on the system PATH by adding for example "C:\Program Files (x86)\WiX Toolset v3.11\bin" to the Windows Environment Variables.
14
+
15
+ You may choose to generate a specific type of packaging instead by addionally passing in the `[type]` option. For example, this generates an MSI setup file on Windows:
16
+
17
+ ```
18
+ glimmer package[msi]
19
+ ```
20
+
21
+ - Available Mac packaging types are `dmg`, `pkg`, and `image` (image means a pure Mac `app` without a setup program). Keep in mind that the packages you produce are compatible with the same MacOS you are on or older.
22
+ - Available Windows packaging types are `msi`, `exe`, and `image` (image means a Windows application directory without a setup program). Learn more about Windows packaging are [over here](#windows-application-packaging).
23
+
24
+ Note: if you are using Glimmer manually, to make the `glimmer package` command available, you must add the following line to your application `Rakefile` (automatically done for you if you scaffold an app or gem with `glimmer scaffold[AppName]` or `glimmer scaffold:gem:customshell[GemName]`):
25
+
26
+ ```ruby
27
+ require 'glimmer/rake_task'
28
+ ```
29
+
30
+ The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
31
+ 1. Generate gemspec via [Juwelier](https://rubygems.org/gems/juwelier) (`glimmer package:gemspec`): Having a gemspec is required by the [`jar-dependencies`](https://github.com/mkristian/jar-dependencies) JRuby gem, used by JRuby libraries to declare JAR dependencies.
32
+ 1. Lock JAR versions (`glimmer package:lock_jars`): This locks versions of JAR dependencies leveraged by the `jar-dependencies` JRuby gem, downloading them into the `./vendor` directory so they would get inside the top-level Glimmer app/gem JAR file.
33
+ 1. Generate [Warbler](https://github.com/jruby/warbler) config (`glimmer package:config`): Generates initial Warbler config file (under `./config/warble.rb`) to use for generating JAR file.
34
+ 1. Generate JAR file using [Warbler](https://github.com/jruby/warbler) (`glimmer package:jar`): Enables bundling a Glimmer app into a JAR file under the `./dist` directory
35
+ 1. Generate native executable using [javapackager](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html) (`glimmer package:native`): Enables packaging a JAR file as a DMG/PKG/APP file on Mac, MSI/EXE/APP on Windows, and DEB/RPM/APP on Linux (Glimmer does not officially support Linux with the `glimmer package` command yet, but it generates the JAR file successfully, and you could use `javapackager` manually afterwards if needed).
36
+
37
+ Those steps automatically ensure generating a JAR file under the `./dist` directory using [Warbler](https://github.com/jruby/warbler), which is then used to automatically generate a DMG/MSI file (and other executables) under the `./packages/bundles` directory using `javapackager`.
38
+ The JAR file name will match your application local directory name (e.g. `MathBowling.jar` for `~/code/MathBowling`)
39
+ The DMG file name will match the humanized local directory name + dash + application version (e.g. `Math Bowling-1.0.dmg` for `~/code/MathBowling` with version 1.0 or unspecified)
40
+
41
+ The `glimmer package` command will automatically set "mac.CFBundleIdentifier" to ="org.#{project_name}.application.#{project_name}".
42
+ You may override by configuring as an extra argument for javapackger (e.g. Glimmer::RakeTask::Package.javapackager_extra_args = " -Bmac.CFBundleIdentifier=org.andymaleh.application.MathBowling")
43
+
44
+ ### Packaging Defaults
45
+
46
+ Glimmer employs smart defaults in packaging.
47
+
48
+ The package application name (shows up in top menu bar on the Mac) will be a human form of the app root directory name (e.g. "Math Bowling" for "MathBowling" or "math_bowling" app root directory name). However, application name and version may be specified explicitly via "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
49
+
50
+ Also, the package will only include these directories: app, config, db, lib, script, bin, docs, fonts, images, sounds, videos
51
+
52
+ After running once, you will find a `config/warble.rb` file. It has the JAR packaging configuration. You may adjust included directories in it if needed, and then rerun `glimmer package` and it will pick up your custom configuration. Alternatively, if you'd like to customize the included directories to begin with, don't run `glimmer package` right away. Run this command first:
53
+
54
+ ```
55
+ glimmer package:config
56
+ ```
57
+
58
+ This will generate `config/warble.rb`, which you may configure and then run `glimmer package` afterwards.
59
+
60
+ ### Packaging Configuration
61
+
62
+ - Ensure you have a Ruby script under `bin` directory that launches the application, preferably matching your project directory name (e.g. `bin/math_bowling`) :
63
+ ```ruby
64
+ require_relative '../app/my_application.rb'
65
+ ```
66
+ - Include Icon (Optional): If you'd like to include an icon for your app (.icns format on the Mac), place it under `package/macosx` matching the humanized application local directory name (e.g. 'Math Bowling.icns' [containing space] for MathBowling or math_bowling). You may generate your Mac icon easily using tools like Image2Icon (http://www.img2icnsapp.com/) or manually using the Mac terminal command `iconutil` (iconutil guide: https://applehelpwriter.com/tag/iconutil/)
67
+ - Include DMG Background Icon (Optional): Simply place a .png file under `package/macosx/{HumanAppName}-background.png`
68
+ - Include Version (Optional): Create a `VERSION` file in your application and fill it your app version on one line (e.g. `1.1.0`)
69
+ - Include License (Optional): Create a `LICENSE.txt` file in your application and fill it up with your license (e.g. MIT). It will show up to people when installing your app. Note that, you may optionally also specify license type, but you'd have to do so manually via `-BlicenseType=MIT` shown in an [example below](#javapackager-extra-arguments).
70
+ - Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for javapackager: `Glimmer::RakeTask::Package.javapackager_extra_args = "..."` (Useful to avoid re-entering extra arguments on every run of rake task.). Read about them in [their section below](#javapackager-extra-arguments).
71
+
72
+ ### javapackager Extra Arguments
73
+
74
+ (note: currently `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh)
75
+
76
+ In order to explicitly configure javapackager, Mac package attributes, or sign your Mac app to distribute on the App Store, you can follow more advanced instructions for `javapackager` here:
77
+ - https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
78
+ - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html
79
+ - https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#BCGICFDB
80
+ - https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html
81
+ - https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
82
+
83
+ The Glimmer rake task allows passing extra options to javapackager via:
84
+ - `Glimmer::RakeTask::Package.javapackager_extra_args="..."` in your application Rakefile
85
+ - Environment variable: `JAVAPACKAGER_EXTRA_ARGS`
86
+
87
+ Example (Rakefile):
88
+
89
+ ```ruby
90
+ require 'glimmer/rake_task'
91
+
92
+ Glimmer::RakeTask::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
93
+ ```
94
+
95
+ Note that `mac.category` defaults to "public.app-category.business", but can be overridden with one of the category UTI values mentioned here:
96
+
97
+ https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
98
+
99
+ Example (env var):
100
+
101
+ ```
102
+ JAVAPACKAGER_EXTRA_ARGS='-Bmac.CFBundleName="Math Bowling Game"' glimmer package
103
+ ```
104
+
105
+ That overrides the default application display name.
106
+
107
+ ### Verbose Mode
108
+
109
+ Pass `-v` to javapackager in `Glimmer::RakeTask::Package.javapackager_extra_args` or by running `glimmer package:native[type] -v` to learn more about further available customizations for the installer you are requesting to generate.
110
+
111
+ ### Windows Application Packaging
112
+
113
+ Windows s two options for setup packaging:
114
+ - `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)).
115
+ - `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.
116
+
117
+ If you just want to test out packaging into a native Windows app that is not packaged for Windows setup, just pass `image` to generate a native Windows app only.
118
+
119
+ ### Mac Application Distribution
120
+
121
+ Recent macOS versions (starting with Catalina) have very stringent security requirements requiring all applications to be signed before running (unless the user goes to System Preferences -> Privacy -> General tab and clicks "Open Anyway" after failing to open application the first time they run it). So, to release a desktop application on the Mac, it is recommended to enroll in the [Apple Developer Program](https://developer.apple.com/programs/) to distribute on the [Mac App Store](https://developer.apple.com/distribute/) or otherwise request [app notarization from Apple](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution) to distribute independently.
122
+
123
+ Afterwards, you may add developer-id/signing-key arguments to `javapackager` via `Glimmer::RakeTask::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS` according to this webpage: https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
124
+
125
+ DMG signing key argument:
126
+ ```
127
+ -Bmac.signing-key-developer-id-app="..."
128
+ ```
129
+
130
+ PKG signing key argument:
131
+ ```
132
+ -Bmac.signing-key-developer-id-installer="..."
133
+ ```
134
+
135
+ Mac App Store signing key arguments:
136
+ ```
137
+ -Bmac.signing-key-app="..."
138
+ -Bmac.signing-key-pkg="..."
139
+ ```
140
+
141
+ ### Self Signed Certificate
142
+
143
+ You may still release a signed DMG file without enrolling into the Apple Developer Program with the caveat that users will always fail in opening the app the first time, and have to go to System Preferences -> Privacy -> General tab to "Open Anyway".
144
+
145
+ To do so, you may follow these steps (abbreviated version from https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW2):
146
+ - Open Keychain Access
147
+ - Choose Keychain Access > Certificate Assistant > Create Certificate ...
148
+ - Enter Name (referred to below as "CertificateName")
149
+ - Set 'Certificate Type' to 'Code Signing'
150
+ - Create (if you alternatively override defaults, make sure to enable all capabilities)
151
+ - Add the following option to javapackager: `-Bmac.signing-key-developer-id-app="CertificateName"` via `Glimmer::RakeTask::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS`
152
+
153
+ Example:
154
+
155
+ ```ruby
156
+ Glimmer::RakeTask::Package.javapackager_extra_args = '-Bmac.signing-key-developer-id-app="Andy Maleh"'
157
+ ```
158
+
159
+ Now, when you run `glimmer package`, it builds a self-signed DMG file. When you make available online, and users download, upon launching application, they are presented with your certificate, which they have to sign if they trust you in order to use the application.
160
+
161
+ ### Packaging Gotchas
162
+
163
+ 1. Specifying License File
164
+
165
+ The javapackager documentation states that a license file may be specified with "-BlicenseFile" javapackager option. However, in order for that to work, one must specify as a source file via "-srcfiles" javapackager option.
166
+ Keep that in mind if you are not going to rely on the default `LICENSE.txt` support.
167
+
168
+ Example:
169
+
170
+ ```ruby
171
+ Glimmer::RakeTask::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="ACME.txt" -BlicenseType="ACME"'
172
+ ```
173
+
174
+ 2. Mounted DMG Residue
175
+
176
+ If you run `glimmer package` multiple times, sometimes it leaves a mounted DMG project in your finder. Unmount before you run the command again or it might fail with an error saying: "Error: Bundler "DMG Installer" (dmg) failed to produce a bundle."
177
+
178
+ By the way, keep in mind that during normal operation, it does also indicate a false-negative while completing successfully similar to the following (please ignore):
179
+
180
+ ```
181
+ Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1sw__tx6mjdgyh3mky7vydc0000gp/T/fxbundler4076750801763032201/images/MathBowling/.VolumeIcon.icns] in unspecified directory
182
+ ```
183
+
184
+ 3. Zsh (Z Shell)
185
+
186
+ Currently, `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh.
187
+
188
+ You can get around that in zsh by running glimmer package commands with `bash -c` prefix:
189
+
190
+ ```
191
+ bash -c 'glimmer package'
192
+ ```
193
+
194
+ 4. Java on Windows System PATH
195
+
196
+ If you get any errors running Java on Windows, keep in mind that you need to have the Java binaries on the Windows System PATH environment variable:
197
+ c:\program files\java\jre1.8.0_241
198
+
199
+ The problem is Oracle seems to be adding an indirect Java path junction in later versions of their installer:
200
+ C:\Program Files (x86)\Common Files\Oracle\Java\javapath
201
+
202
+ Simply replace with the simple one above (setting the correct version number) and then reinstall JRuby to have it use Java from the right path.
@@ -0,0 +1,676 @@
1
+ ## Samples
2
+
3
+ Check the [samples](samples) directory in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) for examples on how to write Glimmer applications. To run a sample, make sure to install the `glimmer` gem first and then use the `glimmer samples` command to run it (alternatively, you may clone the repo, follow [CONTRIBUTING.md](CONTRIBUTING.md) instructions, and run samples locally with development glimmer command: `bin/glimmer`).
4
+
5
+ You may run any sample via this command:
6
+
7
+ ```
8
+ glimmer samples
9
+ ```
10
+
11
+ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](samples/elaborate/meta_sample.rb)
12
+
13
+ ![Glimmer Meta-Sample](/images/glimmer-meta-sample.png)
14
+
15
+ 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.
16
+
17
+ 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):
18
+
19
+ ```ruby
20
+ bin/glimmer samples/hello/hello_canvas_transform.rb
21
+ ```
22
+
23
+ ### Hello Samples
24
+
25
+ For hello-type simple samples, check the following.
26
+
27
+ #### Hello, World!
28
+
29
+ Code:
30
+
31
+ [samples/hello/hello_world.rb](samples/hello/hello_world.rb)
32
+
33
+ ![Hello World](/images/glimmer-hello-world.png)
34
+
35
+ #### Hello, Tab!
36
+
37
+ Code:
38
+
39
+ [samples/hello/hello_tab.rb](samples/hello/hello_tab.rb)
40
+
41
+ ![Hello Tab English](/images/glimmer-hello-tab-english.png)
42
+ ![Hello Tab French](/images/glimmer-hello-tab-french.png)
43
+
44
+ #### Hello, Combo!
45
+
46
+ This sample demonstrates combo data-binding.
47
+
48
+ Code:
49
+
50
+ [samples/hello/hello_combo.rb](samples/hello/hello_combo.rb)
51
+
52
+ ![Hello Combo](/images/glimmer-hello-combo.png)
53
+ ![Hello Combo Expanded](/images/glimmer-hello-combo-expanded.png)
54
+
55
+ #### Hello, List Single Selection!
56
+
57
+ This sample demonstrates list single-selection data-binding.
58
+
59
+ Code:
60
+
61
+ [samples/hello/hello_list_single_selection.rb](samples/hello/hello_list_single_selection.rb)
62
+
63
+ ![Hello List Single Selection](/images/glimmer-hello-list-single-selection.png)
64
+
65
+ #### Hello, List Multi Selection!
66
+
67
+ This sample demonstrates list multi-selection data-binding.
68
+
69
+ Code:
70
+
71
+ [samples/hello/hello_list_multi_selection.rb](samples/hello/hello_list_multi_selection.rb)
72
+
73
+ ![Hello List Multi Selection](/images/glimmer-hello-list-multi-selection.png)
74
+
75
+ #### Hello, Computed!
76
+
77
+ This sample demonstrates computed data-binding.
78
+
79
+ Code:
80
+
81
+ [samples/hello/hello_computed.rb](samples/hello/hello_computed.rb)
82
+
83
+ ![Hello Browser](/images/glimmer-hello-computed.png)
84
+
85
+ #### Hello, Message Box!
86
+
87
+ This sample demonstrates a `message_box` dialog.
88
+
89
+ Code:
90
+
91
+ [samples/hello/hello_message_box.rb](samples/hello/hello_message_box.rb)
92
+
93
+ ![Hello Message Box](/images/glimmer-hello-message-box.png)
94
+ ![Hello Message Box Dialog](/images/glimmer-hello-message-box-dialog.png)
95
+
96
+ #### Hello, Browser!
97
+
98
+ This sample demonstrates the `browser` widget.
99
+
100
+ Code:
101
+
102
+ [samples/hello/hello_browser.rb](samples/hello/hello_browser.rb)
103
+
104
+ ![Hello Browser](/images/glimmer-hello-browser.png)
105
+
106
+ #### Hello, Drag and Drop!
107
+
108
+ This sample demonstrates drag and drop in Glimmer.
109
+
110
+ Code:
111
+
112
+ [samples/hello/hello_drag_and_drop.rb](samples/hello/hello_drag_and_drop.rb)
113
+
114
+ ![Hello Drag and Drop](/images/glimmer-hello-drag-and-drop.gif)
115
+
116
+ #### Hello, Menu Bar!
117
+
118
+ This sample demonstrates menus in Glimmer, including accelerators on the Mac.
119
+
120
+ Code:
121
+
122
+ [samples/hello/hello_menu_bar.rb](samples/hello/hello_menu_bar.rb)
123
+
124
+ ![Hello Menu Bar](/images/glimmer-hello-menu-bar.png)
125
+
126
+ ![Hello Menu Bar File Menu](/images/glimmer-hello-menu-bar-file-menu.png)
127
+
128
+ The Mac Menu includes Accelerator Keys (keyboard shortcuts).
129
+
130
+ ![Hello Menu Bar File Menu Mac Accelerators](/images/glimmer-hello-menu-bar-file-menu-mac-accelerators.png)
131
+
132
+ ![Hello Menu Bar Edit Menu](/images/glimmer-hello-menu-bar-edit-menu.png)
133
+
134
+ The Mac Menu includes Accelerator Keys (keyboard shortcuts).
135
+
136
+ ![Hello Menu Bar Edit Menu Mac Accelerators](/images/glimmer-hello-menu-bar-edit-menu-mac-accelerators.png)
137
+
138
+ ![Hello Menu Bar Options Menu Disabled](/images/glimmer-hello-menu-bar-options-menu-disabled.png)
139
+
140
+ ![Hello Menu Bar Options Menu Select One](/images/glimmer-hello-menu-bar-options-menu-select-one.png)
141
+
142
+ ![Hello Menu Bar Options Menu Select Multiple](/images/glimmer-hello-menu-bar-options-menu-select-multiple.png)
143
+
144
+ ![Hello Menu Bar Format Menu Background Color](/images/glimmer-hello-menu-bar-format-menu-background-color.png)
145
+
146
+ ![Hello Menu Bar Format Menu Foreground Color](/images/glimmer-hello-menu-bar-format-menu-foreground-color.png)
147
+
148
+ ![Hello Menu Bar View Menu](/images/glimmer-hello-menu-bar-view-menu.png)
149
+
150
+ ![Hello Menu Bar View Small](/images/glimmer-hello-menu-bar-view-small.png)
151
+
152
+ ![Hello Menu Bar View Large](/images/glimmer-hello-menu-bar-view-large.png)
153
+
154
+ ![Hello Menu Bar Help Menu](/images/glimmer-hello-menu-bar-help-menu.png)
155
+
156
+ The Mac Menu includes Accelerator Keys (keyboard shortcuts) and Mac built-in Search.
157
+
158
+ ![Hello Menu Bar Help Menu Mac Accelerators](/images/glimmer-hello-menu-bar-help-menu-mac-accelerators.png)
159
+
160
+ #### Hello, Pop Up Context Menu!
161
+
162
+ This sample demonstrates pop up context menus in Glimmer.
163
+
164
+ Code:
165
+
166
+ [samples/hello/hello_pop_up_context_menu.rb](samples/hello/hello_pop_up_context_menu.rb)
167
+
168
+ ![Hello Pop Up Context Menu](/images/glimmer-hello-pop-up-context-menu.png)
169
+ ![Hello Pop Up Context Menu Popped Up](/images/glimmer-hello-pop-up-context-menu-popped-up.png)
170
+
171
+ #### Hello, Custom Widget!
172
+
173
+ This sample demonstrates the use of a custom widget in Glimmer.
174
+
175
+ Code:
176
+
177
+ [samples/hello/hello_custom_widget.rb](samples/hello/hello_custom_widget.rb)
178
+
179
+ ![Hello Custom Widget](/images/glimmer-hello-custom-widget.gif)
180
+
181
+ #### Hello, Custom Shell!
182
+
183
+ This sample demonstrates the use of a custom shell (aka custom window) in Glimmer.
184
+
185
+ Code:
186
+
187
+ [samples/hello/hello_custom_shell.rb](samples/hello/hello_custom_shell.rb)
188
+
189
+ ![Hello Custom Shell](/images/glimmer-hello-custom-shell.png)
190
+ ![Hello Custom Shell Email1](/images/glimmer-hello-custom-shell-email1.png)
191
+ ![Hello Custom Shell Email2](/images/glimmer-hello-custom-shell-email2.png)
192
+ ![Hello Custom Shell Email3](/images/glimmer-hello-custom-shell-email3.png)
193
+
194
+ #### Hello, Sash Form!
195
+
196
+ This sample demonstrates the use of a `sash_form` in Glimmer.
197
+
198
+ Code:
199
+
200
+ [samples/hello/hello_sash_form.rb](samples/hello/hello_sash_form.rb)
201
+
202
+ Hello, Sash Form! Horizontal Orientation
203
+
204
+ ![Hello Sash Form](/images/glimmer-hello-sash-form.png)
205
+
206
+ Hello, Sash Form! Resized
207
+
208
+ ![Hello Sash Form Resized](/images/glimmer-hello-sash-form-resized.png)
209
+
210
+ Hello, Sash Form! Sash Width Changed
211
+
212
+ ![Hello Sash Form Sash Width Changed](/images/glimmer-hello-sash-form-sash-width-changed.png)
213
+
214
+ Hello, Sash Form! Vertical Orientation
215
+
216
+ ![Hello Sash Form Vertical](/images/glimmer-hello-sash-form-vertical.png)
217
+
218
+ Hello, Sash Form! Green Label Maximized
219
+
220
+ ![Hello Sash Form Green Maximized](/images/glimmer-hello-sash-form-green-maximized.png)
221
+
222
+ Hello, Sash Form! Red Label Maximized
223
+
224
+ ![Hello Sash Form Red Maximized](/images/glimmer-hello-sash-form-red-maximized.png)
225
+
226
+ #### Hello, Styled Text!
227
+
228
+ This sample demonstrates the use of a `styled_text` in Glimmer.
229
+
230
+ Code:
231
+
232
+ [samples/hello/hello_styled_text.rb](samples/hello/hello_styled_text.rb)
233
+
234
+ Hello, Styled Text!
235
+
236
+ ![Hello Styled Text](/images/glimmer-hello-styled-text.png)
237
+
238
+ #### Hello, Expand Bar!
239
+
240
+ This sample demonstrates the use of a `expand_bar` and `expand_item` in Glimmer.
241
+
242
+ Code:
243
+
244
+ [samples/hello/hello_expand_bar.rb](samples/hello/hello_expand_bar.rb)
245
+
246
+ Hello, Expand Bar! All Expanded
247
+
248
+ ![Hello Expand Bar All Expanded](/images/glimmer-hello-expand-bar-all-expanded.png)
249
+
250
+ Hello, Expand Bar! Productivity Expanded
251
+
252
+ ![Hello Expand Bar Productivity Expanded](/images/glimmer-hello-expand-bar-productivity-expanded.png)
253
+
254
+ Hello, Expand Bar! Tools Expanded
255
+
256
+ ![Hello Expand Bar Tools Expanded](/images/glimmer-hello-expand-bar-tools-expanded.png)
257
+
258
+ Hello, Expand Bar! Reading Expanded
259
+
260
+ ![Hello Expand Bar Reading Expanded](/images/glimmer-hello-expand-bar-reading-expanded.png)
261
+
262
+ #### Hello, Radio!
263
+
264
+ This sample demonstrates the use of a `radio` (aka `button(:radio)`) in Glimmer.
265
+
266
+ Code:
267
+
268
+ [samples/hello/hello_radio.rb](samples/hello/hello_radio.rb)
269
+
270
+ Hello, Radio!
271
+
272
+ ![Hello Radio](/images/glimmer-hello-radio.png)
273
+
274
+ #### Hello, Radio Group!
275
+
276
+ This sample demonstrates the use of a `radio_group` in Glimmer, which provides terser syntax for representing multiple radio buttons by relying on data-binding to automatically spawn the `radio` widgets based on available options on the model.
277
+
278
+ Code:
279
+
280
+ [samples/hello/hello_radio_group.rb](samples/hello/hello_radio_group.rb)
281
+
282
+ Hello, Radio Group!
283
+
284
+ ![Hello Radio Group](/images/glimmer-hello-radio-group.png)
285
+
286
+ #### Hello, Group!
287
+
288
+ This sample demonstrates the use of a `group` in Glimmer (not to be confused with the logical radio group custom widget, this is just an alternative to `composite` that provides a border around content).
289
+
290
+ Code:
291
+
292
+ [samples/hello/hello_group.rb](samples/hello/hello_group.rb)
293
+
294
+ Hello, Group!
295
+
296
+ ![Hello Group](/images/glimmer-hello-group.png)
297
+
298
+ #### Hello, Checkbox!
299
+
300
+ This sample demonstrates the use of a `checkbox` (aka `check` or `button(:check)`) in Glimmer.
301
+
302
+ Code:
303
+
304
+ [samples/hello/hello_checkbox.rb](samples/hello/hello_checkbox.rb)
305
+
306
+ Hello, Checkbox!
307
+
308
+ ![Hello Checkbox](/images/glimmer-hello-checkbox.png)
309
+
310
+ #### Hello, Checkbox Group!
311
+
312
+ This sample demonstrates the use of a `checkbox_group` (aka `check_group`) in Glimmer, which provides terser syntax for representing multiple checkbox buttons (`button(:check)`) by relying on data-binding to automatically spawn the `checkbox` widgets (`button(:check)`) based on available options on the model.
313
+
314
+ Code:
315
+
316
+ [samples/hello/hello_checkbox_group.rb](samples/hello/hello_checkbox_group.rb)
317
+
318
+ Hello, Checkbox Group!
319
+
320
+ ![Hello Checkbox Group](/images/glimmer-hello-checkbox-group.png)
321
+
322
+ #### Hello, Directory Dialog!
323
+
324
+ This sample demonstrates the use of a `directory_dialog` in Glimmer.
325
+
326
+ Code:
327
+
328
+ [samples/hello/hello_directory_dialog.rb](samples/hello/hello_directory_dialog.rb)
329
+
330
+ Hello, Directory Dialog!
331
+
332
+ ![Hello Directory Dialog](/images/glimmer-hello-directory-dialog.png)
333
+
334
+ Hello, Directory Dialog! Browse...
335
+
336
+ ![Hello Directory Dialog](/images/glimmer-hello-directory-dialog-browse.png)
337
+
338
+ Hello, Directory Dialog! Selected Directory
339
+
340
+ ![Hello Directory Dialog](/images/glimmer-hello-directory-dialog-selected-directory.png)
341
+
342
+ #### Hello, File Dialog!
343
+
344
+ This sample demonstrates the use of a `file_dialog` in Glimmer.
345
+
346
+ Code:
347
+
348
+ [samples/hello/hello_file_dialog.rb](samples/hello/hello_file_dialog.rb)
349
+
350
+ Hello, File Dialog!
351
+
352
+ ![Hello File Dialog](/images/glimmer-hello-file-dialog.png)
353
+
354
+ Hello, File Dialog! Browse...
355
+
356
+ ![Hello File Dialog](/images/glimmer-hello-file-dialog-browse.png)
357
+
358
+ Hello, File Dialog! Selected File
359
+
360
+ ![Hello File Dialog](/images/glimmer-hello-file-dialog-selected-file.png)
361
+
362
+ #### Hello, Date Time!
363
+
364
+ This sample demonstrates the use of [date_time](#datetime) widget keywords in Glimmer: `date`, `date_drop_down`, `time`, and `calendar`
365
+
366
+ Code:
367
+
368
+ [samples/hello/hello_date_time.rb](samples/hello/hello_date_time.rb)
369
+
370
+ Hello, Date Time!
371
+
372
+ ![Hello Date Time](/images/glimmer-hello-date-time.png)
373
+
374
+ #### Hello, Spinner!
375
+
376
+ This sample demonstrates the use of `spinner` widget in Glimmer
377
+
378
+ Code:
379
+
380
+ [samples/hello/hello_spinner.rb](samples/hello/hello_spinner.rb)
381
+
382
+ Hello, Spinner!
383
+
384
+ ![Hello Spinner](/images/glimmer-hello-spinner.png)
385
+
386
+ #### Hello, Table!
387
+
388
+ This sample demonstrates the use of [table](#table) widget in Glimmer, including data-binding, multi-type editing, sorting, and filtering.
389
+
390
+ Code:
391
+
392
+ [samples/hello/hello_table.rb](samples/hello/hello_table.rb)
393
+
394
+ Hello, Table!
395
+
396
+ ![Hello Table](/images/glimmer-hello-table.png)
397
+
398
+ Hello, Table! Editing Game Date
399
+
400
+ ![Hello Table](/images/glimmer-hello-table-editing-game-date.png)
401
+
402
+ Hello, Table! Editing Game Time
403
+
404
+ ![Hello Table](/images/glimmer-hello-table-editing-game-time.png)
405
+
406
+ Hello, Table! Editing Home Team
407
+
408
+ ![Hello Table](/images/glimmer-hello-table-editing-home-team.png)
409
+
410
+ Hello, Table! Sorted Game Date Ascending
411
+
412
+ ![Hello Table](/images/glimmer-hello-table-sorted-game-date-ascending.png)
413
+
414
+ Hello, Table! Sorted Game Date Descending
415
+
416
+ ![Hello Table](/images/glimmer-hello-table-sorted-game-date-descending.png)
417
+
418
+ Hello, Table! Playoff Type Combo
419
+
420
+ ![Hello Table](/images/glimmer-hello-table-playoff-type-combo.png)
421
+
422
+ Hello, Table! Playoff Type Changed
423
+
424
+ ![Hello Table](/images/glimmer-hello-table-playoff-type-changed.png)
425
+
426
+ Hello, Table! Game Booked
427
+
428
+ ![Hello Table](/images/glimmer-hello-table-game-booked.png)
429
+
430
+ Hello, Table! Context Menu
431
+
432
+ ![Hello Table](/images/glimmer-hello-table-context-menu.png)
433
+
434
+ #### Hello, Button!
435
+
436
+ This sample demonstrates the use of the `button` widget in Glimmer, including data-binding and click event triggering via `on_widget_selected`.
437
+
438
+ Code:
439
+
440
+ [samples/hello/hello_button.rb](samples/hello/hello_button.rb)
441
+
442
+ Hello, Button!
443
+
444
+ ![Hello Button](/images/glimmer-hello-button.png)
445
+
446
+ Hello, Button! Incremented 7 times!
447
+
448
+ ![Hello Button Incremented](/images/glimmer-hello-button-incremented.png)
449
+
450
+ #### Hello, Link!
451
+
452
+ This sample demonstrates the use of the `link` widget in Glimmer, including identifying which link was clicked and performing an action (displaying help) based on its location.
453
+
454
+ Code:
455
+
456
+ [samples/hello/hello_link.rb](samples/hello/hello_link.rb)
457
+
458
+ Hello, Link!
459
+
460
+ ![Hello Link](/images/glimmer-hello-link.png)
461
+
462
+ Hello, Link! Clicked
463
+
464
+ ![Hello Link Clicked](/images/glimmer-hello-link-clicked.png)
465
+
466
+ #### Hello, Dialog!
467
+
468
+ This sample demonstrates the use of the `dialog` widget in Glimmer, which provides a modal `shell` that blocks shells beneath it until closed. And unlike `message_box`, it can contain arbitrary widgets (not just a message).
469
+
470
+ Code:
471
+
472
+ [samples/hello/hello_dialog.rb](samples/hello/hello_dialog.rb)
473
+
474
+ Hello, Dialog!
475
+
476
+ ![Hello Dialog](/images/glimmer-hello-dialog.png)
477
+
478
+ Hello, Dialog! Open Dialog
479
+
480
+ ![Hello Dialog Open Dialog](/images/glimmer-hello-dialog-open-dialog.png)
481
+
482
+ #### Hello, Code Text!
483
+
484
+ This sample demonstrates the Glimmer Built-In [Code Text Custom Widget](#code-text-custom-widget).
485
+
486
+ Code:
487
+
488
+ [samples/hello/hello_code_text.rb](samples/hello/hello_code_text.rb)
489
+
490
+ Hello, Code Text! Ruby Language / Glimmer Theme / Show Line Numbers (default width of 4)
491
+
492
+ ![Hello Code Text Ruby](/images/glimmer-hello-code-text-ruby.png)
493
+
494
+ Hello, Code Text! JavaScript Language / Pastie Theme / Show Line Numbers (custom width of 2)
495
+
496
+ ![Hello Code Text JavaScript](/images/glimmer-hello-code-text-javascript.png)
497
+
498
+ Hello, Code Text! HTML Language / GitHub Theme / No Line Numbers
499
+
500
+ ![Hello Code Text HTML](/images/glimmer-hello-code-text-html.png)
501
+
502
+ #### Hello, Canvas!
503
+
504
+ This sample demonstrates the use of the `canvas` widget and [Shape DSL](#canvas-shape-dsl) in Glimmer.
505
+
506
+ Code:
507
+
508
+ [samples/hello/hello_canvas.rb](samples/hello/hello_canvas.rb)
509
+
510
+ Hello, Canvas!
511
+
512
+ ![Hello Canvas](/images/glimmer-hello-canvas.png)
513
+
514
+ #### Hello, Canvas Animation!
515
+
516
+ This sample demonstrates the use of the `canvas` widget and [Animation DSL](#canvas-animation-dsl) in Glimmer.
517
+
518
+ Code:
519
+
520
+ [samples/hello/hello_canvas_animation.rb](samples/hello/hello_canvas_animation.rb)
521
+
522
+ Hello, Canvas Animation!
523
+
524
+ ![Hello Canvas Animation](/images/glimmer-hello-canvas-animation.png)
525
+
526
+ Hello, Canvas Animation Another Frame!
527
+
528
+ ![Hello Canvas Animation Frame 2](/images/glimmer-hello-canvas-animation-frame2.png)
529
+
530
+ #### Hello, Canvas Transform!
531
+
532
+ 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).
533
+
534
+ Code:
535
+
536
+ [samples/hello/hello_canvas_transform.rb](samples/hello/hello_canvas_transform.rb)
537
+
538
+ Hello, Canvas Transform!
539
+
540
+ ![Hello Canvas Transform](/images/glimmer-hello-canvas-transform.png)
541
+
542
+
543
+ ### Elaborate Samples
544
+
545
+ For more elaborate samples, check the following:
546
+
547
+ #### User Profile
548
+
549
+ This sample was used in the [DZone Article about Glimmer](https://dzone.com/articles/an-introduction-glimmer), demonstrating Glimmer widgets in general.
550
+
551
+ Please note that the code has changed since that article was written (the GUI DSL has been improved/simplified), so use the code sample mentioned here instead as the correct version.
552
+
553
+ Code:
554
+
555
+ [samples/elaborate/user_profile.rb](samples/elaborate/user_profile.rb)
556
+
557
+ ![User Profile](/images/glimmer-user-profile.png)
558
+
559
+ #### Login
560
+
561
+ This sample demonstrates basic data-binding, password and text fields, and field enablement data-binding.
562
+
563
+ Code:
564
+
565
+ [samples/elaborate/login.rb](samples/elaborate/login.rb)
566
+
567
+ ![Login](/images/glimmer-login.png)
568
+ ![Login Filled In](/images/glimmer-login-filled-in.png)
569
+ ![Login Logged In](/images/glimmer-login-logged-in.png)
570
+
571
+ #### Tic Tac Toe
572
+
573
+ This sample demonstrates a full MVC application, including GUI layout, text and enablement data-binding, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/tic_tac_toe/board_spec.rb)).
574
+
575
+ Code:
576
+
577
+ (Please note that on some Linux instances where the display x-axis is set to double-scale, you need to set the `shell` `minimum_size` to `300, 178` instead of `150, 178`)
578
+
579
+ [samples/elaborate/tic_tac_toe.rb](samples/elaborate/tic_tac_toe.rb)
580
+
581
+ ![Tic Tac Toe](/images/glimmer-tic-tac-toe.png)
582
+ ![Tic Tac Toe In Progress](/images/glimmer-tic-tac-toe-in-progress.png)
583
+ ![Tic Tac Toe Game Over](/images/glimmer-tic-tac-toe-game-over.png)
584
+
585
+ #### Contact Manager
586
+
587
+ This sample demonstrates table data-binding, sorting, filtering, GUI layout, MVP pattern, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/contact_manager/contact_manager_presenter_spec.rb)).
588
+
589
+ Code:
590
+
591
+ [samples/elaborate/contact_manager.rb](samples/elaborate/contact_manager.rb)
592
+
593
+ Contact Manager
594
+
595
+ ![Contact Manager](/images/glimmer-contact-manager.png)
596
+
597
+ Contact Manager - Find
598
+
599
+ ![Contact Manager](/images/glimmer-contact-manager-find.png)
600
+
601
+ Contact Manager - Edit Started
602
+
603
+ ![Contact Manager](/images/glimmer-contact-manager-edit-started.png)
604
+
605
+ Contact Manager - Edit In Progress
606
+
607
+ ![Contact Manager](/images/glimmer-contact-manager-edit-in-progress.png)
608
+
609
+ Contact Manager - Edit Done
610
+
611
+ ![Contact Manager](/images/glimmer-contact-manager-edit-done.png)
612
+
613
+ #### Glimmer Tetris
614
+
615
+ 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.
616
+
617
+ Note that it works optimally on the Mac. It is very new, so it has not been optimized for Windows and Linux yet given their minor differences from the Mac.
618
+
619
+ Code:
620
+
621
+ [samples/elaborate/tetris.rb](samples/elaborate/tetris.rb)
622
+
623
+ ![Tetris Icon](/images/glimmer-tetris-icon.png)
624
+
625
+ ![Tetris](/images/glimmer-tetris.png)
626
+
627
+ ![Tetris Game Over](/images/glimmer-tetris-game-over.png)
628
+
629
+ ![Tetris Game Over](/images/glimmer-tetris-game-over-sorted-by-score.png)
630
+
631
+ ![Tetris High Scores](/images/glimmer-tetris-high-score-dialog.png)
632
+
633
+ ![Tetris Game Menu](/images/glimmer-tetris-game-menu.png)
634
+
635
+ ![Tetris View Menu](/images/glimmer-tetris-view-menu.png)
636
+
637
+ ![Tetris Options Menu](/images/glimmer-tetris-options-menu.png)
638
+
639
+ ![Tetris Help Menu](/images/glimmer-tetris-help-menu.png)
640
+
641
+ ### External Samples
642
+
643
+ #### Glimmer Calculator
644
+
645
+ [<img alt="Glimmer Calculator Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-icon.png" height=40 /> Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) is a basic calculator sample app demonstrating data-binding and TDD (test-driven-development) with Glimmer following the MVP pattern (Model-View-Presenter).
646
+
647
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-calculator)
648
+
649
+ #### Gladiator
650
+
651
+ [<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=40 /> Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
652
+ You may check it out to learn how to build a Glimmer Custom Shell gem.
653
+
654
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-gladiator.png" />](https://github.com/AndyObtiva/glimmer-cs-gladiator)
655
+
656
+ Gladiator is a good demonstration of:
657
+ - MVP Pattern
658
+ - Tree data-binding
659
+ - List data-binding
660
+ - Text selection data-binding
661
+ - Tabs
662
+ - Context menus
663
+ - Custom Shell
664
+ - Custom widget
665
+
666
+ #### Timer
667
+
668
+ [<img alt="Glimmer Timer Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=40 /> Timer](https://github.com/AndyObtiva/glimmer-cs-timer) is a sample app demonstrating data-binding, multi-threading, and JSound (Java Sound) library integration in a desktop application.
669
+
670
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
671
+
672
+ ## License
673
+
674
+ [MIT](LICENSE.txt)
675
+
676
+ Copyright (c) 2007-2021 - Andy Maleh.