glimmer-dsl-swt 4.21.0.0 → 4.21.2.0

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: 5cdb03595910fbb0a4e8a6e40262aea904904063f08e8cf6144bb5569408fc60
4
- data.tar.gz: efe9220cb985da71aa1c27efc914cdd9d71d21a0466adad994d0e751c3063219
3
+ metadata.gz: 06baa33f2bcb64eee399561cbc5b92ea160d677462b690d36746816385d5c81a
4
+ data.tar.gz: de77d266007ed06d74ff5f28374167561f6989620d3293ab0597bc006b7e1af3
5
5
  SHA512:
6
- metadata.gz: 516f678f951f896a4421f1dbb46bb6b7c5e2c53713892627e6c3d51f097f74f50328d82582a04c33db786cdf6c71a7de0afc89299f34262b8e5af99b18e2429c
7
- data.tar.gz: 11ce0f19287bc04ff2f1824896400d8ed90061a738960d8495131245ebefdd9e1dfd04868f4a8ef4a9ada9a7c16654a5f035a6d92a88bbf8296c23f832bbb892
6
+ metadata.gz: 4a16bdc52e1fa03b29f602b163e170d00acddd9858a438dbedff4d60895521f3b9597b5bca920a2bc8b657854772ee79c367b95e2433545c954975ab3fb81f17
7
+ data.tar.gz: 3a414799220cf1257a5c8c5af278e924a547a54ba17c6c201dfde25dcdf3f91f522ee42326e35ce3b34e00a1b039d2e9604aa400dda1457f1ddcea65d3cd922b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.21.2.0
4
+
5
+ - Support Linux packaging into deb/rpm native executables (not just gems) through standard `glimmer package` call (e.g. `glimmer package[deb]` or `glimmer package[rpm]`)
6
+ - Update `Glimmer::SWT::ImageProxy` implementation of image loading from JAR to use `JRuby.runtime.jruby_class_loader.get_resource_as_stream(file_path).to_io.to_input_stream`
7
+ - Remove scaffolding/packaging building/using of a generated Java `Resource` class
8
+ - Force installing `gem 'psych', '3.3.2'` in scaffolded app as a temporary workaround to `psych` issues with the latest jruby (jruby-9.3.1.0)
9
+
10
+ ### 4.21.1.1
11
+
12
+ - Fix samples for Windows, espcially Hello, Cool Bar!, Hello, Tool Bar!, and Weather
13
+ - Fix down button for Tetris on Windows/Linux
14
+ - Fix pause menu item for Tetris
15
+
16
+ ### 4.21.1.0
17
+
18
+ - Upgrade to jruby 9.3.1.0
19
+ - Upgrade to glimmer 2.4.0 (with better observing of array of arrays nested changes)
20
+ - Minor sample fixes for Linux: Tetris (down button now works), Hello, Scale! (now fits horizontally), and Hello, Slider! (now fits horizontally)
21
+ - Adjusted minimum size of Meta-Sample to allow more shrinking (`minimum_size 640, 384`)
22
+ - Do not clean observers when disposing of a widget while closing the last shell (e.g. when closing an app, it is not needed to clean observers, so it is better to exit faster)
23
+
24
+ ### 4.21.0.1
25
+
26
+ - Updated default width for `shell` to `190` (was `130` before)
27
+
3
28
  ### 4.21.0.0
4
29
 
5
30
  - Upgrade to SWT 4.21
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.21.0.0
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.21.2.0
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -10,12 +10,12 @@
10
10
 
11
11
  **(The Original Glimmer Library Handling the World’s Ruby GUI Needs Since 2007. Beware of Imitators!)**
12
12
 
13
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) 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), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gems](docs/reference/GLIMMER_COMMAND.md#packaging) on [Linux](https://www.linux.org/). [Glimmer](https://github.com/AndyObtiva/glimmer) was the [first Ruby gem](https://rubygems.org/gems/glimmer) to bring [SWT](https://www.eclipse.org/swt/) (Standard Widget Toolkit) to [Ruby](https://www.ruby-lang.org/en/), thanks to creator [Andy Maleh](https://andymaleh.blogspot.com/), EclipseCon/EclipseWorld/RubyConf speaker.
13
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) 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), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and DEB/RPM files on [Linux](https://www.linux.org/). [Glimmer](https://github.com/AndyObtiva/glimmer) was the [first Ruby gem](https://rubygems.org/gems/glimmer) to bring [SWT](https://www.eclipse.org/swt/) (Standard Widget Toolkit) to [Ruby](https://www.ruby-lang.org/en/), thanks to creator [Andy Maleh](https://andymaleh.blogspot.com/), EclipseCon/EclipseWorld/RubyConf speaker.
14
14
 
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.21.0.0 includes [SWT 4.21](https://download.eclipse.org/eclipse/downloads/drops4/R-4.21-202109060500/), which was released on September 6, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.21.2.0 includes [SWT 4.21](https://download.eclipse.org/eclipse/downloads/drops4/R-4.21-202109060500/), which was released on September 6, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
19
19
 
20
20
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
@@ -290,7 +290,7 @@ https://www.eclipse.org/swt/faq.php
290
290
 
291
291
  ## Pre-requisites
292
292
 
293
- - JDK 16 (16.0.2) (find at https://www.oracle.com/java/technologies/downloads/#java16 / On Windows, ensure PATH includes Java bin directory for jpackage to work during packaging Glimmer applications)
293
+ - JDK 16 (16.0.2) (find at https://www.oracle.com/java/technologies/javase/jdk16-archive-downloads.html / Ensure PATH includes Java bin directory for `jpackage` command to work when packaging Glimmer applications)
294
294
  - [RVM](http://rvm.io) on Mac & Linux (not available on Windows)
295
295
  - JRuby 9.3.0.0 (supporting Ruby 2.6.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.3.0.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download) [you might have to dual-install JDK8 temporarily as it might be required by jruby installer and then switch JAVA_HOME to JDK16 once done installing and restart command prompt/git bash])
296
296
  - SWT 4.21 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem). Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested with Glimmer DSL for SWT yet, so it is considered experimental until declared otherwise.
@@ -322,7 +322,7 @@ jgem install glimmer-dsl-swt
322
322
 
323
323
  Or this command if you want a specific version:
324
324
  ```
325
- jgem install glimmer-dsl-swt -v 4.21.0.0
325
+ jgem install glimmer-dsl-swt -v 4.21.2.0
326
326
  ```
327
327
 
328
328
  `jgem` is JRuby's version of `gem` command.
@@ -350,7 +350,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
350
350
 
351
351
  Add the following to `Gemfile`:
352
352
  ```
353
- gem 'glimmer-dsl-swt', '~> 4.21.0.0'
353
+ gem 'glimmer-dsl-swt', '~> 4.21.2.0'
354
354
  ```
355
355
 
356
356
  And, then run:
@@ -371,7 +371,7 @@ glimmer
371
371
  ```
372
372
 
373
373
  ```
374
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.21.0.0
374
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.21.2.0
375
375
 
376
376
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
377
377
 
@@ -535,6 +535,10 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
535
535
 
536
536
  [<img alt="Connector Logo" src="https://raw.githubusercontent.com/AndyObtiva/dcr/f31cd45a8503051e899ed8e831fd03654d38e418/package/linux/Draw%20Color%20Repeat.png" height=40 /> Draw Color Repeat](https://github.com/AndyObtiva/dcr): A young boy programming language for Drawing and Coloring with Repetition
537
537
 
538
+ ### Befunge 98 Programming Language
539
+
540
+ [Befunge 98 GUI](https://github.com/AndyObtiva/befunge98/tree/gui)
541
+
538
542
  ## Packaging & Distribution
539
543
 
540
544
  Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single command:
@@ -672,7 +676,8 @@ You may apply for contributing to any of these Glimmer DSL gems whether you pref
672
676
  ## Contributors
673
677
 
674
678
  * [Andy Maleh](https://github.com/AndyObtiva) (Founder)
675
- * [Dennis Theisen](https://github.com/Soleone) (Contributor, originally in [Glimmer](https://github.com/AndyObtiva/glimmer/graphs/contributors) before splitting glimmer-dsl-swt)
679
+ * [Dennis Theisen](https://github.com/Soleone) (Contributor, originally in [Glimmer](https://github.com/AndyObtiva/glimmer/graphs/contributors) before splitting [glimmer-dsl-swt](https://rubygems.org/gems/glimmer))
680
+ * [Wayne Vucenic](https://github.com/rubycoder)
676
681
 
677
682
  [Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-swt/graphs/contributors)
678
683
 
data/RUBY_VERSION CHANGED
@@ -1 +1 @@
1
- jruby-9.3.0.0
1
+ jruby-9.3.1.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.21.0.0
1
+ 4.21.2.0
@@ -213,7 +213,7 @@ In order to run the app after making changes, you must run the `glimmer run`. It
213
213
  glimmer run
214
214
  ```
215
215
 
216
- Alternatively, to mantually run the app, you may type:
216
+ Alternatively, to manually run the app, you may type:
217
217
 
218
218
  ```
219
219
  glimmer run[bin/greeter]
@@ -1270,6 +1270,17 @@ It is a graphics `Image` object (not a widget), but is used used in setting the
1270
1270
 
1271
1271
  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
1272
1272
 
1273
+ When an app is packaged (i.e. JAR inside a DMG or MSI native executable), jruby generates file paths that start with "uri:classloader". The `image` keyword automatically knows how to interpret such paths when passed as an argument.
1274
+
1275
+ Should you need to read a file from a JAR file manually, you may use this code (assuming a `file_path` formed using standard Ruby `File.expand_path` call, which jruby automatically overrides when running from a JAR to generate a `uri:classloader` path) :
1276
+ ```ruby
1277
+ require 'jruby'
1278
+ file_path = file_path.sub(/^uri\:classloader\:/, '').sub(/^\/+/, '')
1279
+ jcl = JRuby.runtime.jruby_class_loader
1280
+ resource = jcl.get_resource_as_stream(file_path)
1281
+ file_input_stream = resource.to_io.to_input_stream
1282
+ ```
1283
+
1273
1284
  Learn more about images in general at this SWT Image guide: https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
1274
1285
 
1275
1286
  #### Image Options
@@ -2383,8 +2394,6 @@ Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you
2383
2394
 
2384
2395
  #### Shine
2385
2396
 
2386
- **(BETA FEATURE)**
2387
-
2388
2397
  The new Shine syntax for View/Model Attribute Mapping allows data-binding visually with simple arrow operators in Ruby.
2389
2398
 
2390
2399
  Use `<=> [model, attribute, options]` for bidirectional (two-way) data-binding instead of `bind(model, attribute, options)`.
@@ -3872,7 +3881,7 @@ class Example
3872
3881
  text 'Application Menu Items'
3873
3882
  font height: 30
3874
3883
  }
3875
- }
3884
+ }
3876
3885
  }
3877
3886
  end
3878
3887
 
@@ -1,16 +1,12 @@
1
1
  ## Glimmer Packaging and Distribution
2
2
 
3
- Note: this section mostly applies to Mac and Windows. On Linux, you can just run `glimmer package:gem` and after installing the gem, you get an executable matching the name of the app/custom-shell-gem you are building (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem). On Windows, ensure system PATH includes Java bin directory `"C:\Program Files\Java\jdk-16.0.2\bin"` at the top for `jpackage` command to work during packaging Glimmer applications.
4
-
5
- Note 2: Glimmer packaging has a strong dependency on JDK16 since it includes the packaging tool `jpackage`.
6
-
7
- Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
3
+ Glimmer simplifies the process of native-executable packaging and distribution on Mac, Windows, and Linux via a single `glimmer package` command:
8
4
 
9
5
  ```
10
6
  glimmer package
11
7
  ```
12
8
 
13
- It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating default packaging type on the current platform if not specified (i.e. `app-image`) and displaying a message indicating what pre-requisite setup tools are needed if not installed already (e.g. [Wix Toolset](https://wixtoolset.org/) to generate MSI files on Windows). If you install Wix, make sure it is on the system PATH by adding for example "C:\Program Files (x86)\WiX Toolset v3.11\bin" to the Windows Environment Variables.
9
+ It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating default packaging type on the current platform if not specified (i.e. `app-image`) and displaying a message indicating what pre-requisite setup tools are needed if not installed already (e.g. [Wix Toolset](https://wixtoolset.org/) to generate MSI files on Windows. If you install Wix, make sure it is on the system PATH by adding for example "C:\Program Files (x86)\WiX Toolset v3.11\bin" to the Windows Environment Variables.).
14
10
 
15
11
  You may choose to generate a specific type of packaging instead by addionally passing in the `[type]` option. For example, this generates an MSI setup file on Windows:
16
12
 
@@ -18,7 +14,7 @@ You may choose to generate a specific type of packaging instead by addionally pa
18
14
  glimmer package[msi]
19
15
  ```
20
16
 
21
- This generates a DMG file on the Mac:
17
+ This command generates a DMG file on the Mac:
22
18
 
23
19
  ```
24
20
  glimmer package[dmg]
@@ -30,11 +26,23 @@ Make sure to surround with double-quotes when running from ZShell (zsh):
30
26
  glimmer "package[dmg]"
31
27
  ```
32
28
 
29
+ This command generates a DEB file on a Linux that supports deb packages (e.g. Linux Mint Cinnamon):
30
+
31
+ ```
32
+ glimmer package[deb]
33
+ ```
34
+
33
35
  - Available Mac packaging types are `dmg`, `pkg`, and `app-image` (image means a pure Mac `app` without a setup program). Keep in mind that the packages you produce are compatible with the same MacOS you are on or older.
34
36
  - Available Windows packaging types are `msi`, `exe`, and `app-image` (image means a Windows application directory without a setup program). Learn more about Windows packaging are [over here](#windows-application-packaging).
35
- - Available Linux packaging types are `deb`, `rpm`, and `app-image` (Note: Linux native packaging has not been tested successfully, which is why `glimmer package:gem` is recommended on Linux instead. If you get it working, please contribute to this doc file with a Pull Request).
37
+ - Available Linux packaging types are `deb`, `rpm`, and `app-image` (note the prerequisites: for Red Hat Linux, the `rpm-build` package is required (for rpm) and for Ubuntu Linux, the `fakeroot` package is required (for deb). Also, use common sense to know which package type to generate on what Linux [e.g. use `deb` on `Linux Mint Cinnamon` or use `rpm` on `Fedora Linux`]).
38
+
39
+ Note 1: On Windows, ensure system environment PATH includes Java bin directory `"C:\Program Files\Java\jdk-16.0.2\bin"` at the top for `jpackage` command to work during packaging Glimmer applications (the default Oracle setup path for Java after installing the JDK is usually not sufficient).
40
+
41
+ Note 2: Glimmer packaging has a strong dependency on JDK16 since it includes the packaging tool `jpackage`. On the Mac, it seems there is a new gotcha in the latest JDK 16 DMG/PKG installable that is resulting in `jpackage` to be missing from `PATH`. To include, you might need to add `export PATH="/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home/bin:$PATH"` to `~/.zprofile` or `~/.bashrc`
36
42
 
37
- Note: if you are using Glimmer manually, to make the `glimmer package` command available, you must add the following line to your application `Rakefile` (automatically done for you if you scaffold an app or gem with `glimmer scaffold[AppName]` or `glimmer scaffold:gem:customshell[GemName]`):
43
+ Note 3: On Linux, note the prerequisites: for Red Hat Linux, the `rpm-build` package is required (for rpm) and for Ubuntu Linux, the `fakeroot` package is required (for deb). Also, use common sense to know which package type to generate on what Linux (e.g. use `deb` on `Linux Mint Cinnamon` or use `rpm` on `Fedora Linux`)
44
+
45
+ Note 4: if you are using Glimmer packaging with a manually generated app (without scaffolding), in order to make the `glimmer package` command available, you must add the following line to your application `Rakefile` (automatically done for you if you scaffold an app or gem with `glimmer scaffold[AppName]` or `glimmer scaffold:gem:customshell[GemName]`):
38
46
 
39
47
  ```ruby
40
48
  require 'glimmer/rake_task'
@@ -45,7 +53,7 @@ The Glimmer packaging process done in the `glimmer package` command consists of
45
53
  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.
46
54
  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.
47
55
  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
48
- 1. Generate native executable using [jpackage](https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf) (`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 `jpackage` manually afterwards if needed).
56
+ 1. Generate native executable using [jpackage](https://docs.oracle.com/en/java/javase/16/jpackage/packaging-tool-user-guide.pdf) (`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 `jpackage` manually afterwards if needed).
49
57
 
50
58
  Those steps automatically ensure generating a JAR file under the `./dist` directory using [Warbler](https://github.com/jruby/warbler), which is then used to automatically generate a DMG/MSI file (and other executables) under the `./packages/bundles` directory using `jpackage`.
51
59
  The JAR file name will match your application local directory name (e.g. `MathBowling.jar` for `~/code/MathBowling`)
@@ -88,7 +96,7 @@ require_relative '../app/my_application.rb'
88
96
 
89
97
  In order to explicitly configure jpackage, Mac package attributes, or sign your Mac app to distribute on the App Store, you can follow more advanced instructions for `jpackage` here:
90
98
  - Run `jpackage --help` for more info
91
- - https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf
99
+ - https://docs.oracle.com/en/java/javase/16/jpackage/packaging-tool-user-guide.pdf
92
100
  - https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
93
101
 
94
102
  The Glimmer rake task allows passing extra options to jpackage via:
@@ -117,17 +125,17 @@ Pass `-v` to jpackage in `Glimmer::RakeTask::Package.jpackage_extra_args` or by
117
125
 
118
126
  ### Windows Application Packaging
119
127
 
120
- Windows s two options for setup packaging:
128
+ Windows offers two options for packaging:
121
129
  - `msi` (recommended): simpler packaging option. Requires [WiX Toolset](https://wixtoolset.org/) and [.NET Framework](https://dotnet.microsoft.com/download/dotnet-framework). Simply run `glimmer package[msi]` (or `glimmer package:native[msi]` if it's not your first time) and it will give you more details on the pre-requisites you need to install (e.g. [WiX Toolset](https://wixtoolset.org/) and [.NET Framework 3.5 SP1](https://dotnet.microsoft.com/download/dotnet-framework/net35-sp1)).
122
130
  - `exe`: more advanced packaging option. Requires [Inno Setup](https://jrsoftware.org/isinfo.php). Simply run `glimmer package[exe]` (or `glimmer package:native[exe]` if it's not your first time) and it will tell you what you need to install.
123
131
 
124
- If you just want to test out packaging into a native Windows app that is not packaged for Windows setup, just pass `image` to generate a native Windows app only.
132
+ If you just want to test out packaging into a native Windows app that is not packaged for Windows setup, just pass `app-image` (default) to generate a native Windows app only.
125
133
 
126
134
  ### Mac Application Distribution
127
135
 
128
136
  Recent macOS versions (starting with Catalina) have very stringent security requirements requiring all applications to be signed before running (unless the user goes to System Preferences -> Privacy -> General tab and clicks "Open Anyway" after failing to open application the first time they run it). So, to release a desktop application on the Mac, it is recommended to enroll in the [Apple Developer Program](https://developer.apple.com/programs/) to distribute on the [Mac App Store](https://developer.apple.com/distribute/) or otherwise request [app notarization from Apple](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution) to distribute independently.
129
137
 
130
- Afterwards, you may add signing arguments to `jpackage` via `Glimmer::RakeTask::Package.jpackage_extra_args` or `JPACKAGE_EXTRA_ARGS` according to this webpage: https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf
138
+ Afterwards, you may add signing arguments to `jpackage` via `Glimmer::RakeTask::Package.jpackage_extra_args` or `JPACKAGE_EXTRA_ARGS` according to this webpage: https://docs.oracle.com/en/java/javase/16/jpackage/packaging-tool-user-guide.pdf
131
139
 
132
140
  ```
133
141
  --mac-package-signing-prefix <prefix string>
@@ -180,6 +188,12 @@ org.apache.maven.InternalErrorException: Internal error: org.jruby.exceptions.Ra
180
188
  Caused by: org.jruby.exceptions.RaiseException: (LoadError) library `java' could not be loaded: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @138caeca
181
189
  [ERROR]
182
190
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
191
+ ```
192
+
193
+ 3. jpackage missing from PATH on the Mac
194
+
195
+ On the Mac, the latest JDK 16 installable DMG/PKG is resulting in `jpackage` to be missing from `PATH`. To include, you might need to add `export PATH="/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home/bin:$PATH"` to `~/.zprofile` or `~/.bashrc`
196
+ ```
183
197
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
184
198
  [ERROR]
185
199
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
@@ -188,7 +202,7 @@ Caused by: org.jruby.exceptions.RaiseException: (LoadError) library `java' could
188
202
 
189
203
  Please ignore. It should be harmless. If you get blocked by it for any reason, please open an Issue about it.
190
204
 
191
- 3. Java on Windows System PATH
205
+ 4. Java on Windows System PATH
192
206
 
193
207
  If you get any errors running Java on Windows, keep in mind that you need to have the Java binaries "C:\Program Files\Java\jdk-16.0.2\bin" on the Windows System PATH environment variable.
194
208
 
@@ -198,3 +212,21 @@ The problem is Oracle seems to be adding an indirect Java path junction in later
198
212
  Simply replace it with the simple path mentioned above (`"C:\Program Files\Java\jdk-16.0.2\bin"` matching your correct version number)
199
213
 
200
214
  Lastly, reinstall JRuby to ensure it is using Java from the right path.
215
+
216
+ 5. File paths in app running from packaged JAR file
217
+
218
+ Glimmer packaged apps always reside within a JAR file before being wrapped by a native executable.
219
+
220
+ JRuby automatically converts any paths produced by File.expand_path inside packaged JAR file into uri:classloader prefixed paths. They work just fine when performing File.read, but if you need to access as a Java input stream, you need to use special code:
221
+
222
+ ```ruby
223
+ require 'jruby'
224
+ file_path = File.expand_path(some_path, __dir__)
225
+ file_path = file_path.sub(/^uri\:classloader\:/, '').sub(/^\/+/, '')
226
+ jcl = JRuby.runtime.jruby_class_loader
227
+ resource = jcl.get_resource_as_stream(file_path)
228
+ file_input_stream = resource.to_io.to_input_stream
229
+ ```
230
+
231
+ The `image` keyword in Glimmer automatically does that work when passing an image path produced from inside a JAR file.
232
+
Binary file
@@ -40,7 +40,7 @@ module Glimmer
40
40
  SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
41
41
  if @widget.respond_to?(:on_widget_disposed)
42
42
  @widget.on_widget_disposed do |dispose_event|
43
- unregister_all_observables
43
+ deregister_all_observables unless @widget.shell_proxy.last_shell_closing?
44
44
  end
45
45
  end
46
46
  end
@@ -49,7 +49,7 @@ module Glimmer
49
49
  def call(value)
50
50
  SWT::DisplayProxy.instance.auto_exec(override_sync_exec: @sync_exec, override_async_exec: @async_exec) do
51
51
  if @widget.respond_to?(:disposed?) && @widget.disposed?
52
- unregister_all_observables
52
+ deregister_all_observables
53
53
  return
54
54
  end
55
55
  # need the rescue false for a scenario with tree items not being equal to model objects raising an exception
@@ -61,7 +61,7 @@ module Glimmer
61
61
 
62
62
  def evaluate_property
63
63
  if @widget.respond_to?(:disposed?) && @widget.disposed?
64
- unregister_all_observables
64
+ deregister_all_observables
65
65
  return
66
66
  end
67
67
  @widget.get_attribute(@property)
@@ -112,7 +112,7 @@ module Glimmer
112
112
  FileUtils.mkdir_p('packages/bundles')
113
113
  command = "jpackage"
114
114
  command += " --type #{native_type}"
115
- command += " --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar '#{project_name}.jar' --java-options '-Dproject_name=#{project_name}' --name '#{human_name}' --vendor '#{human_name}' --icon '#{icon}' "
115
+ command += " --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar '#{project_name}.jar' --name '#{human_name}' --vendor '#{human_name}' --icon '#{icon}' "
116
116
  command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows? && native_type != 'app-image'
117
117
  command += " --linux-menu-group '#{human_name}' " if OS.linux? && native_type != 'app-image'
118
118
  command += " --java-options '-XstartOnFirstThread' --mac-package-name '#{human_name}' --mac-package-identifier 'org.#{project_name}.application.#{project_name}' " if OS.mac?
@@ -116,10 +116,12 @@ module Glimmer
116
116
  GEMFILE_APP_MIDFIX = <<~MULTI_LINE_STRING
117
117
 
118
118
  gem 'glimmer-dsl-swt', '~> #{VERSION}'
119
+ gem 'psych', '3.3.2' # Fixed temporarily because installing latest on JDK16 was causing issues
119
120
  MULTI_LINE_STRING
120
121
  GEMFILE_GEM_MIDFIX = <<~MULTI_LINE_STRING
121
122
 
122
123
  gem 'glimmer-dsl-swt', '~> #{VERSION.split('.')[0...2].join('.')}'
124
+ gem 'psych', '3.3.2' # Fixed temporarily because installing latest on JDK16 was causing issues
123
125
  MULTI_LINE_STRING
124
126
  GEMFILE_SUFFIX = <<~MULTI_LINE_STRING
125
127
 
@@ -182,11 +184,6 @@ module Glimmer
182
184
  cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
183
185
  puts "Created #{current_dir_name}/#{icon_file}"
184
186
 
185
- write "Resource.java", resource_java_file(app_name)
186
- cd '..'
187
- system "javac #{file_name(app_name)}/Resource.java"
188
- cd gem_name
189
-
190
187
  mkdir_p "app/#{file_name(app_name)}"
191
188
  write "app/#{file_name(app_name)}/launch.rb", app_launch_file(app_name)
192
189
  mkdir_p 'bin'
@@ -298,11 +295,6 @@ module Glimmer
298
295
  cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
299
296
  puts "Created #{current_dir_name}/#{icon_file}"
300
297
 
301
- write "Resource.java", resource_java_file(custom_shell_name)
302
- cd '..'
303
- system "javac #{file_name(custom_shell_name)}/Resource.java"
304
- cd gem_name
305
-
306
298
  if OS.windows?
307
299
  system "glimmer package" # TODO handle windows properly with batch file
308
300
  system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
@@ -496,16 +488,6 @@ module Glimmer
496
488
  MULTI_LINE_STRING
497
489
  end
498
490
 
499
- def resource_java_file(app_name)
500
- <<~MULTI_LINE_STRING
501
- package #{file_name(app_name)};
502
-
503
- /** The soul purpose of this class is to retrieve icons for uri:classloader paths used from JAR */
504
- class Resource {
505
- }
506
- MULTI_LINE_STRING
507
- end
508
-
509
491
  def app_bin_command_file(app_name_or_gem_name, custom_shell_name=nil, namespace=nil)
510
492
  if custom_shell_name.nil?
511
493
  runner = "File.expand_path('../../app/#{file_name(app_name_or_gem_name)}/launch.rb', __FILE__)"
@@ -545,7 +527,7 @@ module Glimmer
545
527
  lines.insert(require_rake_line_index, "require 'glimmer/launcher'")
546
528
  gem_files_line_index = lines.index(lines.detect {|l| l.include?('# dependencies defined in Gemfile') })
547
529
  if custom_shell_name
548
- lines.insert(gem_files_line_index, " gem.files = Dir['Resource.class', 'VERSION', 'LICENSE.txt', 'app/**/*', 'bin/**/*', 'config/**/*', 'db/**/*', 'docs/**/*', 'fonts/**/*', 'icons/**/*', 'images/**/*', 'lib/**/*', 'script/**/*', 'sounds/**/*', 'vendor/**/*', 'videos/**/*']")
530
+ lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'app/**/*', 'bin/**/*', 'config/**/*', 'db/**/*', 'docs/**/*', 'fonts/**/*', 'icons/**/*', 'images/**/*', 'lib/**/*', 'script/**/*', 'sounds/**/*', 'vendor/**/*', 'videos/**/*']")
549
531
  # the second executable is needed for warbler as it matches the gem name, which is the default expected file (alternatively in the future, we could do away with it and configure warbler to use the other file)
550
532
  lines.insert(gem_files_line_index+1, " gem.require_paths = ['vendor', 'lib', 'app']")
551
533
  lines.insert(gem_files_line_index+2, " gem.executables = ['#{file_name(custom_shell_name)}']") if custom_shell_name
@@ -561,7 +543,7 @@ module Glimmer
561
543
  Glimmer::RakeTask::Package.jpackage_extra_args =
562
544
  " --name '#{human_name(custom_shell_name)}'" +
563
545
  " --description '#{human_name(custom_shell_name)}'"
564
- # You can add more options from https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf
546
+ # You can add more options from https://docs.oracle.com/en/java/javase/16/jpackage/packaging-tool-user-guide.pdf
565
547
  MULTI_LINE_STRING
566
548
  end
567
549
  file_content
@@ -111,11 +111,7 @@ namespace :glimmer do
111
111
  Rake::Task['glimmer:package:lock_jars'].execute
112
112
  Rake::Task['glimmer:package:config'].execute
113
113
  Rake::Task['glimmer:package:jar'].execute
114
- if OS.linux?
115
- Rake::Task['glimmer:package:gem'].execute
116
- else
117
- Rake::Task['glimmer:package:native'].execute(args)
118
- end
114
+ Rake::Task['glimmer:package:native'].execute(args)
119
115
  end
120
116
 
121
117
  desc 'Scaffold Glimmer application directory structure to build a new app'
@@ -122,9 +122,11 @@ module Glimmer
122
122
  def input_stream
123
123
  if @file_path.start_with?('uri:classloader')
124
124
  @jar_file_path = @file_path
125
- file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '') # the latter sub is needed for Mac
126
- project_name = java.lang.System.getProperty('project_name')
127
- file_input_stream = java_import("#{project_name}.Resource").last.java_class.resource_as_stream(file_path)
125
+ file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub(/^\/+/, '')
126
+ require 'jruby'
127
+ jcl = JRuby.runtime.jruby_class_loader
128
+ resource = jcl.get_resource_as_stream(file_path)
129
+ file_input_stream = resource.to_io.to_input_stream
128
130
  else
129
131
  file_input_stream = java.io.FileInputStream.new(@file_path)
130
132
  end
@@ -32,10 +32,11 @@ module Glimmer
32
32
  include_package 'org.eclipse.swt.widgets'
33
33
  include_package 'org.eclipse.swt.layout'
34
34
 
35
- WIDTH_MIN = 130
35
+ WIDTH_MIN = 190
36
36
  HEIGHT_MIN = 0
37
37
 
38
- attr_reader :opened_before
38
+ attr_reader :opened_before, :last_shell_closing
39
+ alias last_shell_closing? last_shell_closing
39
40
  alias opened_before? opened_before
40
41
 
41
42
  # Instantiates ShellProxy with same arguments expected by SWT Shell
@@ -85,9 +86,10 @@ module Glimmer
85
86
  end
86
87
  end
87
88
  end
88
- on_widget_disposed {
89
+ on_widget_disposed do
90
+ @last_shell_closing = true if @display.shells.count == 1 && @display.shells.first == @swt_widget
89
91
  clear_shapes
90
- }
92
+ end
91
93
  @display ||= @swt_widget.getDisplay
92
94
  end
93
95
  end
@@ -198,6 +198,10 @@ module Glimmer
198
198
  @finished_add_content = true
199
199
  end
200
200
 
201
+ def shell_proxy
202
+ @swt_widget.shell.get_data('proxy')
203
+ end
204
+
201
205
  def extract_args(underscored_widget_name, args)
202
206
  @arg_extractor_mapping ||= {
203
207
  'menu_item' => lambda do |args|
@@ -45,21 +45,21 @@ class Battleship
45
45
  }
46
46
 
47
47
  text player.to_s.capitalize
48
- font height: 20, style: :bold
48
+ font height: OS.windows? ? 18 : 20, style: :bold
49
49
  }
50
50
 
51
51
  label # filler
52
52
  Model::Grid::WIDTH.times do |column_index|
53
53
  label {
54
54
  text (column_index + 1).to_s
55
- font height: 16
55
+ font height: OS.windows? ? 14 : 16
56
56
  }
57
57
  end
58
58
 
59
59
  Model::Grid::HEIGHT.times do |row_index|
60
60
  label {
61
61
  text Model::Grid::ROW_ALPHABETS[row_index]
62
- font height: 16
62
+ font height: OS.windows? ? 14 : 16
63
63
  }
64
64
  Model::Grid::WIDTH.times do |column_index|
65
65
  cell(game: game, player: player, row_index: row_index, column_index: column_index) {
@@ -38,7 +38,7 @@ class Battleship
38
38
 
39
39
  label {
40
40
  text ship_name.to_s.titlecase
41
- font height: 16
41
+ font height: OS.windows? ? 14 : 16
42
42
  }
43
43
 
44
44
  composite {
@@ -23,8 +23,6 @@ require 'glimmer-dsl-swt'
23
23
  require 'fileutils'
24
24
 
25
25
  class Sample
26
- include Glimmer::DataBinding::ObservableModel
27
-
28
26
  class << self
29
27
  def glimmer_directory
30
28
  File.expand_path('../../..', __FILE__)
@@ -42,6 +40,10 @@ class Sample
42
40
  end
43
41
  end
44
42
  end
43
+
44
+ include Glimmer::DataBinding::ObservableModel
45
+
46
+ UNEDITABLE = ['meta_sample.rb'] + (OS.windows? ? ['calculator.rb', 'weather.rb'] : []) # Windows StyledText does not support unicode characters found in certain samples
45
47
 
46
48
  attr_accessor :sample_directory, :file, :selected
47
49
 
@@ -74,9 +76,13 @@ class Sample
74
76
  end
75
77
 
76
78
  def editable
79
+ !UNEDITABLE.include?(File.basename(file))
80
+ end
81
+ alias editable? editable
82
+
83
+ def launchable
77
84
  File.basename(file) != 'meta_sample.rb'
78
85
  end
79
- alias launchable editable
80
86
 
81
87
  def file_relative_path
82
88
  file.sub(self.class.glimmer_directory, '')
@@ -97,6 +103,7 @@ class Sample
97
103
  def launch(modified_code)
98
104
  launch_file = user_file
99
105
  begin
106
+ raise 'Unsupported through editor!' unless editable?
100
107
  FileUtils.cp_r(file, user_file_parent_directory)
101
108
  FileUtils.cp_r(directory, user_file_parent_directory) if File.exist?(directory)
102
109
  File.write(user_file, modified_code)
@@ -202,12 +209,12 @@ class MetaSampleApplication
202
209
 
203
210
  body {
204
211
  shell(:fill_screen) {
205
- minimum_size 1280, 768
212
+ minimum_size 640, 384
206
213
  text 'Glimmer Meta-Sample (The Sample of Samples)'
207
214
  image File.expand_path('../../icons/scaffold_app.png', __dir__)
208
215
 
209
216
  sash_form {
210
- weights 4, 14
217
+ weights 1, 2
211
218
 
212
219
  composite {
213
220
  grid_layout(1, false) {
@@ -45,8 +45,8 @@ class Tetris
45
45
  menu_item(:check) {
46
46
  text '&Pause'
47
47
  accelerator COMMAND_KEY, :p
48
- enabled <= [game, :game_over, on_read: ->(value) { value && !game.show_high_scores }]
49
- enabled <= [game, :show_high_scores, on_read: ->(value) { value && !game.game_over }]
48
+ enabled <= [game, :game_over, on_read: ->(value) { !value && !game.show_high_scores }]
49
+ enabled <= [game, :show_high_scores, on_read: ->(value) { !value && !game.game_over }]
50
50
  selection <=> [game, :paused]
51
51
  }
52
52
  menu_item {
@@ -57,7 +57,17 @@ class Tetris
57
57
  on_swt_keydown { |key_event|
58
58
  case key_event.keyCode
59
59
  when swt(:arrow_down), 's'.bytes.first
60
- game.down! if OS.mac?
60
+ if OS.mac?
61
+ game.down!
62
+ else
63
+ # rate limit downs in Windows/Linux as they go too fast when key is held
64
+ @queued_downs ||= 0
65
+ @queued_downs += 1
66
+ async_exec do
67
+ game.down! if @queued_downs < 3
68
+ @queued_downs -= 1
69
+ end
70
+ end
61
71
  when swt(:arrow_up)
62
72
  case game.up_arrow_action
63
73
  when :instant_down
@@ -80,16 +90,6 @@ class Tetris
80
90
  end
81
91
  }
82
92
 
83
- # invoke game.down! on keyup with Windows/Linux since they seem to group-render similar events, preventing intermediate renders (causing invisiblity while holding keys)
84
- if !OS.mac?
85
- on_swt_keyup { |key_event|
86
- case key_event.keyCode
87
- when swt(:arrow_down), 's'.bytes.first
88
- game.down!
89
- end
90
- }
91
- end
92
-
93
93
  # if running in app mode, set the Mac app about dialog (ignored in platforms)
94
94
  on_about {
95
95
  show_about_dialog
@@ -170,9 +170,7 @@ class Tetris
170
170
  sleep @game.delay
171
171
  break if @game.game_over? || body_root.disposed?
172
172
  # ensure entire game tetromino down movement happens as one GUI update event with sync_exec (to avoid flicker/stutter)
173
- sync_exec {
174
- @game.down! unless @game.paused?
175
- }
173
+ sync_exec { @game.down! unless @game.paused? }
176
174
  end
177
175
  end
178
176
  end
@@ -41,18 +41,21 @@ class TicTacToe
41
41
  shell {
42
42
  text "Tic-Tac-Toe"
43
43
  minimum_size 176, 200
44
+
44
45
  composite {
45
46
  grid_layout 3, true
47
+
46
48
  (1..3).each { |row|
47
49
  (1..3).each { |column|
48
50
  button {
49
51
  layout_data :fill, :fill, true, true
50
52
  text <= [@tic_tac_toe_board[row, column], :sign]
51
53
  enabled <= [@tic_tac_toe_board[row, column], :empty]
52
- font style: :bold, height: 20
53
- on_widget_selected {
54
+ font style: :bold, height: (OS.windows? ? 18 : 20)
55
+
56
+ on_widget_selected do
54
57
  @tic_tac_toe_board.mark(row, column)
55
- }
58
+ end
56
59
  }
57
60
  }
58
61
  }
@@ -67,7 +67,6 @@ class Timer
67
67
 
68
68
  # Replace example content below with custom shell content
69
69
  minimum_size (OS.windows? ? 214 : 200), 114
70
- image File.join(APP_ROOT, 'package', 'windows', "Timer.ico") if OS.windows?
71
70
  text "Glimmer Timer"
72
71
 
73
72
  timer_menu_bar
@@ -102,6 +102,7 @@ class Weather
102
102
  layout_data(:fill, :center, true, false)
103
103
  text <= [self, field_name, on_read: ->(t) { "#{kelvin_to_temp_unit(t, temp_unit).to_f.round}°" }]
104
104
  font height: DEFAULT_FONT_HEIGHT
105
+ background DEFAULT_BACKGROUND
105
106
  foreground DEFAULT_FOREGROUND
106
107
  }
107
108
  end
@@ -112,6 +113,7 @@ class Weather
112
113
  layout_data(:fill, :center, true, false)
113
114
  text <= [self, 'humidity', on_read: ->(h) { "#{h.to_f.round}%" }]
114
115
  font height: DEFAULT_FONT_HEIGHT
116
+ background DEFAULT_BACKGROUND
115
117
  foreground DEFAULT_FOREGROUND
116
118
  }
117
119
  end
@@ -121,6 +123,7 @@ class Weather
121
123
  layout_data :fill, :center, false, false
122
124
  text field_name.titlecase
123
125
  font height: DEFAULT_FONT_HEIGHT
126
+ background DEFAULT_BACKGROUND
124
127
  foreground DEFAULT_FOREGROUND
125
128
  }
126
129
  end
@@ -65,7 +65,7 @@ class HelloCanvas
65
65
  y :default, 1 # add 1 pixel to default y (shape centered within parent vertically)
66
66
  background :yellow
67
67
  foreground :dark_magenta
68
- font name: 'Courier', height: 30
68
+ font name: 'Courier', height: (OS.windows? ? 26 : 30)
69
69
  }
70
70
  }
71
71
  rectangle(155, 30) { # width and height are assumed to be the default (calculated from children)
@@ -6,7 +6,7 @@ glimmer_logo = File.expand_path('../../icons/scaffold_app.png', __dir__)
6
6
 
7
7
  shell {
8
8
  text 'Hello, Canvas Transform!'
9
- minimum_size 330, 352
9
+ minimum_size (OS.windows? ? 347 : 330), (OS.windows? ? 372 : 352)
10
10
 
11
11
  canvas {
12
12
  background :white
@@ -40,27 +40,28 @@ class HelloCoolBar
40
40
  margin_width 0
41
41
  margin_height 0
42
42
  }
43
-
43
+
44
44
  text 'Hello, Cool Bar!'
45
+ minimum_size 280, 50
45
46
 
46
47
  cool_bar { # optionally takes a :flat style and/or :vertical style if you need vertical layout
47
48
  tool_bar {
48
49
  tool_item {
49
- image cut_image # alternatively you can pass an image file path
50
+ image File.expand_path('./images/cut.png', __dir__), height: 16
50
51
 
51
52
  on_widget_selected do
52
53
  self.operation = 'Cut'
53
54
  end
54
55
  }
55
56
  tool_item {
56
- image copy_image # alternatively you can pass an image file path
57
+ image File.expand_path('./images/copy.png', __dir__), height: 16
57
58
 
58
59
  on_widget_selected do
59
60
  self.operation = 'Copy'
60
61
  end
61
62
  }
62
63
  tool_item {
63
- image paste_image # alternatively you can pass an image file path
64
+ image File.expand_path('./images/paste.png', __dir__), height: 16
64
65
 
65
66
  on_widget_selected do
66
67
  self.operation = 'Paste'
@@ -86,62 +87,6 @@ class HelloCoolBar
86
87
  }
87
88
  }
88
89
  }
89
-
90
- def cut_image
91
- # building image on the fly with Canvas Shape DSL
92
- image(25, 25) {
93
- rectangle(0, 0, 25, 25) {
94
- background_pattern 0, 0, 0, 25, :white, :gray
95
- line(20, 2, 9, 15) {
96
- line_width 2
97
- }
98
- line(5, 2, 16, 15) {
99
- line_width 2
100
- }
101
- oval(2, 15, 8, 8) {
102
- line_width 2
103
- }
104
- oval(16, 15, 8, 8) {
105
- line_width 2
106
- }
107
- }
108
- }
109
- end
110
-
111
- def copy_image
112
- # building image on the fly with Canvas Shape DSL
113
- image(25, 25) {
114
- rectangle(0, 0, 25, 25) {
115
- background_pattern 0, 0, 0, 25, :white, :gray
116
- rectangle([:default, 2], [:default, -2], 14, 14, 5, 5) {
117
- line_width 2
118
- }
119
- rectangle([:default, -2], [:default, 2], 14, 14, 5, 5) {
120
- line_width 2
121
- }
122
- }
123
- }
124
- end
125
-
126
- def paste_image
127
- image(25, 25) {
128
- rectangle(0, 0, 25, 25) {
129
- background_pattern 0, 0, 0, 25, :white, :gray
130
- rectangle(:default, [:default, 1], 15, 20, 5, 5) {
131
- line_width 2
132
- }
133
- line(7, 8, 18, 8) {
134
- line_width 2
135
- }
136
- line(7, 13, 18, 13) {
137
- line_width 2
138
- }
139
- line(7, 18, 18, 18) {
140
- line_width 2
141
- }
142
- }
143
- }
144
- end
145
90
  end
146
91
 
147
92
  HelloCoolBar.launch
@@ -32,10 +32,7 @@ class HelloScale
32
32
 
33
33
  body {
34
34
  shell {
35
- row_layout(:vertical) {
36
- fill true
37
- center true
38
- }
35
+ fill_layout :vertical
39
36
 
40
37
  text 'Hello, Scale!'
41
38
 
@@ -32,10 +32,7 @@ class HelloSlider
32
32
 
33
33
  body {
34
34
  shell {
35
- row_layout(:vertical) {
36
- fill true
37
- center true
38
- }
35
+ fill_layout :vertical
39
36
 
40
37
  text 'Hello, Slider!'
41
38
 
@@ -42,33 +42,31 @@ class HelloToolBar
42
42
  }
43
43
 
44
44
  text 'Hello, Tool Bar!'
45
+ minimum_size 280, 50
45
46
 
46
47
  tool_bar { # optionally takes a :flat style, :wrap style if you need wrapping upon shrinking window, and :vertical style if you need vertical layout
47
48
  tool_item {
48
- image cut_image # alternatively you can pass an image file path
49
+ image File.expand_path('./images/cut.png', __dir__), height: 16
49
50
 
50
51
  on_widget_selected do
51
52
  self.operation = 'Cut'
52
53
  end
53
54
  }
54
55
  tool_item {
55
- image copy_image # alternatively you can pass an image file path
56
+ image File.expand_path('./images/copy.png', __dir__), height: 16
56
57
 
57
58
  on_widget_selected do
58
59
  self.operation = 'Copy'
59
60
  end
60
61
  }
61
62
  tool_item {
62
- image paste_image # alternatively you can pass an image file path
63
+ image File.expand_path('./images/paste.png', __dir__), height: 16
63
64
 
64
65
  on_widget_selected do
65
66
  self.operation = 'Paste'
66
67
  end
67
68
  }
68
69
  tool_item(:separator)
69
- tool_item {
70
- text 'Font Size'
71
- }
72
70
  # a combo can be nested in a tool_bar (it auto-generates a tool_item for itself behind the scenes)
73
71
  combo {
74
72
  selection <=> [self, :font_size]
@@ -84,59 +82,15 @@ class HelloToolBar
84
82
  }
85
83
 
86
84
  def cut_image
87
- # building image on the fly with Canvas Shape DSL
88
- image(25, 25) {
89
- rectangle(0, 0, 25, 25) {
90
- background_pattern 0, 0, 0, 25, :white, :gray
91
- line(20, 2, 9, 15) {
92
- line_width 2
93
- }
94
- line(5, 2, 16, 15) {
95
- line_width 2
96
- }
97
- oval(2, 15, 8, 8) {
98
- line_width 2
99
- }
100
- oval(16, 15, 8, 8) {
101
- line_width 2
102
- }
103
- }
104
- }
85
+ File.expand_path('./images/cut.png', __dir__)
105
86
  end
106
87
 
107
88
  def copy_image
108
- # building image on the fly with Canvas Shape DSL
109
- image(25, 25) {
110
- rectangle(0, 0, 25, 25) {
111
- background_pattern 0, 0, 0, 25, :white, :gray
112
- rectangle([:default, 2], [:default, -2], 14, 14, 5, 5) {
113
- line_width 2
114
- }
115
- rectangle([:default, -2], [:default, 2], 14, 14, 5, 5) {
116
- line_width 2
117
- }
118
- }
119
- }
89
+ File.expand_path('./images/copy.png', __dir__)
120
90
  end
121
91
 
122
92
  def paste_image
123
- image(25, 25) {
124
- rectangle(0, 0, 25, 25) {
125
- background_pattern 0, 0, 0, 25, :white, :gray
126
- rectangle(:default, [:default, 1], 15, 20, 5, 5) {
127
- line_width 2
128
- }
129
- line(7, 8, 18, 8) {
130
- line_width 2
131
- }
132
- line(7, 13, 18, 13) {
133
- line_width 2
134
- }
135
- line(7, 18, 18, 18) {
136
- line_width 2
137
- }
138
- }
139
- }
93
+ File.expand_path('./images/paste.png', __dir__)
140
94
  end
141
95
  end
142
96
 
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.21.0.0
4
+ version: 4.21.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-27 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 2.1.5
18
+ version: 2.4.0
19
19
  name: glimmer
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.5
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -376,10 +376,9 @@ description: Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a
376
376
  started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets.
377
377
  Glimmer also includes native-executable packaging support, sorely lacking in other
378
378
  libraries, thus enabling the delivery of desktop apps written in Ruby as truly native
379
- DMG/PKG/APP files on the Mac, MSI/EXE files on Windows, and Gem Packaged Shell Scripts
380
- on Linux. Glimmer was the first Ruby gem to bring SWT (Standard Widget Toolkit)
381
- to Ruby, thanks to creator Andy Maleh, EclipseCon/EclipseWorld/RubyConf speaker
382
- and expert.
379
+ DMG/PKG/APP files on the Mac, MSI/EXE files on Windows, and DEB/RPM files on Linux.
380
+ Glimmer was the first Ruby gem to bring SWT (Standard Widget Toolkit) to Ruby, thanks
381
+ to creator Andy Maleh, EclipseCon/EclipseWorld/RubyConf speaker.
383
382
  email: andy.am@gmail.com
384
383
  executables:
385
384
  - glimmer
@@ -682,6 +681,8 @@ files:
682
681
  - samples/hello/hello_tray_item.rb
683
682
  - samples/hello/hello_tree.rb
684
683
  - samples/hello/hello_world.rb
684
+ - samples/hello/images/copy.png
685
+ - samples/hello/images/cut.png
685
686
  - samples/hello/images/denmark.png
686
687
  - samples/hello/images/finland.png
687
688
  - samples/hello/images/france.png
@@ -690,6 +691,7 @@ files:
690
691
  - samples/hello/images/mexico.png
691
692
  - samples/hello/images/netherlands.png
692
693
  - samples/hello/images/norway.png
694
+ - samples/hello/images/paste.png
693
695
  - samples/hello/images/usa.png
694
696
  - sounds/metronome-down.wav
695
697
  - sounds/metronome-up.wav
@@ -726,7 +728,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
726
728
  - !ruby/object:Gem::Version
727
729
  version: '0'
728
730
  requirements: []
729
- rubygems_version: 3.2.14
731
+ rubygems_version: 3.2.29
730
732
  signing_key:
731
733
  specification_version: 4
732
734
  summary: Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)