glimmer-dsl-swt 4.19.0.2 → 4.20.0.4
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 +26 -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 +157 -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 +18 -16
- data/samples/elaborate/mandelbrot_fractal.rb +2 -2
- data/samples/elaborate/metronome.rb +3 -3
- data/samples/elaborate/tetris/model/game.rb +0 -3
- data/samples/elaborate/tic_tac_toe.rb +2 -2
- data/samples/elaborate/weather.rb +164 -0
- 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_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 +14 -3
@@ -83,47 +83,14 @@ class HelloCodeText
|
|
83
83
|
tab_folder {
|
84
84
|
tab_item {
|
85
85
|
fill_layout
|
86
|
-
text 'Ruby (glimmer)'
|
86
|
+
text 'Ruby (glimmer theme)'
|
87
87
|
code_text(language: 'ruby', theme: 'glimmer', lines: true) {
|
88
88
|
text bind(self, :ruby_code)
|
89
89
|
}
|
90
90
|
}
|
91
91
|
tab_item {
|
92
92
|
fill_layout
|
93
|
-
text '
|
94
|
-
code_text(language: 'ruby', theme: 'pastie', lines: {width: 2}) {
|
95
|
-
text bind(self, :ruby_code)
|
96
|
-
}
|
97
|
-
}
|
98
|
-
tab_item {
|
99
|
-
fill_layout
|
100
|
-
text 'Ruby (github)'
|
101
|
-
code_text(language: 'ruby', theme: 'github', lines: false) {
|
102
|
-
text bind(self, :ruby_code)
|
103
|
-
}
|
104
|
-
}
|
105
|
-
tab_item {
|
106
|
-
fill_layout
|
107
|
-
text 'JavaScript (glimmer)'
|
108
|
-
# No border (SWT styles are passed explicitly)
|
109
|
-
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'glimmer', lines: true) {
|
110
|
-
# With lines, the custom widget has a root composite, which can be configured separately
|
111
|
-
root {
|
112
|
-
grid_layout(2, false) {
|
113
|
-
margin_width 2
|
114
|
-
}
|
115
|
-
background :white
|
116
|
-
}
|
117
|
-
# With lines, the line numbers widget can be configured separately
|
118
|
-
line_numbers {
|
119
|
-
background :white
|
120
|
-
}
|
121
|
-
text bind(self, :js_code)
|
122
|
-
}
|
123
|
-
}
|
124
|
-
tab_item {
|
125
|
-
fill_layout
|
126
|
-
text 'JavaScript (pastie)'
|
93
|
+
text 'JavaScript (pastie theme)'
|
127
94
|
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'pastie', lines: {width: 2}) {
|
128
95
|
root {
|
129
96
|
grid_layout(2, false) {
|
@@ -139,28 +106,7 @@ class HelloCodeText
|
|
139
106
|
}
|
140
107
|
tab_item {
|
141
108
|
fill_layout
|
142
|
-
text '
|
143
|
-
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'github') { # default is lines: false
|
144
|
-
text bind(self, :js_code)
|
145
|
-
}
|
146
|
-
}
|
147
|
-
tab_item {
|
148
|
-
fill_layout
|
149
|
-
text 'HTML (glimmer)'
|
150
|
-
code_text(language: 'html', theme: 'glimmer', lines: true) {
|
151
|
-
text bind(self, :html_code)
|
152
|
-
}
|
153
|
-
}
|
154
|
-
tab_item {
|
155
|
-
fill_layout
|
156
|
-
text 'HTML (pastie)'
|
157
|
-
code_text(language: 'html', theme: 'pastie', lines: {width: 2}) {
|
158
|
-
text bind(self, :html_code)
|
159
|
-
}
|
160
|
-
}
|
161
|
-
tab_item {
|
162
|
-
fill_layout
|
163
|
-
text 'HTML (github)'
|
109
|
+
text 'HTML (github theme)'
|
164
110
|
code_text(language: 'html', theme: 'github') { # default is lines: false
|
165
111
|
text bind(self, :html_code)
|
166
112
|
}
|
@@ -0,0 +1,71 @@
|
|
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 HelloComposite
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
body {
|
28
|
+
shell {
|
29
|
+
# shell (which is a composite) has fill_layout(:horizontal) by default with no margins
|
30
|
+
# we override below
|
31
|
+
fill_layout(:vertical)
|
32
|
+
text 'Hello, Composite!'
|
33
|
+
|
34
|
+
composite { # composite simply contains widgets for visual organization via a layout
|
35
|
+
# it has grid_layout(1, false) as its default layout
|
36
|
+
label {
|
37
|
+
text "Field is above its text widget"
|
38
|
+
}
|
39
|
+
text {
|
40
|
+
layout_data :fill, :center, true, false # fill horizontally, align center vertically, grab remaining horizontal space, but not vertical
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
composite { # composite simply contains widgets for visual organization via a layout
|
45
|
+
grid_layout 2, true
|
46
|
+
|
47
|
+
label {
|
48
|
+
text "Field has equal width to its text widget's"
|
49
|
+
}
|
50
|
+
text {
|
51
|
+
layout_data :fill, :center, true, false # fill horizontally, align center vertically, grab remaining horizontal space, but not vertical
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
composite { # composite simply contains widgets for visual organization via a layout
|
56
|
+
grid_layout 2, false
|
57
|
+
|
58
|
+
label {
|
59
|
+
text "Field has inequal width"
|
60
|
+
}
|
61
|
+
|
62
|
+
text {
|
63
|
+
layout_data :fill, :center, true, false # fill horizontally, align center vertically, grab remaining horizontal space, but not vertical
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
HelloComposite.launch
|
@@ -48,7 +48,7 @@ class HelloComputed
|
|
48
48
|
|
49
49
|
label {text 'First &Name: '}
|
50
50
|
text {
|
51
|
-
text
|
51
|
+
text <=> [@contact, :first_name]
|
52
52
|
layout_data {
|
53
53
|
horizontal_alignment :fill
|
54
54
|
grab_excess_horizontal_space true
|
@@ -57,7 +57,7 @@ class HelloComputed
|
|
57
57
|
|
58
58
|
label {text '&Last Name: '}
|
59
59
|
text {
|
60
|
-
text
|
60
|
+
text <=> [@contact, :last_name]
|
61
61
|
layout_data {
|
62
62
|
horizontal_alignment :fill
|
63
63
|
grab_excess_horizontal_space true
|
@@ -66,7 +66,7 @@ class HelloComputed
|
|
66
66
|
|
67
67
|
label {text '&Year of Birth: '}
|
68
68
|
text {
|
69
|
-
text
|
69
|
+
text <=> [@contact, :year_of_birth]
|
70
70
|
layout_data {
|
71
71
|
horizontal_alignment :fill
|
72
72
|
grab_excess_horizontal_space true
|
@@ -75,7 +75,7 @@ class HelloComputed
|
|
75
75
|
|
76
76
|
label {text 'Name: '}
|
77
77
|
label {
|
78
|
-
text
|
78
|
+
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
79
79
|
layout_data {
|
80
80
|
horizontal_alignment :fill
|
81
81
|
grab_excess_horizontal_space true
|
@@ -84,7 +84,7 @@ class HelloComputed
|
|
84
84
|
|
85
85
|
label {text 'Age: '}
|
86
86
|
label {
|
87
|
-
text
|
87
|
+
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
88
88
|
layout_data {
|
89
89
|
horizontal_alignment :fill
|
90
90
|
grab_excess_horizontal_space true
|
@@ -0,0 +1,147 @@
|
|
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 HelloCoolBar
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
attr_accessor :operation, :font_size
|
28
|
+
|
29
|
+
def font_size_options
|
30
|
+
(10..30).to_a.map(&:to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
before_body {
|
34
|
+
self.font_size = '10'
|
35
|
+
}
|
36
|
+
|
37
|
+
body {
|
38
|
+
shell {
|
39
|
+
fill_layout(:vertical) {
|
40
|
+
margin_width 0
|
41
|
+
margin_height 0
|
42
|
+
}
|
43
|
+
|
44
|
+
text 'Hello, Cool Bar!'
|
45
|
+
|
46
|
+
cool_bar { # optionally takes a :flat style and/or :vertical style if you need vertical layout
|
47
|
+
tool_bar {
|
48
|
+
tool_item {
|
49
|
+
image cut_image # alternatively you can pass an image file path
|
50
|
+
|
51
|
+
on_widget_selected do
|
52
|
+
self.operation = 'Cut'
|
53
|
+
end
|
54
|
+
}
|
55
|
+
tool_item {
|
56
|
+
image copy_image # alternatively you can pass an image file path
|
57
|
+
|
58
|
+
on_widget_selected do
|
59
|
+
self.operation = 'Copy'
|
60
|
+
end
|
61
|
+
}
|
62
|
+
tool_item {
|
63
|
+
image paste_image # alternatively you can pass an image file path
|
64
|
+
|
65
|
+
on_widget_selected do
|
66
|
+
self.operation = 'Paste'
|
67
|
+
end
|
68
|
+
}
|
69
|
+
}
|
70
|
+
tool_bar {
|
71
|
+
tool_item {
|
72
|
+
text 'Font Size'
|
73
|
+
}
|
74
|
+
# a combo can be nested in a tool_bar (it auto-generates a tool_item for itself behind the scenes)
|
75
|
+
combo {
|
76
|
+
selection bind(self, :font_size)
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
label {
|
83
|
+
font height: 30
|
84
|
+
text bind(self, :operation)
|
85
|
+
text bind(self, :font_size)
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
def cut_image
|
91
|
+
# building image on the fly with Canvas Shape DSL
|
92
|
+
image(25, 25) {
|
93
|
+
rectangle(0, 0, 25, 25) {
|
94
|
+
background_pattern 0, 0, 0, 25, :white, :gray
|
95
|
+
line(20, 2, 9, 15) {
|
96
|
+
line_width 2
|
97
|
+
}
|
98
|
+
line(5, 2, 16, 15) {
|
99
|
+
line_width 2
|
100
|
+
}
|
101
|
+
oval(2, 15, 8, 8) {
|
102
|
+
line_width 2
|
103
|
+
}
|
104
|
+
oval(16, 15, 8, 8) {
|
105
|
+
line_width 2
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def copy_image
|
112
|
+
# building image on the fly with Canvas Shape DSL
|
113
|
+
image(25, 25) {
|
114
|
+
rectangle(0, 0, 25, 25) {
|
115
|
+
background_pattern 0, 0, 0, 25, :white, :gray
|
116
|
+
rectangle([:default, 2], [:default, -2], 14, 14, 5, 5) {
|
117
|
+
line_width 2
|
118
|
+
}
|
119
|
+
rectangle([:default, -2], [:default, 2], 14, 14, 5, 5) {
|
120
|
+
line_width 2
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
def paste_image
|
127
|
+
image(25, 25) {
|
128
|
+
rectangle(0, 0, 25, 25) {
|
129
|
+
background_pattern 0, 0, 0, 25, :white, :gray
|
130
|
+
rectangle(:default, [:default, 1], 15, 20, 5, 5) {
|
131
|
+
line_width 2
|
132
|
+
}
|
133
|
+
line(7, 8, 18, 8) {
|
134
|
+
line_width 2
|
135
|
+
}
|
136
|
+
line(7, 13, 18, 13) {
|
137
|
+
line_width 2
|
138
|
+
}
|
139
|
+
line(7, 18, 18, 18) {
|
140
|
+
line_width 2
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
HelloCoolBar.launch
|
@@ -46,19 +46,19 @@ class HelloDateTime
|
|
46
46
|
}
|
47
47
|
|
48
48
|
date { # alias for date_time(:date)
|
49
|
-
date_time
|
49
|
+
date_time <=> [@person, :date_of_birth]
|
50
50
|
}
|
51
51
|
|
52
52
|
date_drop_down { # alias for date_time(:date, :drop_down)
|
53
|
-
date_time
|
53
|
+
date_time <=> [@person, :date_of_birth]
|
54
54
|
}
|
55
55
|
|
56
56
|
time { # alias for date_time(:time)
|
57
|
-
date_time
|
57
|
+
date_time <=> [@person, :date_of_birth]
|
58
58
|
}
|
59
59
|
|
60
60
|
calendar { # alias for date_time(:calendar)
|
61
|
-
date_time
|
61
|
+
date_time <=> [@person, :date_of_birth]
|
62
62
|
}
|
63
63
|
}
|
64
64
|
}
|
@@ -23,7 +23,7 @@ require 'glimmer-dsl-swt'
|
|
23
23
|
|
24
24
|
include Glimmer
|
25
25
|
|
26
|
-
shell {
|
26
|
+
shell { |shell_proxy|
|
27
27
|
row_layout :vertical
|
28
28
|
|
29
29
|
text 'Hello, Dialog!'
|
@@ -39,7 +39,8 @@ shell {
|
|
39
39
|
text "Dialog #{dialog_number}"
|
40
40
|
|
41
41
|
on_widget_selected {
|
42
|
-
dialog
|
42
|
+
# pass the shell proxy as a parent to make the dialog support hitting the escape button for closing alone without closing app
|
43
|
+
dialog(shell_proxy) { |dialog_proxy|
|
43
44
|
row_layout(:vertical) {
|
44
45
|
center true
|
45
46
|
}
|
@@ -51,8 +51,8 @@ class HelloFontDialog
|
|
51
51
|
height_hint 200
|
52
52
|
}
|
53
53
|
background :white
|
54
|
-
font
|
55
|
-
text
|
54
|
+
font <=> [self, 'selected_font_data']
|
55
|
+
text <=> [self, 'selected_font_data', on_read: ->(font_data) {
|
56
56
|
style = case font_data.style
|
57
57
|
when swt(:normal)
|
58
58
|
'Normal'
|
@@ -64,7 +64,7 @@ class HelloFontDialog
|
|
64
64
|
'Bold Italic'
|
65
65
|
end
|
66
66
|
"#{font_data.name}\n#{font_data.height}\n#{style}"
|
67
|
-
}
|
67
|
+
}]
|
68
68
|
}
|
69
69
|
|
70
70
|
button {
|