glimmer-dsl-opal 0.26.1 → 0.28.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 +30 -0
- data/README.md +68 -2
- data/VERSION +1 -1
- data/lib/glimmer/dsl/opal/dsl.rb +1 -0
- data/lib/glimmer/dsl/opal/shape_expression.rb +34 -6
- data/lib/glimmer/swt/c_tab_folder_proxy.rb +1 -1
- data/lib/glimmer/swt/canvas_proxy.rb +27 -0
- data/lib/glimmer/swt/combo_proxy.rb +0 -39
- data/lib/glimmer/swt/composite_proxy.rb +0 -2
- data/lib/glimmer/swt/custom/shape/line.rb +50 -0
- data/lib/glimmer/swt/custom/shape/oval.rb +58 -0
- data/lib/glimmer/swt/custom/shape/point.rb +50 -0
- data/lib/glimmer/swt/custom/shape/polygon.rb +50 -0
- data/lib/glimmer/swt/custom/shape/polyline.rb +50 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +50 -0
- data/lib/glimmer/swt/custom/shape/text.rb +64 -0
- data/lib/glimmer/swt/custom/shape.rb +109 -0
- data/lib/glimmer/swt/date_time_proxy.rb +0 -37
- data/lib/glimmer/swt/display_proxy.rb +0 -97
- data/lib/glimmer/swt/point.rb +2 -0
- data/lib/glimmer/swt/rectangle.rb +7 -0
- data/lib/glimmer/swt/spinner_proxy.rb +0 -39
- data/lib/glimmer/swt/text_proxy.rb +81 -57
- data/lib/glimmer/swt/widget_proxy.rb +146 -56
- data/lib/glimmer-dsl-opal/samples/elaborate/tetris.rb +9 -8
- data/lib/glimmer-dsl-opal/samples/hello/hello_canvas.rb +83 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_text.rb +149 -0
- metadata +14 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -25,11 +25,7 @@ require_relative 'tetris/view/playfield'
|
|
25
25
|
require_relative 'tetris/view/score_lane'
|
26
26
|
require_relative 'tetris/view/high_score_dialog'
|
27
27
|
require_relative 'tetris/view/tetris_menu_bar'
|
28
|
-
|
29
|
-
def location
|
30
|
-
`#@native.location`
|
31
|
-
end
|
32
|
-
end
|
28
|
+
|
33
29
|
class Tetris
|
34
30
|
include Glimmer::UI::CustomShell
|
35
31
|
|
@@ -72,8 +68,13 @@ class Tetris
|
|
72
68
|
when 'e'.bytes.first
|
73
69
|
game.rotate!(:right)
|
74
70
|
when swt(:shift), swt(:alt)
|
75
|
-
|
71
|
+
if key_event.keyLocation == swt(:right) # right key
|
72
|
+
game.rotate!(:right)
|
73
|
+
elsif key_event.keyLocation == swt(:left) # left key
|
74
|
+
game.rotate!(:left)
|
75
|
+
end
|
76
76
|
end
|
77
|
+
|
77
78
|
end
|
78
79
|
}
|
79
80
|
end
|
@@ -142,7 +143,7 @@ class Tetris
|
|
142
143
|
def show_about_dialog
|
143
144
|
message_box {
|
144
145
|
text 'Glimmer Tetris'
|
145
|
-
message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\n\
|
146
|
+
message "Glimmer Tetris\n\nGlimmer DSL for SWT Sample\n\nUse arrow keys for movement\nand right/left alt/shift keys for rotation\nAlternatively:\nLeft is A\nRight is D\nDown is S\nUp is W\nRotate Left is Q\nRotate Right is E\n\nCopyright (c) 2007-2021 Andy Maleh"
|
146
147
|
}.open
|
147
148
|
end
|
148
149
|
end
|
@@ -0,0 +1,83 @@
|
|
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 HelloCanvas
|
23
|
+
include Glimmer::UI::CustomShell
|
24
|
+
|
25
|
+
body {
|
26
|
+
shell {
|
27
|
+
text 'Hello, Canvas!'
|
28
|
+
minimum_size 320, 400
|
29
|
+
|
30
|
+
canvas {
|
31
|
+
background :yellow
|
32
|
+
|
33
|
+
rectangle(0, 0, 220, 400) {
|
34
|
+
background rgb(255, 0, 0)
|
35
|
+
}
|
36
|
+
rectangle(50, 20, 300, 150, 30, 50) {
|
37
|
+
background :magenta
|
38
|
+
}
|
39
|
+
rectangle(50, 20, 300, 150, 30, 50) {
|
40
|
+
foreground :yellow
|
41
|
+
}
|
42
|
+
rectangle(205, 50, 86, 97) {
|
43
|
+
foreground :yellow
|
44
|
+
}
|
45
|
+
rectangle(67, 75, 128, 38) {
|
46
|
+
background :yellow
|
47
|
+
}
|
48
|
+
rectangle(150, 200, 100, 70) {
|
49
|
+
background :dark_magenta
|
50
|
+
}
|
51
|
+
rectangle(50, 200, 30, 70) {
|
52
|
+
background :magenta
|
53
|
+
}
|
54
|
+
oval(110, 310, 100, 100) {
|
55
|
+
background :yellow
|
56
|
+
}
|
57
|
+
text('Picasso', 67, 103) {
|
58
|
+
foreground :dark_magenta
|
59
|
+
font name: 'Courier', height: 30
|
60
|
+
}
|
61
|
+
polygon(250, 210, 260, 170, 270, 210, 290, 230) {
|
62
|
+
background :dark_yellow
|
63
|
+
}
|
64
|
+
polyline(250, 110, 260, 70, 270, 110, 290, 130, 250, 110) {
|
65
|
+
foreground :black
|
66
|
+
}
|
67
|
+
3.times do |n|
|
68
|
+
line(250, 120 + n*10, 270 + n*10, 80 + n*10) {
|
69
|
+
foreground :yellow
|
70
|
+
}
|
71
|
+
end
|
72
|
+
10.times do |n|
|
73
|
+
point(220 + n*5, 100 + n*5) {
|
74
|
+
foreground :yellow
|
75
|
+
}
|
76
|
+
end
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
HelloCanvas.launch
|
83
|
+
|
@@ -0,0 +1,149 @@
|
|
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 HelloText
|
23
|
+
include Glimmer::UI::CustomShell
|
24
|
+
|
25
|
+
attr_accessor :default, :no_border, :center, :left, :right, :password, :telephone, :read_only, :wrap, :multi
|
26
|
+
|
27
|
+
before_body do
|
28
|
+
self.default = 'default is :border style'
|
29
|
+
self.no_border = 'no border'
|
30
|
+
self.center = 'centered'
|
31
|
+
self.left = 'left-aligned'
|
32
|
+
self.right = 'right-aligned'
|
33
|
+
self.password = 'password'
|
34
|
+
self.telephone = '555-555-5555'
|
35
|
+
self.read_only = 'Telephone area code is 555'
|
36
|
+
self.wrap = 'wraps if text content is too long like this example'
|
37
|
+
self.multi = "multi-line enables hitting enter,\nbut works like wrap on the web"
|
38
|
+
end
|
39
|
+
|
40
|
+
body {
|
41
|
+
shell {
|
42
|
+
grid_layout 2, false
|
43
|
+
|
44
|
+
text 'Hello, Text!'
|
45
|
+
minimum_size 350, 100
|
46
|
+
|
47
|
+
label {
|
48
|
+
text 'text'
|
49
|
+
}
|
50
|
+
text { # includes :border style by default
|
51
|
+
layout_data :fill, :center, true, false
|
52
|
+
text <=> [self, :default]
|
53
|
+
}
|
54
|
+
|
55
|
+
label {
|
56
|
+
text 'text(:none)'
|
57
|
+
}
|
58
|
+
text(:none) { # no border
|
59
|
+
layout_data :fill, :center, true, false
|
60
|
+
text <=> [self, :no_border]
|
61
|
+
}
|
62
|
+
|
63
|
+
label {
|
64
|
+
text 'text(:center, :border)'
|
65
|
+
}
|
66
|
+
text(:center, :border) {
|
67
|
+
layout_data :fill, :center, true, false
|
68
|
+
text <=> [self, :center]
|
69
|
+
}
|
70
|
+
|
71
|
+
label {
|
72
|
+
text 'text(:left, :border)'
|
73
|
+
}
|
74
|
+
text(:left, :border) {
|
75
|
+
layout_data :fill, :center, true, false
|
76
|
+
text <=> [self, :left]
|
77
|
+
}
|
78
|
+
|
79
|
+
label {
|
80
|
+
text 'text(:right, :border)'
|
81
|
+
}
|
82
|
+
text(:right, :border) {
|
83
|
+
layout_data :fill, :center, true, false
|
84
|
+
text <=> [self, :right]
|
85
|
+
}
|
86
|
+
|
87
|
+
label {
|
88
|
+
text 'text(:password, :border)'
|
89
|
+
}
|
90
|
+
text(:password, :border) {
|
91
|
+
layout_data :fill, :center, true, false
|
92
|
+
text <=> [self, :password]
|
93
|
+
}
|
94
|
+
|
95
|
+
label {
|
96
|
+
text 'text(:read_only, :border)'
|
97
|
+
}
|
98
|
+
text(:read_only, :border) {
|
99
|
+
layout_data :fill, :center, true, false
|
100
|
+
text <= [self, :read_only]
|
101
|
+
}
|
102
|
+
|
103
|
+
label {
|
104
|
+
text 'text with event handlers'
|
105
|
+
}
|
106
|
+
text {
|
107
|
+
layout_data :fill, :center, true, false
|
108
|
+
text <=> [self, :telephone]
|
109
|
+
|
110
|
+
# this event kicks in just after the user typed and before modifying the text attribute value
|
111
|
+
on_verify_text do |verify_event|
|
112
|
+
new_text = verify_event.widget.text.clone
|
113
|
+
# new_text[verify_event.start...verify_event.end] = verify_event.text # Opal does not allow string mutation like JRuby in Glimmer DSL for SWT
|
114
|
+
new_text = "#{new_text[0...verify_event.start]}#{verify_event.text}#{new_text[verify_event.end..-1]}"
|
115
|
+
verify_event.doit = telephone?(new_text)
|
116
|
+
end
|
117
|
+
|
118
|
+
# this event kicks in just after the text widget is verified and modified
|
119
|
+
on_modify_text do |modify_event|
|
120
|
+
self.read_only = "Telephone area code is #{modify_event.widget.text.gsub(/[^0-9]/, '')[0...3]}"
|
121
|
+
end
|
122
|
+
}
|
123
|
+
|
124
|
+
label {
|
125
|
+
text 'text(:wrap, :border)'
|
126
|
+
}
|
127
|
+
text(:wrap, :border) {
|
128
|
+
layout_data(:fill, :center, true, false) {
|
129
|
+
width_hint 100
|
130
|
+
}
|
131
|
+
text <=> [self, :wrap]
|
132
|
+
}
|
133
|
+
|
134
|
+
label {
|
135
|
+
text 'text(:multi, :border)'
|
136
|
+
}
|
137
|
+
text(:multi, :border) {
|
138
|
+
layout_data :fill, :center, true, false
|
139
|
+
text <=> [self, :multi]
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
def telephone?(text)
|
145
|
+
!!text.match(/^\d{0,3}[-.\/]?\d{0,3}[-.\/]?\d{0,4}$/)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
HelloText.launch
|
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.28.0
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- lib/glimmer-dsl-opal/samples/hello/hello_button.rb
|
301
301
|
- lib/glimmer-dsl-opal/samples/hello/hello_c_combo.rb
|
302
302
|
- lib/glimmer-dsl-opal/samples/hello/hello_c_tab.rb
|
303
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_canvas.rb
|
303
304
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb
|
304
305
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb
|
305
306
|
- lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
|
@@ -328,6 +329,7 @@ files:
|
|
328
329
|
- lib/glimmer-dsl-opal/samples/hello/hello_tab.rb
|
329
330
|
- lib/glimmer-dsl-opal/samples/hello/hello_table.rb
|
330
331
|
- lib/glimmer-dsl-opal/samples/hello/hello_table/baseball_park.png
|
332
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_text.rb
|
331
333
|
- lib/glimmer-dsl-opal/samples/hello/hello_world.rb
|
332
334
|
- lib/glimmer-dsl-opal/samples/hello/images/denmark.png
|
333
335
|
- lib/glimmer-dsl-opal/samples/hello/images/finland.png
|
@@ -406,6 +408,7 @@ files:
|
|
406
408
|
- lib/glimmer/swt/c_combo_proxy.rb
|
407
409
|
- lib/glimmer/swt/c_tab_folder_proxy.rb
|
408
410
|
- lib/glimmer/swt/c_tab_item_proxy.rb
|
411
|
+
- lib/glimmer/swt/canvas_proxy.rb
|
409
412
|
- lib/glimmer/swt/checkbox_proxy.rb
|
410
413
|
- lib/glimmer/swt/color_proxy.rb
|
411
414
|
- lib/glimmer/swt/combo_proxy.rb
|
@@ -413,6 +416,14 @@ files:
|
|
413
416
|
- lib/glimmer/swt/control_editor.rb
|
414
417
|
- lib/glimmer/swt/custom/checkbox_group.rb
|
415
418
|
- lib/glimmer/swt/custom/radio_group.rb
|
419
|
+
- lib/glimmer/swt/custom/shape.rb
|
420
|
+
- lib/glimmer/swt/custom/shape/line.rb
|
421
|
+
- lib/glimmer/swt/custom/shape/oval.rb
|
422
|
+
- lib/glimmer/swt/custom/shape/point.rb
|
423
|
+
- lib/glimmer/swt/custom/shape/polygon.rb
|
424
|
+
- lib/glimmer/swt/custom/shape/polyline.rb
|
425
|
+
- lib/glimmer/swt/custom/shape/rectangle.rb
|
426
|
+
- lib/glimmer/swt/custom/shape/text.rb
|
416
427
|
- lib/glimmer/swt/date_time_proxy.rb
|
417
428
|
- lib/glimmer/swt/dialog_proxy.rb
|
418
429
|
- lib/glimmer/swt/display_proxy.rb
|
@@ -436,6 +447,7 @@ files:
|
|
436
447
|
- lib/glimmer/swt/progress_bar_proxy.rb
|
437
448
|
- lib/glimmer/swt/property_owner.rb
|
438
449
|
- lib/glimmer/swt/radio_proxy.rb
|
450
|
+
- lib/glimmer/swt/rectangle.rb
|
439
451
|
- lib/glimmer/swt/row_layout_proxy.rb
|
440
452
|
- lib/glimmer/swt/scale_proxy.rb
|
441
453
|
- lib/glimmer/swt/scrolled_composite_proxy.rb
|