glimmer-dsl-swt 4.17.2.3 → 4.17.2.4

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: 790b2acf622313d3b41027169575662d7eea029bf1fc30555ed1198e6f0d291a
4
+ data.tar.gz: 8d6f48a5eb0a8e3d1469292a8c697acd4106c17bf567188f75ae8929ec3165e1
5
5
  SHA512:
6
- metadata.gz: 46ecd1fbe2700184f8b3ea5f447cd7d3e2209a777080d40a787821edee1d65d7525e28befd96bd4ec5dbd48f646371810470eeef8777388d60bd6fce823da525
7
- data.tar.gz: 74ecccfa3cbb21712178fa695ddbd2eed4cb3cbb400aae3b3bf5b5dc5358ccba3ae2ff056d1992d7adfc0dcd173dcf77cf52a6f6e4ecabe961f5ece49c6b69d9
6
+ metadata.gz: d41b1753d14ae5905b157e2fedd75679b8bcf627e5a7ef4277dbf5340ce1fde97b1badea9fe6ff644351c0b43918c4b085e90967ccbfe4cfc17f3d1e5deddcbd
7
+ data.tar.gz: cf2e38dc4254d96b38a0e6c2ed3b414e74df29771e2a3a6f7af4bae5a1c1a36d796eac6b627de3f0b99ffd833ea1089e47bcade4b994fc4e09b0efade7e620c1
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.2.4
4
+
5
+ - New `glimmer run` glimmer command task.
6
+ - Add built in support for handling jar file paths like that in ImageProxy code processing "uri:classloader" path
7
+ - Document that gif background_image only works without on_top and no_trim styles in Windows
8
+ - Give a good error message when Git is not properly setup for Glimmer Scaffolding
9
+ - Give an error message when attempting to scaffold over an already scaffolded directory
10
+ - Fix issue on Windows regarding use of the new EXPERIMENTAL Animated gif support in the `composite#background_image` property
11
+ - Fix SWTProxy.deconstruct method
12
+
13
+
3
14
  ### 4.17.2.3
4
15
 
5
16
  - 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.2.4
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)
@@ -237,6 +237,7 @@ Glimmer App:
237
237
  - [Hello, World!](#hello-world)
238
238
  - [Tic Tac Toe](#tic-tac-toe)
239
239
  - [Contact Manager](#contact-manager)
240
+ - [Desktop Apps Built with Glimmer DSL for SWT](#desktop-apps-built-with-glimmer-dsl-for-swt)
240
241
  - [Table of contents](#table-of-contents)
241
242
  - [Background](#background)
242
243
  - [Platform Support](#platform-support)
@@ -268,9 +269,10 @@ Glimmer App:
268
269
  - [Glimmer GUI DSL Syntax](#glimmer-gui-dsl-syntax)
269
270
  - [DSL Auto-Expansion](#dsl-auto-expansion)
270
271
  - [Widgets](#widgets)
271
- - [Display](#display)
272
272
  - [SWT Proxies](#swt-proxies)
273
273
  - [Dialog](#dialog)
274
+ - [Display](#display)
275
+ - [Multi-Threading](#multi-threading)
274
276
  - [Menus](#menus)
275
277
  - [ScrolledComposite](#scrolledcomposite)
276
278
  - [Widget Styles](#widget-styles)
@@ -280,6 +282,7 @@ Glimmer App:
280
282
  - [Widget Properties](#widget-properties)
281
283
  - [Color](#color)
282
284
  - [Font](#font)
285
+ - [Image](#image)
283
286
  - [Cursor](#cursor)
284
287
  - [Layouts](#layouts)
285
288
  - [Layout Data](#layout-data)
@@ -294,10 +297,10 @@ Glimmer App:
294
297
  - [Observing Models](#observing-models)
295
298
  - [Custom Widgets](#custom-widgets)
296
299
  - [Simple Example](#simple-example)
297
- - [Lifecycle Hook Example](#lifecycle-hook-example)
300
+ - [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
301
+ - [Lifecycle Hooks Example](#lifecycle-hooks-example)
298
302
  - [Custom Widget API](#custom-widget-api)
299
303
  - [Content/Options Example](#contentoptions-example)
300
- - [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
301
304
  - [Gotcha](#gotcha)
302
305
  - [Final Notes](#final-notes)
303
306
  - [Custom Shells](#custom-shells)
@@ -428,7 +431,7 @@ jgem install glimmer-dsl-swt
428
431
 
429
432
  Or this command if you want a specific version:
430
433
  ```
431
- jgem install glimmer-dsl-swt -v 4.17.2.3
434
+ jgem install glimmer-dsl-swt -v 4.17.2.4
432
435
  ```
433
436
 
434
437
  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 +442,7 @@ Otherwise, you may also run `jruby -S gem install ...`
439
442
 
440
443
  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
444
 
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.
445
+ 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
446
 
444
447
  Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
445
448
 
@@ -505,7 +508,7 @@ bin/glimmer sample:run[hello_world]
505
508
  Below are the full usage instructions that come up when running `glimmer` without args.
506
509
 
507
510
  ```
508
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.3
511
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.4
509
512
 
510
513
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
511
514
 
@@ -538,6 +541,7 @@ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and
538
541
  glimmer package:jar # Generate JAR file
539
542
  glimmer package:lock_jars # Lock JARs
540
543
  glimmer package:native[type] # Generate Native files
544
+ 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)
541
545
  glimmer sample:code[name] # Outputs code for a Glimmer internal sample [included in gem] (name is required)
542
546
  glimmer sample:list[query] # Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)
543
547
  glimmer sample:run[name] # Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples
@@ -621,7 +625,7 @@ This will run the hello_tab sample and output its code:
621
625
  ```
622
626
  $ glimmer sample:run[hello_tab]
623
627
 
624
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.3/samples/hello/hello_tab.rb
628
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.4/samples/hello/hello_tab.rb
625
629
 
626
630
  class HelloTab
627
631
  include Glimmer
@@ -666,7 +670,7 @@ Example:
666
670
  ```
667
671
  $ glimmer sample:code[tic_tac_toe]
668
672
 
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
673
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.4/samples/elaborate/tic_tac_toe.rb
670
674
 
671
675
  require_relative "tic_tac_toe/board"
672
676
 
@@ -727,7 +731,7 @@ TicTacToe.new.open
727
731
  # # #
728
732
 
729
733
 
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
734
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.4/samples/elaborate/tic_tac_toe/cell.rb
731
735
 
732
736
  class TicTacToe
733
737
  class Cell
@@ -760,7 +764,7 @@ end
760
764
  # # #
761
765
 
762
766
 
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
767
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.4/samples/elaborate/tic_tac_toe/board.rb
764
768
 
765
769
  require_relative 'cell'
766
770
 
@@ -893,7 +897,7 @@ end
893
897
  ### Scaffolding
894
898
 
895
899
  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.
900
+ helps you get started just like true building scaffolding helps construction workers, civil engineers, and architects.
897
901
 
898
902
  Glimmer scaffolding goes beyond just scaffolding the app files that Rails does. It also packages it and launches it,
899
903
  getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
@@ -909,7 +913,7 @@ letting Glimmer scaffolding take care of initial app file structure concerns, su
909
913
  - Icon (under `package/{platform}/{App Name}.{icon_extension}` for `macosx` .icns, `windows` .ico, and `linux` .png)
910
914
  - Bin file for starting application (`bin/{app_name}.rb`)
911
915
 
912
- NOTE: Scaffolding supports Mac and Windows packaging at the moment.
916
+ NOTE: 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
917
 
914
918
  #### App
915
919
 
@@ -979,7 +983,19 @@ And, here is the Windows version of the boilerplate Preferences dialog.
979
983
 
980
984
  ![Glimmer Scaffold App Windows Preferences](images/glimmer-scaffolding-app-windows-preferences.png)
981
985
 
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:
986
+ 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.
987
+
988
+ ```
989
+ glimmer run
990
+ ```
991
+
992
+ Alternatively, to mantually run the app, you may type:
993
+
994
+ ```
995
+ glimmer run[bin/greeter]
996
+ ```
997
+
998
+ or:
983
999
 
984
1000
  ```
985
1001
  glimmer bin/greeter
@@ -1192,7 +1208,7 @@ Output:
1192
1208
 
1193
1209
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1194
1210
  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
1211
+ Swt glimmer-dsl-swt 4.17.2.4 AndyMaleh Glimmer DSL for SWT
1196
1212
  Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
1197
1213
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
1198
1214
  ```
@@ -1464,28 +1480,6 @@ If you are advanced and need more widgets, check out the [Nebula Project](https:
1464
1480
 
1465
1481
  https://www.eclipse.org/nebula/
1466
1482
 
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
1483
  #### SWT Proxies
1490
1484
 
1491
1485
  Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT objects:
@@ -1501,7 +1495,26 @@ Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT o
1501
1495
 
1502
1496
  These proxy objects have an API and provide some convenience methods, some of which are mentioned below.
1503
1497
 
1504
- ##### `#content { ... }`
1498
+ ##### swt_widget
1499
+
1500
+ 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.
1501
+
1502
+ ##### Shell widget proxy methods
1503
+
1504
+ Shell widget proxy has extra methods specific to SWT Shell:
1505
+ - `#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.
1506
+ - `#show`: Alias for `#open`
1507
+ - `#hide`: Hides a shell setting "visible" property to false
1508
+ - `#close`: Closes the shell
1509
+ - `#center`: Centers the shell within monitor it is in
1510
+ - `#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.
1511
+ - `#visible?`: Returns whether a shell is visible
1512
+ - `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
1513
+ - `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
1514
+ - `#pack`: Packs contained widgets using SWT's `Shell#pack` method
1515
+ - `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
1516
+
1517
+ ##### Widget Content Block
1505
1518
 
1506
1519
  Glimmer allows re-opening any widget and adding properties or extra content after it has been constructed already by using the `#content` method.
1507
1520
 
@@ -1527,7 +1540,31 @@ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1527
1540
  @shell.open
1528
1541
  ```
1529
1542
 
1530
- ##### `message_box`
1543
+ ##### Shell Icon
1544
+
1545
+ 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)
1546
+
1547
+ Example:
1548
+
1549
+ ```ruby
1550
+ shell {
1551
+ # ...
1552
+ image 'path/to/image.png'
1553
+ # ...
1554
+ }
1555
+ ```
1556
+
1557
+ ###### Shell Icon Tip for Packaging on Windows
1558
+
1559
+ 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'`)
1560
+
1561
+ #### Dialog
1562
+
1563
+ 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.
1564
+
1565
+ 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.
1566
+
1567
+ ##### message_box
1531
1568
 
1532
1569
  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
1570
 
@@ -1566,48 +1603,65 @@ message_box {
1566
1603
  }.open
1567
1604
  ```
1568
1605
 
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
1606
+ #### Display
1587
1607
 
1588
- ##### Shell Icon
1608
+ 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
1609
+ 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
1610
 
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)
1611
+ `Display` is automatically instantiated upon first instantiation of a `shell` widget.
1591
1612
 
1592
- Example:
1613
+ Alternatively, for advanced use cases, a `Display` can be created explicitly with the Glimmer `display` keyword. When a `shell` is later declared, it
1614
+ automatically uses the `display` created earlier without having to explicitly hook it.
1593
1615
 
1594
1616
  ```ruby
1595
- shell {
1596
- # ...
1597
- image 'path/to/image.png'
1617
+ @display = display {
1618
+ cursor_location 300, 300
1619
+ on_swt_keydown {
1620
+ # ...
1621
+ }
1598
1622
  # ...
1599
1623
  }
1624
+ @shell = shell { # uses display created above
1625
+ }
1600
1626
  ```
1627
+ The benefit of instantiating an SWT Display explicitly is to set [Properties](#widget-properties) or [Observers](#observer).
1628
+ Although SWT Display is not technically a widget, it has similar APIs and DSL support.
1601
1629
 
1602
- ###### Shell Icon Tip for Packaging on Windows
1630
+ #### Multi-Threading
1603
1631
 
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'`)
1632
+ [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
1633
 
1606
- #### Dialog
1634
+ ##### async_exec
1607
1635
 
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.
1636
+ `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
1637
 
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.
1638
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1639
+
1640
+ ```
1641
+ @shell = shell {
1642
+ text 'Glimmer'
1643
+ @label = label {
1644
+ text 'Hello, World!'
1645
+ }
1646
+ }
1647
+
1648
+ Thread.new {
1649
+ [:red, :dark_green, :blue].cycle { |color|
1650
+ async_exec {
1651
+ @label.content {
1652
+ foreground color if @shell.visible?
1653
+ }
1654
+ }
1655
+ sleep(1)
1656
+ }
1657
+ }
1658
+
1659
+ @shell.open
1660
+ ```
1661
+
1662
+ ##### sync_exec
1663
+
1664
+ `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
1665
 
1612
1666
  #### Menus
1613
1667
 
@@ -1940,6 +1994,16 @@ Example:
1940
1994
  @font = font(name: 'Arial', height: 36, style: :normal)
1941
1995
  ```
1942
1996
 
1997
+ ### Image
1998
+
1999
+ 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).
2000
+
2001
+ 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)
2002
+
2003
+ Glimmer recently included **EXPERIMENTAL** gif animation support for the `background_image` property on `composite' since SWT does not support animation by default.
2004
+
2005
+ Learn more about images in general at this SWT Image guide: https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
2006
+
1943
2007
  ### Cursor
1944
2008
 
1945
2009
  SWT widget `cursor` property represents the mouse cursor you see on the screen when you hover over that widget.
@@ -2693,7 +2757,6 @@ shell {
2693
2757
  }.open
2694
2758
  ```
2695
2759
 
2696
-
2697
2760
  ##### Class-Based Custom Widget Example
2698
2761
 
2699
2762
  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 `__`)
@@ -3490,6 +3553,14 @@ Here is an SWT Custom Widget guide:
3490
3553
 
3491
3554
  https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
3492
3555
 
3556
+ Here is an SWT Image guide:
3557
+
3558
+ https://www.eclipse.org/articles/Article-SWT-images/graphics-resources.html
3559
+
3560
+ Here is an SWT Graphics / Canvas-Drawing guide:
3561
+
3562
+ https://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html
3563
+
3493
3564
  Here is the Nebula Project (custom widget library) homepage:
3494
3565
 
3495
3566
  https://www.eclipse.org/nebula/
@@ -3892,8 +3963,8 @@ require 'glimmer/rake_task'
3892
3963
  ```
3893
3964
 
3894
3965
  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.
3966
+ 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.
3967
+ 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
3968
  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
3969
  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
3970
  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).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.2.3
1
+ 4.17.2.4
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.2.3 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.2.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.2.3"
9
+ s.version = "4.17.2.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-10-16"
14
+ s.date = "2020-10-17"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -48,6 +48,20 @@ require_relative '../ext/glimmer/config.rb'
48
48
  require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
49
49
 
50
50
  namespace :glimmer do
51
+ desc 'Runs Glimmer app or custom shell gem in the current directory, unless app_path is specified, then runs it instead (app_path is optional)'
52
+ task :run, [:app_path] do |t, args|
53
+ require_relative 'launcher'
54
+ if args[:app_path].nil?
55
+ require 'fileutils'
56
+ current_directory_name = File.basename(FileUtils.pwd)
57
+ assumed_shell_script = File.join('.', 'bin', current_directory_name)
58
+ assumed_shell_script = Dir.glob('./bin/*').detect {|f| File.file?(f)} if !File.exist?(assumed_shell_script)
59
+ Glimmer::Launcher.new([assumed_shell_script]).launch
60
+ else
61
+ Glimmer::Launcher.new([args[:app_path]]).launch
62
+ end
63
+ end
64
+
51
65
  namespace :sample do
52
66
  task :requires do
53
67
  require_relative 'rake_task/sample'
@@ -40,7 +40,7 @@ module Glimmer
40
40
  end
41
41
 
42
42
  def lock_jars
43
- puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
43
+ puts 'Locking gem jar-dependencies by downloading and storing in vendor/jars...'
44
44
  FileUtils.mkdir_p('vendor/jars')
45
45
  command = "lock_jars --vendor-dir vendor/jars"
46
46
  puts command
@@ -123,8 +123,10 @@ module Glimmer
123
123
  def app(app_name)
124
124
  gem_name = file_name(app_name)
125
125
  gem_summary = human_name(app_name)
126
+ return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
126
127
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
127
128
  system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
129
+ return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
128
130
  cd gem_name
129
131
  rm_rf 'lib'
130
132
  write '.gitignore', GITIGNORE
@@ -181,6 +183,7 @@ module Glimmer
181
183
  namespace ||= current_dir_name
182
184
  root_dir = File.exists?('app') ? 'app' : 'lib'
183
185
  parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
186
+ return puts("The file '#{parent_dir}/#{file_name(custom_shell_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shell_name)}.rb")
184
187
  mkdir_p parent_dir unless File.exists?(parent_dir)
185
188
  write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type)
186
189
  end
@@ -189,6 +192,7 @@ module Glimmer
189
192
  namespace ||= current_dir_name
190
193
  root_dir = File.exists?('app') ? 'app' : 'lib'
191
194
  parent_dir = "#{root_dir}/views/#{file_name(namespace)}"
195
+ return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
192
196
  mkdir_p parent_dir unless File.exists?(parent_dir)
193
197
  write "#{parent_dir}/#{file_name(custom_widget_name)}.rb", custom_widget_file(custom_widget_name, namespace)
194
198
  end
@@ -210,8 +214,10 @@ module Glimmer
210
214
  return puts('Namespace is required! Usage: glimmer scaffold:gem:customshell[name,namespace]') unless `git config --get github.user`.to_s.strip == 'AndyObtiva'
211
215
  namespace = 'glimmer'
212
216
  end
217
+ return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
213
218
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
214
219
  system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
220
+ return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
215
221
  cd gem_name
216
222
  write '.gitignore', GITIGNORE
217
223
  write '.ruby-version', RUBY_VERSION
@@ -278,8 +284,10 @@ module Glimmer
278
284
  namespace = 'glimmer'
279
285
  end
280
286
 
287
+ return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
281
288
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
282
289
  system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
290
+ return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
283
291
  cd gem_name
284
292
  write '.gitignore', GITIGNORE
285
293
  write '.ruby-version', RUBY_VERSION
@@ -27,10 +27,20 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class ImageProxy
30
+ class << self
31
+ def create(*args)
32
+ if args.size == 1 && args.first.is_a?(ImageProxy)
33
+ args.first
34
+ else
35
+ new(*args)
36
+ end
37
+ end
38
+ end
39
+
30
40
  include_package 'org.eclipse.swt.graphics'
31
41
 
32
42
  attr_reader :file_path, :jar_file_path, :image_data, :swt_image
33
-
43
+
34
44
  # Initializes a proxy for an SWT Image object
35
45
  #
36
46
  # Takes the same args as the SWT Image class
@@ -38,8 +48,10 @@ module Glimmer
38
48
  # and returns an image object.
39
49
  def initialize(*args)
40
50
  @args = args
41
- @file_path = @args.first if @args.first.is_a?(String) && @args.size == 1
42
- options = @args.delete_at(-1) if @args.last.is_a?(Hash)
51
+ options = @args.last.is_a?(Hash) ? @args.delete_at(-1) : {}
52
+ options[:swt_image] = @args.first if @args.size == 1 && @args.first.is_a?(Image)
53
+ @file_path = @args.first if @args.size == 1 && @args.first.is_a?(String)
54
+ @args = @args.first if @args.size == 1 && @args.first.is_a?(Array)
43
55
  if options&.keys&.include?(:swt_image)
44
56
  @swt_image = options[:swt_image]
45
57
  @image_data = @swt_image.image_data
@@ -128,7 +128,7 @@ module Glimmer
128
128
  def deconstruct(integer)
129
129
  constant_source_class.constants.reduce([]) do |found, c|
130
130
  constant_value = constant_source_class.const_get(c) rescue -1
131
- is_found = constant_value.is_a?(Integer) && (integer & constant_value) == integer
131
+ is_found = constant_value.is_a?(Integer) && (integer & constant_value) == constant_value
132
132
  is_found ? found += [c] : found
133
133
  end
134
134
  end
@@ -136,6 +136,7 @@ module Glimmer
136
136
  # Reverse engineer a style integer into a symbol
137
137
  # Useful for debugging
138
138
  def reverse_lookup(integer)
139
+ # TODO support looking up compound style mixes
139
140
  constant_source_class.constants.reduce([]) do |found, c|
140
141
  constant_value = constant_source_class.const_get(c) rescue -1
141
142
  is_found = constant_value.is_a?(Integer) && integer == constant_value
@@ -684,16 +684,7 @@ module Glimmer
684
684
  },
685
685
  :background => color_converter,
686
686
  :background_image => lambda do |value|
687
- # TODO push this code to ImageProxy
688
- image_proxy = if value.is_a?(String)
689
- ImageProxy.new(value)
690
- elsif value.is_a?(Array)
691
- ImageProxy.new(*value)
692
- elsif value.is_a?(Image)
693
- ImageProxy.new(swt_image: value)
694
- else
695
- value
696
- end
687
+ image_proxy = ImageProxy.create(value)
697
688
 
698
689
  if image_proxy&.file_path&.end_with?('.gif')
699
690
  image = image_proxy.swt_image
@@ -752,37 +743,18 @@ module Glimmer
752
743
  end
753
744
  end,
754
745
  :image => lambda do |value|
755
- image_proxy = if value.is_a?(String)
756
- ImageProxy.new(value).swt_image
757
- elsif value.is_a?(Array)
758
- ImageProxy.new(*value).swt_image
759
- elsif value.is_a?(Image)
760
- ImageProxy.new(swt_image: value)
761
- else
762
- value
763
- end
764
- image_proxy.swt_image
746
+ ImageProxy.create(value).swt_image
765
747
  end,
766
748
  :images => lambda do |array|
767
749
  array.to_a.map do |value|
768
- if value.is_a?(String)
769
- ImageProxy.new(value).swt_image
770
- elsif value.is_a?(Array)
771
- ImageProxy.new(*value).swt_image
772
- else
773
- value
774
- end
750
+ ImageProxy.create(value).swt_image
775
751
  end.to_java(Image)
776
752
  end,
777
753
  :items => lambda do |value|
778
754
  value.to_java :string
779
755
  end,
780
756
  :text => lambda do |value|
781
- if swt_widget.is_a?(Browser)
782
- value.to_s
783
- else
784
- value.to_s
785
- end
757
+ value.to_s
786
758
  end,
787
759
  :transfer => lambda do |value|
788
760
  value = value.first if value.is_a?(Array) && value.size == 1 && value.first.is_a?(Array)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.2.3
4
+ version: 4.17.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2020-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement