glimmer-dsl-swt 4.17.2.2 → 4.17.4.1
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 +398 -523
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +9 -6
- 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/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 +95 -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 +99 -35
- data/samples/elaborate/meta_sample.rb +166 -0
- data/samples/hello/hello_sash_form.rb +137 -0
- metadata +11 -8
- 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: 6cddf113bb01ca3a0023665a0005d6ae1b78745ee877178c19b8e55c53ff31ce
|
4
|
+
data.tar.gz: 147ec77329bcda0e0ff86b6a0443a4cdcc9b63f87b2cf29ccae2bc05bb5dd2db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4b03838352129fb30d8ee1e5652bc0e41f9524613e2cdb03ec11acf3e5552804472c09aa33efffeef02279b6f92f7cad1b465046bb74e9f5d1a24087251dd3
|
7
|
+
data.tar.gz: 5b8c69a4ab87b47b1e024b764329e946da803949243f841bf62970c19153740298bc46628eec89da516958d4df5584a1120342ef4d515fbe00656961fea198be
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,55 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.17.4.1
|
4
|
+
|
5
|
+
- Optimize code_text line style listener algorithm or avoid setting code_text style via listener for performance reasons
|
6
|
+
- Optimize code_text syntax highlighting by not lexing except when content changes (e.g. during scrolling, do not lex)
|
7
|
+
|
8
|
+
### 4.17.4.0
|
9
|
+
|
10
|
+
- Glimmer sample app to launch samples (sample of samples meta-sample)
|
11
|
+
- Syntax Color Highlighting in meta-sample
|
12
|
+
- Make sash_form weights accept splat array elements (not wrapped in [])
|
13
|
+
- 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)
|
14
|
+
- Replace dependency on tty-markdown gem with dependency on rouge gem instead
|
15
|
+
- Remove rake tasks `sample:list`, `sample:code` and `sample:run`
|
16
|
+
- Add rake task `samples` to point to the new Glimmer Meta-Sample
|
17
|
+
- Have meta-sample load samples from gems
|
18
|
+
|
19
|
+
### 4.17.3.0
|
20
|
+
|
21
|
+
- `glimmer scaffold:desktopify[appname,website]` Mac
|
22
|
+
- `glimmer scaffold:desktopify[appname,website]` Windows
|
23
|
+
- `glimmer scaffold:desktopify[appname,website]` Linux (have scaffolding include the glimmer-cw-browser-chromium gem in scaffolded app on Linux)
|
24
|
+
- Remove the native packaging from Linux scaffolding since it is not officially supported
|
25
|
+
- Add gem packaging as part of scaffolding on Linux
|
26
|
+
- Launch the app at the end of scaffolding in Linux
|
27
|
+
- Provide a `glimmer package:gem` task
|
28
|
+
- 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
|
29
|
+
- Add a binary executable shell in "app" mode (just like "custom shell gem" mode)
|
30
|
+
- Have glimmer packaging check the Java version and give a warning if an unsupported version is used.
|
31
|
+
|
32
|
+
|
33
|
+
### 4.17.2.4
|
34
|
+
|
35
|
+
- New `glimmer run` glimmer command task.
|
36
|
+
- Add built in support for handling jar file paths like that in ImageProxy code processing "uri:classloader" path
|
37
|
+
- Document that gif background_image only works without on_top and no_trim styles in Windows
|
38
|
+
- Give a good error message when Git is not properly setup for Glimmer Scaffolding
|
39
|
+
- Give an error message when attempting to scaffold over an already scaffolded directory
|
40
|
+
- Fix issue on Windows regarding use of the new EXPERIMENTAL Animated gif support in the `composite#background_image` property
|
41
|
+
- Fix SWTProxy.deconstruct method
|
42
|
+
|
43
|
+
|
44
|
+
### 4.17.2.3
|
45
|
+
|
46
|
+
- Maintain image file path upon scaling an ImageProxy
|
47
|
+
- Add a glimmer rake task that wraps the juwelier rake gemspec:generate task
|
48
|
+
- Accept `ImageProxy` as arg for `image` and `background_image` property methods
|
49
|
+
- (EXPERIMENTAL) Animate gif images when set as a `background_image` on a `composite`
|
50
|
+
- Fix issue with table redraw after data-binding changes leaving old removed table items visible (even if user cannot interact with anymore)
|
51
|
+
- Fix issue with running package rake task from `glimmer` command TUI
|
52
|
+
|
3
53
|
### 4.17.2.2
|
4
54
|
|
5
55
|
- Small updates/refactorings in samples
|
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.1
|
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,7 +10,7 @@
|
|
10
10
|
|
11
11
|
(The Original Glimmer Library Since 2007. Beware of Imitators!)
|
12
12
|
|
13
|
-
[**Glimmer**](https://
|
13
|
+
[**Glimmer**](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster 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
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.
|
16
16
|
|
@@ -40,9 +40,10 @@ shell {
|
|
40
40
|
}.open
|
41
41
|
```
|
42
42
|
|
43
|
-
Run:
|
43
|
+
Run via `glimmer samples` or directly:
|
44
|
+
|
44
45
|
```
|
45
|
-
glimmer
|
46
|
+
glimmer samples/hello/hello_world.rb
|
46
47
|
```
|
47
48
|
|
48
49
|
Glimmer app:
|
@@ -85,10 +86,10 @@ Glimmer code (from [samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObt
|
|
85
86
|
# ...
|
86
87
|
```
|
87
88
|
|
88
|
-
Run:
|
89
|
+
Run via `glimmer samples` or directly:
|
89
90
|
|
90
91
|
```
|
91
|
-
glimmer
|
92
|
+
glimmer samples/elaborate/tic_tac_toe.rb
|
92
93
|
```
|
93
94
|
|
94
95
|
Glimmer app:
|
@@ -210,10 +211,10 @@ Glimmer code (from [samples/elaborate/contact_manager.rb](https://github.com/And
|
|
210
211
|
# ...
|
211
212
|
```
|
212
213
|
|
213
|
-
Run:
|
214
|
+
Run via `glimmer samples` or directly:
|
214
215
|
|
215
216
|
```
|
216
|
-
glimmer
|
217
|
+
glimmer samples/elaborate/contact_manager.rb
|
217
218
|
```
|
218
219
|
|
219
220
|
Glimmer App:
|
@@ -237,6 +238,7 @@ Glimmer App:
|
|
237
238
|
- [Hello, World!](#hello-world)
|
238
239
|
- [Tic Tac Toe](#tic-tac-toe)
|
239
240
|
- [Contact Manager](#contact-manager)
|
241
|
+
- [Desktop Apps Built with Glimmer DSL for SWT](#desktop-apps-built-with-glimmer-dsl-for-swt)
|
240
242
|
- [Table of contents](#table-of-contents)
|
241
243
|
- [Background](#background)
|
242
244
|
- [Platform Support](#platform-support)
|
@@ -247,12 +249,10 @@ Glimmer App:
|
|
247
249
|
- [Glimmer Command](#glimmer-command)
|
248
250
|
- [Basic Usage](#basic-usage)
|
249
251
|
- [Advanced Usage](#advanced-usage)
|
250
|
-
- [
|
251
|
-
- [Sample List](#sample-list)
|
252
|
-
- [Sample Run](#sample-run)
|
253
|
-
- [Sample Code](#sample-code)
|
252
|
+
- [Samples](#samples)
|
254
253
|
- [Scaffolding](#scaffolding)
|
255
254
|
- [App](#app)
|
255
|
+
- [Desktopify](#desktopify)
|
256
256
|
- [Custom Shell](#custom-shell)
|
257
257
|
- [Custom Widget](#custom-widget)
|
258
258
|
- [Custom Shell Gem](#custom-shell-gem)
|
@@ -268,9 +268,10 @@ Glimmer App:
|
|
268
268
|
- [Glimmer GUI DSL Syntax](#glimmer-gui-dsl-syntax)
|
269
269
|
- [DSL Auto-Expansion](#dsl-auto-expansion)
|
270
270
|
- [Widgets](#widgets)
|
271
|
-
- [Display](#display)
|
272
271
|
- [SWT Proxies](#swt-proxies)
|
273
272
|
- [Dialog](#dialog)
|
273
|
+
- [Display](#display)
|
274
|
+
- [Multi-Threading](#multi-threading)
|
274
275
|
- [Menus](#menus)
|
275
276
|
- [ScrolledComposite](#scrolledcomposite)
|
276
277
|
- [Widget Styles](#widget-styles)
|
@@ -280,6 +281,7 @@ Glimmer App:
|
|
280
281
|
- [Widget Properties](#widget-properties)
|
281
282
|
- [Color](#color)
|
282
283
|
- [Font](#font)
|
284
|
+
- [Image](#image)
|
283
285
|
- [Cursor](#cursor)
|
284
286
|
- [Layouts](#layouts)
|
285
287
|
- [Layout Data](#layout-data)
|
@@ -294,10 +296,10 @@ Glimmer App:
|
|
294
296
|
- [Observing Models](#observing-models)
|
295
297
|
- [Custom Widgets](#custom-widgets)
|
296
298
|
- [Simple Example](#simple-example)
|
297
|
-
- [Lifecycle
|
299
|
+
- [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
|
300
|
+
- [Lifecycle Hooks Example](#lifecycle-hooks-example)
|
298
301
|
- [Custom Widget API](#custom-widget-api)
|
299
302
|
- [Content/Options Example](#contentoptions-example)
|
300
|
-
- [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
|
301
303
|
- [Gotcha](#gotcha)
|
302
304
|
- [Final Notes](#final-notes)
|
303
305
|
- [Custom Shells](#custom-shells)
|
@@ -306,7 +308,9 @@ Glimmer App:
|
|
306
308
|
- [Multi-DSL Support](#multi-dsl-support)
|
307
309
|
- [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
|
308
310
|
- [App Name and Version](#app-name-and-version)
|
311
|
+
- [Code Text Widget](#code-text-widget)
|
309
312
|
- [Video Widget](#video-widget)
|
313
|
+
- [Sash Form Widget](#sash-form-widget)
|
310
314
|
- [Browser Widget](#browser-widget)
|
311
315
|
- [Glimmer Configuration](#glimmer-configuration)
|
312
316
|
- [logger](#logger)
|
@@ -335,6 +339,7 @@ Glimmer App:
|
|
335
339
|
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
336
340
|
- [Hello, Custom Widget!](#hello-custom-widget)
|
337
341
|
- [Hello, Custom Shell!](#hello-custom-shell)
|
342
|
+
- [Hello, Sash Form!](#hello-sash-form)
|
338
343
|
- [Elaborate Samples](#elaborate-samples)
|
339
344
|
- [User Profile](#user-profile)
|
340
345
|
- [Login](#login)
|
@@ -370,7 +375,7 @@ Glimmer App:
|
|
370
375
|
- [Contributors](#contributors)
|
371
376
|
- [Hire Me](#hire-me)
|
372
377
|
- [License](#license)
|
373
|
-
|
378
|
+
|
374
379
|
## Background
|
375
380
|
|
376
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.
|
@@ -428,7 +433,7 @@ jgem install glimmer-dsl-swt
|
|
428
433
|
|
429
434
|
Or this command if you want a specific version:
|
430
435
|
```
|
431
|
-
jgem install glimmer-dsl-swt -v 4.17.
|
436
|
+
jgem install glimmer-dsl-swt -v 4.17.4.1
|
432
437
|
```
|
433
438
|
|
434
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.
|
@@ -439,7 +444,7 @@ Otherwise, you may also run `jruby -S gem install ...`
|
|
439
444
|
|
440
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.
|
441
446
|
|
442
|
-
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.
|
443
448
|
|
444
449
|
Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
|
445
450
|
|
@@ -487,17 +492,18 @@ glimmer application.rb
|
|
487
492
|
Runs a Glimmer application using JRuby, automatically preloading
|
488
493
|
the glimmer ruby gem and SWT jar dependency.
|
489
494
|
|
490
|
-
|
495
|
+
Run Glimmer samples with:
|
496
|
+
|
491
497
|
```
|
492
|
-
glimmer
|
498
|
+
glimmer samples
|
493
499
|
```
|
494
|
-
This
|
500
|
+
This brings up the [Glimmer Meta-Sample (The Sample of Samples)](#samples)
|
495
501
|
|
496
|
-
If you cloned this project locally
|
502
|
+
If you cloned this project locally instead of installing the gem, run `bin/glimmer` instead.
|
497
503
|
|
498
504
|
Example:
|
499
505
|
```
|
500
|
-
bin/glimmer
|
506
|
+
bin/glimmer samples
|
501
507
|
```
|
502
508
|
|
503
509
|
### Advanced Usage
|
@@ -505,7 +511,7 @@ bin/glimmer sample:run[hello_world]
|
|
505
511
|
Below are the full usage instructions that come up when running `glimmer` without args.
|
506
512
|
|
507
513
|
```
|
508
|
-
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.1
|
509
515
|
|
510
516
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
511
517
|
|
@@ -534,12 +540,12 @@ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and
|
|
534
540
|
glimmer package[type] # Package app for distribution (generating config, jar, and native files) (type is optional)
|
535
541
|
glimmer package:clean # Clean by removing "dist" and "packages" directories
|
536
542
|
glimmer package:config # Generate JAR config file
|
543
|
+
glimmer package:gemspec # Generate gemspec
|
537
544
|
glimmer package:jar # Generate JAR file
|
538
545
|
glimmer package:lock_jars # Lock JARs
|
539
546
|
glimmer package:native[type] # Generate Native files
|
540
|
-
glimmer
|
541
|
-
glimmer
|
542
|
-
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
|
543
549
|
glimmer scaffold[app_name] # Scaffold Glimmer application directory structure to build a new app
|
544
550
|
glimmer scaffold:customshell[name,namespace] # Scaffold Glimmer::UI::CustomShell subclass (full window view) under app/views (namespace is optional) [alt: scaffold:cs]
|
545
551
|
glimmer scaffold:customwidget[name,namespace] # Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cw]
|
@@ -561,338 +567,22 @@ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
|
|
561
567
|
|
562
568
|
Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
|
563
569
|
|
564
|
-
###
|
565
|
-
|
566
|
-
#### Sample List
|
570
|
+
### Glimmer Samples
|
567
571
|
|
568
572
|
You can list available Glimmer samples by running:
|
569
573
|
|
570
574
|
```
|
571
|
-
glimmer
|
572
|
-
```
|
573
|
-
|
574
|
-
This should output the following (providing the name of each sample, description, and command to run the sample and view its code):
|
575
|
-
|
576
|
-
```
|
577
|
-
$ glimmer sample:list
|
578
|
-
|
579
|
-
Glimmer Hello Samples:
|
580
|
-
|
581
|
-
Name Description Run
|
582
|
-
|
583
|
-
hello_browser Hello Browser glimmer sample:run[hello_browser]
|
584
|
-
hello_combo Hello Combo glimmer sample:run[hello_combo]
|
585
|
-
hello_computed Hello Computed glimmer sample:run[hello_computed]
|
586
|
-
hello_drag_and_drop Hello Drag And Drop glimmer sample:run[hello_drag_and_drop]
|
587
|
-
hello_list_multi_selection Hello List Multi Selection glimmer sample:run[hello_list_multi_selection]
|
588
|
-
hello_list_single_selection Hello List Single Selection glimmer sample:run[hello_list_single_selection]
|
589
|
-
hello_menu_bar Hello Menu Bar glimmer sample:run[hello_menu_bar]
|
590
|
-
hello_message_box Hello Message Box glimmer sample:run[hello_message_box]
|
591
|
-
hello_pop_up_context_menu Hello Pop Up Context Menu glimmer sample:run[hello_pop_up_context_menu]
|
592
|
-
hello_tab Hello Tab glimmer sample:run[hello_tab]
|
593
|
-
hello_world Hello World glimmer sample:run[hello_world]
|
594
|
-
|
595
|
-
|
596
|
-
Glimmer Elaborate Samples:
|
597
|
-
|
598
|
-
Name Description Run
|
599
|
-
|
600
|
-
contact_manager Contact Manager glimmer sample:run[contact_manager]
|
601
|
-
login Login glimmer sample:run[login]
|
602
|
-
tic_tac_toe Tic Tac Toe glimmer sample:run[tic_tac_toe]
|
603
|
-
user_profile User Profile glimmer sample:run[user_profile]
|
604
|
-
```
|
605
|
-
|
606
|
-
#### Sample Run
|
607
|
-
|
608
|
-
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.
|
609
|
-
|
610
|
-
If the sample name is left empty (e.g. `glimmer sample:run`), then all samples are run.
|
611
|
-
|
612
|
-
Example:
|
613
|
-
|
614
|
-
```
|
615
|
-
glimmer sample:run[hello_tab]
|
616
|
-
```
|
617
|
-
|
618
|
-
This will run the hello_tab sample and output its code:
|
619
|
-
|
620
|
-
```
|
621
|
-
$ glimmer sample:run[hello_tab]
|
622
|
-
|
623
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/hello/hello_tab.rb
|
624
|
-
|
625
|
-
class HelloTab
|
626
|
-
include Glimmer
|
627
|
-
def launch
|
628
|
-
shell {
|
629
|
-
text "Hello, Tab!"
|
630
|
-
tab_folder {
|
631
|
-
tab_item {
|
632
|
-
text "English"
|
633
|
-
label {
|
634
|
-
text "Hello, World!"
|
635
|
-
}
|
636
|
-
}
|
637
|
-
tab_item {
|
638
|
-
text "French"
|
639
|
-
label {
|
640
|
-
text "Bonjour, Univers!"
|
641
|
-
}
|
642
|
-
}
|
643
|
-
}
|
644
|
-
}.open
|
645
|
-
end
|
646
|
-
end
|
647
|
-
|
648
|
-
HelloTab.new.launch
|
649
|
-
|
650
|
-
# # #
|
651
|
-
```
|
652
|
-
|
653
|
-
![Hello Tab English](images/glimmer-hello-tab-english.png)
|
654
|
-
|
655
|
-
#### Sample Code
|
656
|
-
|
657
|
-
You may output any sample code via this command: `glimmer sample:code[name]`
|
658
|
-
|
659
|
-
This is very similar to the sample run command, except the name is required.
|
660
|
-
|
661
|
-
It will not only output the main sample file, but any required supporting files as well.
|
662
|
-
|
663
|
-
Example:
|
664
|
-
|
575
|
+
glimmer samples
|
665
576
|
```
|
666
|
-
$ glimmer sample:code[tic_tac_toe]
|
667
|
-
|
668
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe.rb
|
669
|
-
|
670
|
-
require_relative "tic_tac_toe/board"
|
671
|
-
|
672
|
-
class TicTacToe
|
673
|
-
include Glimmer
|
674
|
-
|
675
|
-
def initialize
|
676
|
-
@tic_tac_toe_board = Board.new
|
677
|
-
@shell = shell {
|
678
|
-
text "Tic-Tac-Toe"
|
679
|
-
minimum_size 150, 178
|
680
|
-
composite {
|
681
|
-
grid_layout 3, true
|
682
|
-
(1..3).each { |row|
|
683
|
-
(1..3).each { |column|
|
684
|
-
button {
|
685
|
-
layout_data :fill, :fill, true, true
|
686
|
-
text bind(@tic_tac_toe_board[row, column], :sign)
|
687
|
-
enabled bind(@tic_tac_toe_board[row, column], :empty)
|
688
|
-
font style: :bold, height: 20
|
689
|
-
on_widget_selected {
|
690
|
-
@tic_tac_toe_board.mark(row, column)
|
691
|
-
}
|
692
|
-
}
|
693
|
-
}
|
694
|
-
}
|
695
|
-
}
|
696
|
-
}
|
697
|
-
observe(@tic_tac_toe_board, :game_status) { |game_status|
|
698
|
-
display_win_message if game_status == Board::WIN
|
699
|
-
display_draw_message if game_status == Board::DRAW
|
700
|
-
}
|
701
|
-
end
|
702
577
|
|
703
|
-
|
704
|
-
display_game_over_message("Player #{@tic_tac_toe_board.winning_sign} has won!")
|
705
|
-
end
|
578
|
+
This brings up the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
|
706
579
|
|
707
|
-
|
708
|
-
display_game_over_message("Draw!")
|
709
|
-
end
|
710
|
-
|
711
|
-
def display_game_over_message(message_text)
|
712
|
-
message_box(@shell) {
|
713
|
-
text 'Game Over'
|
714
|
-
message message_text
|
715
|
-
}.open
|
716
|
-
@tic_tac_toe_board.reset
|
717
|
-
end
|
718
|
-
|
719
|
-
def open
|
720
|
-
@shell.open
|
721
|
-
end
|
722
|
-
end
|
723
|
-
|
724
|
-
TicTacToe.new.open
|
725
|
-
|
726
|
-
# # #
|
727
|
-
|
728
|
-
|
729
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe/cell.rb
|
730
|
-
|
731
|
-
class TicTacToe
|
732
|
-
class Cell
|
733
|
-
EMPTY = ""
|
734
|
-
attr_accessor :sign, :empty
|
735
|
-
|
736
|
-
def initialize
|
737
|
-
reset
|
738
|
-
end
|
739
|
-
|
740
|
-
def mark(sign)
|
741
|
-
self.sign = sign
|
742
|
-
end
|
743
|
-
|
744
|
-
def reset
|
745
|
-
self.sign = EMPTY
|
746
|
-
end
|
747
|
-
|
748
|
-
def sign=(sign_symbol)
|
749
|
-
@sign = sign_symbol
|
750
|
-
self.empty = sign == EMPTY
|
751
|
-
end
|
752
|
-
|
753
|
-
def marked
|
754
|
-
!empty
|
755
|
-
end
|
756
|
-
end
|
757
|
-
end
|
758
|
-
|
759
|
-
# # #
|
760
|
-
|
761
|
-
|
762
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe/board.rb
|
763
|
-
|
764
|
-
require_relative 'cell'
|
765
|
-
|
766
|
-
class TicTacToe
|
767
|
-
class Board
|
768
|
-
DRAW = :draw
|
769
|
-
IN_PROGRESS = :in_progress
|
770
|
-
WIN = :win
|
771
|
-
attr :winning_sign
|
772
|
-
attr_accessor :game_status
|
773
|
-
|
774
|
-
def initialize
|
775
|
-
@sign_state_machine = {nil => "X", "X" => "O", "O" => "X"}
|
776
|
-
build_grid
|
777
|
-
@winning_sign = Cell::EMPTY
|
778
|
-
@game_status = IN_PROGRESS
|
779
|
-
end
|
780
|
-
|
781
|
-
#row and column numbers are 1-based
|
782
|
-
def mark(row, column)
|
783
|
-
self[row, column].mark(current_sign)
|
784
|
-
game_over? #updates winning sign
|
785
|
-
end
|
786
|
-
|
787
|
-
def current_sign
|
788
|
-
@current_sign = @sign_state_machine[@current_sign]
|
789
|
-
end
|
790
|
-
|
791
|
-
def [](row, column)
|
792
|
-
@grid[row-1][column-1]
|
793
|
-
end
|
794
|
-
|
795
|
-
def game_over?
|
796
|
-
win? or draw?
|
797
|
-
end
|
798
|
-
|
799
|
-
def win?
|
800
|
-
win = (row_win? or column_win? or diagonal_win?)
|
801
|
-
self.game_status=WIN if win
|
802
|
-
win
|
803
|
-
end
|
804
|
-
|
805
|
-
def reset
|
806
|
-
(1..3).each do |row|
|
807
|
-
(1..3).each do |column|
|
808
|
-
self[row, column].reset
|
809
|
-
end
|
810
|
-
end
|
811
|
-
@winning_sign = Cell::EMPTY
|
812
|
-
@current_sign = nil
|
813
|
-
self.game_status=IN_PROGRESS
|
814
|
-
end
|
815
|
-
|
816
|
-
private
|
817
|
-
|
818
|
-
def build_grid
|
819
|
-
@grid = []
|
820
|
-
3.times do |row_index| #0-based
|
821
|
-
@grid << []
|
822
|
-
3.times { @grid[row_index] << Cell.new }
|
823
|
-
end
|
824
|
-
end
|
825
|
-
|
826
|
-
def row_win?
|
827
|
-
(1..3).each do |row|
|
828
|
-
if row_has_same_sign(row)
|
829
|
-
@winning_sign = self[row, 1].sign
|
830
|
-
return true
|
831
|
-
end
|
832
|
-
end
|
833
|
-
false
|
834
|
-
end
|
835
|
-
|
836
|
-
def column_win?
|
837
|
-
(1..3).each do |column|
|
838
|
-
if column_has_same_sign(column)
|
839
|
-
@winning_sign = self[1, column].sign
|
840
|
-
return true
|
841
|
-
end
|
842
|
-
end
|
843
|
-
false
|
844
|
-
end
|
845
|
-
|
846
|
-
#needs refactoring if we ever decide to make the board size dynamic
|
847
|
-
def diagonal_win?
|
848
|
-
if (self[1, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[3, 3].sign) and self[1, 1].marked
|
849
|
-
@winning_sign = self[1, 1].sign
|
850
|
-
return true
|
851
|
-
end
|
852
|
-
if (self[3, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[1, 3].sign) and self[3, 1].marked
|
853
|
-
@winning_sign = self[3, 1].sign
|
854
|
-
return true
|
855
|
-
end
|
856
|
-
false
|
857
|
-
end
|
858
|
-
|
859
|
-
def draw?
|
860
|
-
@board_full = true
|
861
|
-
3.times do |x|
|
862
|
-
3.times do |y|
|
863
|
-
@board_full = false if self[x, y].empty
|
864
|
-
end
|
865
|
-
end
|
866
|
-
self.game_status = DRAW if @board_full
|
867
|
-
@board_full
|
868
|
-
end
|
869
|
-
|
870
|
-
def row_has_same_sign(number)
|
871
|
-
row_sign = self[number, 1].sign
|
872
|
-
[2, 3].each do |column|
|
873
|
-
return false unless row_sign == (self[number, column].sign)
|
874
|
-
end
|
875
|
-
true if self[number, 1].marked
|
876
|
-
end
|
877
|
-
|
878
|
-
def column_has_same_sign(number)
|
879
|
-
column_sign = self[1, number].sign
|
880
|
-
[2, 3].each do |row|
|
881
|
-
return false unless column_sign == (self[row, number].sign)
|
882
|
-
end
|
883
|
-
true if self[1, number].marked
|
884
|
-
end
|
885
|
-
|
886
|
-
end
|
887
|
-
end
|
888
|
-
|
889
|
-
# # #
|
890
|
-
```
|
580
|
+
![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
|
891
581
|
|
892
582
|
### Scaffolding
|
893
583
|
|
894
584
|
Glimmer borrows from Rails the idea of Scaffolding, that is generating a structure for your app files that
|
895
|
-
helps you get started just like true
|
585
|
+
helps you get started just like true building scaffolding helps construction workers, civil engineers, and architects.
|
896
586
|
|
897
587
|
Glimmer scaffolding goes beyond just scaffolding the app files that Rails does. It also packages it and launches it,
|
898
588
|
getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
|
@@ -908,7 +598,7 @@ letting Glimmer scaffolding take care of initial app file structure concerns, su
|
|
908
598
|
- Icon (under `package/{platform}/{App Name}.{icon_extension}` for `macosx` .icns, `windows` .ico, and `linux` .png)
|
909
599
|
- Bin file for starting application (`bin/{app_name}.rb`)
|
910
600
|
|
911
|
-
|
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.
|
912
602
|
|
913
603
|
#### App
|
914
604
|
|
@@ -920,7 +610,7 @@ To scaffold a Glimmer app from scratch, run the following command:
|
|
920
610
|
glimmer scaffold[AppName]
|
921
611
|
```
|
922
612
|
|
923
|
-
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.
|
924
614
|
|
925
615
|
Suppose you run:
|
926
616
|
|
@@ -978,12 +668,119 @@ And, here is the Windows version of the boilerplate Preferences dialog.
|
|
978
668
|
|
979
669
|
![Glimmer Scaffold App Windows Preferences](images/glimmer-scaffolding-app-windows-preferences.png)
|
980
670
|
|
981
|
-
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:
|
982
684
|
|
983
685
|
```
|
984
686
|
glimmer bin/greeter
|
985
687
|
```
|
986
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
|
+
|
987
784
|
#### Custom Shell
|
988
785
|
|
989
786
|
To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
|
@@ -1040,7 +837,7 @@ Only official Glimmer gems created by the Glimmer project committers will have n
|
|
1040
837
|
|
1041
838
|
Since custom shell gems are both an app and a gem, they provide two ways to run:
|
1042
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`)
|
1043
|
-
- 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.
|
1044
841
|
|
1045
842
|
Examples:
|
1046
843
|
|
@@ -1190,9 +987,9 @@ Output:
|
|
1190
987
|
Name Gem Version Author Description
|
1191
988
|
|
1192
989
|
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
|
1193
|
-
Opal glimmer-dsl-opal 0.
|
1194
|
-
Swt glimmer-dsl-swt 4.17.
|
1195
|
-
Tk glimmer-dsl-tk 0.0.
|
990
|
+
Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
|
991
|
+
Swt glimmer-dsl-swt 4.17.4.1 AndyMaleh Glimmer DSL for SWT
|
992
|
+
Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
|
1196
993
|
Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
|
1197
994
|
```
|
1198
995
|
|
@@ -1207,10 +1004,28 @@ On Linux, the Glimmer [Custom Shell Gem](#custom-shell-gem) approach provides a
|
|
1207
1004
|
### Raw JRuby Command
|
1208
1005
|
|
1209
1006
|
If there is a need to run Glimmer directly via the `jruby` command, you
|
1210
|
-
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:
|
1020
|
+
|
1021
|
+
```
|
1022
|
+
jruby -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
|
1023
|
+
```
|
1024
|
+
|
1025
|
+
Or, the following on Mac:
|
1211
1026
|
|
1212
1027
|
```
|
1213
|
-
jruby -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
|
1028
|
+
jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer-dsl-swt -S application.rb
|
1214
1029
|
```
|
1215
1030
|
|
1216
1031
|
The `-J-classpath` option specifies the `swt.jar` file path, which can be a
|
@@ -1228,7 +1043,7 @@ However, if there is a reason to use the raw `jruby` command directly instead of
|
|
1228
1043
|
|
1229
1044
|
Example:
|
1230
1045
|
```
|
1231
|
-
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
|
1232
1047
|
```
|
1233
1048
|
|
1234
1049
|
## Girb (Glimmer irb) Command
|
@@ -1312,19 +1127,21 @@ Glimmer DSL syntax consists mainly of:
|
|
1312
1127
|
|
1313
1128
|
### DSL Auto-Expansion
|
1314
1129
|
|
1315
|
-
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.
|
1316
1131
|
|
1317
1132
|
Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `display`, `message_box`, `async_exec`, `sync_exec`, and `bind`.
|
1318
1133
|
|
1319
|
-
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.
|
1320
1137
|
|
1321
|
-
|
1138
|
+
For example, if a project adds this custom Java SWT library from the [Nebula Project](https://www.eclipse.org/nebula/):
|
1322
1139
|
|
1323
|
-
|
1140
|
+
https://www.eclipse.org/nebula/widgets/gallery/gallery.php
|
1324
1141
|
|
1325
|
-
|
1142
|
+
Glimmer will automatically support using the keyword `gallery`
|
1326
1143
|
|
1327
|
-
|
1144
|
+
This is what DSL Auto-Expansion is.
|
1328
1145
|
|
1329
1146
|
You will learn more about widgets next.
|
1330
1147
|
|
@@ -1439,27 +1256,9 @@ shell {
|
|
1439
1256
|
|
1440
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.
|
1441
1258
|
|
1442
|
-
|
1443
|
-
|
1444
|
-
SWT Display is a singleton in Glimmer. It is used in SWT to represent your display device, allowing you to manage GUI globally
|
1445
|
-
and access available monitors.
|
1446
|
-
It is automatically instantiated upon first instantiation of a `shell` widget.
|
1447
|
-
Alternatively, for advanced use cases, it can be created explicitly with Glimmer `display` keyword. When a `shell` is later declared, it
|
1448
|
-
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:
|
1449
1260
|
|
1450
|
-
|
1451
|
-
@display = display {
|
1452
|
-
cursor_location 300, 300
|
1453
|
-
on_swt_keydown {
|
1454
|
-
# ...
|
1455
|
-
}
|
1456
|
-
# ...
|
1457
|
-
}
|
1458
|
-
@shell = shell { # uses display created above
|
1459
|
-
}
|
1460
|
-
```
|
1461
|
-
The benefit of instantiating an SWT Display explicitly is to set [Properties](#widget-properties) or [Observers](#observer).
|
1462
|
-
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/
|
1463
1262
|
|
1464
1263
|
#### SWT Proxies
|
1465
1264
|
|
@@ -1476,7 +1275,26 @@ Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT o
|
|
1476
1275
|
|
1477
1276
|
These proxy objects have an API and provide some convenience methods, some of which are mentioned below.
|
1478
1277
|
|
1479
|
-
#####
|
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
|
1480
1298
|
|
1481
1299
|
Glimmer allows re-opening any widget and adding properties or extra content after it has been constructed already by using the `#content` method.
|
1482
1300
|
|
@@ -1502,7 +1320,31 @@ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
|
1502
1320
|
@shell.open
|
1503
1321
|
```
|
1504
1322
|
|
1505
|
-
#####
|
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
|
1506
1348
|
|
1507
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.
|
1508
1350
|
|
@@ -1541,48 +1383,65 @@ message_box {
|
|
1541
1383
|
}.open
|
1542
1384
|
```
|
1543
1385
|
|
1544
|
-
|
1545
|
-
|
1546
|
-
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.
|
1547
|
-
|
1548
|
-
##### Shell widget proxy methods
|
1549
|
-
|
1550
|
-
Shell widget proxy has extra methods specific to SWT Shell:
|
1551
|
-
- `#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.
|
1552
|
-
- `#show`: Alias for `#open`
|
1553
|
-
- `#hide`: Hides a shell setting "visible" property to false
|
1554
|
-
- `#close`: Closes the shell
|
1555
|
-
- `#center`: Centers the shell within monitor it is in
|
1556
|
-
- `#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.
|
1557
|
-
- `#visible?`: Returns whether a shell is visible
|
1558
|
-
- `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
|
1559
|
-
- `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
|
1560
|
-
- `#pack`: Packs contained widgets using SWT's `Shell#pack` method
|
1561
|
-
- `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
|
1386
|
+
#### Display
|
1562
1387
|
|
1563
|
-
|
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.
|
1564
1390
|
|
1565
|
-
|
1391
|
+
`Display` is automatically instantiated upon first instantiation of a `shell` widget.
|
1566
1392
|
|
1567
|
-
|
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.
|
1568
1395
|
|
1569
1396
|
```ruby
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1397
|
+
@display = display {
|
1398
|
+
cursor_location 300, 300
|
1399
|
+
on_swt_keydown {
|
1400
|
+
# ...
|
1401
|
+
}
|
1573
1402
|
# ...
|
1574
1403
|
}
|
1404
|
+
@shell = shell { # uses display created above
|
1405
|
+
}
|
1575
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.
|
1576
1409
|
|
1577
|
-
|
1410
|
+
#### Multi-Threading
|
1578
1411
|
|
1579
|
-
|
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.
|
1580
1413
|
|
1581
|
-
|
1414
|
+
##### async_exec
|
1582
1415
|
|
1583
|
-
|
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.
|
1584
1417
|
|
1585
|
-
|
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.
|
1586
1445
|
|
1587
1446
|
#### Menus
|
1588
1447
|
|
@@ -1915,6 +1774,16 @@ Example:
|
|
1915
1774
|
@font = font(name: 'Arial', height: 36, style: :normal)
|
1916
1775
|
```
|
1917
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
|
+
|
1918
1787
|
### Cursor
|
1919
1788
|
|
1920
1789
|
SWT widget `cursor` property represents the mouse cursor you see on the screen when you hover over that widget.
|
@@ -2636,7 +2505,9 @@ end
|
|
2636
2505
|
|
2637
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`)
|
2638
2507
|
|
2639
|
-
|
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:
|
2640
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.
|
2641
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.
|
2642
2513
|
|
@@ -2666,7 +2537,6 @@ shell {
|
|
2666
2537
|
}.open
|
2667
2538
|
```
|
2668
2539
|
|
2669
|
-
|
2670
2540
|
##### Class-Based Custom Widget Example
|
2671
2541
|
|
2672
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 `__`)
|
@@ -2842,6 +2712,8 @@ Custom shells are a kind of custom widgets that have shells only as the body roo
|
|
2842
2712
|
|
2843
2713
|
They may also be chained in a wizard fashion.
|
2844
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
|
+
|
2845
2717
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
2846
2718
|
|
2847
2719
|
```ruby
|
@@ -3181,6 +3053,28 @@ shell(:no_resize) {
|
|
3181
3053
|
|
3182
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.
|
3183
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
|
+
|
3184
3078
|
#### Video Widget
|
3185
3079
|
|
3186
3080
|
[![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
|
@@ -3189,6 +3083,41 @@ Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-c
|
|
3189
3083
|
|
3190
3084
|
You may obtain via `glimmer-cw-video` gem.
|
3191
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
|
+
One noteworthy thing about the Glimmer implementation is that, unlike behavior in SWT, it allows declaring `weights` before the content of the `sash_form`, thus providing more natural and convenient syntax (Glimmer automatically takes care of sending that declaration to SWT at the end of declaring `sash_form` content as per the SWT requirements)
|
3093
|
+
|
3094
|
+
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
3095
|
+
|
3096
|
+
```ruby
|
3097
|
+
shell {
|
3098
|
+
text 'Sash Form Example'
|
3099
|
+
sash_form {
|
3100
|
+
label {
|
3101
|
+
text '(resize >>)'
|
3102
|
+
background :dark_green
|
3103
|
+
foreground :white
|
3104
|
+
font height: 20
|
3105
|
+
}
|
3106
|
+
label {
|
3107
|
+
text '(<< resize)'
|
3108
|
+
background :red
|
3109
|
+
foreground :white
|
3110
|
+
font height: 20
|
3111
|
+
}
|
3112
|
+
weights 1, 2
|
3113
|
+
}
|
3114
|
+
}.open
|
3115
|
+
```
|
3116
|
+
|
3117
|
+
You may check out a more full-fledged example in [Hello, Sash Form!](#hello-sash-form)
|
3118
|
+
|
3119
|
+
![Hello Sash Form](images/glimmer-hello-sash-form.png)
|
3120
|
+
|
3192
3121
|
#### Browser Widget
|
3193
3122
|
|
3194
3123
|
![Hello Browser](images/glimmer-hello-browser.png)
|
@@ -3461,16 +3390,32 @@ Here is an SWT Custom Widget guide:
|
|
3461
3390
|
|
3462
3391
|
https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
|
3463
3392
|
|
3393
|
+
Here is an SWT Image guide:
|
3394
|
+
|
3395
|
+
https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
|
3396
|
+
|
3397
|
+
Here is an SWT Graphics / Canvas-Drawing guide:
|
3398
|
+
|
3399
|
+
https://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html
|
3400
|
+
|
3401
|
+
Here is the Nebula Project (custom widget library) homepage:
|
3402
|
+
|
3403
|
+
https://www.eclipse.org/nebula/
|
3404
|
+
|
3464
3405
|
## Samples
|
3465
3406
|
|
3466
3407
|
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`).
|
3467
3408
|
|
3468
|
-
|
3409
|
+
You may run any sample via this command:
|
3469
3410
|
|
3470
3411
|
```
|
3471
|
-
samples
|
3412
|
+
glimmer samples
|
3472
3413
|
```
|
3473
3414
|
|
3415
|
+
This brings up the [Glimmer Meta-Sample (The Sample of Samples)](samples/elaborate/meta_sample.rb)
|
3416
|
+
|
3417
|
+
![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
|
3418
|
+
|
3474
3419
|
### Hello Samples
|
3475
3420
|
|
3476
3421
|
For hello-type simple samples, check the following.
|
@@ -3481,12 +3426,6 @@ Code:
|
|
3481
3426
|
|
3482
3427
|
[samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_world.rb)
|
3483
3428
|
|
3484
|
-
Run:
|
3485
|
-
|
3486
|
-
```
|
3487
|
-
glimmer sample:run[hello_world]
|
3488
|
-
```
|
3489
|
-
|
3490
3429
|
![Hello World](images/glimmer-hello-world.png)
|
3491
3430
|
|
3492
3431
|
#### Hello, Tab!
|
@@ -3495,12 +3434,6 @@ Code:
|
|
3495
3434
|
|
3496
3435
|
[samples/hello/hello_tab.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_tab.rb)
|
3497
3436
|
|
3498
|
-
Run:
|
3499
|
-
|
3500
|
-
```
|
3501
|
-
glimmer sample:run[hello_tab]
|
3502
|
-
```
|
3503
|
-
|
3504
3437
|
![Hello Tab English](images/glimmer-hello-tab-english.png)
|
3505
3438
|
![Hello Tab French](images/glimmer-hello-tab-french.png)
|
3506
3439
|
|
@@ -3512,12 +3445,6 @@ Code:
|
|
3512
3445
|
|
3513
3446
|
[samples/hello/hello_combo.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_combo.rb)
|
3514
3447
|
|
3515
|
-
Run:
|
3516
|
-
|
3517
|
-
```
|
3518
|
-
glimmer sample:run[hello_combo]
|
3519
|
-
```
|
3520
|
-
|
3521
3448
|
![Hello Combo](images/glimmer-hello-combo.png)
|
3522
3449
|
![Hello Combo Expanded](images/glimmer-hello-combo-expanded.png)
|
3523
3450
|
|
@@ -3529,12 +3456,6 @@ Code:
|
|
3529
3456
|
|
3530
3457
|
[samples/hello/hello_list_single_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_single_selection.rb)
|
3531
3458
|
|
3532
|
-
Run:
|
3533
|
-
|
3534
|
-
```
|
3535
|
-
glimmer sample:run[hello_list_single_selection]
|
3536
|
-
```
|
3537
|
-
|
3538
3459
|
![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
|
3539
3460
|
|
3540
3461
|
#### Hello, List Multi Selection!
|
@@ -3545,12 +3466,6 @@ Code:
|
|
3545
3466
|
|
3546
3467
|
[samples/hello/hello_list_multi_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_multi_selection.rb)
|
3547
3468
|
|
3548
|
-
Run:
|
3549
|
-
|
3550
|
-
```
|
3551
|
-
glimmer sample:run[hello_list_multi_selection]
|
3552
|
-
```
|
3553
|
-
|
3554
3469
|
![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
|
3555
3470
|
|
3556
3471
|
#### Hello, Computed!
|
@@ -3561,12 +3476,6 @@ Code:
|
|
3561
3476
|
|
3562
3477
|
[samples/hello/hello_computed.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_computed.rb)
|
3563
3478
|
|
3564
|
-
Run:
|
3565
|
-
|
3566
|
-
```
|
3567
|
-
glimmer sample:run[hello_computed]
|
3568
|
-
```
|
3569
|
-
|
3570
3479
|
![Hello Browser](images/glimmer-hello-computed.png)
|
3571
3480
|
|
3572
3481
|
#### Hello, Message Box!
|
@@ -3577,12 +3486,6 @@ Code:
|
|
3577
3486
|
|
3578
3487
|
[samples/hello/hello_message_box.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_message_box.rb)
|
3579
3488
|
|
3580
|
-
Run:
|
3581
|
-
|
3582
|
-
```
|
3583
|
-
glimmer sample:run[hello_message_box]
|
3584
|
-
```
|
3585
|
-
|
3586
3489
|
![Hello Message Box](images/glimmer-hello-message-box.png)
|
3587
3490
|
![Hello Message Box Dialog](images/glimmer-hello-message-box-dialog.png)
|
3588
3491
|
|
@@ -3594,12 +3497,6 @@ Code:
|
|
3594
3497
|
|
3595
3498
|
[samples/hello/hello_browser.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_browser.rb)
|
3596
3499
|
|
3597
|
-
Run:
|
3598
|
-
|
3599
|
-
```
|
3600
|
-
glimmer sample:run[hello_browser]
|
3601
|
-
```
|
3602
|
-
|
3603
3500
|
![Hello Browser](images/glimmer-hello-browser.png)
|
3604
3501
|
|
3605
3502
|
#### Hello, Drag and Drop!
|
@@ -3610,12 +3507,6 @@ Code:
|
|
3610
3507
|
|
3611
3508
|
[samples/hello/hello_drag_and_drop.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_drag_and_drop.rb)
|
3612
3509
|
|
3613
|
-
Run:
|
3614
|
-
|
3615
|
-
```
|
3616
|
-
glimmer sample:run[hello_drag_and_drop]
|
3617
|
-
```
|
3618
|
-
|
3619
3510
|
![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
|
3620
3511
|
|
3621
3512
|
#### Hello, Menu Bar!
|
@@ -3626,12 +3517,6 @@ Code:
|
|
3626
3517
|
|
3627
3518
|
[samples/hello/hello_menu_bar.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_menu_bar.rb)
|
3628
3519
|
|
3629
|
-
Run:
|
3630
|
-
|
3631
|
-
```
|
3632
|
-
glimmer sample:run[hello_menu_bar]
|
3633
|
-
```
|
3634
|
-
|
3635
3520
|
![Hello Menu Bar](images/glimmer-hello-menu-bar.png)
|
3636
3521
|
![Hello Menu Bar File Menu](images/glimmer-hello-menu-bar-file-menu.png)
|
3637
3522
|
![Hello Menu Bar History Menu](images/glimmer-hello-menu-bar-history-menu.png)
|
@@ -3644,12 +3529,6 @@ Code:
|
|
3644
3529
|
|
3645
3530
|
[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)
|
3646
3531
|
|
3647
|
-
Run:
|
3648
|
-
|
3649
|
-
```
|
3650
|
-
glimmer sample:run[hello_pop_up_context_menu]
|
3651
|
-
```
|
3652
|
-
|
3653
3532
|
![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
|
3654
3533
|
![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
|
3655
3534
|
|
@@ -3661,12 +3540,6 @@ Code:
|
|
3661
3540
|
|
3662
3541
|
[samples/hello/hello_custom_widget.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_widget.rb)
|
3663
3542
|
|
3664
|
-
Run:
|
3665
|
-
|
3666
|
-
```
|
3667
|
-
glimmer sample:run[hello_custom_widget]
|
3668
|
-
```
|
3669
|
-
|
3670
3543
|
![Hello Custom Widget](images/glimmer-hello-custom-widget.gif)
|
3671
3544
|
|
3672
3545
|
#### Hello, Custom Shell!
|
@@ -3677,17 +3550,43 @@ Code:
|
|
3677
3550
|
|
3678
3551
|
[samples/hello/hello_custom_shell.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_shell.rb)
|
3679
3552
|
|
3680
|
-
Run:
|
3681
|
-
|
3682
|
-
```
|
3683
|
-
glimmer sample:run[hello_custom_shell]
|
3684
|
-
```
|
3685
|
-
|
3686
3553
|
![Hello Custom Shell](images/glimmer-hello-custom-shell.png)
|
3687
3554
|
![Hello Custom Shell Email1](images/glimmer-hello-custom-shell-email1.png)
|
3688
3555
|
![Hello Custom Shell Email2](images/glimmer-hello-custom-shell-email2.png)
|
3689
3556
|
![Hello Custom Shell Email3](images/glimmer-hello-custom-shell-email3.png)
|
3690
3557
|
|
3558
|
+
#### Hello, Sash Form!
|
3559
|
+
|
3560
|
+
This sample demonstrates the use of a `sash_form` in Glimmer.
|
3561
|
+
|
3562
|
+
Code:
|
3563
|
+
|
3564
|
+
[samples/hello/hello_sash_form.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_sash_form.rb)
|
3565
|
+
|
3566
|
+
Hello, Sash Form! Horizontal Orientation
|
3567
|
+
|
3568
|
+
![Hello Sash Form](images/glimmer-hello-sash-form.png)
|
3569
|
+
|
3570
|
+
Hello, Sash Form! Resized
|
3571
|
+
|
3572
|
+
![Hello Sash Form Resized](images/glimmer-hello-sash-form-resized.png)
|
3573
|
+
|
3574
|
+
Hello, Sash Form! Sash Width Changed
|
3575
|
+
|
3576
|
+
![Hello Sash Form Sash Width Changed](images/glimmer-hello-sash-form-sash-width-changed.png)
|
3577
|
+
|
3578
|
+
Hello, Sash Form! Vertical Orientation
|
3579
|
+
|
3580
|
+
![Hello Sash Form Vertical](images/glimmer-hello-sash-form-vertical.png)
|
3581
|
+
|
3582
|
+
Hello, Sash Form! Green Label Maximized
|
3583
|
+
|
3584
|
+
![Hello Sash Form Green Maximized](images/glimmer-hello-sash-form-green-maximized.png)
|
3585
|
+
|
3586
|
+
Hello, Sash Form! Red Label Maximized
|
3587
|
+
|
3588
|
+
![Hello Sash Form Red Maximized](images/glimmer-hello-sash-form-red-maximized.png)
|
3589
|
+
|
3691
3590
|
### Elaborate Samples
|
3692
3591
|
|
3693
3592
|
For more elaborate samples, check the following:
|
@@ -3702,12 +3601,6 @@ Code:
|
|
3702
3601
|
|
3703
3602
|
[samples/elaborate/user_profile.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/user_profile.rb)
|
3704
3603
|
|
3705
|
-
Run:
|
3706
|
-
|
3707
|
-
```
|
3708
|
-
glimmer sample:run[user_profile]
|
3709
|
-
```
|
3710
|
-
|
3711
3604
|
![User Profile](images/glimmer-user-profile.png)
|
3712
3605
|
|
3713
3606
|
#### Login
|
@@ -3718,12 +3611,6 @@ Code:
|
|
3718
3611
|
|
3719
3612
|
[samples/elaborate/login.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/login.rb)
|
3720
3613
|
|
3721
|
-
Run:
|
3722
|
-
|
3723
|
-
```
|
3724
|
-
glimmer sample:run[login]
|
3725
|
-
```
|
3726
|
-
|
3727
3614
|
![Login](images/glimmer-login.png)
|
3728
3615
|
![Login Filled In](images/glimmer-login-filled-in.png)
|
3729
3616
|
![Login Logged In](images/glimmer-login-logged-in.png)
|
@@ -3738,12 +3625,6 @@ Code:
|
|
3738
3625
|
|
3739
3626
|
[samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/tic_tac_toe.rb)
|
3740
3627
|
|
3741
|
-
Run:
|
3742
|
-
|
3743
|
-
```
|
3744
|
-
glimmer sample:run[tic_tac_toe]
|
3745
|
-
```
|
3746
|
-
|
3747
3628
|
![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
|
3748
3629
|
![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
|
3749
3630
|
![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
|
@@ -3756,12 +3637,6 @@ Code:
|
|
3756
3637
|
|
3757
3638
|
[samples/elaborate/contact_manager.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/contact_manager.rb)
|
3758
3639
|
|
3759
|
-
Run:
|
3760
|
-
|
3761
|
-
```
|
3762
|
-
glimmer sample:run[contact_manager]
|
3763
|
-
```
|
3764
|
-
|
3765
3640
|
Contact Manager
|
3766
3641
|
|
3767
3642
|
![Contact Manager](images/glimmer-contact-manager.png)
|
@@ -3833,7 +3708,7 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
|
|
3833
3708
|
|
3834
3709
|
## Packaging & Distribution
|
3835
3710
|
|
3836
|
-
Note: this section mostly applies to Mac and Windows. On Linux,
|
3711
|
+
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)
|
3837
3712
|
|
3838
3713
|
Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
|
3839
3714
|
|
@@ -3859,7 +3734,7 @@ require 'glimmer/rake_task'
|
|
3859
3734
|
```
|
3860
3735
|
|
3861
3736
|
The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
|
3862
|
-
1. Generate gemspec via [Juwelier](https://rubygems.org/gems/juwelier) (`
|
3737
|
+
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.
|
3863
3738
|
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.
|
3864
3739
|
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.
|
3865
3740
|
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
|