glimmer-dsl-swt 4.17.2.1 → 4.17.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -0
- data/README.md +443 -534
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +13 -10
- data/lib/ext/glimmer/config.rb +1 -0
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +1 -0
- data/lib/glimmer/launcher.rb +3 -2
- data/lib/glimmer/rake_task.rb +38 -21
- data/lib/glimmer/rake_task/package.rb +21 -10
- data/lib/glimmer/rake_task/scaffold.rb +146 -42
- data/lib/glimmer/swt/custom/code_text.rb +88 -0
- data/lib/glimmer/swt/image_proxy.rb +34 -11
- data/lib/glimmer/swt/message_box_proxy.rb +1 -1
- data/lib/glimmer/swt/sash_form_proxy.rb +53 -0
- data/lib/glimmer/swt/style_constantizable.rb +2 -1
- data/lib/glimmer/swt/widget_proxy.rb +43 -34
- data/samples/elaborate/contact_manager/contact_repository.rb +3 -99
- data/samples/elaborate/meta_sample.rb +166 -0
- data/samples/hello/hello_combo.rb +10 -6
- data/samples/hello/hello_custom_shell.rb +22 -1
- data/samples/hello/hello_custom_widget.rb +21 -0
- data/samples/hello/hello_sash_form.rb +137 -0
- data/samples/hello/hello_tab.rb +10 -5
- data/samples/hello/hello_world.rb +2 -2
- metadata +15 -12
- data/lib/glimmer/rake_task/sample.rb +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d8d95c12f301621467ded0dd2abb7b1c055ce22594e5a93e744d4bcfe84e1d4
|
4
|
+
data.tar.gz: 7458a6dec1a2700e9005c11eddf7e42c9585b54bb10a18efbd8273a969c2906a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1595178259263a3d6127035a0917f4e350316f4dd7af6cdc8def67cb0e5f39ed63da8ed3b76a978db6a1b95fe88da413640ed96117f69b55d5596b3f8031b42
|
7
|
+
data.tar.gz: e42731662e6757942c3eb7db9ca33e6f45c6990eb37b170dc851c3773a2b7bce8aa9a2a42b52cf961be8937682663104ce6f5298852b263fd0f367025df4dc31
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,55 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.17.4.0
|
4
|
+
|
5
|
+
- Glimmer sample app to launch samples (sample of samples meta-sample)
|
6
|
+
- Syntax Color Highlighting in meta-sample
|
7
|
+
- Make sash_form weights accept splat array elements (not wrapped in [])
|
8
|
+
- Make sash_form weights not get set till the closing of the sash_form (to allow putting it above content instead of below as originally required by SWT)
|
9
|
+
- Replace dependency on tty-markdown gem with dependency on rouge gem instead
|
10
|
+
- Remove rake tasks `sample:list`, `sample:code` and `sample:run`
|
11
|
+
- Add rake task `samples` to point to the new Glimmer Meta-Sample
|
12
|
+
- Have meta-sample load samples from gems
|
13
|
+
|
14
|
+
### 4.17.3.0
|
15
|
+
|
16
|
+
- `glimmer scaffold:desktopify[appname,website]` Mac
|
17
|
+
- `glimmer scaffold:desktopify[appname,website]` Windows
|
18
|
+
- `glimmer scaffold:desktopify[appname,website]` Linux (have scaffolding include the glimmer-cw-browser-chromium gem in scaffolded app on Linux)
|
19
|
+
- Remove the native packaging from Linux scaffolding since it is not officially supported
|
20
|
+
- Add gem packaging as part of scaffolding on Linux
|
21
|
+
- Launch the app at the end of scaffolding in Linux
|
22
|
+
- Provide a `glimmer package:gem` task
|
23
|
+
- Add support for scaffolding "app/scaffolded_app/launch" and "lib/namespace/custom_shell/launch" to enable launching SWT apps in Glimmer DSL for Opal without changing a line of code
|
24
|
+
- Add a binary executable shell in "app" mode (just like "custom shell gem" mode)
|
25
|
+
- Have glimmer packaging check the Java version and give a warning if an unsupported version is used.
|
26
|
+
|
27
|
+
|
28
|
+
### 4.17.2.4
|
29
|
+
|
30
|
+
- New `glimmer run` glimmer command task.
|
31
|
+
- Add built in support for handling jar file paths like that in ImageProxy code processing "uri:classloader" path
|
32
|
+
- Document that gif background_image only works without on_top and no_trim styles in Windows
|
33
|
+
- Give a good error message when Git is not properly setup for Glimmer Scaffolding
|
34
|
+
- Give an error message when attempting to scaffold over an already scaffolded directory
|
35
|
+
- Fix issue on Windows regarding use of the new EXPERIMENTAL Animated gif support in the `composite#background_image` property
|
36
|
+
- Fix SWTProxy.deconstruct method
|
37
|
+
|
38
|
+
|
39
|
+
### 4.17.2.3
|
40
|
+
|
41
|
+
- Maintain image file path upon scaling an ImageProxy
|
42
|
+
- Add a glimmer rake task that wraps the juwelier rake gemspec:generate task
|
43
|
+
- Accept `ImageProxy` as arg for `image` and `background_image` property methods
|
44
|
+
- (EXPERIMENTAL) Animate gif images when set as a `background_image` on a `composite`
|
45
|
+
- Fix issue with table redraw after data-binding changes leaving old removed table items visible (even if user cannot interact with anymore)
|
46
|
+
- Fix issue with running package rake task from `glimmer` command TUI
|
47
|
+
|
48
|
+
### 4.17.2.2
|
49
|
+
|
50
|
+
- Small updates/refactorings in samples
|
51
|
+
- Fix issue with displaying `glimmer` command tasks on Windows
|
52
|
+
|
3
53
|
### 4.17.2.1
|
4
54
|
|
5
55
|
- Add `--bundler=group` option to `glimmer` command
|
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.17.
|
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.17.4.0
|
2
2
|
## JRuby Desktop Development GUI Library
|
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)
|
@@ -10,11 +10,9 @@
|
|
10
10
|
|
11
11
|
(The Original Glimmer Library Since 2007. Beware of Imitators!)
|
12
12
|
|
13
|
-
[**Glimmer**](https://rubygems.org/gems/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://rubygems.org/gems/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces while 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. 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/)
|
13
|
+
[**Glimmer**](https://rubygems.org/gems/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://rubygems.org/gems/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces while 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. 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/).
|
14
14
|
|
15
|
-
[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.
|
16
|
-
|
17
|
-
NOTE: Glimmer is in beta mode. Please make better by providing feedback and [contributing](#contributing) when possible. The more feedback and issues you report the better.
|
15
|
+
[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.
|
18
16
|
|
19
17
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
20
18
|
Featured in<br />JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do)
|
@@ -42,9 +40,10 @@ shell {
|
|
42
40
|
}.open
|
43
41
|
```
|
44
42
|
|
45
|
-
Run:
|
43
|
+
Run via `glimmer samples` or directly:
|
44
|
+
|
46
45
|
```
|
47
|
-
glimmer
|
46
|
+
glimmer samples/hello/hello_world.rb
|
48
47
|
```
|
49
48
|
|
50
49
|
Glimmer app:
|
@@ -87,10 +86,10 @@ Glimmer code (from [samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObt
|
|
87
86
|
# ...
|
88
87
|
```
|
89
88
|
|
90
|
-
Run:
|
89
|
+
Run via `glimmer samples` or directly:
|
91
90
|
|
92
91
|
```
|
93
|
-
glimmer
|
92
|
+
glimmer samples/elaborate/tic_tac_toe.rb
|
94
93
|
```
|
95
94
|
|
96
95
|
Glimmer app:
|
@@ -212,10 +211,10 @@ Glimmer code (from [samples/elaborate/contact_manager.rb](https://github.com/And
|
|
212
211
|
# ...
|
213
212
|
```
|
214
213
|
|
215
|
-
Run:
|
214
|
+
Run via `glimmer samples` or directly:
|
216
215
|
|
217
216
|
```
|
218
|
-
glimmer
|
217
|
+
glimmer samples/elaborate/contact_manager.rb
|
219
218
|
```
|
220
219
|
|
221
220
|
Glimmer App:
|
@@ -239,6 +238,7 @@ Glimmer App:
|
|
239
238
|
- [Hello, World!](#hello-world)
|
240
239
|
- [Tic Tac Toe](#tic-tac-toe)
|
241
240
|
- [Contact Manager](#contact-manager)
|
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
244
|
- [Platform Support](#platform-support)
|
@@ -249,12 +249,10 @@ Glimmer App:
|
|
249
249
|
- [Glimmer Command](#glimmer-command)
|
250
250
|
- [Basic Usage](#basic-usage)
|
251
251
|
- [Advanced Usage](#advanced-usage)
|
252
|
-
- [
|
253
|
-
- [Sample List](#sample-list)
|
254
|
-
- [Sample Run](#sample-run)
|
255
|
-
- [Sample Code](#sample-code)
|
252
|
+
- [Samples](#samples)
|
256
253
|
- [Scaffolding](#scaffolding)
|
257
254
|
- [App](#app)
|
255
|
+
- [Desktopify](#desktopify)
|
258
256
|
- [Custom Shell](#custom-shell)
|
259
257
|
- [Custom Widget](#custom-widget)
|
260
258
|
- [Custom Shell Gem](#custom-shell-gem)
|
@@ -270,9 +268,10 @@ Glimmer App:
|
|
270
268
|
- [Glimmer GUI DSL Syntax](#glimmer-gui-dsl-syntax)
|
271
269
|
- [DSL Auto-Expansion](#dsl-auto-expansion)
|
272
270
|
- [Widgets](#widgets)
|
273
|
-
- [Display](#display)
|
274
271
|
- [SWT Proxies](#swt-proxies)
|
275
272
|
- [Dialog](#dialog)
|
273
|
+
- [Display](#display)
|
274
|
+
- [Multi-Threading](#multi-threading)
|
276
275
|
- [Menus](#menus)
|
277
276
|
- [ScrolledComposite](#scrolledcomposite)
|
278
277
|
- [Widget Styles](#widget-styles)
|
@@ -282,6 +281,7 @@ Glimmer App:
|
|
282
281
|
- [Widget Properties](#widget-properties)
|
283
282
|
- [Color](#color)
|
284
283
|
- [Font](#font)
|
284
|
+
- [Image](#image)
|
285
285
|
- [Cursor](#cursor)
|
286
286
|
- [Layouts](#layouts)
|
287
287
|
- [Layout Data](#layout-data)
|
@@ -296,10 +296,10 @@ Glimmer App:
|
|
296
296
|
- [Observing Models](#observing-models)
|
297
297
|
- [Custom Widgets](#custom-widgets)
|
298
298
|
- [Simple Example](#simple-example)
|
299
|
-
- [Lifecycle
|
299
|
+
- [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
|
300
|
+
- [Lifecycle Hooks Example](#lifecycle-hooks-example)
|
300
301
|
- [Custom Widget API](#custom-widget-api)
|
301
302
|
- [Content/Options Example](#contentoptions-example)
|
302
|
-
- [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
|
303
303
|
- [Gotcha](#gotcha)
|
304
304
|
- [Final Notes](#final-notes)
|
305
305
|
- [Custom Shells](#custom-shells)
|
@@ -308,7 +308,9 @@ Glimmer App:
|
|
308
308
|
- [Multi-DSL Support](#multi-dsl-support)
|
309
309
|
- [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
|
310
310
|
- [App Name and Version](#app-name-and-version)
|
311
|
+
- [Code Text Widget](#code-text-widget)
|
311
312
|
- [Video Widget](#video-widget)
|
313
|
+
- [Sash Form Widget](#sash-form-widget)
|
312
314
|
- [Browser Widget](#browser-widget)
|
313
315
|
- [Glimmer Configuration](#glimmer-configuration)
|
314
316
|
- [logger](#logger)
|
@@ -337,6 +339,7 @@ Glimmer App:
|
|
337
339
|
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
338
340
|
- [Hello, Custom Widget!](#hello-custom-widget)
|
339
341
|
- [Hello, Custom Shell!](#hello-custom-shell)
|
342
|
+
- [Hello, Sash Form!](#hello-sash-form)
|
340
343
|
- [Elaborate Samples](#elaborate-samples)
|
341
344
|
- [User Profile](#user-profile)
|
342
345
|
- [Login](#login)
|
@@ -372,7 +375,7 @@ Glimmer App:
|
|
372
375
|
- [Contributors](#contributors)
|
373
376
|
- [Hire Me](#hire-me)
|
374
377
|
- [License](#license)
|
375
|
-
|
378
|
+
|
376
379
|
## Background
|
377
380
|
|
378
381
|
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.
|
@@ -430,7 +433,7 @@ jgem install glimmer-dsl-swt
|
|
430
433
|
|
431
434
|
Or this command if you want a specific version:
|
432
435
|
```
|
433
|
-
jgem install glimmer-dsl-swt -v 4.17.
|
436
|
+
jgem install glimmer-dsl-swt -v 4.17.4.0
|
434
437
|
```
|
435
438
|
|
436
439
|
Note: Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
|
@@ -441,7 +444,7 @@ Otherwise, you may also run `jruby -S gem install ...`
|
|
441
444
|
|
442
445
|
If you are new to Glimmer and would like to continue learning the basics, you may continue to the [Glimmer Command](https://github.com/AndyObtiva/glimmer#glimmer-command) section.
|
443
446
|
|
444
|
-
Otherwise, if you are ready to build a Glimmer app
|
447
|
+
Otherwise, if you are ready to build a Glimmer app, you can jump to the [Glimmer Scaffolding](https://github.com/AndyObtiva/glimmer#scaffolding) section next.
|
445
448
|
|
446
449
|
Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
|
447
450
|
|
@@ -489,17 +492,18 @@ glimmer application.rb
|
|
489
492
|
Runs a Glimmer application using JRuby, automatically preloading
|
490
493
|
the glimmer ruby gem and SWT jar dependency.
|
491
494
|
|
492
|
-
|
495
|
+
Run Glimmer samples with:
|
496
|
+
|
493
497
|
```
|
494
|
-
glimmer
|
498
|
+
glimmer samples
|
495
499
|
```
|
496
|
-
This
|
500
|
+
This brings up the [Glimmer Meta-Sample (The Sample of Samples)](#samples)
|
497
501
|
|
498
|
-
If you cloned this project locally
|
502
|
+
If you cloned this project locally instead of installing the gem, run `bin/glimmer` instead.
|
499
503
|
|
500
504
|
Example:
|
501
505
|
```
|
502
|
-
bin/glimmer
|
506
|
+
bin/glimmer samples
|
503
507
|
```
|
504
508
|
|
505
509
|
### Advanced Usage
|
@@ -507,7 +511,7 @@ bin/glimmer sample:run[hello_world]
|
|
507
511
|
Below are the full usage instructions that come up when running `glimmer` without args.
|
508
512
|
|
509
513
|
```
|
510
|
-
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.
|
514
|
+
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.4.0
|
511
515
|
|
512
516
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
513
517
|
|
@@ -536,12 +540,12 @@ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and
|
|
536
540
|
glimmer package[type] # Package app for distribution (generating config, jar, and native files) (type is optional)
|
537
541
|
glimmer package:clean # Clean by removing "dist" and "packages" directories
|
538
542
|
glimmer package:config # Generate JAR config file
|
543
|
+
glimmer package:gemspec # Generate gemspec
|
539
544
|
glimmer package:jar # Generate JAR file
|
540
545
|
glimmer package:lock_jars # Lock JARs
|
541
546
|
glimmer package:native[type] # Generate Native files
|
542
|
-
glimmer
|
543
|
-
glimmer
|
544
|
-
glimmer sample:run[name] # Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples
|
547
|
+
glimmer run[app_path] # Runs Glimmer app or custom shell gem in the current directory, unless app_path is specified, then runs it instead (app_path is optional)
|
548
|
+
glimmer samples # Brings up the Glimmer Meta-Sample app to allow browsing, running, and viewing code of Glimmer samples
|
545
549
|
glimmer scaffold[app_name] # Scaffold Glimmer application directory structure to build a new app
|
546
550
|
glimmer scaffold:customshell[name,namespace] # Scaffold Glimmer::UI::CustomShell subclass (full window view) under app/views (namespace is optional) [alt: scaffold:cs]
|
547
551
|
glimmer scaffold:customwidget[name,namespace] # Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cw]
|
@@ -563,338 +567,22 @@ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
|
|
563
567
|
|
564
568
|
Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
|
565
569
|
|
566
|
-
###
|
567
|
-
|
568
|
-
#### Sample List
|
570
|
+
### Glimmer Samples
|
569
571
|
|
570
572
|
You can list available Glimmer samples by running:
|
571
573
|
|
572
574
|
```
|
573
|
-
glimmer
|
574
|
-
```
|
575
|
-
|
576
|
-
This should output the following (providing the name of each sample, description, and command to run the sample and view its code):
|
577
|
-
|
575
|
+
glimmer samples
|
578
576
|
```
|
579
|
-
$ glimmer sample:list
|
580
|
-
|
581
|
-
Glimmer Hello Samples:
|
582
|
-
|
583
|
-
Name Description Run
|
584
|
-
|
585
|
-
hello_browser Hello Browser glimmer sample:run[hello_browser]
|
586
|
-
hello_combo Hello Combo glimmer sample:run[hello_combo]
|
587
|
-
hello_computed Hello Computed glimmer sample:run[hello_computed]
|
588
|
-
hello_drag_and_drop Hello Drag And Drop glimmer sample:run[hello_drag_and_drop]
|
589
|
-
hello_list_multi_selection Hello List Multi Selection glimmer sample:run[hello_list_multi_selection]
|
590
|
-
hello_list_single_selection Hello List Single Selection glimmer sample:run[hello_list_single_selection]
|
591
|
-
hello_menu_bar Hello Menu Bar glimmer sample:run[hello_menu_bar]
|
592
|
-
hello_message_box Hello Message Box glimmer sample:run[hello_message_box]
|
593
|
-
hello_pop_up_context_menu Hello Pop Up Context Menu glimmer sample:run[hello_pop_up_context_menu]
|
594
|
-
hello_tab Hello Tab glimmer sample:run[hello_tab]
|
595
|
-
hello_world Hello World glimmer sample:run[hello_world]
|
596
|
-
|
597
|
-
|
598
|
-
Glimmer Elaborate Samples:
|
599
|
-
|
600
|
-
Name Description Run
|
601
|
-
|
602
|
-
contact_manager Contact Manager glimmer sample:run[contact_manager]
|
603
|
-
login Login glimmer sample:run[login]
|
604
|
-
tic_tac_toe Tic Tac Toe glimmer sample:run[tic_tac_toe]
|
605
|
-
user_profile User Profile glimmer sample:run[user_profile]
|
606
|
-
```
|
607
|
-
|
608
|
-
#### Sample Run
|
609
|
-
|
610
|
-
A sample may be run via `glimmer sample:run[name]`. This also outputs the sample code so that you could take a look at it and compare to the GUI that launches.
|
611
|
-
|
612
|
-
If the sample name is left empty (e.g. `glimmer sample:run`), then all samples are run.
|
613
|
-
|
614
|
-
Example:
|
615
|
-
|
616
|
-
```
|
617
|
-
glimmer sample:run[hello_tab]
|
618
|
-
```
|
619
|
-
|
620
|
-
This will run the hello_tab sample and output its code:
|
621
|
-
|
622
|
-
```
|
623
|
-
$ glimmer sample:run[hello_tab]
|
624
|
-
|
625
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/hello/hello_tab.rb
|
626
|
-
|
627
|
-
class HelloTab
|
628
|
-
include Glimmer
|
629
|
-
def launch
|
630
|
-
shell {
|
631
|
-
text "Hello, Tab!"
|
632
|
-
tab_folder {
|
633
|
-
tab_item {
|
634
|
-
text "English"
|
635
|
-
label {
|
636
|
-
text "Hello, World!"
|
637
|
-
}
|
638
|
-
}
|
639
|
-
tab_item {
|
640
|
-
text "French"
|
641
|
-
label {
|
642
|
-
text "Bonjour, Univers!"
|
643
|
-
}
|
644
|
-
}
|
645
|
-
}
|
646
|
-
}.open
|
647
|
-
end
|
648
|
-
end
|
649
|
-
|
650
|
-
HelloTab.new.launch
|
651
|
-
|
652
|
-
# # #
|
653
|
-
```
|
654
|
-
|
655
|
-
![Hello Tab English](images/glimmer-hello-tab-english.png)
|
656
|
-
|
657
|
-
#### Sample Code
|
658
|
-
|
659
|
-
You may output any sample code via this command: `glimmer sample:code[name]`
|
660
|
-
|
661
|
-
This is very similar to the sample run command, except the name is required.
|
662
|
-
|
663
|
-
It will not only output the main sample file, but any required supporting files as well.
|
664
|
-
|
665
|
-
Example:
|
666
|
-
|
667
|
-
```
|
668
|
-
$ glimmer sample:code[tic_tac_toe]
|
669
|
-
|
670
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe.rb
|
671
|
-
|
672
|
-
require_relative "tic_tac_toe/board"
|
673
|
-
|
674
|
-
class TicTacToe
|
675
|
-
include Glimmer
|
676
|
-
|
677
|
-
def initialize
|
678
|
-
@tic_tac_toe_board = Board.new
|
679
|
-
@shell = shell {
|
680
|
-
text "Tic-Tac-Toe"
|
681
|
-
minimum_size 150, 178
|
682
|
-
composite {
|
683
|
-
grid_layout 3, true
|
684
|
-
(1..3).each { |row|
|
685
|
-
(1..3).each { |column|
|
686
|
-
button {
|
687
|
-
layout_data :fill, :fill, true, true
|
688
|
-
text bind(@tic_tac_toe_board[row, column], :sign)
|
689
|
-
enabled bind(@tic_tac_toe_board[row, column], :empty)
|
690
|
-
font style: :bold, height: 20
|
691
|
-
on_widget_selected {
|
692
|
-
@tic_tac_toe_board.mark(row, column)
|
693
|
-
}
|
694
|
-
}
|
695
|
-
}
|
696
|
-
}
|
697
|
-
}
|
698
|
-
}
|
699
|
-
observe(@tic_tac_toe_board, :game_status) { |game_status|
|
700
|
-
display_win_message if game_status == Board::WIN
|
701
|
-
display_draw_message if game_status == Board::DRAW
|
702
|
-
}
|
703
|
-
end
|
704
|
-
|
705
|
-
def display_win_message
|
706
|
-
display_game_over_message("Player #{@tic_tac_toe_board.winning_sign} has won!")
|
707
|
-
end
|
708
|
-
|
709
|
-
def display_draw_message
|
710
|
-
display_game_over_message("Draw!")
|
711
|
-
end
|
712
|
-
|
713
|
-
def display_game_over_message(message_text)
|
714
|
-
message_box(@shell) {
|
715
|
-
text 'Game Over'
|
716
|
-
message message_text
|
717
|
-
}.open
|
718
|
-
@tic_tac_toe_board.reset
|
719
|
-
end
|
720
|
-
|
721
|
-
def open
|
722
|
-
@shell.open
|
723
|
-
end
|
724
|
-
end
|
725
|
-
|
726
|
-
TicTacToe.new.open
|
727
|
-
|
728
|
-
# # #
|
729
|
-
|
730
|
-
|
731
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe/cell.rb
|
732
|
-
|
733
|
-
class TicTacToe
|
734
|
-
class Cell
|
735
|
-
EMPTY = ""
|
736
|
-
attr_accessor :sign, :empty
|
737
|
-
|
738
|
-
def initialize
|
739
|
-
reset
|
740
|
-
end
|
741
|
-
|
742
|
-
def mark(sign)
|
743
|
-
self.sign = sign
|
744
|
-
end
|
745
|
-
|
746
|
-
def reset
|
747
|
-
self.sign = EMPTY
|
748
|
-
end
|
749
|
-
|
750
|
-
def sign=(sign_symbol)
|
751
|
-
@sign = sign_symbol
|
752
|
-
self.empty = sign == EMPTY
|
753
|
-
end
|
754
|
-
|
755
|
-
def marked
|
756
|
-
!empty
|
757
|
-
end
|
758
|
-
end
|
759
|
-
end
|
760
577
|
|
761
|
-
|
578
|
+
This brings up the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
|
762
579
|
|
763
|
-
|
764
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe/board.rb
|
765
|
-
|
766
|
-
require_relative 'cell'
|
767
|
-
|
768
|
-
class TicTacToe
|
769
|
-
class Board
|
770
|
-
DRAW = :draw
|
771
|
-
IN_PROGRESS = :in_progress
|
772
|
-
WIN = :win
|
773
|
-
attr :winning_sign
|
774
|
-
attr_accessor :game_status
|
775
|
-
|
776
|
-
def initialize
|
777
|
-
@sign_state_machine = {nil => "X", "X" => "O", "O" => "X"}
|
778
|
-
build_grid
|
779
|
-
@winning_sign = Cell::EMPTY
|
780
|
-
@game_status = IN_PROGRESS
|
781
|
-
end
|
782
|
-
|
783
|
-
#row and column numbers are 1-based
|
784
|
-
def mark(row, column)
|
785
|
-
self[row, column].mark(current_sign)
|
786
|
-
game_over? #updates winning sign
|
787
|
-
end
|
788
|
-
|
789
|
-
def current_sign
|
790
|
-
@current_sign = @sign_state_machine[@current_sign]
|
791
|
-
end
|
792
|
-
|
793
|
-
def [](row, column)
|
794
|
-
@grid[row-1][column-1]
|
795
|
-
end
|
796
|
-
|
797
|
-
def game_over?
|
798
|
-
win? or draw?
|
799
|
-
end
|
800
|
-
|
801
|
-
def win?
|
802
|
-
win = (row_win? or column_win? or diagonal_win?)
|
803
|
-
self.game_status=WIN if win
|
804
|
-
win
|
805
|
-
end
|
806
|
-
|
807
|
-
def reset
|
808
|
-
(1..3).each do |row|
|
809
|
-
(1..3).each do |column|
|
810
|
-
self[row, column].reset
|
811
|
-
end
|
812
|
-
end
|
813
|
-
@winning_sign = Cell::EMPTY
|
814
|
-
@current_sign = nil
|
815
|
-
self.game_status=IN_PROGRESS
|
816
|
-
end
|
817
|
-
|
818
|
-
private
|
819
|
-
|
820
|
-
def build_grid
|
821
|
-
@grid = []
|
822
|
-
3.times do |row_index| #0-based
|
823
|
-
@grid << []
|
824
|
-
3.times { @grid[row_index] << Cell.new }
|
825
|
-
end
|
826
|
-
end
|
827
|
-
|
828
|
-
def row_win?
|
829
|
-
(1..3).each do |row|
|
830
|
-
if row_has_same_sign(row)
|
831
|
-
@winning_sign = self[row, 1].sign
|
832
|
-
return true
|
833
|
-
end
|
834
|
-
end
|
835
|
-
false
|
836
|
-
end
|
837
|
-
|
838
|
-
def column_win?
|
839
|
-
(1..3).each do |column|
|
840
|
-
if column_has_same_sign(column)
|
841
|
-
@winning_sign = self[1, column].sign
|
842
|
-
return true
|
843
|
-
end
|
844
|
-
end
|
845
|
-
false
|
846
|
-
end
|
847
|
-
|
848
|
-
#needs refactoring if we ever decide to make the board size dynamic
|
849
|
-
def diagonal_win?
|
850
|
-
if (self[1, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[3, 3].sign) and self[1, 1].marked
|
851
|
-
@winning_sign = self[1, 1].sign
|
852
|
-
return true
|
853
|
-
end
|
854
|
-
if (self[3, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[1, 3].sign) and self[3, 1].marked
|
855
|
-
@winning_sign = self[3, 1].sign
|
856
|
-
return true
|
857
|
-
end
|
858
|
-
false
|
859
|
-
end
|
860
|
-
|
861
|
-
def draw?
|
862
|
-
@board_full = true
|
863
|
-
3.times do |x|
|
864
|
-
3.times do |y|
|
865
|
-
@board_full = false if self[x, y].empty
|
866
|
-
end
|
867
|
-
end
|
868
|
-
self.game_status = DRAW if @board_full
|
869
|
-
@board_full
|
870
|
-
end
|
871
|
-
|
872
|
-
def row_has_same_sign(number)
|
873
|
-
row_sign = self[number, 1].sign
|
874
|
-
[2, 3].each do |column|
|
875
|
-
return false unless row_sign == (self[number, column].sign)
|
876
|
-
end
|
877
|
-
true if self[number, 1].marked
|
878
|
-
end
|
879
|
-
|
880
|
-
def column_has_same_sign(number)
|
881
|
-
column_sign = self[1, number].sign
|
882
|
-
[2, 3].each do |row|
|
883
|
-
return false unless column_sign == (self[row, number].sign)
|
884
|
-
end
|
885
|
-
true if self[1, number].marked
|
886
|
-
end
|
887
|
-
|
888
|
-
end
|
889
|
-
end
|
890
|
-
|
891
|
-
# # #
|
892
|
-
```
|
580
|
+
![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
|
893
581
|
|
894
582
|
### Scaffolding
|
895
583
|
|
896
584
|
Glimmer borrows from Rails the idea of Scaffolding, that is generating a structure for your app files that
|
897
|
-
helps you get started just like true
|
585
|
+
helps you get started just like true building scaffolding helps construction workers, civil engineers, and architects.
|
898
586
|
|
899
587
|
Glimmer scaffolding goes beyond just scaffolding the app files that Rails does. It also packages it and launches it,
|
900
588
|
getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
|
@@ -910,7 +598,7 @@ letting Glimmer scaffolding take care of initial app file structure concerns, su
|
|
910
598
|
- Icon (under `package/{platform}/{App Name}.{icon_extension}` for `macosx` .icns, `windows` .ico, and `linux` .png)
|
911
599
|
- Bin file for starting application (`bin/{app_name}.rb`)
|
912
600
|
|
913
|
-
|
601
|
+
You need to have your Git `user.name` and `github.user` configured before scaffolding since Glimmer uses Juwelier, which relies on them in creating a Git repo for your Glimmer app.
|
914
602
|
|
915
603
|
#### App
|
916
604
|
|
@@ -922,7 +610,7 @@ To scaffold a Glimmer app from scratch, run the following command:
|
|
922
610
|
glimmer scaffold[AppName]
|
923
611
|
```
|
924
612
|
|
925
|
-
This will generate an advanced "Hello, World!" app, package it as a Mac
|
613
|
+
This will generate an advanced "Hello, World!" app, package it as a Mac DMG/PKG/APP, Windows APP, or Linux GEM, and launch it all in one fell swoop.
|
926
614
|
|
927
615
|
Suppose you run:
|
928
616
|
|
@@ -946,7 +634,7 @@ $ glimmer scaffold[greeter]
|
|
946
634
|
create spec/spec_helper.rb
|
947
635
|
create spec/greeter_spec.rb
|
948
636
|
create .rspec
|
949
|
-
|
637
|
+
Juwelier has prepared your gem in ./greeter
|
950
638
|
Created greeter/.gitignore
|
951
639
|
Created greeter/.ruby-version
|
952
640
|
Created greeter/.ruby-gemset
|
@@ -980,12 +668,119 @@ And, here is the Windows version of the boilerplate Preferences dialog.
|
|
980
668
|
|
981
669
|
![Glimmer Scaffold App Windows Preferences](images/glimmer-scaffolding-app-windows-preferences.png)
|
982
670
|
|
983
|
-
In order to run the app after making changes, you must run the `glimmer
|
671
|
+
In order to run the app after making changes, you must run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.
|
672
|
+
|
673
|
+
```
|
674
|
+
glimmer run
|
675
|
+
```
|
676
|
+
|
677
|
+
Alternatively, to mantually run the app, you may type:
|
678
|
+
|
679
|
+
```
|
680
|
+
glimmer run[bin/greeter]
|
681
|
+
```
|
682
|
+
|
683
|
+
or:
|
984
684
|
|
985
685
|
```
|
986
686
|
glimmer bin/greeter
|
987
687
|
```
|
988
688
|
|
689
|
+
#### Desktopify
|
690
|
+
|
691
|
+
This scaffolding mode enables you to desktopify a web app. Glimmer Scaffolding basically wraps the website with a [Browser Widget](#browser-widget).
|
692
|
+
|
693
|
+
The desktopify app is similar to the standard scaffolded app. It can be extended and the [browser may even be instrumented](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/browser/Browser.html).
|
694
|
+
|
695
|
+
The app even remembers your cookies if you log into the website, close the app, and reopen again.
|
696
|
+
|
697
|
+
Note that on Linux, the default SWT browser, which runs on webkit, does not support HTML5 Video out of the box. If you need video support, open `Gemfile` after scaffolding and enable the line that has the `glimmer-cw-browser-chromium` gem then replace the `browser` in "app/views/snowboard_utah/app_view.rb" with `browser(:chromium)`
|
698
|
+
|
699
|
+
Before you start, make sure you are in a JRuby environment with Glimmer gem installed as per "Direct Install" pre-requisites.
|
700
|
+
|
701
|
+
To scaffold a Glimmer desktopify app from scratch, run the following command:
|
702
|
+
|
703
|
+
```
|
704
|
+
glimmer scaffold:desktopify[app_name,website]
|
705
|
+
```
|
706
|
+
|
707
|
+
This will generate a Glimmer app, package it as a Mac DMG/PKG/APP, Windows APP, or Linux GEM, and launch it all in one fell swoop.
|
708
|
+
|
709
|
+
Suppose you run:
|
710
|
+
|
711
|
+
```
|
712
|
+
glimmer scaffold:desktopify[snowboard_utah,https://www.brightonresort.com]
|
713
|
+
```
|
714
|
+
|
715
|
+
You should see output like the following:
|
716
|
+
|
717
|
+
```
|
718
|
+
$ glimmer scaffold:desktopify[snowboard_utah,https://www.brightonresort.com]
|
719
|
+
Fetching kamelcase-0.0.2.gem
|
720
|
+
Fetching github_api-0.19.0.gem
|
721
|
+
Fetching highline-2.0.3.gem
|
722
|
+
Fetching juwelier-2.4.9.gem
|
723
|
+
Fetching hashie-3.6.0.gem
|
724
|
+
Fetching nokogiri-1.10.10-java.gem
|
725
|
+
Fetching semver2-3.4.2.gem
|
726
|
+
Successfully installed semver2-3.4.2
|
727
|
+
Successfully installed kamelcase-0.0.2
|
728
|
+
Successfully installed highline-2.0.3
|
729
|
+
Successfully installed hashie-3.6.0
|
730
|
+
Successfully installed github_api-0.19.0
|
731
|
+
Successfully installed nokogiri-1.10.10-java
|
732
|
+
Successfully installed juwelier-2.4.9
|
733
|
+
7 gems installed
|
734
|
+
create .gitignore
|
735
|
+
create Rakefile
|
736
|
+
create Gemfile
|
737
|
+
create LICENSE.txt
|
738
|
+
create README.markdown
|
739
|
+
create .document
|
740
|
+
create lib
|
741
|
+
create lib/snowboard_utah.rb
|
742
|
+
create .rspec
|
743
|
+
Juwelier has prepared your gem in ./snowboard_utah
|
744
|
+
Created snowboard_utah/.gitignore
|
745
|
+
Created snowboard_utah/.ruby-version
|
746
|
+
Created snowboard_utah/.ruby-gemset
|
747
|
+
Created snowboard_utah/VERSION
|
748
|
+
Created snowboard_utah/LICENSE.txt
|
749
|
+
Created snowboard_utah/Gemfile
|
750
|
+
Created snowboard_utah/Rakefile
|
751
|
+
Created snowboard_utah/app/snowboard_utah.rb
|
752
|
+
Created snowboard_utah/app/views/snowboard_utah/app_view.rb
|
753
|
+
Created snowboard_utah/package/windows/Snowboard Utah.ico
|
754
|
+
Created snowboard_utah/package/macosx/Snowboard Utah.icns
|
755
|
+
Created snowboard_utah/package/linux/Snowboard Utah.png
|
756
|
+
Created snowboard_utah/bin/snowboard_utah
|
757
|
+
...
|
758
|
+
```
|
759
|
+
|
760
|
+
Eventually, it will launch a desktopified version of "https://www.brightonresort.com" having the title of ("Snowboard Utah").
|
761
|
+
|
762
|
+
Desktopified App on Mac
|
763
|
+
|
764
|
+
![Glimmer Scaffold App](images/glimmer-scaffolding-desktopify.png)
|
765
|
+
|
766
|
+
It also comes with a boilerplate About dialog.
|
767
|
+
|
768
|
+
![Glimmer Scaffold App About](images/glimmer-scaffolding-desktopify-about.png)
|
769
|
+
|
770
|
+
Desktopified App on Windows
|
771
|
+
|
772
|
+
![Glimmer Scaffold App](images/glimmer-scaffolding-desktopify-windows.png)
|
773
|
+
|
774
|
+
Desktopified App on Linux
|
775
|
+
|
776
|
+
![Glimmer Scaffold App](images/glimmer-scaffolding-desktopify-linux.png)
|
777
|
+
|
778
|
+
In order to run the app after making changes, you must run the `glimmer run`. It automatically detects the generated run script under the `bin` directory and uses it as an argument.
|
779
|
+
|
780
|
+
```
|
781
|
+
glimmer run
|
782
|
+
```
|
783
|
+
|
989
784
|
#### Custom Shell
|
990
785
|
|
991
786
|
To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
|
@@ -1017,7 +812,7 @@ glimmer scaffold:cw[name]
|
|
1017
812
|
#### Custom Shell Gem
|
1018
813
|
|
1019
814
|
Custom shell gems are self-contained Glimmer apps as well as reusable custom shells.
|
1020
|
-
They have everything scaffolded Glimmer apps come with in addition to gem content like a [
|
815
|
+
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.
|
1021
816
|
Unlike scaffolded Glimmer apps, custom shell gem content lives under the `lib` directory (not `app`).
|
1022
817
|
They can be packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
|
1023
818
|
Of course, you can just build a Ruby gem and disregard native executable packaging if you do not need it.
|
@@ -1042,7 +837,7 @@ Only official Glimmer gems created by the Glimmer project committers will have n
|
|
1042
837
|
|
1043
838
|
Since custom shell gems are both an app and a gem, they provide two ways to run:
|
1044
839
|
- Run the `glimmer` command and pass it the generated script under the `bin` directory that matches the gem name (e.g. run `glimmer bin/glimmer-cs-calculator`)
|
1045
|
-
- Run the executable
|
840
|
+
- Run the executable shell script that ships with the gem directly (does not need the `glimmer` command). It intentionally has a shorter name for convenience since it is meant to be used on the command line (not in a package), so you can leave out the `glimmer-cs-` prefix (e.g. run `bin/calculator` directly). This is also used as the main way of running custom shell gems on Linux.
|
1046
841
|
|
1047
842
|
Examples:
|
1048
843
|
|
@@ -1191,24 +986,46 @@ Output:
|
|
1191
986
|
|
1192
987
|
Name Gem Version Author Description
|
1193
988
|
|
1194
|
-
Css glimmer-dsl-css
|
1195
|
-
Opal glimmer-dsl-opal 0.
|
1196
|
-
Swt glimmer-dsl-swt 4.17.
|
1197
|
-
Tk glimmer-dsl-tk 0.0.
|
1198
|
-
Xml glimmer-dsl-xml
|
989
|
+
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
|
990
|
+
Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
|
991
|
+
Swt glimmer-dsl-swt 4.17.4.0 AndyMaleh Glimmer DSL for SWT
|
992
|
+
Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
|
993
|
+
Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
|
1199
994
|
```
|
1200
995
|
|
1201
996
|
### Packaging
|
1202
997
|
|
998
|
+
Glimmer supports packaging applications as native files on Mac and Windows.
|
999
|
+
|
1203
1000
|
Glimmer packaging tasks are detailed under [Packaging & Distribution](#packaging--distribution).
|
1204
1001
|
|
1002
|
+
On Linux, the Glimmer [Custom Shell Gem](#custom-shell-gem) approach provides a [Gem Packaged Shell Script](#custom-shell-gem) (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem)
|
1003
|
+
|
1205
1004
|
### Raw JRuby Command
|
1206
1005
|
|
1207
1006
|
If there is a need to run Glimmer directly via the `jruby` command, you
|
1208
|
-
may run the following:
|
1007
|
+
may run the following on Windows/Linux:
|
1008
|
+
|
1009
|
+
```
|
1010
|
+
jruby -r glimmer-dsl-swt -S application.rb
|
1011
|
+
```
|
1012
|
+
|
1013
|
+
Or, the following on Mac:
|
1014
|
+
|
1015
|
+
```
|
1016
|
+
jruby -J-XstartOnFirstThread -r glimmer-dsl-swt -S application.rb
|
1017
|
+
```
|
1018
|
+
|
1019
|
+
If you want to use a specific custom version of SWT, run the following on Windows/Linux:
|
1209
1020
|
|
1210
1021
|
```
|
1211
|
-
jruby -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
|
1022
|
+
jruby -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
|
1023
|
+
```
|
1024
|
+
|
1025
|
+
Or, the following on Mac:
|
1026
|
+
|
1027
|
+
```
|
1028
|
+
jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
|
1212
1029
|
```
|
1213
1030
|
|
1214
1031
|
The `-J-classpath` option specifies the `swt.jar` file path, which can be a
|
@@ -1226,7 +1043,7 @@ However, if there is a reason to use the raw `jruby` command directly instead of
|
|
1226
1043
|
|
1227
1044
|
Example:
|
1228
1045
|
```
|
1229
|
-
jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
|
1046
|
+
jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
|
1230
1047
|
```
|
1231
1048
|
|
1232
1049
|
## Girb (Glimmer irb) Command
|
@@ -1310,19 +1127,21 @@ Glimmer DSL syntax consists mainly of:
|
|
1310
1127
|
|
1311
1128
|
### DSL Auto-Expansion
|
1312
1129
|
|
1313
|
-
Glimmer supports a new and radical Ruby DSL concept called DSL Auto-Expansion.
|
1130
|
+
Glimmer supports a new and radical Ruby DSL concept called DSL Auto-Expansion. To explain, let's first mention the two types of Glimmer GUI DSL keywords: static and dynamic.
|
1314
1131
|
|
1315
1132
|
Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `display`, `message_box`, `async_exec`, `sync_exec`, and `bind`.
|
1316
1133
|
|
1317
|
-
Dynamic keywords are dynamically figured out from currently imported (aka required/loaded) SWT widgets
|
1134
|
+
Dynamic keywords are dynamically figured out from currently imported (aka required/loaded) SWT widgets and custom widgets. Examples are: `label`, `combo`, and `list` for SWT widgets and `c_date_time`, `video`, and `gantt_chart` for custom widgets.
|
1135
|
+
|
1136
|
+
The only reason to distinguish between the two is to realize that importing new Glimmer [custom widgets](#custom-widgets) and Java SWT custom widget libraries automatically expands Glimmer's DSL vocabulary with new dynamic keywords.
|
1318
1137
|
|
1319
|
-
|
1138
|
+
For example, if a project adds this custom Java SWT library from the [Nebula Project](https://www.eclipse.org/nebula/):
|
1320
1139
|
|
1321
|
-
|
1140
|
+
https://www.eclipse.org/nebula/widgets/gallery/gallery.php
|
1322
1141
|
|
1323
|
-
|
1142
|
+
Glimmer will automatically support using the keyword `gallery`
|
1324
1143
|
|
1325
|
-
|
1144
|
+
This is what DSL Auto-Expansion is.
|
1326
1145
|
|
1327
1146
|
You will learn more about widgets next.
|
1328
1147
|
|
@@ -1437,27 +1256,9 @@ shell {
|
|
1437
1256
|
|
1438
1257
|
If you are new to Glimmer, you have learned enough to start running some [samples](#samples). Go ahead and run all Glimmer [samples](#samples), and come back to read the rest in any order you like since this material is more organized like a reference.
|
1439
1258
|
|
1440
|
-
|
1441
|
-
|
1442
|
-
SWT Display is a singleton in Glimmer. It is used in SWT to represent your display device, allowing you to manage GUI globally
|
1443
|
-
and access available monitors.
|
1444
|
-
It is automatically instantiated upon first instantiation of a `shell` widget.
|
1445
|
-
Alternatively, for advanced use cases, it can be created explicitly with Glimmer `display` keyword. When a `shell` is later declared, it
|
1446
|
-
automatically uses the display created earlier without having to explicitly hook it.
|
1259
|
+
If you are advanced and need more widgets, check out the [Nebula Project](https://www.eclipse.org/nebula/) for an extensive list of high quality custom widgets:
|
1447
1260
|
|
1448
|
-
|
1449
|
-
@display = display {
|
1450
|
-
cursor_location 300, 300
|
1451
|
-
on_swt_keydown {
|
1452
|
-
# ...
|
1453
|
-
}
|
1454
|
-
# ...
|
1455
|
-
}
|
1456
|
-
@shell = shell { # uses display created above
|
1457
|
-
}
|
1458
|
-
```
|
1459
|
-
The benefit of instantiating an SWT Display explicitly is to set [Properties](#widget-properties) or [Observers](#observer).
|
1460
|
-
Although SWT Display is not technically a widget, it has similar APIs in SWT and similar DSL support in Glimmer.
|
1261
|
+
https://www.eclipse.org/nebula/
|
1461
1262
|
|
1462
1263
|
#### SWT Proxies
|
1463
1264
|
|
@@ -1474,7 +1275,26 @@ Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT o
|
|
1474
1275
|
|
1475
1276
|
These proxy objects have an API and provide some convenience methods, some of which are mentioned below.
|
1476
1277
|
|
1477
|
-
#####
|
1278
|
+
##### swt_widget
|
1279
|
+
|
1280
|
+
Glimmer SWT proxies come with the instance method `#swt_widget`, which returns the actual SWT `Widget` object wrapped by the Glimmer widget proxy. It is useful in cases you'd like to do some custom SWT programming outside of Glimmer.
|
1281
|
+
|
1282
|
+
##### Shell widget proxy methods
|
1283
|
+
|
1284
|
+
Shell widget proxy has extra methods specific to SWT Shell:
|
1285
|
+
- `#open`: Opens the shell, making it visible and active, and starting the SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). If shell was already open, but hidden, it makes the shell visible.
|
1286
|
+
- `#show`: Alias for `#open`
|
1287
|
+
- `#hide`: Hides a shell setting "visible" property to false
|
1288
|
+
- `#close`: Closes the shell
|
1289
|
+
- `#center`: Centers the shell within monitor it is in
|
1290
|
+
- `#start_event_loop`: (happens as part of `#open`) Starts SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). This method is not needed except in rare circumstances where there is a need to start the SWT Event Loop before opening the shell.
|
1291
|
+
- `#visible?`: Returns whether a shell is visible
|
1292
|
+
- `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
|
1293
|
+
- `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
|
1294
|
+
- `#pack`: Packs contained widgets using SWT's `Shell#pack` method
|
1295
|
+
- `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
|
1296
|
+
|
1297
|
+
##### Widget Content Block
|
1478
1298
|
|
1479
1299
|
Glimmer allows re-opening any widget and adding properties or extra content after it has been constructed already by using the `#content` method.
|
1480
1300
|
|
@@ -1500,7 +1320,31 @@ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
|
1500
1320
|
@shell.open
|
1501
1321
|
```
|
1502
1322
|
|
1503
|
-
#####
|
1323
|
+
##### Shell Icon
|
1324
|
+
|
1325
|
+
To set the shell icon, simply set the `image` property under the `shell` widget. This shows up in the operating system toolbar and app-switcher (e.g. CMD+TAB) (and application window top-left corner in Windows)
|
1326
|
+
|
1327
|
+
Example:
|
1328
|
+
|
1329
|
+
```ruby
|
1330
|
+
shell {
|
1331
|
+
# ...
|
1332
|
+
image 'path/to/image.png'
|
1333
|
+
# ...
|
1334
|
+
}
|
1335
|
+
```
|
1336
|
+
|
1337
|
+
###### Shell Icon Tip for Packaging on Windows
|
1338
|
+
|
1339
|
+
When setting shell icon for a [packaged](#packaging--distribution) app, which has a JAR file at its core, you can reference the `ico` file that ships with the app by going one level up (e.g. `'../AppName.ico'`)
|
1340
|
+
|
1341
|
+
#### Dialog
|
1342
|
+
|
1343
|
+
Dialog is a variation on Shell. It is basically a shell that is modal (blocks what's behind it) and belongs to another shell. It only has a close button.
|
1344
|
+
|
1345
|
+
Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT.DIALOG_TRIM and SWT.APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
|
1346
|
+
|
1347
|
+
##### message_box
|
1504
1348
|
|
1505
1349
|
The Glimmer DSL `message_box` keyword is similar to `shell`, but renders a modal dialog with a title `text` property and main body `message` property. It may also be opened via the `#open` method.
|
1506
1350
|
|
@@ -1539,48 +1383,65 @@ message_box {
|
|
1539
1383
|
}.open
|
1540
1384
|
```
|
1541
1385
|
|
1542
|
-
|
1543
|
-
|
1544
|
-
Glimmer widget objects come with an instance method `#swt_widget` that returns the actual SWT `Widget` object wrapped by the Glimmer widget object. It is useful in cases you'd like to do some custom SWT programming outside of Glimmer.
|
1545
|
-
|
1546
|
-
##### Shell widget proxy methods
|
1547
|
-
|
1548
|
-
Shell widget proxy has extra methods specific to SWT Shell:
|
1549
|
-
- `#open`: Opens the shell, making it visible and active, and starting the SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). If shell was already open, but hidden, it makes the shell visible.
|
1550
|
-
- `#show`: Alias for `#open`
|
1551
|
-
- `#hide`: Hides a shell setting "visible" property to false
|
1552
|
-
- `#close`: Closes the shell
|
1553
|
-
- `#center`: Centers the shell within monitor it is in
|
1554
|
-
- `#start_event_loop`: (happens as part of `#open`) Starts SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). This method is not needed except in rare circumstances where there is a need to start the SWT Event Loop before opening the shell.
|
1555
|
-
- `#visible?`: Returns whether a shell is visible
|
1556
|
-
- `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
|
1557
|
-
- `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
|
1558
|
-
- `#pack`: Packs contained widgets using SWT's `Shell#pack` method
|
1559
|
-
- `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
|
1386
|
+
#### Display
|
1560
1387
|
|
1561
|
-
|
1388
|
+
The SWT `Display` class is a singleton in Glimmer. It is used in SWT to represent your display device, allowing you to manage GUI globally
|
1389
|
+
and access available monitors. Additionally, it is responsible for the SWT event loop, which runs on the first thread the Glimmer application starts on. In multi-threaded programming, `Display` provides the methods `async_exec` and `sync_exec` to enable enqueuing GUI changes asynchronously or synchronously from threads other than the main (first) thread since direct GUI changes are forbidden from other threads by design.
|
1562
1390
|
|
1563
|
-
|
1391
|
+
`Display` is automatically instantiated upon first instantiation of a `shell` widget.
|
1564
1392
|
|
1565
|
-
|
1393
|
+
Alternatively, for advanced use cases, a `Display` can be created explicitly with the Glimmer `display` keyword. When a `shell` is later declared, it
|
1394
|
+
automatically uses the `display` created earlier without having to explicitly hook it.
|
1566
1395
|
|
1567
1396
|
```ruby
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1397
|
+
@display = display {
|
1398
|
+
cursor_location 300, 300
|
1399
|
+
on_swt_keydown {
|
1400
|
+
# ...
|
1401
|
+
}
|
1571
1402
|
# ...
|
1572
1403
|
}
|
1404
|
+
@shell = shell { # uses display created above
|
1405
|
+
}
|
1573
1406
|
```
|
1407
|
+
The benefit of instantiating an SWT Display explicitly is to set [Properties](#widget-properties) or [Observers](#observer).
|
1408
|
+
Although SWT Display is not technically a widget, it has similar APIs and DSL support.
|
1574
1409
|
|
1575
|
-
|
1410
|
+
#### Multi-Threading
|
1576
1411
|
|
1577
|
-
|
1412
|
+
[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.
|
1578
1413
|
|
1579
|
-
|
1414
|
+
##### async_exec
|
1580
1415
|
|
1581
|
-
|
1416
|
+
`async_exec` is a Glimmer DSL keyword in addition to being a method on `display`. It accepts a block and when invoked, adds the block to the end of a queue of GUI events scheduled to run on the SWT event loop, executing asynchronously.
|
1582
1417
|
|
1583
|
-
|
1418
|
+
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
1419
|
+
|
1420
|
+
```
|
1421
|
+
@shell = shell {
|
1422
|
+
text 'Glimmer'
|
1423
|
+
@label = label {
|
1424
|
+
text 'Hello, World!'
|
1425
|
+
}
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
Thread.new {
|
1429
|
+
[:red, :dark_green, :blue].cycle { |color|
|
1430
|
+
async_exec {
|
1431
|
+
@label.content {
|
1432
|
+
foreground color if @shell.visible?
|
1433
|
+
}
|
1434
|
+
}
|
1435
|
+
sleep(1)
|
1436
|
+
}
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
@shell.open
|
1440
|
+
```
|
1441
|
+
|
1442
|
+
##### sync_exec
|
1443
|
+
|
1444
|
+
`sync_exec` works just like `async_exec` except it executes the block synchronously at the earliest opportunity possible, waiting for the block to be finished.
|
1584
1445
|
|
1585
1446
|
#### Menus
|
1586
1447
|
|
@@ -1913,6 +1774,16 @@ Example:
|
|
1913
1774
|
@font = font(name: 'Arial', height: 36, style: :normal)
|
1914
1775
|
```
|
1915
1776
|
|
1777
|
+
### Image
|
1778
|
+
|
1779
|
+
The `image` keyword creates an instance of [org.eclipse.swt.graphics.Image](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Image.html).
|
1780
|
+
|
1781
|
+
It is a graphics `Image` object (not a widget), but is used used in setting the `image` property on `label` and `background_image` on `composite` (and subclasses)
|
1782
|
+
|
1783
|
+
Glimmer recently included **EXPERIMENTAL** gif animation support for the `background_image` property on `composite' since SWT does not support animation by default. On Windows, it only works inside composites nested under standard shells, not ones that have the SWT styles :on_top or :no_trim
|
1784
|
+
|
1785
|
+
Learn more about images in general at this SWT Image guide: https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
|
1786
|
+
|
1916
1787
|
### Cursor
|
1917
1788
|
|
1918
1789
|
SWT widget `cursor` property represents the mouse cursor you see on the screen when you hover over that widget.
|
@@ -2632,12 +2503,44 @@ end
|
|
2632
2503
|
|
2633
2504
|
### Custom Widgets
|
2634
2505
|
|
2635
|
-
Glimmer
|
2506
|
+
Custom widgets are brand new Glimmer DSL keywords that represent aggregates of existing widgets (e.g. `address_form`), customized existing widgets (e.g. `greeting_label`), or brand new widgets (e.g. `oscilloscope`)
|
2636
2507
|
|
2637
|
-
|
2508
|
+
You can find out about [published Glimmer Custom Widgets](https://github.com/AndyObtiva/glimmer-dsl-swt#gem-listing) by running the `glimmer list:gems:customwidget` command
|
2509
|
+
|
2510
|
+
Glimmer supports three ways of creating custom widgets with minimal code:
|
2511
|
+
1. Method-based Custom Widgets (for single-view-internal reuse): Extract a method containing Glimmer DSL widget syntax. Useful for quickly eliminating redundant code within a single view.
|
2512
|
+
2. Class-based Custom Widgets (for multiple-view-external reuse): Create a class that includes the `Glimmer::UI::CustomWidget` module and Glimmer DSL widget syntax in a `body {}` block. This will automatically extend Glimmer's DSL syntax with an underscored lowercase keyword matching the class name by convention. Useful in making a custom widget available in many views.
|
2513
|
+
|
2514
|
+
Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer approach. Typically, when referring to Custom Widgets, we are talking about Class-based Custom Widgets.
|
2515
|
+
|
2516
|
+
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.
|
2517
|
+
|
2518
|
+
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.
|
2638
2519
|
|
2639
2520
|
#### Simple Example
|
2640
2521
|
|
2522
|
+
##### Method-Based Custom Widget Example
|
2523
|
+
|
2524
|
+
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
2525
|
+
|
2526
|
+
Definition and usage in the same file:
|
2527
|
+
```ruby
|
2528
|
+
def red_label(label_text)
|
2529
|
+
label {
|
2530
|
+
text label_text
|
2531
|
+
background :red
|
2532
|
+
}
|
2533
|
+
end
|
2534
|
+
|
2535
|
+
shell {
|
2536
|
+
red_label('Red Label')
|
2537
|
+
}.open
|
2538
|
+
```
|
2539
|
+
|
2540
|
+
##### Class-Based Custom Widget Example
|
2541
|
+
|
2542
|
+
Simply create a new class that includes `Glimmer::UI::CustomWidget` and put Glimmer DSL code in its `#body` block (its return value is stored in `#body_root` attribute). Glimmer will then automatically recognize this class by convention when it encounters a keyword matching the class name converted to underscored lowercase (and namespace double-colons `::` replaced with double-underscores `__`)
|
2543
|
+
|
2641
2544
|
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
2642
2545
|
|
2643
2546
|
Definition:
|
@@ -2656,13 +2559,14 @@ end
|
|
2656
2559
|
Usage:
|
2657
2560
|
```ruby
|
2658
2561
|
shell {
|
2659
|
-
red_label {
|
2660
|
-
text 'Red Label'
|
2562
|
+
red_label(:center) {
|
2563
|
+
text 'Red Label'
|
2564
|
+
foreground :green
|
2661
2565
|
}
|
2662
2566
|
}.open
|
2663
2567
|
```
|
2664
2568
|
|
2665
|
-
As you can see, `RedLabel` became Glimmer DSL keyword
|
2569
|
+
As you can see, `RedLabel` became the Glimmer DSL keyword `red_label` and worked just like a standard label by taking in SWT style and nested properties. As such, it is a first-class citizen of the Glimmer GUI DSL.
|
2666
2570
|
|
2667
2571
|
#### Custom Widget Lifecycle Hooks
|
2668
2572
|
|
@@ -2808,6 +2712,8 @@ Custom shells are a kind of custom widgets that have shells only as the body roo
|
|
2808
2712
|
|
2809
2713
|
They may also be chained in a wizard fashion.
|
2810
2714
|
|
2715
|
+
You can find out about [published Glimmer Custom Shells](https://github.com/AndyObtiva/glimmer-dsl-swt#gem-listing) by running the `glimmer list:gems:customshell` command
|
2716
|
+
|
2811
2717
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2812
2718
|
|
2813
2719
|
```ruby
|
@@ -3147,6 +3053,28 @@ shell(:no_resize) {
|
|
3147
3053
|
|
3148
3054
|
Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
|
3149
3055
|
|
3056
|
+
#### Code Text Widget
|
3057
|
+
|
3058
|
+
`code_text` is a Glimmer built-in custom widget that displays syntax highlighted Ruby code in a customized SWT [StyledText](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/StyledText.html) widget.
|
3059
|
+
|
3060
|
+
It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
|
3061
|
+
|
3062
|
+
![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
|
3063
|
+
|
3064
|
+
Glimmer Meta-Sample Code Example:
|
3065
|
+
|
3066
|
+
```ruby
|
3067
|
+
# ...
|
3068
|
+
code_text {
|
3069
|
+
text bind(SampleDirectory, 'selected_sample.content')
|
3070
|
+
editable false
|
3071
|
+
caret nil
|
3072
|
+
}
|
3073
|
+
# ...
|
3074
|
+
```
|
3075
|
+
|
3076
|
+
To use, simply use `code_text` in place of `text` or `styled_text` widget. If you set its `text` value to Ruby code, it automatically styles it with syntax highlighting.
|
3077
|
+
|
3150
3078
|
#### Video Widget
|
3151
3079
|
|
3152
3080
|
[![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
|
@@ -3155,6 +3083,39 @@ Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-c
|
|
3155
3083
|
|
3156
3084
|
You may obtain via `glimmer-cw-video` gem.
|
3157
3085
|
|
3086
|
+
#### Sash Form Widget
|
3087
|
+
|
3088
|
+
`sash_form` is an SWT built-in custom widget that provides a resizable sash that splits a window area into two or more panes.
|
3089
|
+
|
3090
|
+
It can be customized with the `weights` attribute by setting initial weights to size the panes at first display.
|
3091
|
+
|
3092
|
+
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
3093
|
+
|
3094
|
+
```ruby
|
3095
|
+
shell {
|
3096
|
+
text 'Sash Form Example'
|
3097
|
+
sash_form {
|
3098
|
+
label {
|
3099
|
+
text '(resize >>)'
|
3100
|
+
background :dark_green
|
3101
|
+
foreground :white
|
3102
|
+
font height: 20
|
3103
|
+
}
|
3104
|
+
label {
|
3105
|
+
text '(<< resize)'
|
3106
|
+
background :red
|
3107
|
+
foreground :white
|
3108
|
+
font height: 20
|
3109
|
+
}
|
3110
|
+
weights 1, 2
|
3111
|
+
}
|
3112
|
+
}.open
|
3113
|
+
```
|
3114
|
+
|
3115
|
+
You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
|
3116
|
+
|
3117
|
+
![Hello Sash Form](images/glimmer-hello-sash-form.png)
|
3118
|
+
|
3158
3119
|
#### Browser Widget
|
3159
3120
|
|
3160
3121
|
![Hello Browser](images/glimmer-hello-browser.png)
|
@@ -3427,16 +3388,32 @@ Here is an SWT Custom Widget guide:
|
|
3427
3388
|
|
3428
3389
|
https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
|
3429
3390
|
|
3391
|
+
Here is an SWT Image guide:
|
3392
|
+
|
3393
|
+
https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
|
3394
|
+
|
3395
|
+
Here is an SWT Graphics / Canvas-Drawing guide:
|
3396
|
+
|
3397
|
+
https://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html
|
3398
|
+
|
3399
|
+
Here is the Nebula Project (custom widget library) homepage:
|
3400
|
+
|
3401
|
+
https://www.eclipse.org/nebula/
|
3402
|
+
|
3430
3403
|
## Samples
|
3431
3404
|
|
3432
3405
|
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` 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`).
|
3433
3406
|
|
3434
|
-
|
3407
|
+
You may run any sample via this command:
|
3435
3408
|
|
3436
3409
|
```
|
3437
|
-
samples
|
3410
|
+
glimmer samples
|
3438
3411
|
```
|
3439
3412
|
|
3413
|
+
This brings up the [Glimmer Meta-Sample (The Sample of Samples)](samples/elaborate/meta_sample.rb)
|
3414
|
+
|
3415
|
+
![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
|
3416
|
+
|
3440
3417
|
### Hello Samples
|
3441
3418
|
|
3442
3419
|
For hello-type simple samples, check the following.
|
@@ -3447,12 +3424,6 @@ Code:
|
|
3447
3424
|
|
3448
3425
|
[samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_world.rb)
|
3449
3426
|
|
3450
|
-
Run:
|
3451
|
-
|
3452
|
-
```
|
3453
|
-
glimmer sample:run[hello_world]
|
3454
|
-
```
|
3455
|
-
|
3456
3427
|
![Hello World](images/glimmer-hello-world.png)
|
3457
3428
|
|
3458
3429
|
#### Hello, Tab!
|
@@ -3461,12 +3432,6 @@ Code:
|
|
3461
3432
|
|
3462
3433
|
[samples/hello/hello_tab.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_tab.rb)
|
3463
3434
|
|
3464
|
-
Run:
|
3465
|
-
|
3466
|
-
```
|
3467
|
-
glimmer sample:run[hello_tab]
|
3468
|
-
```
|
3469
|
-
|
3470
3435
|
![Hello Tab English](images/glimmer-hello-tab-english.png)
|
3471
3436
|
![Hello Tab French](images/glimmer-hello-tab-french.png)
|
3472
3437
|
|
@@ -3478,12 +3443,6 @@ Code:
|
|
3478
3443
|
|
3479
3444
|
[samples/hello/hello_combo.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_combo.rb)
|
3480
3445
|
|
3481
|
-
Run:
|
3482
|
-
|
3483
|
-
```
|
3484
|
-
glimmer sample:run[hello_combo]
|
3485
|
-
```
|
3486
|
-
|
3487
3446
|
![Hello Combo](images/glimmer-hello-combo.png)
|
3488
3447
|
![Hello Combo Expanded](images/glimmer-hello-combo-expanded.png)
|
3489
3448
|
|
@@ -3495,12 +3454,6 @@ Code:
|
|
3495
3454
|
|
3496
3455
|
[samples/hello/hello_list_single_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_single_selection.rb)
|
3497
3456
|
|
3498
|
-
Run:
|
3499
|
-
|
3500
|
-
```
|
3501
|
-
glimmer sample:run[hello_list_single_selection]
|
3502
|
-
```
|
3503
|
-
|
3504
3457
|
![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
|
3505
3458
|
|
3506
3459
|
#### Hello, List Multi Selection!
|
@@ -3511,12 +3464,6 @@ Code:
|
|
3511
3464
|
|
3512
3465
|
[samples/hello/hello_list_multi_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_multi_selection.rb)
|
3513
3466
|
|
3514
|
-
Run:
|
3515
|
-
|
3516
|
-
```
|
3517
|
-
glimmer sample:run[hello_list_multi_selection]
|
3518
|
-
```
|
3519
|
-
|
3520
3467
|
![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
|
3521
3468
|
|
3522
3469
|
#### Hello, Computed!
|
@@ -3527,12 +3474,6 @@ Code:
|
|
3527
3474
|
|
3528
3475
|
[samples/hello/hello_computed.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_computed.rb)
|
3529
3476
|
|
3530
|
-
Run:
|
3531
|
-
|
3532
|
-
```
|
3533
|
-
glimmer sample:run[hello_computed]
|
3534
|
-
```
|
3535
|
-
|
3536
3477
|
![Hello Browser](images/glimmer-hello-computed.png)
|
3537
3478
|
|
3538
3479
|
#### Hello, Message Box!
|
@@ -3543,12 +3484,6 @@ Code:
|
|
3543
3484
|
|
3544
3485
|
[samples/hello/hello_message_box.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_message_box.rb)
|
3545
3486
|
|
3546
|
-
Run:
|
3547
|
-
|
3548
|
-
```
|
3549
|
-
glimmer sample:run[hello_message_box]
|
3550
|
-
```
|
3551
|
-
|
3552
3487
|
![Hello Message Box](images/glimmer-hello-message-box.png)
|
3553
3488
|
![Hello Message Box Dialog](images/glimmer-hello-message-box-dialog.png)
|
3554
3489
|
|
@@ -3560,12 +3495,6 @@ Code:
|
|
3560
3495
|
|
3561
3496
|
[samples/hello/hello_browser.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_browser.rb)
|
3562
3497
|
|
3563
|
-
Run:
|
3564
|
-
|
3565
|
-
```
|
3566
|
-
glimmer sample:run[hello_browser]
|
3567
|
-
```
|
3568
|
-
|
3569
3498
|
![Hello Browser](images/glimmer-hello-browser.png)
|
3570
3499
|
|
3571
3500
|
#### Hello, Drag and Drop!
|
@@ -3576,12 +3505,6 @@ Code:
|
|
3576
3505
|
|
3577
3506
|
[samples/hello/hello_drag_and_drop.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_drag_and_drop.rb)
|
3578
3507
|
|
3579
|
-
Run:
|
3580
|
-
|
3581
|
-
```
|
3582
|
-
glimmer sample:run[hello_drag_and_drop]
|
3583
|
-
```
|
3584
|
-
|
3585
3508
|
![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
|
3586
3509
|
|
3587
3510
|
#### Hello, Menu Bar!
|
@@ -3592,12 +3515,6 @@ Code:
|
|
3592
3515
|
|
3593
3516
|
[samples/hello/hello_menu_bar.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_menu_bar.rb)
|
3594
3517
|
|
3595
|
-
Run:
|
3596
|
-
|
3597
|
-
```
|
3598
|
-
glimmer sample:run[hello_menu_bar]
|
3599
|
-
```
|
3600
|
-
|
3601
3518
|
![Hello Menu Bar](images/glimmer-hello-menu-bar.png)
|
3602
3519
|
![Hello Menu Bar File Menu](images/glimmer-hello-menu-bar-file-menu.png)
|
3603
3520
|
![Hello Menu Bar History Menu](images/glimmer-hello-menu-bar-history-menu.png)
|
@@ -3610,12 +3527,6 @@ Code:
|
|
3610
3527
|
|
3611
3528
|
[samples/hello/hello_pop_up_context_menu.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_pop_up_context_menu.rb)
|
3612
3529
|
|
3613
|
-
Run:
|
3614
|
-
|
3615
|
-
```
|
3616
|
-
glimmer sample:run[hello_pop_up_context_menu]
|
3617
|
-
```
|
3618
|
-
|
3619
3530
|
![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
|
3620
3531
|
![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
|
3621
3532
|
|
@@ -3627,12 +3538,6 @@ Code:
|
|
3627
3538
|
|
3628
3539
|
[samples/hello/hello_custom_widget.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_widget.rb)
|
3629
3540
|
|
3630
|
-
Run:
|
3631
|
-
|
3632
|
-
```
|
3633
|
-
glimmer sample:run[hello_custom_widget]
|
3634
|
-
```
|
3635
|
-
|
3636
3541
|
![Hello Custom Widget](images/glimmer-hello-custom-widget.gif)
|
3637
3542
|
|
3638
3543
|
#### Hello, Custom Shell!
|
@@ -3643,17 +3548,43 @@ Code:
|
|
3643
3548
|
|
3644
3549
|
[samples/hello/hello_custom_shell.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_shell.rb)
|
3645
3550
|
|
3646
|
-
Run:
|
3647
|
-
|
3648
|
-
```
|
3649
|
-
glimmer sample:run[hello_custom_shell]
|
3650
|
-
```
|
3651
|
-
|
3652
3551
|
![Hello Custom Shell](images/glimmer-hello-custom-shell.png)
|
3653
3552
|
![Hello Custom Shell Email1](images/glimmer-hello-custom-shell-email1.png)
|
3654
3553
|
![Hello Custom Shell Email2](images/glimmer-hello-custom-shell-email2.png)
|
3655
3554
|
![Hello Custom Shell Email3](images/glimmer-hello-custom-shell-email3.png)
|
3656
3555
|
|
3556
|
+
#### Hello, Sash Form!
|
3557
|
+
|
3558
|
+
This sample demonstrates the use of a `sash_form` in Glimmer.
|
3559
|
+
|
3560
|
+
Code:
|
3561
|
+
|
3562
|
+
[samples/hello/hello_sash_form.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_sash_form.rb)
|
3563
|
+
|
3564
|
+
Hello, Sash Form! Horizontal Orientation
|
3565
|
+
|
3566
|
+
![Hello Sash Form](images/glimmer-hello-sash-form.png)
|
3567
|
+
|
3568
|
+
Hello, Sash Form! Resized
|
3569
|
+
|
3570
|
+
![Hello Sash Form Resized](images/glimmer-hello-sash-form-resized.png)
|
3571
|
+
|
3572
|
+
Hello, Sash Form! Sash Width Changed
|
3573
|
+
|
3574
|
+
![Hello Sash Form Sash Width Changed](images/glimmer-hello-sash-form-sash-width-changed.png)
|
3575
|
+
|
3576
|
+
Hello, Sash Form! Vertical Orientation
|
3577
|
+
|
3578
|
+
![Hello Sash Form Vertical](images/glimmer-hello-sash-form-vertical.png)
|
3579
|
+
|
3580
|
+
Hello, Sash Form! Green Label Maximized
|
3581
|
+
|
3582
|
+
![Hello Sash Form Green Maximized](images/glimmer-hello-sash-form-green-maximized.png)
|
3583
|
+
|
3584
|
+
Hello, Sash Form! Red Label Maximized
|
3585
|
+
|
3586
|
+
![Hello Sash Form Red Maximized](images/glimmer-hello-sash-form-red-maximized.png)
|
3587
|
+
|
3657
3588
|
### Elaborate Samples
|
3658
3589
|
|
3659
3590
|
For more elaborate samples, check the following:
|
@@ -3668,12 +3599,6 @@ Code:
|
|
3668
3599
|
|
3669
3600
|
[samples/elaborate/user_profile.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/user_profile.rb)
|
3670
3601
|
|
3671
|
-
Run:
|
3672
|
-
|
3673
|
-
```
|
3674
|
-
glimmer sample:run[user_profile]
|
3675
|
-
```
|
3676
|
-
|
3677
3602
|
![User Profile](images/glimmer-user-profile.png)
|
3678
3603
|
|
3679
3604
|
#### Login
|
@@ -3684,12 +3609,6 @@ Code:
|
|
3684
3609
|
|
3685
3610
|
[samples/elaborate/login.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/login.rb)
|
3686
3611
|
|
3687
|
-
Run:
|
3688
|
-
|
3689
|
-
```
|
3690
|
-
glimmer sample:run[login]
|
3691
|
-
```
|
3692
|
-
|
3693
3612
|
![Login](images/glimmer-login.png)
|
3694
3613
|
![Login Filled In](images/glimmer-login-filled-in.png)
|
3695
3614
|
![Login Logged In](images/glimmer-login-logged-in.png)
|
@@ -3704,12 +3623,6 @@ Code:
|
|
3704
3623
|
|
3705
3624
|
[samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/tic_tac_toe.rb)
|
3706
3625
|
|
3707
|
-
Run:
|
3708
|
-
|
3709
|
-
```
|
3710
|
-
glimmer sample:run[tic_tac_toe]
|
3711
|
-
```
|
3712
|
-
|
3713
3626
|
![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
|
3714
3627
|
![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
|
3715
3628
|
![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
|
@@ -3722,12 +3635,6 @@ Code:
|
|
3722
3635
|
|
3723
3636
|
[samples/elaborate/contact_manager.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/contact_manager.rb)
|
3724
3637
|
|
3725
|
-
Run:
|
3726
|
-
|
3727
|
-
```
|
3728
|
-
glimmer sample:run[contact_manager]
|
3729
|
-
```
|
3730
|
-
|
3731
3638
|
Contact Manager
|
3732
3639
|
|
3733
3640
|
![Contact Manager](images/glimmer-contact-manager.png)
|
@@ -3775,7 +3682,7 @@ Gladiator is a good demonstration of:
|
|
3775
3682
|
|
3776
3683
|
#### Timer
|
3777
3684
|
|
3778
|
-
[<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
|
3685
|
+
[<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 Java (Sound) library integration in a desktop application.
|
3779
3686
|
|
3780
3687
|
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
|
3781
3688
|
|
@@ -3799,6 +3706,8 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
|
|
3799
3706
|
|
3800
3707
|
## Packaging & Distribution
|
3801
3708
|
|
3709
|
+
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)
|
3710
|
+
|
3802
3711
|
Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
|
3803
3712
|
|
3804
3713
|
```
|
@@ -3823,7 +3732,7 @@ require 'glimmer/rake_task'
|
|
3823
3732
|
```
|
3824
3733
|
|
3825
3734
|
The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
|
3826
|
-
1. Generate gemspec via
|
3735
|
+
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.
|
3827
3736
|
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.
|
3828
3737
|
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.
|
3829
3738
|
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
|
@@ -3981,7 +3890,7 @@ Glimmer already supports automatic (and manual) app updates via the Mac App Stor
|
|
3981
3890
|
## Glimmer Supporting Libraries
|
3982
3891
|
|
3983
3892
|
Here is a list of notable 3rd party gems used by Glimmer:
|
3984
|
-
- [
|
3893
|
+
- [juwelier](https://rubygems.org/gems/juwelier): generates app gems during [Glimmer Scaffolding](#scaffolding)
|
3985
3894
|
- [logging](https://github.com/TwP/logging): provides extra logging capabilities not available in Ruby Logger such as multi-threaded buffered asynchronous logging (to avoid affecting app performance) and support for multiple appenders such as stdout, syslog, and log files (the last one is needed on Windows where syslog is not supported)
|
3986
3895
|
- [nested_inherited_jruby_include_package](https://github.com/AndyObtiva/nested_inherited_jruby_include_package): makes included [SWT](https://www.eclipse.org/swt/)/[Java](https://www.java.com/en/) packages available to all classes/modules that mix in the Glimmer module without having to manually reimport
|
3987
3896
|
- [os](https://github.com/rdp/os): provides OS detection capabilities (e.g. `OS.mac?` or `OS.windows?`) to write cross-platform code inexpensively
|