glimmer-dsl-swt 4.19.0.1 → 4.20.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +26 -27
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +44 -15
- data/docs/reference/GLIMMER_SAMPLES.md +136 -17
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/data_binding/shine.rb +41 -26
- data/lib/glimmer/dsl/swt/dsl.rb +2 -1
- data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +49 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -0
- data/lib/glimmer/launcher.rb +6 -0
- data/lib/glimmer/rake_task/scaffold.rb +0 -2
- data/lib/glimmer/swt/combo_proxy.rb +48 -0
- data/lib/glimmer/swt/custom/code_text.rb +13 -9
- data/lib/glimmer/swt/tool_bar_proxy.rb +51 -0
- data/lib/glimmer/swt/widget_proxy.rb +6 -0
- data/samples/elaborate/contact_manager.rb +7 -5
- data/samples/elaborate/login.rb +7 -7
- data/samples/elaborate/mandelbrot_fractal.rb +12 -7
- data/samples/elaborate/meta_sample.rb +4 -2
- data/samples/elaborate/metronome.rb +4 -4
- data/samples/elaborate/tetris/model/game.rb +0 -3
- data/samples/elaborate/tic_tac_toe.rb +2 -2
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_c_combo.rb +2 -1
- data/samples/hello/hello_c_tab.rb +1 -0
- data/samples/hello/hello_canvas.rb +5 -5
- data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
- data/samples/hello/hello_canvas_data_binding.rb +16 -16
- data/samples/hello/hello_checkbox.rb +4 -4
- data/samples/hello/hello_code_text.rb +3 -57
- data/samples/hello/hello_color_dialog.rb +1 -1
- data/samples/hello/hello_combo.rb +1 -1
- data/samples/hello/hello_composite.rb +71 -0
- data/samples/hello/hello_computed.rb +5 -5
- data/samples/hello/hello_cool_bar.rb +147 -0
- data/samples/hello/hello_custom_widget.rb +1 -1
- data/samples/hello/hello_date_time.rb +4 -4
- data/samples/hello/hello_dialog.rb +3 -2
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_file_dialog.rb +1 -1
- data/samples/hello/hello_font_dialog.rb +3 -3
- data/samples/hello/hello_group.rb +6 -6
- data/samples/hello/hello_layout.rb +243 -0
- data/samples/hello/hello_link.rb +56 -50
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_progress_bar.rb +10 -10
- data/samples/hello/hello_radio.rb +6 -6
- data/samples/hello/hello_sash_form.rb +4 -4
- data/samples/hello/hello_shape.rb +1 -0
- data/samples/hello/hello_shell.rb +205 -0
- data/samples/hello/hello_spinner.rb +6 -2
- data/samples/hello/hello_styled_text.rb +11 -11
- data/samples/hello/hello_tool_bar.rb +143 -0
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/linux_aarch64/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/mac_aarch64/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +15 -3
data/samples/hello/hello_link.rb
CHANGED
@@ -21,62 +21,68 @@
|
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
shell { |main_shell|
|
27
|
-
grid_layout {
|
28
|
-
margin_width 20
|
29
|
-
margin_height 10
|
30
|
-
}
|
24
|
+
class HelloLink
|
25
|
+
include Glimmer::UI::CustomShell
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
font height: 16
|
39
|
-
text <<~MULTI_LINE_STRING
|
40
|
-
|
41
|
-
You may click on any <a>link</a> to get help.
|
27
|
+
body {
|
28
|
+
shell { |main_shell|
|
29
|
+
grid_layout {
|
30
|
+
margin_width 20
|
31
|
+
margin_height 10
|
32
|
+
}
|
42
33
|
|
43
|
-
|
34
|
+
background :white
|
35
|
+
text 'Hello, Link!'
|
44
36
|
|
45
|
-
|
46
|
-
|
37
|
+
@link = link {
|
38
|
+
background :white
|
39
|
+
link_foreground :dark_green
|
40
|
+
font height: 16
|
41
|
+
text <<~MULTI_LINE_STRING
|
47
42
|
|
48
|
-
|
49
|
-
# This retrieves the clicked link href (or contained text if no href is set)
|
50
|
-
@selected_link = selection_event.text
|
51
|
-
}
|
52
|
-
on_mouse_up { |mouse_event|
|
53
|
-
unless @selected_link.nil?
|
54
|
-
@help_shell.close unless @help_shell.nil? || @help_shell.disposed?
|
55
|
-
@help_shell = shell(:no_trim) {
|
56
|
-
grid_layout {
|
57
|
-
margin_width 10
|
58
|
-
margin_height 10
|
59
|
-
}
|
43
|
+
You may click on any <a>link</a> to get help.
|
60
44
|
|
61
|
-
|
45
|
+
How do you know <a href="which-link-href-value">which link</a> you clicked?
|
62
46
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
47
|
+
Just keep clicking <a href="all links">links</a> to find out!
|
48
|
+
MULTI_LINE_STRING
|
49
|
+
|
50
|
+
on_widget_selected { |selection_event|
|
51
|
+
# This retrieves the clicked link href (or contained text if no href is set)
|
52
|
+
@selected_link = selection_event.text
|
53
|
+
}
|
54
|
+
on_mouse_up { |mouse_event|
|
55
|
+
unless @selected_link.nil?
|
56
|
+
@help_shell.close unless @help_shell.nil? || @help_shell.disposed?
|
57
|
+
@help_shell = shell(:no_trim) {
|
58
|
+
grid_layout {
|
59
|
+
margin_width 10
|
60
|
+
margin_height 10
|
61
|
+
}
|
62
|
+
|
63
|
+
background :yellow
|
64
|
+
|
65
|
+
label {
|
66
|
+
background :yellow
|
67
|
+
text "Did someone ask for help about \"#{@selected_link}\"?\nYou don't really need help. You did it!"
|
68
|
+
}
|
69
|
+
|
70
|
+
on_swt_show {
|
71
|
+
x = main_shell.location.x + @link.location.x + mouse_event.x
|
72
|
+
y = main_shell.location.y + @link.location.y + mouse_event.y + 20
|
73
|
+
@help_shell.location = Point.new(x, y)
|
74
|
+
}
|
75
|
+
on_focus_lost {
|
76
|
+
@selected_link = nil
|
77
|
+
@help_shell.close
|
78
|
+
}
|
79
|
+
}
|
80
|
+
@help_shell.open
|
81
|
+
end
|
77
82
|
}
|
78
|
-
|
79
|
-
end
|
83
|
+
}
|
80
84
|
}
|
81
85
|
}
|
82
|
-
|
86
|
+
end
|
87
|
+
|
88
|
+
HelloLink.launch
|
@@ -63,7 +63,7 @@ class HelloListMultiSelection
|
|
63
63
|
text 'Hello, List Multi Selection!'
|
64
64
|
|
65
65
|
list(:multi) {
|
66
|
-
selection
|
66
|
+
selection <=> [@person, :provinces] # also binds to provinces_options by convention
|
67
67
|
}
|
68
68
|
|
69
69
|
button {
|
@@ -48,7 +48,7 @@ class HelloListSingleSelection
|
|
48
48
|
text 'Hello, List Single Selection!'
|
49
49
|
|
50
50
|
list {
|
51
|
-
selection
|
51
|
+
selection <=> [@person, :country] # also binds to country_options by convention
|
52
52
|
}
|
53
53
|
|
54
54
|
button {
|
@@ -65,40 +65,40 @@ class HelloProgressBar
|
|
65
65
|
}
|
66
66
|
|
67
67
|
spinner {
|
68
|
-
selection
|
68
|
+
selection <=> [@progress_model, :minimum]
|
69
69
|
}
|
70
70
|
|
71
71
|
spinner {
|
72
|
-
selection
|
72
|
+
selection <=> [@progress_model, :maximum]
|
73
73
|
}
|
74
74
|
|
75
75
|
spinner {
|
76
|
-
selection
|
76
|
+
selection <=> [@progress_model, :selection]
|
77
77
|
}
|
78
78
|
|
79
79
|
spinner {
|
80
80
|
digits 2
|
81
81
|
minimum 1
|
82
82
|
maximum 200
|
83
|
-
selection
|
83
|
+
selection <=> [@progress_model, :delay, on_read: ->(v) {v.to_f*100.0}, on_write: ->(v) {v.to_f/100.0}]
|
84
84
|
}
|
85
85
|
|
86
86
|
progress_bar {
|
87
87
|
layout_data(:fill, :center, true, false) {
|
88
88
|
horizontal_span 4
|
89
89
|
}
|
90
|
-
minimum
|
91
|
-
maximum
|
92
|
-
selection
|
90
|
+
minimum <= [@progress_model, :minimum]
|
91
|
+
maximum <= [@progress_model, :maximum]
|
92
|
+
selection <= [@progress_model, :selection]
|
93
93
|
}
|
94
94
|
|
95
95
|
progress_bar(:vertical) {
|
96
96
|
layout_data(:fill, :center, true, false) {
|
97
97
|
horizontal_span 4
|
98
98
|
}
|
99
|
-
minimum
|
100
|
-
maximum
|
101
|
-
selection
|
99
|
+
minimum <= [@progress_model, :minimum]
|
100
|
+
maximum <= [@progress_model, :maximum]
|
101
|
+
selection <= [@progress_model, :selection]
|
102
102
|
}
|
103
103
|
|
104
104
|
button {
|
@@ -60,12 +60,12 @@ class HelloRadio
|
|
60
60
|
|
61
61
|
radio {
|
62
62
|
text 'Male'
|
63
|
-
selection
|
63
|
+
selection <=> [@person, :male]
|
64
64
|
}
|
65
65
|
|
66
66
|
radio {
|
67
67
|
text 'Female'
|
68
|
-
selection
|
68
|
+
selection <=> [@person, :female]
|
69
69
|
}
|
70
70
|
}
|
71
71
|
|
@@ -79,22 +79,22 @@ class HelloRadio
|
|
79
79
|
|
80
80
|
radio {
|
81
81
|
text 'Child'
|
82
|
-
selection
|
82
|
+
selection <=> [@person, :child]
|
83
83
|
}
|
84
84
|
|
85
85
|
radio {
|
86
86
|
text 'Teen'
|
87
|
-
selection
|
87
|
+
selection <=> [@person, :teen]
|
88
88
|
}
|
89
89
|
|
90
90
|
radio {
|
91
91
|
text 'Adult'
|
92
|
-
selection
|
92
|
+
selection <=> [@person, :adult]
|
93
93
|
}
|
94
94
|
|
95
95
|
radio {
|
96
96
|
text 'Senior'
|
97
|
-
selection
|
97
|
+
selection <=> [@person, :senior]
|
98
98
|
}
|
99
99
|
}
|
100
100
|
|
@@ -54,8 +54,8 @@ shell {
|
|
54
54
|
layout_data(:fill, :fill, true, true) {
|
55
55
|
height_hint 200
|
56
56
|
}
|
57
|
-
sash_width
|
58
|
-
orientation
|
57
|
+
sash_width <=> [@presenter, :sash_width]
|
58
|
+
orientation <=> [@presenter, :orientation_style]
|
59
59
|
weights 1, 2
|
60
60
|
|
61
61
|
@green_label = label {
|
@@ -86,7 +86,7 @@ shell {
|
|
86
86
|
layout_data(:fill, :center, true, false) {
|
87
87
|
width_hint 100
|
88
88
|
}
|
89
|
-
selection
|
89
|
+
selection <=> [@presenter, :sash_width]
|
90
90
|
font height: 16
|
91
91
|
}
|
92
92
|
|
@@ -99,7 +99,7 @@ shell {
|
|
99
99
|
layout_data(:fill, :center, true, false) {
|
100
100
|
width_hint 100
|
101
101
|
}
|
102
|
-
selection
|
102
|
+
selection <=> [@presenter, :orientation]
|
103
103
|
font height: 16
|
104
104
|
}
|
105
105
|
|
@@ -46,6 +46,7 @@ class HelloShape
|
|
46
46
|
}
|
47
47
|
|
48
48
|
# method-based custom shape using `shape` keyword as a composite shape containing nested shapes
|
49
|
+
# See HelloCustomShape sample for a class-based custom shape alternative that enables extracting custom shape to a separate class/file
|
49
50
|
def stick_figure(x, y, width, height, &block)
|
50
51
|
head_width = width*0.2
|
51
52
|
head_height = height*0.2
|
@@ -0,0 +1,205 @@
|
|
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 HelloShell
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
body {
|
28
|
+
# this is the initial shell that opens. If you close it, you close the app.
|
29
|
+
shell { |root_shell_proxy|
|
30
|
+
row_layout(:vertical)
|
31
|
+
text 'Hello, Shell!'
|
32
|
+
|
33
|
+
button {
|
34
|
+
layout_data {
|
35
|
+
width 200
|
36
|
+
height 50
|
37
|
+
}
|
38
|
+
text "Nested Shell"
|
39
|
+
|
40
|
+
on_widget_selected {
|
41
|
+
# build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
|
42
|
+
shell(root_shell_proxy) {
|
43
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
44
|
+
text 'Nested Shell'
|
45
|
+
|
46
|
+
label {
|
47
|
+
font height: 20
|
48
|
+
text "Since this shell is nested, \nyou can hit ESC to close"
|
49
|
+
}
|
50
|
+
}.open
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
button {
|
55
|
+
layout_data {
|
56
|
+
width 200
|
57
|
+
height 50
|
58
|
+
}
|
59
|
+
text "Independent Shell"
|
60
|
+
|
61
|
+
on_widget_selected {
|
62
|
+
# build an independent shell, meaning a shell that is independent of its parent
|
63
|
+
shell {
|
64
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
65
|
+
text 'Independent Shell'
|
66
|
+
|
67
|
+
label {
|
68
|
+
font height: 20
|
69
|
+
text "Since this shell is independent, \nyou cannot close by hitting ESC"
|
70
|
+
}
|
71
|
+
}.open
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
button {
|
76
|
+
layout_data {
|
77
|
+
width 200
|
78
|
+
height 50
|
79
|
+
}
|
80
|
+
text "Close-Button Shell"
|
81
|
+
|
82
|
+
on_widget_selected {
|
83
|
+
shell(:close) {
|
84
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
85
|
+
text 'Nested Shell'
|
86
|
+
|
87
|
+
label {
|
88
|
+
font height: 20
|
89
|
+
text "Shell with close button only\n(varies per platform)"
|
90
|
+
}
|
91
|
+
}.open
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
button {
|
96
|
+
layout_data {
|
97
|
+
width 200
|
98
|
+
height 50
|
99
|
+
}
|
100
|
+
text "Minimize-Button Shell"
|
101
|
+
|
102
|
+
on_widget_selected {
|
103
|
+
# build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
|
104
|
+
shell(root_shell_proxy, :min) {
|
105
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
106
|
+
text 'Minimize-Button Shell'
|
107
|
+
|
108
|
+
label {
|
109
|
+
font height: 20
|
110
|
+
text "Shell with minimize button only\n(varies per platform)"
|
111
|
+
}
|
112
|
+
}.open
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
button {
|
117
|
+
layout_data {
|
118
|
+
width 200
|
119
|
+
height 50
|
120
|
+
}
|
121
|
+
text "Maximize-Button Shell"
|
122
|
+
|
123
|
+
on_widget_selected {
|
124
|
+
# build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
|
125
|
+
shell(root_shell_proxy, :max) {
|
126
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
127
|
+
text 'Maximize-Button Shell'
|
128
|
+
|
129
|
+
label {
|
130
|
+
font height: 20
|
131
|
+
text "Shell with maximize button only\n(varies per platform)"
|
132
|
+
}
|
133
|
+
}.open
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
button {
|
138
|
+
layout_data {
|
139
|
+
width 200
|
140
|
+
height 50
|
141
|
+
}
|
142
|
+
text "Buttonless Shell"
|
143
|
+
|
144
|
+
on_widget_selected {
|
145
|
+
# build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
|
146
|
+
shell(root_shell_proxy, :title) {
|
147
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
148
|
+
text 'Buttonless Shell'
|
149
|
+
|
150
|
+
label {
|
151
|
+
font height: 20
|
152
|
+
text "Buttonless shell (title only)\n(varies per platform)"
|
153
|
+
}
|
154
|
+
}.open
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
button {
|
159
|
+
layout_data {
|
160
|
+
width 200
|
161
|
+
height 50
|
162
|
+
}
|
163
|
+
text "No Trim Shell"
|
164
|
+
|
165
|
+
on_widget_selected {
|
166
|
+
# build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
|
167
|
+
shell(root_shell_proxy, :no_trim) {
|
168
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
169
|
+
text 'No Trim Shell'
|
170
|
+
|
171
|
+
label {
|
172
|
+
font height: 20
|
173
|
+
text "No trim shell, meaning no buttons or title bar.\n(varies per platform)"
|
174
|
+
}
|
175
|
+
}.open
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
button {
|
180
|
+
layout_data {
|
181
|
+
width 200
|
182
|
+
height 50
|
183
|
+
}
|
184
|
+
text "Always On Top Shell"
|
185
|
+
|
186
|
+
on_widget_selected {
|
187
|
+
# build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
|
188
|
+
shell(root_shell_proxy, :on_top) {
|
189
|
+
# shell has fill_layout(:horizontal) by default with no margins
|
190
|
+
text 'Always On Top Shell'
|
191
|
+
|
192
|
+
label {
|
193
|
+
font height: 20
|
194
|
+
text "Always on top shell.\n(varies per platform)"
|
195
|
+
}
|
196
|
+
}.open
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
}
|
201
|
+
|
202
|
+
}
|
203
|
+
end
|
204
|
+
|
205
|
+
HelloShell.launch
|