glimmer-dsl-swt 4.22.2.3 → 4.22.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +68 -17
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_COMMAND.md +3 -1
  6. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +33 -31
  7. data/docs/reference/GLIMMER_SAMPLES.md +2 -9
  8. data/glimmer-dsl-swt.gemspec +0 -0
  9. data/lib/glimmer/launcher.rb +7 -4
  10. data/lib/glimmer/rake_task/scaffold.rb +28 -15
  11. data/lib/glimmer/swt/custom/shape.rb +6 -2
  12. data/lib/glimmer/swt/image_proxy.rb +1 -0
  13. data/samples/elaborate/calculator.rb +12 -12
  14. data/samples/elaborate/contact_manager.rb +26 -14
  15. data/samples/elaborate/game_of_life.rb +8 -8
  16. data/samples/elaborate/klondike_solitaire/view/action_panel.rb +2 -2
  17. data/samples/elaborate/klondike_solitaire/view/klondike_solitaire_menu_bar.rb +15 -10
  18. data/samples/elaborate/login.rb +16 -10
  19. data/samples/elaborate/mandelbrot_fractal.rb +26 -20
  20. data/samples/elaborate/meta_sample.rb +6 -6
  21. data/samples/elaborate/metronome.rb +4 -4
  22. data/samples/elaborate/stock_ticker.rb +12 -12
  23. data/samples/elaborate/tetris.rb +4 -4
  24. data/samples/elaborate/timer.rb +36 -26
  25. data/samples/elaborate/user_profile.rb +53 -14
  26. data/samples/elaborate/weather.rb +2 -2
  27. data/samples/hello/hello_button.rb +3 -3
  28. data/samples/hello/hello_canvas_animation.rb +2 -2
  29. data/samples/hello/hello_color_dialog.rb +4 -4
  30. data/samples/hello/hello_custom_shell.rb +2 -2
  31. data/samples/hello/hello_dialog.rb +4 -4
  32. data/samples/hello/hello_directory_dialog.rb +2 -2
  33. data/samples/hello/hello_expand_bar.rb +4 -5
  34. data/samples/hello/hello_file_dialog.rb +2 -2
  35. data/samples/hello/hello_font_dialog.rb +2 -2
  36. data/samples/hello/hello_link.rb +5 -4
  37. data/samples/hello/hello_list_multi_selection.rb +3 -1
  38. data/samples/hello/hello_list_single_selection.rb +3 -1
  39. data/samples/hello/hello_menu_bar.rb +28 -28
  40. data/samples/hello/hello_message_box.rb +2 -2
  41. data/samples/hello/hello_pop_up_context_menu.rb +18 -8
  42. data/samples/hello/hello_shell.rb +16 -16
  43. data/samples/hello/hello_styled_text.rb +2 -2
  44. data/samples/hello/hello_table.rb +4 -4
  45. data/samples/hello/hello_tray_item.rb +2 -2
  46. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20cdf050b145adb888f8e82caa9c8d90e5b076cab423bc795ed963a75c279fd4
4
- data.tar.gz: 57e52e57c1fcc8dcc373dec79505fb1ee9547d4a50d4aa4e126395e689f91033
3
+ metadata.gz: ac45c3222d87e368de1345985c6300a82774a9380f5bf6f0741ad652e60adc1e
4
+ data.tar.gz: a4cad66af57489c224ecce5d4609d8b09e422d56b0aed463d6215383d69fcd3b
5
5
  SHA512:
6
- metadata.gz: 7b6102a2d26c71dd635a5f8eadd9704ff263ee7124ac0428fe8dd53f661b893e7c08832e3fbcf17bbbc57b2e60754314d7943a2cce2a3be6bc2104205e1caef0
7
- data.tar.gz: e9090d6f91a0b337e173f478c3371c47e9040d46af340e851f5d8e318ca66297fd0dc043814738b202e1ce0648987a46f4e5d27edf6fba3e81ff504779cd584d
6
+ metadata.gz: 9c5b1663e2f9cfaa118fdc4ec02064d2472bc92daf4a6d6012f1a7a1f98401cacd6b7a1009e5daa91d75b4626e431968be6fb2071c6c7dc25ff0359a481e5f41
7
+ data.tar.gz: d81508da3bbfd45f329f8c63187cf6babd11b719e5dfb668fd1a0ace62258143e168ab7b2b97d1e61a0aadaba657edfc7fcba4c1b71201332de8ff54e5686db6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.22.2.6
4
+
5
+ - Fix issue whereby updating `string` property on the `text`/`string` shape does not trigger a redraw on the shape because the text dimensions remained the same despite the change of content (e.g. switching from `string` content of letter `A` to `S` results in the same dimensions)
6
+ - Canvas Shape DSL graduated from Beta to Final
7
+
8
+ ## 4.22.2.5
9
+
10
+ - Update all samples to match the [GLIMMER_STYLE_GUIDE.md](/docs/reference/GLIMMER_STYLE_GUIDE.md)
11
+ - Update scaffolding code to match the [GLIMMER_STYLE_GUIDE.md](/docs/reference/GLIMMER_STYLE_GUIDE.md)
12
+
13
+ ## 4.22.2.4
14
+
15
+ - Address the warning regarding using Ruby singletons on Java objects (shows up when running `glimmer samples`)
16
+ - Fix order of calling `require 'app_name/view/app_view'` in scaffolded app (must be last)
17
+
3
18
  ## 4.22.2.3
4
19
 
5
20
  - Support `#content { }` on `layout_data`
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.22.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.22.2.6
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)
@@ -17,22 +17,25 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
17
17
 
18
18
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
19
19
 
20
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.2.3 includes [SWT 4.22](https://download.eclipse.org/eclipse/downloads/drops4/R-4.22-202111241800/), which was released on November 24, 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.
20
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.2.6 includes [SWT 4.22](https://download.eclipse.org/eclipse/downloads/drops4/R-4.22-202111241800/), which was released on November 24, 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.
21
21
 
22
22
  **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.
23
23
 
24
24
  Please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) better by providing feedback and [contributing](#contributing) whenever possible. Any feature suggestions that are accepted could be implemented within weeks if not days.
25
25
 
26
- Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems you might be interested in:
27
- - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
28
- - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
29
- - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
30
- - [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)
31
- - [glimmer-dsl-fx](https://github.com/AndyObtiva/glimmer-dsl-fx): Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)
32
- - [glimmer-dsl-jfx](https://github.com/AndyObtiva/glimmer-dsl-jfx): Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library)
33
- - [glimmer-dsl-swing](https://github.com/AndyObtiva/glimmer-dsl-swing): Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library)
34
- - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
35
- - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
26
+ **[Glimmer](https://github.com/AndyObtiva/glimmer) DSL Comparison Table:**
27
+ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
28
+ ----|-----------|---------|------------------|------|------|--------
29
+ [Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)](https://github.com/AndyObtiva/glimmer-dsl-swt) | Mac / Windows / Linux | Yes | Yes (Canvas Shape DSL) | Very Mature / Scaffolding / Native Executable Packaging / Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint | Java / JRuby
30
+ [Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)](https://github.com/AndyObtiva/glimmer-dsl-opal) | All Web Browsers | No | Yes (Canvas Shape DSL) | Simpler than All JavaScript Technologies / Auto-Webify Desktop Apps | Setup Process / Incomplete Alpha | Rails
31
+ [Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-libui) | Mac / Windows / Linux | Yes | Yes (Area API) | Fast Startup Time / Light Memory Footprint | LibUI is an Incomplete Mid-Alpha Only | None Other Than MRI Ruby
32
+ [Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-tk) | Mac / Windows / Linux | Some Native-Themed Widgets (Not Truly Native) | Yes (Canvas) | Fast Startup Time / Light Memory Footprint | Widgets Do Not Look Truly Native, Espcially on Linux | ActiveTcl / MRI Ruby
33
+ [Glimmer DSL for GTK (Ruby-GNOME Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-gtk) | Mac / Windows / Linux | Only on Linux | Yes (Cairo) | Complete Access to GNOME Features on Linux (Forte) | Not Native on Mac and Windows | None Other Than MRI Ruby on Linux / Brew Packages on Mac / MSYS & MING Toolchains on Windows / MRI Ruby
34
+ [Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-fx) | Mac (requires XQuartz) / Windows / Linux | No | Yes (Canvas) | No Prerequisites on Windows (Forte Since Binaries Are Included Out of The Box) | Widgets Do Not Look Native / Mac Usage Obtrusively Starts XQuartz | None Other Than MRI Ruby on Windows / XQuarts on Mac / MRI Ruby
35
+ [Glimmer DSL for JFX (JRuby JavaFX Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-jfx) | Mac / Windows / Linux | No | Yes (javafx.scene.shape and javafx.scene.canvas) | Rich in Custom Widgets | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby / JavaFX SDK
36
+ [Glimmer DSL for Swing (JRuby Swing Desktop Development GUI Library)](https://github.com/AndyObtiva/glimmer-dsl-swing) | Mac / Windows / Linux | No | Yes (Java2D) | Very Mature | Slow JRuby Startup Time / Heavy Memory Footprint / Widgets Do Not Look Native | Java / JRuby
37
+ [Glimmer DSL for XML (& HTML)](https://github.com/AndyObtiva/glimmer-dsl-xml) | All Web Browsers | No | Yes (SVG) | Programmable / Lighter-weight Than Actual XML | XML Elements Are Sometimes Not Well-Named (Many Types of Input) | None
38
+ [Glimmer DSL for CSS](https://github.com/AndyObtiva/glimmer-dsl-css) | All Web Browsers | No | Yes | Programmable | CSS Is Over-Engineered / Too Many Features To Learn | None
36
39
 
37
40
  ## Examples
38
41
 
@@ -328,7 +331,7 @@ jgem install glimmer-dsl-swt
328
331
 
329
332
  Or this command if you want a specific version:
330
333
  ```
331
- jgem install glimmer-dsl-swt -v 4.22.2.3
334
+ jgem install glimmer-dsl-swt -v 4.22.2.6
332
335
  ```
333
336
 
334
337
  `jgem` is JRuby's version of `gem` command.
@@ -356,7 +359,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
356
359
 
357
360
  Add the following to `Gemfile`:
358
361
  ```
359
- gem 'glimmer-dsl-swt', '~> 4.22.2.3'
362
+ gem 'glimmer-dsl-swt', '~> 4.22.2.6'
360
363
  ```
361
364
 
362
365
  And, then run:
@@ -379,7 +382,7 @@ glimmer
379
382
  ```
380
383
 
381
384
  ```
382
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.2.3
385
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.2.6
383
386
 
384
387
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
385
388
 
@@ -456,13 +459,15 @@ In a nutshell, the Glimmer GUI DSL syntax consists mainly of:
456
459
 
457
460
  1. Keywords
458
461
 
462
+ Widgets are declared with keywords denoting their name in underscored format.
463
+
459
464
  Example of a keyword representing a table widget:
460
465
 
461
466
  ```ruby
462
467
  table
463
468
  ```
464
469
 
465
- 2. Style/Args
470
+ Widgets may optionally receive symbol-style/args within parentheses (otherwise, when there are no style/args, the parentheses are left out).
466
471
 
467
472
  Example of a multi-line selection table widget:
468
473
 
@@ -470,7 +475,9 @@ Example of a multi-line selection table widget:
470
475
  table(:multi)
471
476
  ```
472
477
 
473
- 3. Content/Properties
478
+ 2. Content/Properties
479
+
480
+ Widget content is always housed within a curly-brace (`{}`) style block.
474
481
 
475
482
  Example of a multi-line selection table widget with a table column as content that has a header `text` property as 'Name'.
476
483
 
@@ -482,6 +489,37 @@ table(:multi) {
482
489
  }
483
490
  ```
484
491
 
492
+ 3. Listeners
493
+
494
+ Listeners embody the [Observer Design Pattern](https://en.wikipedia.org/wiki/Observer_pattern) and always start with `on_` followed by an event name (e.g. `on_widget_selected`). Also, they are an exception to Glimmer's syntax that requires a `do; end` style block to clearly demarcate as logic as opposed to View syntax.
495
+
496
+ Example of a button widget with a `text` property and an `on_widget_selected` listener.
497
+
498
+ ```ruby
499
+ button {
500
+ text 'Click'
501
+
502
+ on_widget_selected do
503
+ message_box {
504
+ text 'Clicked'
505
+ message 'Thank you for clicking!'
506
+ }.open
507
+ end
508
+ }
509
+ ```
510
+
511
+ 4. Methods
512
+
513
+ Widgets have methods that invoke operations on them. Sometimes, they are required to be called in order to display the widgets (like the `open` method on `shell` and `message_box`)
514
+
515
+ Example of a shell with a `text` property and an invoked `open` method operation.
516
+
517
+ ```ruby
518
+ shell {
519
+ text 'Hello, World!'
520
+ }.open
521
+ ```
522
+
485
523
  If you need more widgets, you can check out the [Nebula Project](https://github.com/AndyObtiva/glimmer-cw-nebula) (50+ enterprise-grade custom widgets)
486
524
 
487
525
  Learn more at:
@@ -527,10 +565,14 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
527
565
 
528
566
  ### Are We There Yet?
529
567
 
568
+ This [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) application connects to a database using [ActiveRecord](https://rubygems.org/gems/activerecord).
569
+
530
570
  [<img alt="Are We There Yet Logo" src="https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-logo.svg" width="40" />Are We There Yet?](https://github.com/AndyObtiva/are-we-there-yet): A tool that helps you learn when your small projects will finish
531
571
 
532
572
  ### Garderie Rainbow Daily Agenda
533
573
 
574
+ This [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) application connects to a [Rails](https://rubyonrails.org/) server to submit an application.
575
+
534
576
  [<img alt="Garderie Rainbow Daily Agenda Logo" src="https://github.com/AndyObtiva/garderie_rainbow_daily_agenda/raw/master/images/garderie_rainbow_daily_agenda_logo.png" width="40" />Garderie Rainbow Daily Agenda](https://github.com/AndyObtiva/garderie_rainbow_daily_agenda): A child nursery daily agenda reporting desktop app
535
577
 
536
578
  ### Glimmer Gab
@@ -549,6 +591,14 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
549
591
 
550
592
  [Befunge 98 GUI](https://github.com/AndyObtiva/befunge98/tree/gui)
551
593
 
594
+ ### Glimmer Metronome
595
+
596
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer_metronome/master/icons/linux/Glimmer%20Metronome.png" height=40 /> Glimmer Metronome](https://github.com/AndyObtiva/glimmer_metronome)
597
+
598
+ ### Glimmer Wordle
599
+
600
+ [<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer_wordle/master/icons/linux/Glimmer Wordle.png' height=40 /> Glimmer Wordle - Word Game](https://github.com/AndyObtiva/glimmer_wordle)
601
+
552
602
  ## Packaging & Distribution
553
603
 
554
604
  Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single command:
@@ -586,6 +636,7 @@ Learn more by reading the [GPG](https://github.com/AndyObtiva/glimmer/blob/maste
586
636
 
587
637
  ## Resources
588
638
 
639
+ * [Glimmer DSL for SWT Video Tutorials](https://andymaleh.blogspot.com/search/label/Tutorial+SWT)
589
640
  * [Code Master Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
590
641
  * [JRuby Cookbook by Justin Edelson & Henry Liu](http://shop.oreilly.com/product/9780596519650.do)
591
642
  * [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.22.2.3
1
+ 4.22.2.6
@@ -10,6 +10,8 @@ glimmer
10
10
 
11
11
  On Mac and Linux, it additionally brings up a TUI (Text-based User Interface) for interactive navigation and execution of Glimmer tasks (courtesy of [rake-tui](https://github.com/AndyObtiva/rake-tui)).
12
12
 
13
+ (note that in ARM64 machines, the TUI does not seem to work at the moment, so simply use glimmer commands directly without the TUI until this is fixed)
14
+
13
15
  On Windows, it simply lists the available Glimmer tasks at the end (courtsey of [rake](https://github.com/ruby/rake)).
14
16
 
15
17
  If you are new to Glimmer, you may read the Basic Usage section and skip the rest until you have gone through [Girb (Glimmer irb) Command](#girb-glimmer-irb-command), [Glimmer GUI DSL Syntax](#glimmer-gui-dsl-syntax), and [Samples](#samples).
@@ -107,7 +109,7 @@ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
107
109
 
108
110
  Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
109
111
 
110
- Note: under Zsh (Z Shell), glimmer can only be used in its advanced TUI mode (e.g. `glimmer` and then selecting a task) not the primitive rake task mode (e.g. `glimmer scaffold[app]`)
112
+ Note: under Zsh (Z Shell), glimmer can only be used in its advanced \ mode (e.g. `glimmer` and then selecting a task) not the primitive rake task mode (e.g. `glimmer scaffold[app]`)
111
113
 
112
114
  ### Glimmer Samples
113
115
 
@@ -1736,8 +1736,6 @@ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/
1736
1736
 
1737
1737
  ### Canvas Shape DSL
1738
1738
 
1739
- **(BETA FEATURE)**
1740
-
1741
1739
  While other GUI toolkits only offer a way to draw graphics imperatively (e.g. draw_arc, draw_rectangle, move_to, line_to, etc...), Glimmer DSL for SWT breaks away from the mold by enabling software engineers to draw graphics declaratively. Simply declare all the shapes you want to see with their attributes, like background/foreground colors, and Glimmer DSL for SWT takes care of the rest, painting graphics on a blank `canvas` widget or amending/decorating an existing widget. This is accomplished through the Canvas Shape DSL, a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax. Still, for the rare cases where imperative logic is needed, Glimmer DSL for SWT supports imperative painting of graphics through direct usage of SWT.
1742
1740
 
1743
1741
  ![Canvas Shape DSL Line](/images/glimmer-canvas-shape-dsl-line.png)
@@ -2723,8 +2721,6 @@ Check [Hello, Canvas!](/docs/reference/GLIMMER_SAMPLES.md#hello-canvas) for an e
2723
2721
 
2724
2722
  #### Pixel Graphics
2725
2723
 
2726
- **(BETA FEATURE)**
2727
-
2728
2724
  If you need to paint pixel graphics, use the optimized `pixel` keyword alternative to `point`, which takes foreground as a hash argument and bypasses the [Glimmer DSL Engine chain of responsibility](https://github.com/AndyObtiva/glimmer#dsl-engine), thus rendering faster when having very large pixel counts.
2729
2725
 
2730
2726
  Example (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
@@ -2905,8 +2901,6 @@ As they say, there are many ways to skin a cat! This is in line with the Ruby wa
2905
2901
 
2906
2902
  ### Canvas Path DSL
2907
2903
 
2908
- **(BETA FEATURE)**
2909
-
2910
2904
  Unlike common imperative GUI graphing toolkits, Glimmer enables declarative rendering of paths with the new Canvas Path DSL (Early Alpha) via the new `path { }` keyword and by nesting one of the following path segment keywords underneath:
2911
2905
  - `point(x1, y1)`: renders a Point (Dot) as part of a path.
2912
2906
  - `line(x1, y1, x2=nil, y2=nil)`: renders a Line as part of a path. If you drop x2, y2, it joins to the previous point automatically. You may repeat for a series of lines forming a curve.
@@ -2951,8 +2945,6 @@ Every path segment object (mixing in [`Glimmer::SWT::Custom::PathSegment`](/lib/
2951
2945
 
2952
2946
  ### Canvas Transform DSL
2953
2947
 
2954
- **(BETA FEATURE)**
2955
-
2956
2948
  The transform DSL builds [org.eclipse.swt.graphics.Transform](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/Transform.html) objects with a nice declarative syntax.
2957
2949
 
2958
2950
  `transform` keyword builds a `Transform` object. It optionally takes the transformation matrix elements: (m11, m12, m21, m22, dx, dy)
@@ -3811,7 +3803,7 @@ Custom widgets are brand new Glimmer DSL keywords that represent aggregates of e
3811
3803
 
3812
3804
  You can find out about [published Glimmer Custom Widgets](https://github.com/AndyObtiva/glimmer-dsl-swt#gem-listing) by running the `glimmer list:gems:customwidget` command
3813
3805
 
3814
- Glimmer supports three ways of creating custom widgets with minimal code:
3806
+ Glimmer supports two ways of creating custom widgets with minimal code:
3815
3807
  1. Method-based Custom Widgets (for single-view-internal reuse): Extract a method containing Glimmer DSL widget syntax. Useful for quickly eliminating redundant code within a single view.
3816
3808
  2. Class-based Custom Widgets (for multiple-view-external reuse): Create a class that includes the `Glimmer::UI::CustomWidget` module and Glimmer DSL widget syntax in a `body {}` block. This will automatically extend Glimmer's DSL syntax with an underscored lowercase keyword matching the class name by convention. Useful in making a custom widget available in many views.
3817
3809
 
@@ -4429,9 +4421,11 @@ Also, you may check out [Hello, Custom Widget!](/docs/reference/GLIMMER_SAMPLES.
4429
4421
 
4430
4422
  ### Custom Shells
4431
4423
 
4432
- Custom shells are a kind of custom widgets that have shells only as the body root. They can be self-contained applications that may be opened and hidden/closed independently of the main app.
4424
+ Custom shell is a kind of a [custom widget](#custom-widgets) that has `shell` (window) as the body root widget. It can be used to represent an application or a reusable window that may be opened/hidden/closed independently of the main application.
4425
+
4426
+ Except in the case of small demos, it is always recommended to build [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) applications as custom shells.
4433
4427
 
4434
- They may also be chained in a wizard fashion.
4428
+ Custom shells may also be chained in a wizard fashion in some cases.
4435
4429
 
4436
4430
  You can find out about [published Glimmer Custom Shells](https://github.com/AndyObtiva/glimmer-dsl-swt#gem-listing) by running the `glimmer list:gems:customshell` command
4437
4431
 
@@ -4468,33 +4462,41 @@ class WizardStep
4468
4462
  }
4469
4463
  end
4470
4464
 
4471
- shell { |app_shell|
4472
- text "Wizard"
4473
- minimum_size 200, 100
4474
- @current_step_number = 1
4475
- @wizard_steps = 5.times.map { |n|
4476
- wizard_step(number: n+1, step_count: 5) {
4477
- on_swt_hide do
4478
- if @current_step_number < 5
4479
- @current_step_number += 1
4465
+ class Wizard
4466
+ include Glimmer::UI::CustomShell
4467
+
4468
+ body {
4469
+ shell { |app_shell|
4470
+ text "Wizard"
4471
+ minimum_size 200, 100
4472
+ @current_step_number = 1
4473
+ @wizard_steps = 5.times.map { |n|
4474
+ wizard_step(number: n+1, step_count: 5) {
4475
+ on_swt_hide do
4476
+ if @current_step_number < 5
4477
+ @current_step_number += 1
4478
+ app_shell.hide
4479
+ @wizard_steps[@current_step_number - 1].open
4480
+ end
4481
+ end
4482
+ }
4483
+ }
4484
+ button {
4485
+ text "Start"
4486
+ font height: 40
4487
+ on_widget_selected do
4480
4488
  app_shell.hide
4481
4489
  @wizard_steps[@current_step_number - 1].open
4482
4490
  end
4483
- end
4491
+ }
4484
4492
  }
4485
4493
  }
4486
- button {
4487
- text "Start"
4488
- font height: 40
4489
- on_widget_selected do
4490
- app_shell.hide
4491
- @wizard_steps[@current_step_number - 1].open
4492
- end
4493
- }
4494
- }.open
4494
+ end
4495
+
4496
+ Wizard.launch
4495
4497
  ```
4496
4498
 
4497
- If you use a Custom Shell as the top-level app shell, you may invoke the class method `.launch` instead to avoid building an app class yourself or including Glimmer into the top-level namespace (e.g. `Tetris.launch` instead of `include Glimmer; tetris.open`)
4499
+ If you use a Custom Shell as the top-level app shell, you may invoke the class method `.launch` instead of `open` to avoid building an app class yourself or including Glimmer into the top-level namespace (e.g. `Tetris.launch` instead of `include Glimmer; tetris.open`)
4498
4500
 
4499
4501
  You may check out [Hello, Custom Shell!](/docs/reference/GLIMMER_SAMPLES.md#hello-custom-shell) for another example.
4500
4502
 
@@ -85,7 +85,6 @@
85
85
  - [Gladiator](#gladiator)
86
86
  - [Timer](#timer)
87
87
  - [Glimmer Klondike Solitaire](#glimmer-klondike-solitaire)
88
- - [Glimmer Metronome](#glimmer-metronome)
89
88
  - [License](#license)
90
89
 
91
90
  ## Samples
@@ -1336,6 +1335,8 @@ This sample demonstrates a Metronome that accepts a beat count and bpm rate, tic
1336
1335
 
1337
1336
  It takes advantage of the Canvas Shape DSL, data-binding, and the Java Sound library. It employs a hybrid approach of relying on standard widget layouts (grid layout) and canvas shape x,y placement.
1338
1337
 
1338
+ An external more full-fledged version exists too as [Glimmer Metronome](https://github.com/AndyObtiva/glimmer_metronome).
1339
+
1339
1340
  Code:
1340
1341
 
1341
1342
  [samples/elaborate/metronome.rb](/samples/elaborate/metronome.rb)
@@ -1429,14 +1430,6 @@ This is a souped up version of the Klondike Solitaire elaborate sample, which is
1429
1430
 
1430
1431
  ![Glimmer Klondike Solitaire](https://raw.githubusercontent.com/AndyObtiva/glimmer_klondike_solitaire/master/images/glimmer-klondike-solitaire.png)
1431
1432
 
1432
- #### Glimmer Metronome
1433
-
1434
- This is an external enhanced version of [Metronome](#metronome) that can be packaged as an independent native executable.
1435
-
1436
- [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer_metronome/master/icons/linux/Glimmer%20Metronome.png" height=40 /> Glimmer Metronome](https://github.com/AndyObtiva/glimmer_metronome)
1437
-
1438
- ![Metronome](https://raw.githubusercontent.com/AndyObtiva/glimmer_metronome/master/screenshots/glimmer-metronome.png)
1439
-
1440
1433
  ## License
1441
1434
 
1442
1435
  [MIT](LICENSE.txt)
Binary file
@@ -72,10 +72,13 @@ module Glimmer
72
72
  OPERATING_SYSTEMS_SUPPORTED.detect {|os| OS.send("#{os}?")}
73
73
  end
74
74
 
75
- def special_cpu_architecture_suffix
75
+ def is_arm64?
76
76
  host_cpu = OS.host_cpu.downcase
77
- special = host_cpu.include?('aarch64') || host_cpu.include?('arm')
78
- special ? "_aarch64" : ''
77
+ host_cpu.include?('aarch64') || host_cpu.include?('arm')
78
+ end
79
+
80
+ def special_cpu_architecture_suffix
81
+ is_arm64? ? "_aarch64" : ''
79
82
  end
80
83
 
81
84
  def swt_jar_file
@@ -187,7 +190,7 @@ module Glimmer
187
190
  end
188
191
 
189
192
  def display_tasks
190
- if OS.windows?
193
+ if OS.windows? || Launcher.is_arm64?
191
194
  require 'rake'
192
195
  Rake::TaskManager.record_task_metadata = true
193
196
  require_relative 'rake_task'
@@ -443,13 +443,14 @@ module Glimmer
443
443
  require 'glimmer-dsl-swt'
444
444
  # add more gems if needed
445
445
  end
446
- require '#{file_name(app_name)}/view/app_view'
447
-
446
+
448
447
  class #{class_name(app_name)}
449
448
  APP_ROOT = File.expand_path('../..', __FILE__)
450
449
  VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
451
450
  LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
452
451
  end
452
+
453
+ require '#{file_name(app_name)}/view/app_view'
453
454
  MULTI_LINE_STRING
454
455
  end
455
456
 
@@ -596,12 +597,13 @@ module Glimmer
596
597
  Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
597
598
  Display.app_version = VERSION
598
599
  @display = display {
599
- on_about {
600
+ on_about do
600
601
  display_about_dialog
601
- }
602
- on_preferences {
602
+ end
603
+
604
+ on_preferences do
603
605
  #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
604
- }
606
+ end
605
607
  }
606
608
  end
607
609
  MULTI_LINE_STRING
@@ -657,17 +659,21 @@ module Glimmer
657
659
  menu_bar {
658
660
  menu {
659
661
  text '&File'
662
+
660
663
  menu_item {
661
664
  text '&About...'
662
- on_widget_selected {
665
+
666
+ on_widget_selected do
663
667
  display_about_dialog
664
- }
668
+ end
665
669
  }
670
+
666
671
  menu_item {
667
672
  text '&Preferences...'
668
- on_widget_selected {
673
+
674
+ on_widget_selected do
669
675
  #{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
670
- }
676
+ end
671
677
  }
672
678
  }
673
679
  }
@@ -696,31 +702,37 @@ module Glimmer
696
702
  custom_shell_file_content += <<-MULTI_LINE_STRING
697
703
  def display_preferences_dialog
698
704
  dialog(swt_widget) {
699
- text 'Preferences'
700
705
  grid_layout {
701
706
  margin_height 5
702
707
  margin_width 5
703
708
  }
709
+
710
+ text 'Preferences'
711
+
704
712
  group {
705
713
  row_layout {
706
714
  type :vertical
707
715
  spacing 10
708
716
  }
717
+
709
718
  text 'Greeting'
710
719
  font style: :bold
720
+
711
721
  [
712
722
  'Hello, World!',
713
723
  'Howdy, Partner!'
714
724
  ].each do |greeting_text|
715
725
  button(:radio) {
716
- text greeting_text
717
- selection <= [self, :greeting, on_read: ->(g) { g == greeting_text }]
718
726
  layout_data {
719
727
  width 160
720
728
  }
721
- on_widget_selected { |event|
729
+
730
+ text greeting_text
731
+ selection <= [self, :greeting, on_read: ->(g) { g == greeting_text }]
732
+
733
+ on_widget_selected do |event|
722
734
  self.greeting = event.widget.getText
723
- }
735
+ end
724
736
  }
725
737
  end
726
738
  }
@@ -822,6 +834,7 @@ end
822
834
  background background_color
823
835
  cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*0.65 - size_width*0.66, 0 - size_height*0.33, size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
824
836
  }
837
+
825
838
  path {
826
839
  background background_color
827
840
  cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*1.35 - size_width*0.66, 0 - size_height*0.33, size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
@@ -1026,14 +1026,17 @@ module Glimmer
1026
1026
 
1027
1027
  def ensure_extent(paint_event)
1028
1028
  old_extent = @extent
1029
+ old_extent_args = @extent_args
1029
1030
  if ['text', 'string'].include?(@name)
1030
1031
  extent_args = [string]
1031
1032
  extent_flags = SWTProxy[:draw_transparent, :draw_delimiter] if current_parameter_name?(:is_transparent) && is_transparent
1032
1033
  extent_flags = flags if current_parameter_name?(:flags)
1033
1034
  extent_args << extent_flags unless extent_flags.nil?
1034
1035
  self.extent = paint_event.gc.send("#{@name}Extent", *extent_args)
1036
+ @extent_args = extent_args
1035
1037
  end
1036
- if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y) # TODO add a check to text content changing too
1038
+ # comparing extent_args with old ones ensures that if content changes, calculated_args_changed! is called
1039
+ if !@extent.nil? && (old_extent&.x != @extent&.x || old_extent&.y != @extent&.y || @extent_args != old_extent_args)
1037
1040
  calculated_args_changed!
1038
1041
  parent.calculated_args_changed_for_defaults! if parent.is_a?(Shape)
1039
1042
  end
@@ -1101,10 +1104,11 @@ module Glimmer
1101
1104
  default_x? && x_delta,
1102
1105
  default_y? && default_y,
1103
1106
  default_y? && y_delta,
1107
+ (['text', 'string'].include?(@name) && string),
1104
1108
  ]
1105
1109
  if calculated_args_dependencies != @calculated_args_dependencies
1106
1110
  # avoid recalculating values again
1107
- x, y, parent_absolute_x, parent_absolute_y, default_width, default_width_delta, default_height, default_height_delta, max_width, max_width_delta, max_height, max_height_delta, default_x, default_x_delta, default_y, default_y_delta = @calculated_args_dependencies = calculated_args_dependencies
1111
+ x, y, parent_absolute_x, parent_absolute_y, default_width, default_width_delta, default_height, default_height_delta, max_width, max_width_delta, max_height, max_height_delta, default_x, default_x_delta, default_y, default_y_delta, string = @calculated_args_dependencies = calculated_args_dependencies
1108
1112
  # Note: Must set x and move_by because not all shapes have a real x and some must translate all their points with move_by
1109
1113
  # TODO change that by setting a bounding box for all shapes with a calculated top-left x, y and
1110
1114
  # a setter that does the moving inside them instead so that I could rely on absolute_x and absolute_y
@@ -97,6 +97,7 @@ module Glimmer
97
97
  end
98
98
  proxy = self
99
99
  # TODO consider adding a get_data/set_data method to conform with other SWT widgets
100
+ @swt_image.class.__persistent__ = true
100
101
  @swt_image.singleton_class.define_method(:dispose) do
101
102
  proxy.clear_shapes
102
103
  super()
@@ -21,14 +21,14 @@ class Calculator
21
21
  Display.setAppName('Glimmer Calculator')
22
22
 
23
23
  display {
24
- on_swt_keydown { |key_event|
24
+ on_swt_keydown do |key_event|
25
25
  char = key_event.character.chr rescue nil
26
26
  @presenter.press(char)
27
- }
27
+ end
28
28
 
29
- on_about {
29
+ on_about do
30
30
  display_about_dialog
31
- }
31
+ end
32
32
  }
33
33
  end
34
34
 
@@ -59,16 +59,16 @@ class Calculator
59
59
  operation_button('÷')
60
60
  operation_button('×')
61
61
  operation_button('−')
62
- (7..9).each { |number|
62
+ (7..9).each do |number|
63
63
  number_button(number)
64
- }
64
+ end
65
65
  operation_button('+', font: BUTTON_FONT_BIG, vertical_span: 2)
66
- (4..6).each { |number|
66
+ (4..6).each do |number|
67
67
  number_button(number)
68
- }
69
- (1..3).each { |number|
68
+ end
69
+ (1..3).each do |number|
70
70
  number_button(number)
71
- }
71
+ end
72
72
  command_button('=', font: BUTTON_FONT_BIG, vertical_span: 2)
73
73
  number_button(0, horizontal_span: 2)
74
74
  operation_button('.')
@@ -98,9 +98,9 @@ class Calculator
98
98
  vertical_span options[:vertical_span]
99
99
  }
100
100
 
101
- on_widget_selected {
101
+ on_widget_selected do
102
102
  @presenter.press(command)
103
- }
103
+ end
104
104
  }
105
105
  end
106
106