glimmer-dsl-swt 4.20.13.18 → 4.20.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_SAMPLES.md +52 -1
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/ext/glimmer/config.rb +1 -0
- data/lib/glimmer/dsl/swt/bind_expression.rb +0 -1
- data/lib/glimmer/dsl/swt/observe_expression.rb +3 -17
- data/lib/glimmer/swt/widget_proxy.rb +32 -0
- data/samples/hello/hello_print.rb +60 -0
- data/samples/hello/hello_print_dialog.rb +87 -0
- data/samples/hello/hello_slider.rb +2 -2
- data/samples/hello/hello_toggle.rb +91 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9add0488847621e3bd25de0e500dab2ec7f8deb149526c1687995d4daeeaae27
|
4
|
+
data.tar.gz: 255b7b6013826605faae2f00ee40aef9d814b7de415bf465f9a73cbe2113abc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35db3de953fc01936d8d71adec7e827bf759e5824e1f3b51eab4d074c9b0d642eafd028a168899aba826f4058fd1ed8aa19a406cb3834caaac244ff80fa6cc14
|
7
|
+
data.tar.gz: d72dd88f5914dfa8f2c698ab0f0c594c125ceb5c86c465a25d19b60c48740e1294e69510e99030f33f2ce7992acb1d52e950f05105aaff511d5d7f4eb9095686
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.20.15.0
|
4
|
+
|
5
|
+
### 4.20.14.1
|
6
|
+
|
7
|
+
- Upgrade to Glimmer 2.1.1
|
8
|
+
- Correct Hello, Slider! sample class name
|
9
|
+
|
3
10
|
### 4.20.14.0
|
4
11
|
|
12
|
+
- Extract ObserveExpression into Glimmer
|
13
|
+
- Upgrade to Glimmer 2.1.0
|
14
|
+
|
15
|
+
### 4.20.13.18
|
16
|
+
|
5
17
|
- Change `arrow` widget default SWT style to include `:down`
|
6
18
|
- Hello, Arrow! sample
|
7
19
|
|
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.20.
|
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.20.15.0
|
2
2
|
## JRuby Desktop Development GUI Framework
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
4
4
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
@@ -15,7 +15,7 @@
|
|
15
15
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
16
16
|
Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
|
17
17
|
|
18
|
-
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.
|
18
|
+
[Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.15.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (please report any issues you may encounter).
|
19
19
|
|
20
20
|
**Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
|
21
21
|
|
@@ -321,7 +321,7 @@ jgem install glimmer-dsl-swt
|
|
321
321
|
|
322
322
|
Or this command if you want a specific version:
|
323
323
|
```
|
324
|
-
jgem install glimmer-dsl-swt -v 4.20.
|
324
|
+
jgem install glimmer-dsl-swt -v 4.20.15.0
|
325
325
|
```
|
326
326
|
|
327
327
|
`jgem` is JRuby's version of `gem` command.
|
@@ -349,7 +349,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
349
349
|
|
350
350
|
Add the following to `Gemfile`:
|
351
351
|
```
|
352
|
-
gem 'glimmer-dsl-swt', '~> 4.20.
|
352
|
+
gem 'glimmer-dsl-swt', '~> 4.20.15.0'
|
353
353
|
```
|
354
354
|
|
355
355
|
And, then run:
|
@@ -370,7 +370,7 @@ glimmer
|
|
370
370
|
```
|
371
371
|
|
372
372
|
```
|
373
|
-
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.
|
373
|
+
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.15.0
|
374
374
|
|
375
375
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
376
376
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.20.
|
1
|
+
4.20.15.0
|
@@ -14,6 +14,7 @@
|
|
14
14
|
- [Hello, List Single Selection!](#hello-list-single-selection)
|
15
15
|
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
16
16
|
- [Hello, Computed!](#hello-computed)
|
17
|
+
- [Hello, Toggle!](#hello-toggle)
|
17
18
|
- [Hello, Message Box!](#hello-message-box)
|
18
19
|
- [Hello, Browser!](#hello-browser)
|
19
20
|
- [Hello, Drag and Drop!](#hello-drag-and-drop)
|
@@ -32,6 +33,8 @@
|
|
32
33
|
- [Hello, Checkbox Group!](#hello-checkbox-group)
|
33
34
|
- [Hello, Directory Dialog!](#hello-directory-dialog)
|
34
35
|
- [Hello, File Dialog!](#hello-file-dialog)
|
36
|
+
- [Hello, Print Dialog!](#hello-print-dialog)
|
37
|
+
- [Hello, Print!](#hello-print)
|
35
38
|
- [Hello, Date Time!](#hello-date-time)
|
36
39
|
- [Hello, Scale!](#hello-scale)
|
37
40
|
- [Hello, Slider!](#hello-slider)
|
@@ -315,6 +318,30 @@ Code:
|
|
315
318
|
|
316
319
|
![Hello Browser](/images/glimmer-hello-computed.png)
|
317
320
|
|
321
|
+
#### Hello, Toggle!
|
322
|
+
|
323
|
+
This sample demonstrates the use of `toggle` button (aka `button(:toggle)`)
|
324
|
+
|
325
|
+
Code:
|
326
|
+
|
327
|
+
[samples/hello/hello_toggle.rb](/samples/hello/hello_toggle.rb)
|
328
|
+
|
329
|
+
![Hello Toggle](/images/glimmer-hello-toggle.png)
|
330
|
+
|
331
|
+
![Hello Toggle Red](/images/glimmer-hello-toggle-red.png)
|
332
|
+
|
333
|
+
![Hello Toggle Green](/images/glimmer-hello-toggle-green.png)
|
334
|
+
|
335
|
+
![Hello Toggle Blue](/images/glimmer-hello-toggle-blue.png)
|
336
|
+
|
337
|
+
![Hello Toggle Red Green](/images/glimmer-hello-toggle-red-green.png)
|
338
|
+
|
339
|
+
![Hello Toggle Red Blue](/images/glimmer-hello-toggle-red-blue.png)
|
340
|
+
|
341
|
+
![Hello Toggle Green Blue](/images/glimmer-hello-toggle-green-blue.png)
|
342
|
+
|
343
|
+
![Hello Toggle Red Green Blue](/images/glimmer-hello-toggle-red-green-blue.png)
|
344
|
+
|
318
345
|
#### Hello, Message Box!
|
319
346
|
|
320
347
|
This sample demonstrates a `message_box` dialog.
|
@@ -588,7 +615,7 @@ Hello, Directory Dialog! Selected Directory
|
|
588
615
|
|
589
616
|
#### Hello, File Dialog!
|
590
617
|
|
591
|
-
This sample demonstrates the use of
|
618
|
+
This sample demonstrates the use of `file_dialog` in Glimmer.
|
592
619
|
|
593
620
|
Code:
|
594
621
|
|
@@ -606,6 +633,30 @@ Hello, File Dialog! Selected File
|
|
606
633
|
|
607
634
|
![Hello File Dialog](/images/glimmer-hello-file-dialog-selected-file.png)
|
608
635
|
|
636
|
+
#### Hello, Print Dialog!
|
637
|
+
|
638
|
+
This sample demonstrates the use of `print_dialog` in Glimmer.
|
639
|
+
|
640
|
+
Code:
|
641
|
+
|
642
|
+
[samples/hello/hello_print_dialog.rb](/samples/hello/hello_print_dialog.rb)
|
643
|
+
|
644
|
+
Hello, Print Dialog!
|
645
|
+
|
646
|
+
![Hello Print Dialog](/images/glimmer-hello-print-dialog.png)
|
647
|
+
|
648
|
+
#### Hello, Print!
|
649
|
+
|
650
|
+
This sample demonstrates the use of `widget#print`, which automates work from Hello, Print Dialog! assuming a single page
|
651
|
+
|
652
|
+
Code:
|
653
|
+
|
654
|
+
[samples/hello/hello_print.rb](/samples/hello/hello_print.rb)
|
655
|
+
|
656
|
+
Hello, Print!
|
657
|
+
|
658
|
+
![Hello Print](/images/glimmer-hello-print.png)
|
659
|
+
|
609
660
|
#### Hello, Date Time!
|
610
661
|
|
611
662
|
This sample demonstrates the use of [date_time](#datetime) widget keywords in Glimmer: `date`, `date_drop_down`, `time`, and `calendar`
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
data/lib/ext/glimmer/config.rb
CHANGED
@@ -21,8 +21,7 @@
|
|
21
21
|
|
22
22
|
require 'glimmer/dsl/static_expression'
|
23
23
|
require 'glimmer/dsl/top_level_expression'
|
24
|
-
require 'glimmer/
|
25
|
-
require 'glimmer/data_binding/model_binding'
|
24
|
+
require 'glimmer/dsl/observe_expression'
|
26
25
|
require 'glimmer/ui/custom_widget'
|
27
26
|
|
28
27
|
module Glimmer
|
@@ -30,23 +29,10 @@ module Glimmer
|
|
30
29
|
module SWT
|
31
30
|
class ObserveExpression < StaticExpression
|
32
31
|
include TopLevelExpression
|
32
|
+
include Glimmer::DSL::ObserveExpression
|
33
33
|
|
34
|
-
REGEX_NESTED_OR_INDEXED_PROPERTY = /([^\[]+)(\[[^\]]+\])?/
|
35
|
-
|
36
|
-
def can_interpret?(parent, keyword, *args, &block)
|
37
|
-
keyword == 'observe' and
|
38
|
-
block_given? and
|
39
|
-
(args.size == 2) and
|
40
|
-
textual?(args[1])
|
41
|
-
end
|
42
|
-
|
43
34
|
def interpret(parent, keyword, *args, &block)
|
44
|
-
|
45
|
-
if args[1].to_s.match(REGEX_NESTED_OR_INDEXED_PROPERTY)
|
46
|
-
observer_registration = observer.observe(DataBinding::ModelBinding.new(args[0], args[1]))
|
47
|
-
else
|
48
|
-
observer_registration = observer.observe(args[0], args[1])
|
49
|
-
end
|
35
|
+
observer_registration = super
|
50
36
|
Glimmer::UI::CustomWidget.current_custom_widgets.last&.observer_registrations&.push(observer_registration)
|
51
37
|
observer_registration
|
52
38
|
end
|
@@ -610,6 +610,38 @@ module Glimmer
|
|
610
610
|
(@swt_widget.style & comparison) == comparison
|
611
611
|
end
|
612
612
|
end
|
613
|
+
|
614
|
+
def print(gc=nil, job_name: nil)
|
615
|
+
if gc.is_a?(org.eclipse.swt.graphics.GC)
|
616
|
+
@swt_widget.print(gc)
|
617
|
+
else
|
618
|
+
image = Image.new(DisplayProxy.instance.swt_display, bounds)
|
619
|
+
gc = org.eclipse.swt.graphics.GC.new(image)
|
620
|
+
success = print(gc)
|
621
|
+
if success
|
622
|
+
printer_data = DialogProxy.new('print_dialog', shell.get_data('proxy')).open
|
623
|
+
printer = Printer.new(printer_data)
|
624
|
+
job_name ||= 'Glimmer'
|
625
|
+
if printer.start_job(job_name)
|
626
|
+
printer_gc = org.eclipse.swt.graphics.GC.new(printer)
|
627
|
+
if printer.start_page
|
628
|
+
printer_gc.drawImage(image, 0, 0)
|
629
|
+
printer.end_page
|
630
|
+
else
|
631
|
+
success = false
|
632
|
+
end
|
633
|
+
printer_gc.dispose
|
634
|
+
printer.end_job
|
635
|
+
else
|
636
|
+
success = false
|
637
|
+
end
|
638
|
+
printer.dispose
|
639
|
+
gc.dispose
|
640
|
+
image.dispose
|
641
|
+
end
|
642
|
+
success
|
643
|
+
end
|
644
|
+
end
|
613
645
|
|
614
646
|
def dispose
|
615
647
|
auto_exec do
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
24
|
+
class HelloPrint
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
body {
|
28
|
+
shell {
|
29
|
+
text 'Hello, Print!'
|
30
|
+
@composite = composite {
|
31
|
+
row_layout(:vertical) {
|
32
|
+
fill true
|
33
|
+
center true
|
34
|
+
}
|
35
|
+
|
36
|
+
label(:center) {
|
37
|
+
text "Whatever you see inside the app composite\nwill get printed when clicking the Print button."
|
38
|
+
font height: 16
|
39
|
+
}
|
40
|
+
|
41
|
+
button {
|
42
|
+
text 'Print'
|
43
|
+
|
44
|
+
on_widget_selected do
|
45
|
+
# The widget#print method automates all the work seen in Hello, Print Dialog!
|
46
|
+
# the caveat is it assumes everything fits on one page
|
47
|
+
unless @composite.print
|
48
|
+
message_box {
|
49
|
+
text 'Unable To Print'
|
50
|
+
message 'Sorry! Printing is not supported on this platform!'
|
51
|
+
}.open
|
52
|
+
end
|
53
|
+
end
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
HelloPrint.launch
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
24
|
+
class HelloPrintDialog
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
body {
|
28
|
+
shell {
|
29
|
+
text 'Hello, Print Dialog!'
|
30
|
+
@composite = composite {
|
31
|
+
row_layout(:vertical) {
|
32
|
+
fill true
|
33
|
+
center true
|
34
|
+
}
|
35
|
+
|
36
|
+
label(:center) {
|
37
|
+
text "Whatever you see inside the app composite\nwill get printed when clicking the Print button."
|
38
|
+
font height: 16
|
39
|
+
}
|
40
|
+
|
41
|
+
button {
|
42
|
+
text 'Print'
|
43
|
+
|
44
|
+
on_widget_selected do
|
45
|
+
# note: you may check out Hello, Print! for a simpler version that automates the work below
|
46
|
+
image = Image.new(display.swt_display, @composite.bounds)
|
47
|
+
gc = org.eclipse.swt.graphics.GC.new(image)
|
48
|
+
success = @composite.print(gc)
|
49
|
+
if success
|
50
|
+
printer_data = print_dialog.open
|
51
|
+
printer = Printer.new(printer_data)
|
52
|
+
if printer.start_job('Glimmer')
|
53
|
+
printer_gc = org.eclipse.swt.graphics.GC.new(printer)
|
54
|
+
if printer.start_page
|
55
|
+
printer_gc.drawImage(image, 0, 0)
|
56
|
+
printer.end_page
|
57
|
+
else
|
58
|
+
message_box {
|
59
|
+
text 'Unable To Print'
|
60
|
+
message 'Sorry! Cannot start printer page!'
|
61
|
+
}.open
|
62
|
+
end
|
63
|
+
printer_gc.dispose
|
64
|
+
printer.end_job
|
65
|
+
else
|
66
|
+
message_box {
|
67
|
+
text 'Unable To Print'
|
68
|
+
message 'Sorry! Cannot start printer job!'
|
69
|
+
}.open
|
70
|
+
end
|
71
|
+
printer.dispose
|
72
|
+
gc.dispose
|
73
|
+
image.dispose
|
74
|
+
else
|
75
|
+
message_box {
|
76
|
+
text 'Unable To Print'
|
77
|
+
message 'Sorry! Printing is not supported on this platform!'
|
78
|
+
}.open
|
79
|
+
end
|
80
|
+
end
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
HelloPrintDialog.launch
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
24
|
+
class HelloToggle
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
attr_accessor :red, :green, :blue, :final_color_text, :final_color
|
28
|
+
|
29
|
+
after_body do
|
30
|
+
observe(self, :red) do
|
31
|
+
update_final_color!
|
32
|
+
end
|
33
|
+
|
34
|
+
observe(self, :green) do
|
35
|
+
update_final_color!
|
36
|
+
end
|
37
|
+
|
38
|
+
observe(self, :blue) do
|
39
|
+
update_final_color!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
body {
|
44
|
+
shell {
|
45
|
+
grid_layout 3, true
|
46
|
+
|
47
|
+
text 'Hello, Toggle!'
|
48
|
+
|
49
|
+
toggle {
|
50
|
+
layout_data :fill, :center, true, false
|
51
|
+
text 'Red'
|
52
|
+
|
53
|
+
selection <=> [self, :red]
|
54
|
+
}
|
55
|
+
|
56
|
+
toggle {
|
57
|
+
layout_data :fill, :center, true, false
|
58
|
+
text 'Green'
|
59
|
+
|
60
|
+
selection <=> [self, :green]
|
61
|
+
}
|
62
|
+
|
63
|
+
toggle {
|
64
|
+
layout_data :fill, :center, true, false
|
65
|
+
text 'Blue'
|
66
|
+
|
67
|
+
selection <=> [self, :blue]
|
68
|
+
}
|
69
|
+
|
70
|
+
label(:center) {
|
71
|
+
layout_data {
|
72
|
+
horizontal_span 3
|
73
|
+
horizontal_alignment :fill
|
74
|
+
grab_excess_horizontal_space true
|
75
|
+
height_hint 20
|
76
|
+
}
|
77
|
+
|
78
|
+
text <= [self, :final_color_text]
|
79
|
+
background <= [self, :final_color]
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
def update_final_color!
|
85
|
+
final_color_symbols = [:red, :green, :blue].map {|color| send(color) ? color : nil}.compact
|
86
|
+
self.final_color_text = final_color_symbols.map {|color_symbol| color_symbol.to_s.capitalize}.join(' + ')
|
87
|
+
self.final_color = final_color_symbols.map {|color_symbol| color(color_symbol)}.reduce {|output_color, color| rgb(output_color.red + color.red, output_color.green + color.green, output_color.blue + color.blue) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
HelloToggle.launch
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.20.
|
4
|
+
version: 4.20.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 2.
|
18
|
+
version: 2.1.1
|
19
19
|
name: glimmer
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.1.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -646,6 +646,8 @@ files:
|
|
646
646
|
- samples/hello/hello_menu_bar.rb
|
647
647
|
- samples/hello/hello_message_box.rb
|
648
648
|
- samples/hello/hello_pop_up_context_menu.rb
|
649
|
+
- samples/hello/hello_print.rb
|
650
|
+
- samples/hello/hello_print_dialog.rb
|
649
651
|
- samples/hello/hello_progress_bar.rb
|
650
652
|
- samples/hello/hello_radio.rb
|
651
653
|
- samples/hello/hello_radio_group.rb
|
@@ -660,6 +662,7 @@ files:
|
|
660
662
|
- samples/hello/hello_table.rb
|
661
663
|
- samples/hello/hello_table/baseball_park.png
|
662
664
|
- samples/hello/hello_text.rb
|
665
|
+
- samples/hello/hello_toggle.rb
|
663
666
|
- samples/hello/hello_tool_bar.rb
|
664
667
|
- samples/hello/hello_tray_item.rb
|
665
668
|
- samples/hello/hello_tree.rb
|