glimmer-dsl-opal 0.23.0 → 0.25.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +69 -27
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +2 -2
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +14 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_print.rb +58 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb +126 -0
- data/lib/glimmer/swt/button_proxy.rb +5 -0
- data/lib/glimmer/swt/fill_layout_proxy.rb +2 -2
- data/lib/glimmer/swt/progress_bar_proxy.rb +105 -0
- data/lib/glimmer/swt/widget_proxy.rb +6 -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: 98f731b5aabef981ca377d64bbd87ca7a86a5f8edd4d0de428c81aeabe8680bf
|
4
|
+
data.tar.gz: 7f7cc811ff007c65a15749a53e4b51b5ae194ffc06714d7e07c101d2c40c5484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c71b8149524cbcd0b44319f24eb22e50476a6891cf479245d2632c3a367b97828b8197132092d0dd1389b5b79e7bf1e3a2abb5b787ad18d62655663252645fce
|
7
|
+
data.tar.gz: 18328ff77046a9fa0fd42abffd15c9251c0a9eed4886071c048fcd2320c1828d7033237cc76abbb2548e52cdb3c4d5ed3f3e235eca66af2a49c8eadca6b0d20c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.25.2
|
4
|
+
|
5
|
+
- Fix sizing of buttons with font height specified to fit text
|
6
|
+
|
7
|
+
## 0.25.1
|
8
|
+
|
9
|
+
- Support `progress_bar` `:vertical` SWT style
|
10
|
+
- Add `progress_bar` `:vertical` SWT style to Hello, Progress Bar!
|
11
|
+
|
12
|
+
## 0.25.0
|
13
|
+
|
14
|
+
- Support `progress_bar` widget without `:vertical` SWT style support
|
15
|
+
- Hello, Progress Bar! sample without `:vertical` SWT style
|
16
|
+
|
17
|
+
## 0.24.0
|
18
|
+
|
19
|
+
- `widget#print` method
|
20
|
+
- Hello, Print! sample
|
21
|
+
|
3
22
|
## 0.23.0
|
4
23
|
|
5
24
|
- Hello, Label! sample
|
data/README.md
CHANGED
@@ -143,7 +143,7 @@ Hello, Table! Game Booked
|
|
143
143
|
|
144
144
|
NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
145
145
|
|
146
|
-
**Alpha Version** 0.
|
146
|
+
**Alpha Version** 0.25.1 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
|
147
147
|
|
148
148
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
149
149
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
@@ -187,6 +187,8 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
187
187
|
- [Hello, Arrow!](#hello-arrow)
|
188
188
|
- [Hello, Message Box!](#hello-message-box)
|
189
189
|
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
190
|
+
- [Hello, Print!](#hello-print)
|
191
|
+
- [Hello, Progress Bar!](#hello-progress-bar)
|
190
192
|
- [Hello, Menu Bar!](#hello-menu-bar)
|
191
193
|
- [Hello, Dialog!](#hello-dialog)
|
192
194
|
- [Elaborate Samples](#elaborate-samples)
|
@@ -262,9 +264,9 @@ Add the following to `Gemfile`:
|
|
262
264
|
```
|
263
265
|
gem 'opal', '1.0.4'
|
264
266
|
gem 'opal-rails', '1.1.2'
|
265
|
-
gem 'opal-async', '~> 1.
|
267
|
+
gem 'opal-async', '~> 1.3.0'
|
266
268
|
gem 'opal-jquery', '~> 0.4.4'
|
267
|
-
gem 'glimmer-dsl-opal', '~> 0.
|
269
|
+
gem 'glimmer-dsl-opal', '~> 0.25.1'
|
268
270
|
gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
|
269
271
|
gem 'glimmer-dsl-css', '~> 1.2.0', require: false
|
270
272
|
|
@@ -472,9 +474,9 @@ class HelloCombo
|
|
472
474
|
|
473
475
|
include Glimmer::UI::CustomShell
|
474
476
|
|
475
|
-
before_body
|
477
|
+
before_body do
|
476
478
|
@person = Person.new
|
477
|
-
|
479
|
+
end
|
478
480
|
|
479
481
|
body {
|
480
482
|
shell {
|
@@ -578,13 +580,13 @@ class HelloComputed
|
|
578
580
|
|
579
581
|
include Glimmer::UI::CustomShell
|
580
582
|
|
581
|
-
before_body
|
583
|
+
before_body do
|
582
584
|
@contact = Contact.new(
|
583
585
|
first_name: 'Barry',
|
584
586
|
last_name: 'McKibbin',
|
585
587
|
year_of_birth: 1985
|
586
588
|
)
|
587
|
-
|
589
|
+
end
|
588
590
|
|
589
591
|
body {
|
590
592
|
shell {
|
@@ -600,51 +602,43 @@ class HelloComputed
|
|
600
602
|
|
601
603
|
label {text 'First &Name: '}
|
602
604
|
text {
|
605
|
+
fill_horizontally_layout_data
|
603
606
|
text <=> [@contact, :first_name]
|
604
|
-
layout_data {
|
605
|
-
horizontal_alignment :fill
|
606
|
-
grab_excess_horizontal_space true
|
607
|
-
}
|
608
607
|
}
|
609
608
|
|
610
609
|
label {text '&Last Name: '}
|
611
610
|
text {
|
611
|
+
fill_horizontally_layout_data
|
612
612
|
text <=> [@contact, :last_name]
|
613
|
-
layout_data {
|
614
|
-
horizontal_alignment :fill
|
615
|
-
grab_excess_horizontal_space true
|
616
|
-
}
|
617
613
|
}
|
618
614
|
|
619
615
|
label {text '&Year of Birth: '}
|
620
616
|
text {
|
617
|
+
fill_horizontally_layout_data
|
621
618
|
text <=> [@contact, :year_of_birth]
|
622
|
-
layout_data {
|
623
|
-
horizontal_alignment :fill
|
624
|
-
grab_excess_horizontal_space true
|
625
|
-
}
|
626
619
|
}
|
627
620
|
|
628
621
|
label {text 'Name: '}
|
629
622
|
label {
|
623
|
+
fill_horizontally_layout_data
|
630
624
|
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
631
|
-
layout_data {
|
632
|
-
horizontal_alignment :fill
|
633
|
-
grab_excess_horizontal_space true
|
634
|
-
}
|
635
625
|
}
|
636
626
|
|
637
627
|
label {text 'Age: '}
|
638
628
|
label {
|
629
|
+
fill_horizontally_layout_data
|
639
630
|
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
640
|
-
layout_data {
|
641
|
-
horizontal_alignment :fill
|
642
|
-
grab_excess_horizontal_space true
|
643
|
-
}
|
644
631
|
}
|
645
632
|
}
|
646
633
|
}
|
647
634
|
}
|
635
|
+
|
636
|
+
def fill_horizontally_layout_data
|
637
|
+
layout_data {
|
638
|
+
horizontal_alignment :fill
|
639
|
+
grab_excess_horizontal_space true
|
640
|
+
}
|
641
|
+
end
|
648
642
|
end
|
649
643
|
|
650
644
|
HelloComputed.launch
|
@@ -1841,6 +1835,54 @@ You should see "Hello, Message Box!"
|
|
1841
1835
|
![Glimmer DSL for Opal Hello Message Box](images/glimmer-dsl-opal-hello-message-box.png)
|
1842
1836
|
![Glimmer DSL for Opal Hello Message Box Dialog](images/glimmer-dsl-opal-hello-message-box-dialog.png)
|
1843
1837
|
|
1838
|
+
#### Hello, Print!
|
1839
|
+
|
1840
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1841
|
+
|
1842
|
+
```ruby
|
1843
|
+
require 'glimmer-dsl-opal/samples/hello/hello_print'
|
1844
|
+
```
|
1845
|
+
|
1846
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1847
|
+
|
1848
|
+
![Glimmer DSL for SWT Hello Print](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-print.png)
|
1849
|
+
|
1850
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1851
|
+
|
1852
|
+
Start the Rails server:
|
1853
|
+
```
|
1854
|
+
rails s
|
1855
|
+
```
|
1856
|
+
|
1857
|
+
Visit `http://localhost:3000`
|
1858
|
+
|
1859
|
+
You should see "Hello, Print!"
|
1860
|
+
|
1861
|
+
#### Hello, Progress Bar!
|
1862
|
+
|
1863
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
1864
|
+
|
1865
|
+
```ruby
|
1866
|
+
require 'glimmer-dsl-opal/samples/hello/hello_progress_bar'
|
1867
|
+
```
|
1868
|
+
|
1869
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1870
|
+
|
1871
|
+
![Glimmer DSL for SWT Hello Progress Bar](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-progress-bar.gif)
|
1872
|
+
|
1873
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1874
|
+
|
1875
|
+
Start the Rails server:
|
1876
|
+
```
|
1877
|
+
rails s
|
1878
|
+
```
|
1879
|
+
|
1880
|
+
Visit `http://localhost:3000`
|
1881
|
+
|
1882
|
+
You should see "Hello, Progress Bar!"
|
1883
|
+
|
1884
|
+
![Glimmer DSL for Opal Hello Progress Bar](https://github.com/AndyObtiva/glimmer-dsl-opal/raw/master/images/glimmer-dsl-opal-hello-progress-bar.gif)
|
1885
|
+
|
1844
1886
|
#### Hello, Pop Up Context Menu!
|
1845
1887
|
|
1846
1888
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.25.2
|
@@ -42,13 +42,13 @@ class HelloComputed
|
|
42
42
|
|
43
43
|
include Glimmer::UI::CustomShell
|
44
44
|
|
45
|
-
before_body
|
45
|
+
before_body do
|
46
46
|
@contact = Contact.new(
|
47
47
|
first_name: 'Barry',
|
48
48
|
last_name: 'McKibbin',
|
49
49
|
year_of_birth: 1985
|
50
50
|
)
|
51
|
-
|
51
|
+
end
|
52
52
|
|
53
53
|
body {
|
54
54
|
shell {
|
@@ -64,51 +64,43 @@ class HelloComputed
|
|
64
64
|
|
65
65
|
label {text 'First &Name: '}
|
66
66
|
text {
|
67
|
+
fill_horizontally_layout_data
|
67
68
|
text <=> [@contact, :first_name]
|
68
|
-
layout_data {
|
69
|
-
horizontal_alignment :fill
|
70
|
-
grab_excess_horizontal_space true
|
71
|
-
}
|
72
69
|
}
|
73
70
|
|
74
71
|
label {text '&Last Name: '}
|
75
72
|
text {
|
73
|
+
fill_horizontally_layout_data
|
76
74
|
text <=> [@contact, :last_name]
|
77
|
-
layout_data {
|
78
|
-
horizontal_alignment :fill
|
79
|
-
grab_excess_horizontal_space true
|
80
|
-
}
|
81
75
|
}
|
82
76
|
|
83
77
|
label {text '&Year of Birth: '}
|
84
78
|
text {
|
79
|
+
fill_horizontally_layout_data
|
85
80
|
text <=> [@contact, :year_of_birth]
|
86
|
-
layout_data {
|
87
|
-
horizontal_alignment :fill
|
88
|
-
grab_excess_horizontal_space true
|
89
|
-
}
|
90
81
|
}
|
91
82
|
|
92
83
|
label {text 'Name: '}
|
93
84
|
label {
|
85
|
+
fill_horizontally_layout_data
|
94
86
|
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
95
|
-
layout_data {
|
96
|
-
horizontal_alignment :fill
|
97
|
-
grab_excess_horizontal_space true
|
98
|
-
}
|
99
87
|
}
|
100
88
|
|
101
89
|
label {text 'Age: '}
|
102
90
|
label {
|
91
|
+
fill_horizontally_layout_data
|
103
92
|
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
104
|
-
layout_data {
|
105
|
-
horizontal_alignment :fill
|
106
|
-
grab_excess_horizontal_space true
|
107
|
-
}
|
108
93
|
}
|
109
94
|
}
|
110
95
|
}
|
111
96
|
}
|
97
|
+
|
98
|
+
def fill_horizontally_layout_data
|
99
|
+
layout_data {
|
100
|
+
horizontal_alignment :fill
|
101
|
+
grab_excess_horizontal_space true
|
102
|
+
}
|
103
|
+
end
|
112
104
|
end
|
113
105
|
|
114
106
|
HelloComputed.launch
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright (c) 2020-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
|
+
class HelloPrint
|
23
|
+
include Glimmer::UI::CustomShell
|
24
|
+
|
25
|
+
body {
|
26
|
+
shell {
|
27
|
+
text 'Hello, Print!'
|
28
|
+
@composite = composite {
|
29
|
+
row_layout(:vertical) {
|
30
|
+
fill true
|
31
|
+
center true
|
32
|
+
}
|
33
|
+
|
34
|
+
label(:center) {
|
35
|
+
text "Whatever you see inside the app composite\nwill get printed when clicking the Print button."
|
36
|
+
font height: 16
|
37
|
+
}
|
38
|
+
|
39
|
+
button {
|
40
|
+
text 'Print'
|
41
|
+
|
42
|
+
on_widget_selected do
|
43
|
+
# Unlike the SWT version, Opal's print always prints the entire window no matter what widget
|
44
|
+
# the print method is invoked from
|
45
|
+
unless @composite.print
|
46
|
+
message_box {
|
47
|
+
text 'Unable To Print'
|
48
|
+
message 'Sorry! Printing is not supported on this platform!'
|
49
|
+
}.open
|
50
|
+
end
|
51
|
+
end
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
HelloPrint.launch
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# Copyright (c) 2020-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
|
+
class HelloProgressBar
|
23
|
+
include Glimmer::UI::CustomShell
|
24
|
+
|
25
|
+
class ProgressModel
|
26
|
+
attr_accessor :minimum, :maximum, :selection, :delay
|
27
|
+
end
|
28
|
+
|
29
|
+
before_body do
|
30
|
+
@progress_model = ProgressModel.new
|
31
|
+
@progress_model.minimum = 0
|
32
|
+
@progress_model.maximum = 100
|
33
|
+
@progress_model.selection = 0
|
34
|
+
@progress_model.delay = 0.01
|
35
|
+
end
|
36
|
+
|
37
|
+
body {
|
38
|
+
shell {
|
39
|
+
grid_layout(4, true)
|
40
|
+
|
41
|
+
text 'Hello, Progress Bar!'
|
42
|
+
|
43
|
+
progress_bar(:indeterminate) {
|
44
|
+
layout_data(:fill, :center, true, false) {
|
45
|
+
horizontal_span 4
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
label {
|
50
|
+
text 'Minimum'
|
51
|
+
}
|
52
|
+
|
53
|
+
label {
|
54
|
+
text 'Maximum'
|
55
|
+
}
|
56
|
+
|
57
|
+
label {
|
58
|
+
text 'Selection'
|
59
|
+
}
|
60
|
+
|
61
|
+
label {
|
62
|
+
text 'Delay in Seconds'
|
63
|
+
}
|
64
|
+
|
65
|
+
spinner {
|
66
|
+
selection <=> [@progress_model, :minimum]
|
67
|
+
}
|
68
|
+
|
69
|
+
spinner {
|
70
|
+
selection <=> [@progress_model, :maximum]
|
71
|
+
}
|
72
|
+
|
73
|
+
spinner {
|
74
|
+
selection <=> [@progress_model, :selection]
|
75
|
+
}
|
76
|
+
|
77
|
+
spinner {
|
78
|
+
digits 2
|
79
|
+
minimum 1
|
80
|
+
maximum 200
|
81
|
+
selection <=> [@progress_model, :delay, on_read: ->(v) {v.to_f*100.0}, on_write: ->(v) {v.to_f/100.0}]
|
82
|
+
}
|
83
|
+
|
84
|
+
progress_bar {
|
85
|
+
layout_data(:fill, :center, true, false) {
|
86
|
+
horizontal_span 4
|
87
|
+
}
|
88
|
+
minimum <= [@progress_model, :minimum]
|
89
|
+
maximum <= [@progress_model, :maximum]
|
90
|
+
selection <= [@progress_model, :selection]
|
91
|
+
}
|
92
|
+
|
93
|
+
# :vertical SWT style is unsupported for now
|
94
|
+
progress_bar(:vertical) {
|
95
|
+
layout_data(:fill, :center, true, false) {
|
96
|
+
horizontal_span 4
|
97
|
+
}
|
98
|
+
minimum <= [@progress_model, :minimum]
|
99
|
+
maximum <= [@progress_model, :maximum]
|
100
|
+
selection <= [@progress_model, :selection]
|
101
|
+
}
|
102
|
+
|
103
|
+
button {
|
104
|
+
layout_data(:fill, :center, true, false) {
|
105
|
+
horizontal_span 4
|
106
|
+
}
|
107
|
+
text "Start"
|
108
|
+
|
109
|
+
on_widget_selected do
|
110
|
+
# if a previous thread is running, then kill first
|
111
|
+
# (killing is not dangerous since it is only a thread about updating progress)
|
112
|
+
@current_thread&.kill
|
113
|
+
@current_thread = Thread.new do
|
114
|
+
@progress_model.selection = @progress_model.minimum
|
115
|
+
(@progress_model.minimum..@progress_model.maximum).to_a.each do |n|
|
116
|
+
@progress_model.selection = n
|
117
|
+
sleep(@progress_model.delay)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
HelloProgressBar.launch
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# Copyright (c) 2020-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/swt/widget_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module SWT
|
26
|
+
class ProgressBarProxy < WidgetProxy
|
27
|
+
STYLE = <<~CSS
|
28
|
+
.ui-progressbar.vertical {
|
29
|
+
transform: rotate(-180deg);
|
30
|
+
height: 140px;
|
31
|
+
width: 28px;
|
32
|
+
margin-left: auto;
|
33
|
+
margin-right: auto;
|
34
|
+
}
|
35
|
+
CSS
|
36
|
+
|
37
|
+
attr_reader :vertical, :indeterminate, :maximum, :selection
|
38
|
+
attr_accessor :state, :minimum #ignored, only there for API compatibility
|
39
|
+
alias vertical? vertical
|
40
|
+
alias indeterminate? indeterminate
|
41
|
+
|
42
|
+
def initialize(parent, args, block)
|
43
|
+
@vertical = args.detect { |arg| SWTProxy[arg] == SWTProxy[:vertical] }
|
44
|
+
@indeterminate = args.detect { |arg| SWTProxy[arg] == SWTProxy[:indeterminate] }
|
45
|
+
super(parent, args, block)
|
46
|
+
# initialize manually if vertical
|
47
|
+
dom_element.progressbar if horizontal?
|
48
|
+
self.minimum = 0
|
49
|
+
self.selection = false if indeterminate?
|
50
|
+
end
|
51
|
+
|
52
|
+
def horizontal
|
53
|
+
!vertical
|
54
|
+
end
|
55
|
+
alias horizontal? horizontal
|
56
|
+
|
57
|
+
def minimum=(value)
|
58
|
+
@minimum = value
|
59
|
+
# re-update maximum and selection since they depend on minimum
|
60
|
+
self.maximum = @maximum if @maximum
|
61
|
+
self.selection = @selection if @selection
|
62
|
+
end
|
63
|
+
|
64
|
+
def maximum=(value)
|
65
|
+
@maximum = value
|
66
|
+
if horizontal?
|
67
|
+
dom_element.progressbar('option', 'max', @maximum - @minimum)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def selection=(selection_value)
|
72
|
+
@selection = selection_value
|
73
|
+
if horizontal?
|
74
|
+
value = @selection ? (@selection - @minimum) : @selection
|
75
|
+
dom_element.progressbar('option', 'value', value)
|
76
|
+
else
|
77
|
+
value = ((@selection - @minimum) / (@maximum - @minimum)) * 100
|
78
|
+
selection_dom_element.css('height', "#{value}%")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def element
|
83
|
+
'div'
|
84
|
+
end
|
85
|
+
|
86
|
+
def selection_dom_element
|
87
|
+
dom_element.find('.ui-progressbar-value')
|
88
|
+
end
|
89
|
+
|
90
|
+
def dom
|
91
|
+
progress_bar_id = id
|
92
|
+
progress_bar_class = name
|
93
|
+
progress_bar_class += ' vertical ui-progressbar ui-corner-all ui-widget ui-widget-content' if vertical?
|
94
|
+
progress_bar_class += ' indeterminate' if indeterminate?
|
95
|
+
@dom ||= html {
|
96
|
+
div(id: progress_bar_id, class: progress_bar_class) {
|
97
|
+
if vertical?
|
98
|
+
div(class: 'ui-progressbar-value ui-corner-left ui-widget-header', style: 'height: 0%;')
|
99
|
+
end
|
100
|
+
}
|
101
|
+
}.to_s
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -241,6 +241,11 @@ module Glimmer
|
|
241
241
|
def dialog_ancestor
|
242
242
|
parents.detect {|p| p.is_a?(DialogProxy)}
|
243
243
|
end
|
244
|
+
|
245
|
+
def print
|
246
|
+
`window.print()`
|
247
|
+
true
|
248
|
+
end
|
244
249
|
|
245
250
|
def enabled=(value)
|
246
251
|
@enabled = value
|
@@ -1032,6 +1037,7 @@ require 'glimmer/swt/table_column_proxy'
|
|
1032
1037
|
require 'glimmer/swt/table_item_proxy'
|
1033
1038
|
require 'glimmer/swt/table_proxy'
|
1034
1039
|
require 'glimmer/swt/text_proxy'
|
1040
|
+
require 'glimmer/swt/progress_bar_proxy'
|
1035
1041
|
require 'glimmer/swt/radio_proxy'
|
1036
1042
|
require 'glimmer/swt/scale_proxy'
|
1037
1043
|
require 'glimmer/swt/scrolled_composite_proxy'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: to_collection
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,6 +308,8 @@ files:
|
|
308
308
|
- lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb
|
309
309
|
- lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb
|
310
310
|
- lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb
|
311
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_print.rb
|
312
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb
|
311
313
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio.rb
|
312
314
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
|
313
315
|
- lib/glimmer-dsl-opal/samples/hello/hello_scale.rb
|
@@ -421,6 +423,7 @@ files:
|
|
421
423
|
- lib/glimmer/swt/menu_proxy.rb
|
422
424
|
- lib/glimmer/swt/message_box_proxy.rb
|
423
425
|
- lib/glimmer/swt/point.rb
|
426
|
+
- lib/glimmer/swt/progress_bar_proxy.rb
|
424
427
|
- lib/glimmer/swt/property_owner.rb
|
425
428
|
- lib/glimmer/swt/radio_proxy.rb
|
426
429
|
- lib/glimmer/swt/row_layout_proxy.rb
|