glimmer-dsl-swt 4.17.2.3 → 4.17.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72abd42bfd0a4074ba03517643ae4f560cc892d1d592cefd9d96b7a4990195de
4
- data.tar.gz: 6479abb04a31e9bd5670a4de48c9c98a46f7b05783f4491082c4e0c127f5aa1c
3
+ metadata.gz: c47c4a09134e8146b6296480549750951211f3a54146d5c3b3136762bd5ee127
4
+ data.tar.gz: 6d6d3b1909b5dcc33102c50321b5f878b06489f807bea8259123c4c01b8547d8
5
5
  SHA512:
6
- metadata.gz: 46ecd1fbe2700184f8b3ea5f447cd7d3e2209a777080d40a787821edee1d65d7525e28befd96bd4ec5dbd48f646371810470eeef8777388d60bd6fce823da525
7
- data.tar.gz: 74ecccfa3cbb21712178fa695ddbd2eed4cb3cbb400aae3b3bf5b5dc5358ccba3ae2ff056d1992d7adfc0dcd173dcf77cf52a6f6e4ecabe961f5ece49c6b69d9
6
+ metadata.gz: 240ae88ff1b8fb6d34833e348dad32ce4c2d17aded1b0579c6955e00e50c399cdbffae1876655f5129079eeef062bad80eb36cacb3d4ff5840e17ae1436e9e4f
7
+ data.tar.gz: 007670d907089de08b83b48ec968b2394b7ecb4ac4c51156535666aa83ce32647a0ca42a508971058e94d993facfa4a331db6e7b8e44e926245e7b9c5be015f4
@@ -1,5 +1,52 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.4.2
4
+
5
+ - Support StyledText data-binding of caret_offset, selection_count, selection, top_index, and top_pixel, useful for code_text
6
+ - Support `width, height` hash options for ImageProxy and image properties on widgets
7
+ - Default SWT styles for tool_bar (:border) and tool_item (:push)
8
+
9
+ ### 4.17.4.1
10
+
11
+ - Optimize code_text line style listener algorithm or avoid setting code_text style via listener for performance reasons
12
+ - Optimize code_text syntax highlighting by not lexing except when content changes (e.g. during scrolling, do not lex)
13
+
14
+ ### 4.17.4.0
15
+
16
+ - Glimmer sample app to launch samples (sample of samples meta-sample)
17
+ - Syntax Color Highlighting in meta-sample
18
+ - Make sash_form weights accept splat array elements (not wrapped in [])
19
+ - 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)
20
+ - Replace dependency on tty-markdown gem with dependency on rouge gem instead
21
+ - Remove rake tasks `sample:list`, `sample:code` and `sample:run`
22
+ - Add rake task `samples` to point to the new Glimmer Meta-Sample
23
+ - Have meta-sample load samples from gems
24
+
25
+ ### 4.17.3.0
26
+
27
+ - `glimmer scaffold:desktopify[appname,website]` Mac
28
+ - `glimmer scaffold:desktopify[appname,website]` Windows
29
+ - `glimmer scaffold:desktopify[appname,website]` Linux (have scaffolding include the glimmer-cw-browser-chromium gem in scaffolded app on Linux)
30
+ - Remove the native packaging from Linux scaffolding since it is not officially supported
31
+ - Add gem packaging as part of scaffolding on Linux
32
+ - Launch the app at the end of scaffolding in Linux
33
+ - Provide a `glimmer package:gem` task
34
+ - 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
35
+ - Add a binary executable shell in "app" mode (just like "custom shell gem" mode)
36
+ - Have glimmer packaging check the Java version and give a warning if an unsupported version is used.
37
+
38
+
39
+ ### 4.17.2.4
40
+
41
+ - New `glimmer run` glimmer command task.
42
+ - Add built in support for handling jar file paths like that in ImageProxy code processing "uri:classloader" path
43
+ - Document that gif background_image only works without on_top and no_trim styles in Windows
44
+ - Give a good error message when Git is not properly setup for Glimmer Scaffolding
45
+ - Give an error message when attempting to scaffold over an already scaffolded directory
46
+ - Fix issue on Windows regarding use of the new EXPERIMENTAL Animated gif support in the `composite#background_image` property
47
+ - Fix SWTProxy.deconstruct method
48
+
49
+
3
50
  ### 4.17.2.3
4
51
 
5
52
  - Maintain image file path upon scaling an ImageProxy
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.2.3
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.2
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://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/).
13
+ [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces 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 sample:run[hello_world]
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 sample:run[tic_tac_toe]
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 sample:run[contact_manager]
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
- - [Sample List/Run/Code](#sample-listruncode)
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 Hook Example](#lifecycle-hook-example)
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.2.3
436
+ jgem install glimmer-dsl-swt -v 4.17.4.2
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 on the Mac, you can jump to the [Glimmer Scaffolding](https://github.com/AndyObtiva/glimmer#scaffolding) section next.
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
- Example:
495
+ Run Glimmer samples with:
496
+
491
497
  ```
492
- glimmer sample:run[hello_world]
498
+ glimmer samples
493
499
  ```
494
- This runs the Glimmer "Hello, World!" sample.
500
+ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](#samples)
495
501
 
496
- If you cloned this project locally, you may run `bin/glimmer` instead.
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 sample:run[hello_world]
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.2.3
514
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.4.2
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
 
@@ -538,9 +544,8 @@ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and
538
544
  glimmer package:jar # Generate JAR file
539
545
  glimmer package:lock_jars # Lock JARs
540
546
  glimmer package:native[type] # Generate Native files
541
- glimmer sample:code[name] # Outputs code for a Glimmer internal sample [included in gem] (name is required)
542
- glimmer sample:list[query] # Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)
543
- 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
544
549
  glimmer scaffold[app_name] # Scaffold Glimmer application directory structure to build a new app
545
550
  glimmer scaffold:customshell[name,namespace] # Scaffold Glimmer::UI::CustomShell subclass (full window view) under app/views (namespace is optional) [alt: scaffold:cs]
546
551
  glimmer scaffold:customwidget[name,namespace] # Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cw]
@@ -562,338 +567,22 @@ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
562
567
 
563
568
  Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
564
569
 
565
- ### Sample List/Run/Code
566
-
567
- #### Sample List
570
+ ### Glimmer Samples
568
571
 
569
572
  You can list available Glimmer samples by running:
570
573
 
571
574
  ```
572
- glimmer sample:list
573
- ```
574
-
575
- This should output the following (providing the name of each sample, description, and command to run the sample and view its code):
576
-
577
- ```
578
- $ glimmer sample:list
579
-
580
- Glimmer Hello Samples:
581
-
582
- Name Description Run
583
-
584
- hello_browser Hello Browser glimmer sample:run[hello_browser]
585
- hello_combo Hello Combo glimmer sample:run[hello_combo]
586
- hello_computed Hello Computed glimmer sample:run[hello_computed]
587
- hello_drag_and_drop Hello Drag And Drop glimmer sample:run[hello_drag_and_drop]
588
- hello_list_multi_selection Hello List Multi Selection glimmer sample:run[hello_list_multi_selection]
589
- hello_list_single_selection Hello List Single Selection glimmer sample:run[hello_list_single_selection]
590
- hello_menu_bar Hello Menu Bar glimmer sample:run[hello_menu_bar]
591
- hello_message_box Hello Message Box glimmer sample:run[hello_message_box]
592
- hello_pop_up_context_menu Hello Pop Up Context Menu glimmer sample:run[hello_pop_up_context_menu]
593
- hello_tab Hello Tab glimmer sample:run[hello_tab]
594
- hello_world Hello World glimmer sample:run[hello_world]
595
-
596
-
597
- Glimmer Elaborate Samples:
598
-
599
- Name Description Run
600
-
601
- contact_manager Contact Manager glimmer sample:run[contact_manager]
602
- login Login glimmer sample:run[login]
603
- tic_tac_toe Tic Tac Toe glimmer sample:run[tic_tac_toe]
604
- user_profile User Profile glimmer sample:run[user_profile]
605
- ```
606
-
607
- #### Sample Run
608
-
609
- 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.
610
-
611
- If the sample name is left empty (e.g. `glimmer sample:run`), then all samples are run.
612
-
613
- Example:
614
-
615
- ```
616
- glimmer sample:run[hello_tab]
617
- ```
618
-
619
- This will run the hello_tab sample and output its code:
620
-
621
- ```
622
- $ glimmer sample:run[hello_tab]
623
-
624
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/hello/hello_tab.rb
625
-
626
- class HelloTab
627
- include Glimmer
628
- def launch
629
- shell {
630
- text "Hello, Tab!"
631
- tab_folder {
632
- tab_item {
633
- text "English"
634
- label {
635
- text "Hello, World!"
636
- }
637
- }
638
- tab_item {
639
- text "French"
640
- label {
641
- text "Bonjour, Univers!"
642
- }
643
- }
644
- }
645
- }.open
646
- end
647
- end
648
-
649
- HelloTab.new.launch
650
-
651
- # # #
652
- ```
653
-
654
- ![Hello Tab English](images/glimmer-hello-tab-english.png)
655
-
656
- #### Sample Code
657
-
658
- You may output any sample code via this command: `glimmer sample:code[name]`
659
-
660
- This is very similar to the sample run command, except the name is required.
661
-
662
- It will not only output the main sample file, but any required supporting files as well.
663
-
664
- Example:
665
-
575
+ glimmer samples
666
576
  ```
667
- $ glimmer sample:code[tic_tac_toe]
668
-
669
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/elaborate/tic_tac_toe.rb
670
-
671
- require_relative "tic_tac_toe/board"
672
-
673
- class TicTacToe
674
- include Glimmer
675
-
676
- def initialize
677
- @tic_tac_toe_board = Board.new
678
- @shell = shell {
679
- text "Tic-Tac-Toe"
680
- minimum_size 150, 178
681
- composite {
682
- grid_layout 3, true
683
- (1..3).each { |row|
684
- (1..3).each { |column|
685
- button {
686
- layout_data :fill, :fill, true, true
687
- text bind(@tic_tac_toe_board[row, column], :sign)
688
- enabled bind(@tic_tac_toe_board[row, column], :empty)
689
- font style: :bold, height: 20
690
- on_widget_selected {
691
- @tic_tac_toe_board.mark(row, column)
692
- }
693
- }
694
- }
695
- }
696
- }
697
- }
698
- observe(@tic_tac_toe_board, :game_status) { |game_status|
699
- display_win_message if game_status == Board::WIN
700
- display_draw_message if game_status == Board::DRAW
701
- }
702
- end
703
-
704
- def display_win_message
705
- display_game_over_message("Player #{@tic_tac_toe_board.winning_sign} has won!")
706
- end
707
-
708
- def display_draw_message
709
- display_game_over_message("Draw!")
710
- end
711
-
712
- def display_game_over_message(message_text)
713
- message_box(@shell) {
714
- text 'Game Over'
715
- message message_text
716
- }.open
717
- @tic_tac_toe_board.reset
718
- end
719
-
720
- def open
721
- @shell.open
722
- end
723
- end
724
-
725
- TicTacToe.new.open
726
-
727
- # # #
728
-
729
-
730
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/elaborate/tic_tac_toe/cell.rb
731
-
732
- class TicTacToe
733
- class Cell
734
- EMPTY = ""
735
- attr_accessor :sign, :empty
736
-
737
- def initialize
738
- reset
739
- end
740
-
741
- def mark(sign)
742
- self.sign = sign
743
- end
744
-
745
- def reset
746
- self.sign = EMPTY
747
- end
748
-
749
- def sign=(sign_symbol)
750
- @sign = sign_symbol
751
- self.empty = sign == EMPTY
752
- end
753
-
754
- def marked
755
- !empty
756
- end
757
- end
758
- end
759
-
760
- # # #
761
-
762
-
763
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/elaborate/tic_tac_toe/board.rb
764
577
 
765
- require_relative 'cell'
766
-
767
- class TicTacToe
768
- class Board
769
- DRAW = :draw
770
- IN_PROGRESS = :in_progress
771
- WIN = :win
772
- attr :winning_sign
773
- attr_accessor :game_status
774
-
775
- def initialize
776
- @sign_state_machine = {nil => "X", "X" => "O", "O" => "X"}
777
- build_grid
778
- @winning_sign = Cell::EMPTY
779
- @game_status = IN_PROGRESS
780
- end
781
-
782
- #row and column numbers are 1-based
783
- def mark(row, column)
784
- self[row, column].mark(current_sign)
785
- game_over? #updates winning sign
786
- end
787
-
788
- def current_sign
789
- @current_sign = @sign_state_machine[@current_sign]
790
- end
791
-
792
- def [](row, column)
793
- @grid[row-1][column-1]
794
- end
795
-
796
- def game_over?
797
- win? or draw?
798
- end
799
-
800
- def win?
801
- win = (row_win? or column_win? or diagonal_win?)
802
- self.game_status=WIN if win
803
- win
804
- end
805
-
806
- def reset
807
- (1..3).each do |row|
808
- (1..3).each do |column|
809
- self[row, column].reset
810
- end
811
- end
812
- @winning_sign = Cell::EMPTY
813
- @current_sign = nil
814
- self.game_status=IN_PROGRESS
815
- end
816
-
817
- private
818
-
819
- def build_grid
820
- @grid = []
821
- 3.times do |row_index| #0-based
822
- @grid << []
823
- 3.times { @grid[row_index] << Cell.new }
824
- end
825
- end
826
-
827
- def row_win?
828
- (1..3).each do |row|
829
- if row_has_same_sign(row)
830
- @winning_sign = self[row, 1].sign
831
- return true
832
- end
833
- end
834
- false
835
- end
836
-
837
- def column_win?
838
- (1..3).each do |column|
839
- if column_has_same_sign(column)
840
- @winning_sign = self[1, column].sign
841
- return true
842
- end
843
- end
844
- false
845
- end
846
-
847
- #needs refactoring if we ever decide to make the board size dynamic
848
- def diagonal_win?
849
- if (self[1, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[3, 3].sign) and self[1, 1].marked
850
- @winning_sign = self[1, 1].sign
851
- return true
852
- end
853
- if (self[3, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[1, 3].sign) and self[3, 1].marked
854
- @winning_sign = self[3, 1].sign
855
- return true
856
- end
857
- false
858
- end
859
-
860
- def draw?
861
- @board_full = true
862
- 3.times do |x|
863
- 3.times do |y|
864
- @board_full = false if self[x, y].empty
865
- end
866
- end
867
- self.game_status = DRAW if @board_full
868
- @board_full
869
- end
870
-
871
- def row_has_same_sign(number)
872
- row_sign = self[number, 1].sign
873
- [2, 3].each do |column|
874
- return false unless row_sign == (self[number, column].sign)
875
- end
876
- true if self[number, 1].marked
877
- end
878
-
879
- def column_has_same_sign(number)
880
- column_sign = self[1, number].sign
881
- [2, 3].each do |row|
882
- return false unless column_sign == (self[row, number].sign)
883
- end
884
- true if self[1, number].marked
885
- end
886
-
887
- end
888
- end
578
+ This brings up the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
889
579
 
890
- # # #
891
- ```
580
+ ![Glimmer Meta-Sample](images/glimmer-meta-sample.png)
892
581
 
893
582
  ### Scaffolding
894
583
 
895
584
  Glimmer borrows from Rails the idea of Scaffolding, that is generating a structure for your app files that
896
- helps you get started just like true buildinThis g scaffolding helps construction workers, civil engineers, and architects.
585
+ helps you get started just like true building scaffolding helps construction workers, civil engineers, and architects.
897
586
 
898
587
  Glimmer scaffolding goes beyond just scaffolding the app files that Rails does. It also packages it and launches it,
899
588
  getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
@@ -909,7 +598,7 @@ letting Glimmer scaffolding take care of initial app file structure concerns, su
909
598
  - Icon (under `package/{platform}/{App Name}.{icon_extension}` for `macosx` .icns, `windows` .ico, and `linux` .png)
910
599
  - Bin file for starting application (`bin/{app_name}.rb`)
911
600
 
912
- NOTE: Scaffolding supports Mac and Windows packaging at the moment.
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.
913
602
 
914
603
  #### App
915
604
 
@@ -921,7 +610,7 @@ To scaffold a Glimmer app from scratch, run the following command:
921
610
  glimmer scaffold[AppName]
922
611
  ```
923
612
 
924
- This will generate an advanced "Hello, World!" app, package it as a Mac native file (DMG/PKG/APP), and launch it all in one fell swoop.
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.
925
614
 
926
615
  Suppose you run:
927
616
 
@@ -979,12 +668,119 @@ And, here is the Windows version of the boilerplate Preferences dialog.
979
668
 
980
669
  ![Glimmer Scaffold App Windows Preferences](images/glimmer-scaffolding-app-windows-preferences.png)
981
670
 
982
- In order to run the app after making changes, you must run the `glimmer` command and pass it the generated script under the `bin` directory as an argument:
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:
983
684
 
984
685
  ```
985
686
  glimmer bin/greeter
986
687
  ```
987
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
+
988
784
  #### Custom Shell
989
785
 
990
786
  To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
@@ -1191,9 +987,9 @@ Output:
1191
987
  Name Gem Version Author Description
1192
988
 
1193
989
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1194
- Opal glimmer-dsl-opal 0.3.0 AndyMaleh Glimmer DSL for Opal
1195
- Swt glimmer-dsl-swt 4.17.2.3 AndyMaleh Glimmer DSL for SWT
1196
- Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
990
+ Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
991
+ Swt glimmer-dsl-swt 4.17.4.2 AndyMaleh Glimmer DSL for SWT
992
+ Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
1197
993
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
1198
994
  ```
1199
995
 
@@ -1464,28 +1260,6 @@ If you are advanced and need more widgets, check out the [Nebula Project](https:
1464
1260
 
1465
1261
  https://www.eclipse.org/nebula/
1466
1262
 
1467
- #### Display
1468
-
1469
- SWT Display is a singleton in Glimmer. It is used in SWT to represent your display device, allowing you to manage GUI globally
1470
- and access available monitors.
1471
- It is automatically instantiated upon first instantiation of a `shell` widget.
1472
- Alternatively, for advanced use cases, it can be created explicitly with Glimmer `display` keyword. When a `shell` is later declared, it
1473
- automatically uses the display created earlier without having to explicitly hook it.
1474
-
1475
- ```ruby
1476
- @display = display {
1477
- cursor_location 300, 300
1478
- on_swt_keydown {
1479
- # ...
1480
- }
1481
- # ...
1482
- }
1483
- @shell = shell { # uses display created above
1484
- }
1485
- ```
1486
- The benefit of instantiating an SWT Display explicitly is to set [Properties](#widget-properties) or [Observers](#observer).
1487
- Although SWT Display is not technically a widget, it has similar APIs in SWT and similar DSL support in Glimmer.
1488
-
1489
1263
  #### SWT Proxies
1490
1264
 
1491
1265
  Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT objects:
@@ -1501,7 +1275,26 @@ Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT o
1501
1275
 
1502
1276
  These proxy objects have an API and provide some convenience methods, some of which are mentioned below.
1503
1277
 
1504
- ##### `#content { ... }`
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
1505
1298
 
1506
1299
  Glimmer allows re-opening any widget and adding properties or extra content after it has been constructed already by using the `#content` method.
1507
1300
 
@@ -1527,7 +1320,31 @@ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1527
1320
  @shell.open
1528
1321
  ```
1529
1322
 
1530
- ##### `message_box`
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
1531
1348
 
1532
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.
1533
1350
 
@@ -1566,48 +1383,65 @@ message_box {
1566
1383
  }.open
1567
1384
  ```
1568
1385
 
1569
- ##### `#swt_widget`
1570
-
1571
- 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.
1572
-
1573
- ##### Shell widget proxy methods
1574
-
1575
- Shell widget proxy has extra methods specific to SWT Shell:
1576
- - `#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.
1577
- - `#show`: Alias for `#open`
1578
- - `#hide`: Hides a shell setting "visible" property to false
1579
- - `#close`: Closes the shell
1580
- - `#center`: Centers the shell within monitor it is in
1581
- - `#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.
1582
- - `#visible?`: Returns whether a shell is visible
1583
- - `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
1584
- - `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
1585
- - `#pack`: Packs contained widgets using SWT's `Shell#pack` method
1586
- - `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
1386
+ #### Display
1587
1387
 
1588
- ##### Shell Icon
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.
1589
1390
 
1590
- 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)
1391
+ `Display` is automatically instantiated upon first instantiation of a `shell` widget.
1591
1392
 
1592
- Example:
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.
1593
1395
 
1594
1396
  ```ruby
1595
- shell {
1596
- # ...
1597
- image 'path/to/image.png'
1397
+ @display = display {
1398
+ cursor_location 300, 300
1399
+ on_swt_keydown {
1400
+ # ...
1401
+ }
1598
1402
  # ...
1599
1403
  }
1404
+ @shell = shell { # uses display created above
1405
+ }
1600
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.
1601
1409
 
1602
- ###### Shell Icon Tip for Packaging on Windows
1410
+ #### Multi-Threading
1603
1411
 
1604
- 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'`)
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.
1605
1413
 
1606
- #### Dialog
1414
+ ##### async_exec
1607
1415
 
1608
- 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.
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.
1609
1417
 
1610
- 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.
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.
1611
1445
 
1612
1446
  #### Menus
1613
1447
 
@@ -1940,6 +1774,16 @@ Example:
1940
1774
  @font = font(name: 'Arial', height: 36, style: :normal)
1941
1775
  ```
1942
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
+
1943
1787
  ### Cursor
1944
1788
 
1945
1789
  SWT widget `cursor` property represents the mouse cursor you see on the screen when you hover over that widget.
@@ -2663,7 +2507,7 @@ Custom widgets are brand new Glimmer DSL keywords that represent aggregates of e
2663
2507
 
2664
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
2665
2509
 
2666
- Glimmer supports two ways of creating custom widgets with minimal code:
2510
+ Glimmer supports three ways of creating custom widgets with minimal code:
2667
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.
2668
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.
2669
2513
 
@@ -2693,7 +2537,6 @@ shell {
2693
2537
  }.open
2694
2538
  ```
2695
2539
 
2696
-
2697
2540
  ##### Class-Based Custom Widget Example
2698
2541
 
2699
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 `__`)
@@ -3210,6 +3053,28 @@ shell(:no_resize) {
3210
3053
 
3211
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.
3212
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
+
3213
3078
  #### Video Widget
3214
3079
 
3215
3080
  [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
@@ -3218,6 +3083,41 @@ Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-c
3218
3083
 
3219
3084
  You may obtain via `glimmer-cw-video` gem.
3220
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
+
3221
3121
  #### Browser Widget
3222
3122
 
3223
3123
  ![Hello Browser](images/glimmer-hello-browser.png)
@@ -3490,6 +3390,14 @@ Here is an SWT Custom Widget guide:
3490
3390
 
3491
3391
  https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
3492
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
+
3493
3401
  Here is the Nebula Project (custom widget library) homepage:
3494
3402
 
3495
3403
  https://www.eclipse.org/nebula/
@@ -3498,12 +3406,16 @@ https://www.eclipse.org/nebula/
3498
3406
 
3499
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`).
3500
3408
 
3501
- If you cloned the project and followed [CONTRIBUTING.md](CONTRIBUTING.md) instructions, you may run all samples in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) at once via `samples/launch` command:
3409
+ You may run any sample via this command:
3502
3410
 
3503
3411
  ```
3504
- samples/launch
3412
+ glimmer samples
3505
3413
  ```
3506
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
+
3507
3419
  ### Hello Samples
3508
3420
 
3509
3421
  For hello-type simple samples, check the following.
@@ -3514,12 +3426,6 @@ Code:
3514
3426
 
3515
3427
  [samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_world.rb)
3516
3428
 
3517
- Run:
3518
-
3519
- ```
3520
- glimmer sample:run[hello_world]
3521
- ```
3522
-
3523
3429
  ![Hello World](images/glimmer-hello-world.png)
3524
3430
 
3525
3431
  #### Hello, Tab!
@@ -3528,12 +3434,6 @@ Code:
3528
3434
 
3529
3435
  [samples/hello/hello_tab.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_tab.rb)
3530
3436
 
3531
- Run:
3532
-
3533
- ```
3534
- glimmer sample:run[hello_tab]
3535
- ```
3536
-
3537
3437
  ![Hello Tab English](images/glimmer-hello-tab-english.png)
3538
3438
  ![Hello Tab French](images/glimmer-hello-tab-french.png)
3539
3439
 
@@ -3545,12 +3445,6 @@ Code:
3545
3445
 
3546
3446
  [samples/hello/hello_combo.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_combo.rb)
3547
3447
 
3548
- Run:
3549
-
3550
- ```
3551
- glimmer sample:run[hello_combo]
3552
- ```
3553
-
3554
3448
  ![Hello Combo](images/glimmer-hello-combo.png)
3555
3449
  ![Hello Combo Expanded](images/glimmer-hello-combo-expanded.png)
3556
3450
 
@@ -3562,12 +3456,6 @@ Code:
3562
3456
 
3563
3457
  [samples/hello/hello_list_single_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_single_selection.rb)
3564
3458
 
3565
- Run:
3566
-
3567
- ```
3568
- glimmer sample:run[hello_list_single_selection]
3569
- ```
3570
-
3571
3459
  ![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
3572
3460
 
3573
3461
  #### Hello, List Multi Selection!
@@ -3578,12 +3466,6 @@ Code:
3578
3466
 
3579
3467
  [samples/hello/hello_list_multi_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_multi_selection.rb)
3580
3468
 
3581
- Run:
3582
-
3583
- ```
3584
- glimmer sample:run[hello_list_multi_selection]
3585
- ```
3586
-
3587
3469
  ![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
3588
3470
 
3589
3471
  #### Hello, Computed!
@@ -3594,12 +3476,6 @@ Code:
3594
3476
 
3595
3477
  [samples/hello/hello_computed.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_computed.rb)
3596
3478
 
3597
- Run:
3598
-
3599
- ```
3600
- glimmer sample:run[hello_computed]
3601
- ```
3602
-
3603
3479
  ![Hello Browser](images/glimmer-hello-computed.png)
3604
3480
 
3605
3481
  #### Hello, Message Box!
@@ -3610,12 +3486,6 @@ Code:
3610
3486
 
3611
3487
  [samples/hello/hello_message_box.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_message_box.rb)
3612
3488
 
3613
- Run:
3614
-
3615
- ```
3616
- glimmer sample:run[hello_message_box]
3617
- ```
3618
-
3619
3489
  ![Hello Message Box](images/glimmer-hello-message-box.png)
3620
3490
  ![Hello Message Box Dialog](images/glimmer-hello-message-box-dialog.png)
3621
3491
 
@@ -3627,12 +3497,6 @@ Code:
3627
3497
 
3628
3498
  [samples/hello/hello_browser.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_browser.rb)
3629
3499
 
3630
- Run:
3631
-
3632
- ```
3633
- glimmer sample:run[hello_browser]
3634
- ```
3635
-
3636
3500
  ![Hello Browser](images/glimmer-hello-browser.png)
3637
3501
 
3638
3502
  #### Hello, Drag and Drop!
@@ -3643,12 +3507,6 @@ Code:
3643
3507
 
3644
3508
  [samples/hello/hello_drag_and_drop.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_drag_and_drop.rb)
3645
3509
 
3646
- Run:
3647
-
3648
- ```
3649
- glimmer sample:run[hello_drag_and_drop]
3650
- ```
3651
-
3652
3510
  ![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
3653
3511
 
3654
3512
  #### Hello, Menu Bar!
@@ -3659,12 +3517,6 @@ Code:
3659
3517
 
3660
3518
  [samples/hello/hello_menu_bar.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_menu_bar.rb)
3661
3519
 
3662
- Run:
3663
-
3664
- ```
3665
- glimmer sample:run[hello_menu_bar]
3666
- ```
3667
-
3668
3520
  ![Hello Menu Bar](images/glimmer-hello-menu-bar.png)
3669
3521
  ![Hello Menu Bar File Menu](images/glimmer-hello-menu-bar-file-menu.png)
3670
3522
  ![Hello Menu Bar History Menu](images/glimmer-hello-menu-bar-history-menu.png)
@@ -3677,12 +3529,6 @@ Code:
3677
3529
 
3678
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)
3679
3531
 
3680
- Run:
3681
-
3682
- ```
3683
- glimmer sample:run[hello_pop_up_context_menu]
3684
- ```
3685
-
3686
3532
  ![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
3687
3533
  ![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
3688
3534
 
@@ -3694,12 +3540,6 @@ Code:
3694
3540
 
3695
3541
  [samples/hello/hello_custom_widget.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_widget.rb)
3696
3542
 
3697
- Run:
3698
-
3699
- ```
3700
- glimmer sample:run[hello_custom_widget]
3701
- ```
3702
-
3703
3543
  ![Hello Custom Widget](images/glimmer-hello-custom-widget.gif)
3704
3544
 
3705
3545
  #### Hello, Custom Shell!
@@ -3710,17 +3550,43 @@ Code:
3710
3550
 
3711
3551
  [samples/hello/hello_custom_shell.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_shell.rb)
3712
3552
 
3713
- Run:
3714
-
3715
- ```
3716
- glimmer sample:run[hello_custom_shell]
3717
- ```
3718
-
3719
3553
  ![Hello Custom Shell](images/glimmer-hello-custom-shell.png)
3720
3554
  ![Hello Custom Shell Email1](images/glimmer-hello-custom-shell-email1.png)
3721
3555
  ![Hello Custom Shell Email2](images/glimmer-hello-custom-shell-email2.png)
3722
3556
  ![Hello Custom Shell Email3](images/glimmer-hello-custom-shell-email3.png)
3723
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
+
3724
3590
  ### Elaborate Samples
3725
3591
 
3726
3592
  For more elaborate samples, check the following:
@@ -3735,12 +3601,6 @@ Code:
3735
3601
 
3736
3602
  [samples/elaborate/user_profile.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/user_profile.rb)
3737
3603
 
3738
- Run:
3739
-
3740
- ```
3741
- glimmer sample:run[user_profile]
3742
- ```
3743
-
3744
3604
  ![User Profile](images/glimmer-user-profile.png)
3745
3605
 
3746
3606
  #### Login
@@ -3751,12 +3611,6 @@ Code:
3751
3611
 
3752
3612
  [samples/elaborate/login.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/login.rb)
3753
3613
 
3754
- Run:
3755
-
3756
- ```
3757
- glimmer sample:run[login]
3758
- ```
3759
-
3760
3614
  ![Login](images/glimmer-login.png)
3761
3615
  ![Login Filled In](images/glimmer-login-filled-in.png)
3762
3616
  ![Login Logged In](images/glimmer-login-logged-in.png)
@@ -3771,12 +3625,6 @@ Code:
3771
3625
 
3772
3626
  [samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/tic_tac_toe.rb)
3773
3627
 
3774
- Run:
3775
-
3776
- ```
3777
- glimmer sample:run[tic_tac_toe]
3778
- ```
3779
-
3780
3628
  ![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
3781
3629
  ![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
3782
3630
  ![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
@@ -3789,12 +3637,6 @@ Code:
3789
3637
 
3790
3638
  [samples/elaborate/contact_manager.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/contact_manager.rb)
3791
3639
 
3792
- Run:
3793
-
3794
- ```
3795
- glimmer sample:run[contact_manager]
3796
- ```
3797
-
3798
3640
  Contact Manager
3799
3641
 
3800
3642
  ![Contact Manager](images/glimmer-contact-manager.png)
@@ -3866,7 +3708,7 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
3866
3708
 
3867
3709
  ## Packaging & Distribution
3868
3710
 
3869
- Note: this section mostly applies to Mac and Windows. 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)
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)
3870
3712
 
3871
3713
  Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
3872
3714
 
@@ -3892,8 +3734,8 @@ require 'glimmer/rake_task'
3892
3734
  ```
3893
3735
 
3894
3736
  The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
3895
- 1. Generate gemspec via [Juwelier](https://rubygems.org/gems/juwelier) (`rake gemspec:generate`): 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.
3896
- 1. Lock JAR versions (`glimmer package:4.17.2.3`): 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.
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.
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.
3897
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.
3898
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
3899
3741
  1. Generate native executable using [javapackager](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html) (`glimmer package:native`): Enables packaging a JAR file as a DMG/PKG/APP file on Mac, MSI/EXE/APP on Windows, and DEB/RPM/APP on Linux (Glimmer does not officially support Linux with the `glimmer package` command yet, but it generates the JAR file successfully, and you could use `javapackager` manually afterwards if needed).