glimmer-dsl-swt 4.22.2.1 → 4.22.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +26 -12
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_COMMAND.md +3 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +145 -0
- data/docs/reference/GLIMMER_SAMPLES.md +17 -9
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/dsl/swt/exec_expression.rb +1 -2
- data/lib/glimmer/launcher.rb +7 -4
- data/lib/glimmer/rake_task/scaffold.rb +28 -15
- data/lib/glimmer/swt/image_proxy.rb +1 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +4 -0
- data/samples/elaborate/calculator.rb +12 -12
- data/samples/elaborate/contact_manager.rb +26 -14
- data/samples/elaborate/game_of_life.rb +8 -8
- data/samples/elaborate/klondike_solitaire/view/action_panel.rb +2 -2
- data/samples/elaborate/klondike_solitaire/view/klondike_solitaire_menu_bar.rb +15 -10
- data/samples/elaborate/login.rb +16 -10
- data/samples/elaborate/mandelbrot_fractal.rb +26 -20
- data/samples/elaborate/meta_sample.rb +6 -6
- data/samples/elaborate/metronome.rb +4 -4
- data/samples/elaborate/snake/model/apple.rb +33 -0
- data/samples/elaborate/snake/model/game.rb +68 -0
- data/samples/elaborate/snake/model/snake.rb +95 -0
- data/samples/elaborate/snake/model/vertebra.rb +22 -0
- data/samples/elaborate/snake/presenter/cell.rb +27 -0
- data/samples/elaborate/snake/presenter/grid.rb +49 -0
- data/samples/elaborate/snake.rb +103 -0
- data/samples/elaborate/stock_ticker.rb +12 -12
- data/samples/elaborate/tetris.rb +10 -10
- data/samples/elaborate/timer.rb +36 -26
- data/samples/elaborate/user_profile.rb +53 -14
- data/samples/elaborate/weather.rb +2 -2
- data/samples/hello/hello_button.rb +3 -3
- data/samples/hello/hello_canvas_animation.rb +2 -2
- data/samples/hello/hello_color_dialog.rb +4 -4
- data/samples/hello/hello_custom_shell.rb +2 -2
- data/samples/hello/hello_dialog.rb +4 -4
- data/samples/hello/hello_directory_dialog.rb +2 -2
- data/samples/hello/hello_expand_bar.rb +4 -5
- data/samples/hello/hello_file_dialog.rb +2 -2
- data/samples/hello/hello_font_dialog.rb +2 -2
- data/samples/hello/hello_link.rb +5 -4
- data/samples/hello/hello_list_multi_selection.rb +3 -1
- data/samples/hello/hello_list_single_selection.rb +3 -1
- data/samples/hello/hello_menu_bar.rb +28 -28
- data/samples/hello/hello_message_box.rb +2 -2
- data/samples/hello/hello_pop_up_context_menu.rb +18 -8
- data/samples/hello/hello_shell.rb +16 -16
- data/samples/hello/hello_styled_text.rb +2 -2
- data/samples/hello/hello_table.rb +4 -4
- data/samples/hello/hello_tray_item.rb +2 -2
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ddae7932813d7434f6ea1013668ca03d899eae9dc6a0aacece9139f1172f98a
|
4
|
+
data.tar.gz: dcf0088e2b10c5861f5833c6962c3f253e043f82e7d304fdd35b3a923241c5ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd84fc1cebaf9e93eff102853f27198cc3bfb4bd5cdad95c63a26a73a05e9331caf54c430883e14f41e8e58688d5e889d9ad0c9758da59341b98f60ec59a4330
|
7
|
+
data.tar.gz: 99021203e9835c9204c248f6bffd333f48cf99dccc3ad5b6a223bb2db61217ff364110948b46da7999e9c3c1b0b8f452040270daf12e18f1d79f4b48b3a84808
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 4.22.2.5
|
4
|
+
|
5
|
+
- Update all samples to match the [GLIMMER_STYLE_GUIDE.md](/docs/reference/GLIMMER_STYLE_GUIDE.md)
|
6
|
+
- Update scaffolding code to match the [GLIMMER_STYLE_GUIDE.md](/docs/reference/GLIMMER_STYLE_GUIDE.md)
|
7
|
+
|
8
|
+
## 4.22.2.4
|
9
|
+
|
10
|
+
- Address the warning regarding using Ruby singletons on Java objects (shows up when running `glimmer samples`)
|
11
|
+
- Fix order of calling `require 'app_name/view/app_view'` in scaffolded app (must be last)
|
12
|
+
|
13
|
+
## 4.22.2.3
|
14
|
+
|
15
|
+
- Support `#content { }` on `layout_data`
|
16
|
+
- Fix issue with data-binding `layout_data {exclude}` property using Shine `<=>` syntax
|
17
|
+
|
18
|
+
## 4.22.2.2
|
19
|
+
|
20
|
+
- Snake elaborate sample
|
21
|
+
- Fixed `timer_exec(time_in_millis) {}` expresion
|
22
|
+
|
3
23
|
## 4.22.2.1
|
4
24
|
|
5
25
|
- Upgrade to glimmer 2.6.0
|
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.
|
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.5
|
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,19 +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.
|
20
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.22.2.5 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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
|
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 / Only Rails 5 Support for Now | 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 (MRI Ruby 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
|
33
39
|
|
34
40
|
## Examples
|
35
41
|
|
@@ -325,7 +331,7 @@ jgem install glimmer-dsl-swt
|
|
325
331
|
|
326
332
|
Or this command if you want a specific version:
|
327
333
|
```
|
328
|
-
jgem install glimmer-dsl-swt -v 4.22.2.
|
334
|
+
jgem install glimmer-dsl-swt -v 4.22.2.5
|
329
335
|
```
|
330
336
|
|
331
337
|
`jgem` is JRuby's version of `gem` command.
|
@@ -353,7 +359,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
353
359
|
|
354
360
|
Add the following to `Gemfile`:
|
355
361
|
```
|
356
|
-
gem 'glimmer-dsl-swt', '~> 4.22.2.
|
362
|
+
gem 'glimmer-dsl-swt', '~> 4.22.2.5'
|
357
363
|
```
|
358
364
|
|
359
365
|
And, then run:
|
@@ -376,7 +382,7 @@ glimmer
|
|
376
382
|
```
|
377
383
|
|
378
384
|
```
|
379
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.2.
|
385
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.22.2.5
|
380
386
|
|
381
387
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
382
388
|
|
@@ -546,6 +552,14 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
|
|
546
552
|
|
547
553
|
[Befunge 98 GUI](https://github.com/AndyObtiva/befunge98/tree/gui)
|
548
554
|
|
555
|
+
### Glimmer Metronome
|
556
|
+
|
557
|
+
[<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)
|
558
|
+
|
559
|
+
### Glimmer Wordle
|
560
|
+
|
561
|
+
[<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)
|
562
|
+
|
549
563
|
## Packaging & Distribution
|
550
564
|
|
551
565
|
Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single command:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.22.2.
|
1
|
+
4.22.2.5
|
@@ -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
|
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
|
|
@@ -1495,6 +1495,13 @@ Glimmer composites always come with `grid_layout` by default, but you can still
|
|
1495
1495
|
|
1496
1496
|
Glimmer shell always comes with `fill_layout` having `:horizontal` type.
|
1497
1497
|
|
1498
|
+
If you ever want to force a re-layout on a `composite` or `shell`, you can call the following:
|
1499
|
+
|
1500
|
+
```ruby
|
1501
|
+
composite_or_shell.layout(true, true)
|
1502
|
+
composite_or_shell.pack(true)
|
1503
|
+
```
|
1504
|
+
|
1498
1505
|
This is a great guide for learning more about SWT layouts:
|
1499
1506
|
|
1500
1507
|
https://www.eclipse.org/articles/Article-Understanding-Layouts/Understanding-Layouts.htm
|
@@ -1579,6 +1586,144 @@ composite {
|
|
1579
1586
|
|
1580
1587
|
If you data-bind any layout data properties, when they change, the shell containing their widget re-packs its children (calls `#pack` method automatically) to ensure proper relayout of all widgets.
|
1581
1588
|
|
1589
|
+
Also, if you ever want a widget to be excluded from layout entirely (in addition to having `visible false` on the widget), you can set `layout_data { exclude true }` or data-bind `exclude` property of `layout_data` to have a widget included/excluded automatically based on a condition.
|
1590
|
+
|
1591
|
+
Here is a re-implementation of the [Login sample](/docs/reference/GLIMMER_SAMPLES.md#login) that hides/shows login/logout buttons upon login/logout (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
|
1592
|
+
|
1593
|
+
```ruby
|
1594
|
+
require 'glimmer-dsl-swt'
|
1595
|
+
|
1596
|
+
class LoginPresenter
|
1597
|
+
|
1598
|
+
attr_accessor :user_name
|
1599
|
+
attr_accessor :password
|
1600
|
+
attr_accessor :status
|
1601
|
+
|
1602
|
+
def initialize
|
1603
|
+
@user_name = ""
|
1604
|
+
@password = ""
|
1605
|
+
@status = "Logged Out"
|
1606
|
+
end
|
1607
|
+
|
1608
|
+
def status=(status)
|
1609
|
+
@status = status
|
1610
|
+
end
|
1611
|
+
|
1612
|
+
def valid?
|
1613
|
+
!@user_name.to_s.strip.empty? && !@password.to_s.strip.empty?
|
1614
|
+
end
|
1615
|
+
|
1616
|
+
def logged_in?
|
1617
|
+
self.status == "Logged In"
|
1618
|
+
end
|
1619
|
+
|
1620
|
+
def logged_out?
|
1621
|
+
!self.logged_in?
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
def login!
|
1625
|
+
return unless valid?
|
1626
|
+
self.status = "Logged In"
|
1627
|
+
end
|
1628
|
+
|
1629
|
+
def logout!
|
1630
|
+
self.user_name = ""
|
1631
|
+
self.password = ""
|
1632
|
+
self.status = "Logged Out"
|
1633
|
+
end
|
1634
|
+
|
1635
|
+
end
|
1636
|
+
|
1637
|
+
class Login
|
1638
|
+
include Glimmer::UI::CustomShell
|
1639
|
+
|
1640
|
+
before_body do
|
1641
|
+
@presenter = LoginPresenter.new
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
body {
|
1645
|
+
shell {
|
1646
|
+
text "Login"
|
1647
|
+
|
1648
|
+
composite {
|
1649
|
+
grid_layout(2, false) #two columns with differing widths
|
1650
|
+
|
1651
|
+
label { text "Username:" } # goes in column 1
|
1652
|
+
@user_name_text = text { # goes in column 2
|
1653
|
+
layout_data :fill, :center, true, false
|
1654
|
+
text <=> [@presenter, :user_name]
|
1655
|
+
enabled <= [@presenter, :logged_out?, computed_by: :status]
|
1656
|
+
|
1657
|
+
on_key_pressed { |event|
|
1658
|
+
@password_text.set_focus if event.keyCode == swt(:cr)
|
1659
|
+
}
|
1660
|
+
}
|
1661
|
+
|
1662
|
+
label { text "Password:" }
|
1663
|
+
@password_text = text(:password, :border) {
|
1664
|
+
layout_data :fill, :center, true, false
|
1665
|
+
text <=> [@presenter, :password]
|
1666
|
+
enabled <= [@presenter, :logged_out?, computed_by: :status]
|
1667
|
+
|
1668
|
+
on_key_pressed { |event|
|
1669
|
+
@presenter.login! if event.keyCode == swt(:cr)
|
1670
|
+
}
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
label { text "Status:" }
|
1674
|
+
label {
|
1675
|
+
layout_data :fill, :center, true, false
|
1676
|
+
text <= [@presenter, :status]
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
button {
|
1680
|
+
layout_data {
|
1681
|
+
exclude <= [@presenter, :logged_in?, computed_by: :status]
|
1682
|
+
}
|
1683
|
+
|
1684
|
+
text "Login"
|
1685
|
+
visible <= [@presenter, :logged_out?, computed_by: :status]
|
1686
|
+
|
1687
|
+
on_widget_selected { @presenter.login! }
|
1688
|
+
on_key_pressed { |event|
|
1689
|
+
if event.keyCode == swt(:cr)
|
1690
|
+
@presenter.login!
|
1691
|
+
end
|
1692
|
+
}
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
button {
|
1696
|
+
layout_data {
|
1697
|
+
exclude <= [@presenter, :logged_out?, computed_by: :status]
|
1698
|
+
}
|
1699
|
+
|
1700
|
+
text "Logout"
|
1701
|
+
visible <= [@presenter, :logged_in?, computed_by: :status]
|
1702
|
+
|
1703
|
+
on_widget_selected { @presenter.logout! }
|
1704
|
+
on_key_pressed { |event|
|
1705
|
+
if event.keyCode == swt(:cr)
|
1706
|
+
@presenter.logout!
|
1707
|
+
@user_name_text.set_focus
|
1708
|
+
end
|
1709
|
+
}
|
1710
|
+
}
|
1711
|
+
}
|
1712
|
+
}
|
1713
|
+
}
|
1714
|
+
end
|
1715
|
+
|
1716
|
+
Login.launch
|
1717
|
+
```
|
1718
|
+
|
1719
|
+
Login (with `exclude` data-binding) - Logged Out
|
1720
|
+
|
1721
|
+
![Login Exclude Logged Out](/images/glimmer-login-exclude-logged-out.png)
|
1722
|
+
|
1723
|
+
Login (with `exclude` data-binding) - Logged In
|
1724
|
+
|
1725
|
+
![Login Exclude Logged In](/images/glimmer-login-exclude-logged-in.png)
|
1726
|
+
|
1582
1727
|
**NOTE**: Layout data must never be reused between widgets. Always specify or clone again for every widget.
|
1583
1728
|
|
1584
1729
|
This is a great guide for learning more about SWT layouts:
|
@@ -79,12 +79,12 @@
|
|
79
79
|
- [Metronome](#metronome)
|
80
80
|
- [Weather](#weather)
|
81
81
|
- [Quarto](#quarto)
|
82
|
+
- [Snake](#snake)
|
82
83
|
- [External Samples](#external-samples)
|
83
84
|
- [Glimmer Calculator](#glimmer-calculator)
|
84
85
|
- [Gladiator](#gladiator)
|
85
86
|
- [Timer](#timer)
|
86
87
|
- [Glimmer Klondike Solitaire](#glimmer-klondike-solitaire)
|
87
|
-
- [Glimmer Metronome](#glimmer-metronome)
|
88
88
|
- [License](#license)
|
89
89
|
|
90
90
|
## Samples
|
@@ -1335,6 +1335,8 @@ This sample demonstrates a Metronome that accepts a beat count and bpm rate, tic
|
|
1335
1335
|
|
1336
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.
|
1337
1337
|
|
1338
|
+
An external more full-fledged version exists too as [Glimmer Metronome](https://github.com/AndyObtiva/glimmer_metronome).
|
1339
|
+
|
1338
1340
|
Code:
|
1339
1341
|
|
1340
1342
|
[samples/elaborate/metronome.rb](/samples/elaborate/metronome.rb)
|
@@ -1375,6 +1377,20 @@ Quarto
|
|
1375
1377
|
|
1376
1378
|
![Quarto](/images/glimmer-quarto.png)
|
1377
1379
|
|
1380
|
+
#### Snake
|
1381
|
+
|
1382
|
+
This is the classic Snake game, which demonstrates MVP (Model-View-Presenter) and data-binding written [test-first](/spec/samples/elaborate/snake/model/game_spec.rb).
|
1383
|
+
|
1384
|
+
Code:
|
1385
|
+
|
1386
|
+
[samples/elaborate/snake.rb](/samples/elaborate/snake.rb)
|
1387
|
+
|
1388
|
+
Snake
|
1389
|
+
|
1390
|
+
![Snake](/images/glimmer-snake.png)
|
1391
|
+
|
1392
|
+
![Snake Video](/images/glimmer-snake.gif)
|
1393
|
+
|
1378
1394
|
### External Samples
|
1379
1395
|
|
1380
1396
|
#### Glimmer Calculator
|
@@ -1414,14 +1430,6 @@ This is a souped up version of the Klondike Solitaire elaborate sample, which is
|
|
1414
1430
|
|
1415
1431
|
![Glimmer Klondike Solitaire](https://raw.githubusercontent.com/AndyObtiva/glimmer_klondike_solitaire/master/images/glimmer-klondike-solitaire.png)
|
1416
1432
|
|
1417
|
-
#### Glimmer Metronome
|
1418
|
-
|
1419
|
-
This is an external enhanced version of [Metronome](#metronome) that can be packaged as an independent native executable.
|
1420
|
-
|
1421
|
-
[<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)
|
1422
|
-
|
1423
|
-
![Metronome](https://raw.githubusercontent.com/AndyObtiva/glimmer_metronome/master/screenshots/glimmer-metronome.png)
|
1424
|
-
|
1425
1433
|
## License
|
1426
1434
|
|
1427
1435
|
[MIT](LICENSE.txt)
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -72,10 +72,13 @@ module Glimmer
|
|
72
72
|
OPERATING_SYSTEMS_SUPPORTED.detect {|os| OS.send("#{os}?")}
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def is_arm64?
|
76
76
|
host_cpu = OS.host_cpu.downcase
|
77
|
-
|
78
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -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()
|
@@ -106,6 +106,10 @@ module Glimmer
|
|
106
106
|
def attribute_getter(attribute_name)
|
107
107
|
"#{attribute_name.to_s.camelcase(:lower)}"
|
108
108
|
end
|
109
|
+
|
110
|
+
def content(&block)
|
111
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::LayoutDataExpression.new, 'layout_data', &block)
|
112
|
+
end
|
109
113
|
end
|
110
114
|
end
|
111
115
|
end
|
@@ -21,14 +21,14 @@ class Calculator
|
|
21
21
|
Display.setAppName('Glimmer Calculator')
|
22
22
|
|
23
23
|
display {
|
24
|
-
on_swt_keydown
|
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
|
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
|
66
|
+
(4..6).each do |number|
|
67
67
|
number_button(number)
|
68
|
-
|
69
|
-
(1..3).each
|
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
|
|