glimmer-dsl-swt 4.18.5.2 → 4.18.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +35 -3
- data/glimmer-dsl-swt.gemspec +3 -3
- data/lib/glimmer/swt/custom/drawable.rb +8 -7
- data/lib/glimmer/swt/custom/shape.rb +153 -13
- data/lib/glimmer/swt/custom/shape/arc.rb +3 -3
- data/lib/glimmer/swt/custom/shape/image.rb +19 -6
- data/lib/glimmer/swt/custom/shape/line.rb +47 -1
- data/lib/glimmer/swt/custom/shape/oval.rb +3 -3
- data/lib/glimmer/swt/custom/shape/point.rb +1 -6
- data/lib/glimmer/swt/custom/shape/polygon.rb +42 -1
- data/lib/glimmer/swt/custom/shape/polyline.rb +45 -4
- data/lib/glimmer/swt/custom/shape/rectangle.rb +5 -1
- data/lib/glimmer/swt/widget_proxy.rb +16 -0
- data/samples/elaborate/contact_manager.rb +2 -0
- data/samples/elaborate/login.rb +2 -0
- data/samples/elaborate/mandelbrot_fractal.rb +1 -0
- data/samples/elaborate/meta_sample.rb +1 -0
- data/samples/elaborate/tetris.rb +2 -1
- data/samples/elaborate/tic_tac_toe.rb +2 -0
- data/samples/elaborate/user_profile.rb +10 -8
- data/samples/hello/hello_browser.rb +2 -0
- data/samples/hello/hello_button.rb +2 -0
- data/samples/hello/hello_canvas.rb +14 -12
- data/samples/hello/hello_canvas_animation.rb +2 -0
- data/samples/hello/hello_canvas_transform.rb +2 -0
- data/samples/hello/hello_checkbox.rb +2 -0
- data/samples/hello/hello_checkbox_group.rb +2 -0
- data/samples/hello/hello_code_text.rb +2 -0
- data/samples/hello/hello_color_dialog.rb +2 -0
- data/samples/hello/hello_combo.rb +2 -0
- data/samples/hello/hello_computed.rb +2 -0
- data/samples/hello/hello_cursor.rb +2 -0
- data/samples/hello/hello_custom_shell.rb +1 -0
- data/samples/hello/hello_custom_widget.rb +2 -0
- data/samples/hello/hello_date_time.rb +2 -0
- data/samples/hello/hello_dialog.rb +2 -0
- data/samples/hello/hello_directory_dialog.rb +2 -0
- data/samples/hello/hello_drag_and_drop.rb +5 -3
- data/samples/hello/hello_expand_bar.rb +2 -0
- data/samples/hello/hello_file_dialog.rb +2 -0
- data/samples/hello/hello_font_dialog.rb +2 -0
- data/samples/hello/hello_group.rb +2 -0
- data/samples/hello/hello_link.rb +2 -0
- data/samples/hello/hello_list_multi_selection.rb +2 -0
- data/samples/hello/hello_list_single_selection.rb +2 -0
- data/samples/hello/hello_menu_bar.rb +2 -0
- data/samples/hello/hello_message_box.rb +2 -0
- data/samples/hello/hello_pop_up_context_menu.rb +2 -0
- data/samples/hello/hello_progress_bar.rb +2 -0
- data/samples/hello/hello_radio.rb +2 -0
- data/samples/hello/hello_radio_group.rb +2 -0
- data/samples/hello/hello_sash_form.rb +2 -0
- data/samples/hello/hello_spinner.rb +2 -0
- data/samples/hello/hello_styled_text.rb +19 -17
- data/samples/hello/hello_tab.rb +2 -0
- data/samples/hello/hello_table.rb +2 -0
- data/samples/hello/hello_world.rb +2 -0
- metadata +2 -2
@@ -46,9 +46,55 @@ module Glimmer
|
|
46
46
|
[:x1, :y1, :x2, :y2]
|
47
47
|
end
|
48
48
|
|
49
|
+
def location_parameter_names
|
50
|
+
parameter_names
|
51
|
+
end
|
52
|
+
|
53
|
+
# Logical x coordinate. Always assumes the first point in the line to be the x coordinate.
|
54
|
+
def x
|
55
|
+
x1
|
56
|
+
end
|
57
|
+
|
58
|
+
# Logical y coordinate. Always assumes the first point in the line to be the y coordinate.
|
59
|
+
def y
|
60
|
+
y1
|
61
|
+
end
|
62
|
+
|
63
|
+
def absolute_x1
|
64
|
+
if parent.is_a?(Shape)
|
65
|
+
parent.absolute_x + x1
|
66
|
+
else
|
67
|
+
x1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def absolute_y1
|
72
|
+
if parent.is_a?(Shape)
|
73
|
+
parent.absolute_y + y1
|
74
|
+
else
|
75
|
+
y1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def absolute_x2
|
80
|
+
if parent.is_a?(Shape)
|
81
|
+
parent.absolute_x + x2
|
82
|
+
else
|
83
|
+
x2
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def absolute_y2
|
88
|
+
if parent.is_a?(Shape)
|
89
|
+
parent.absolute_y + y1
|
90
|
+
else
|
91
|
+
y2
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
49
95
|
def include?(x, y)
|
50
96
|
# TODO must account for line width
|
51
|
-
Line.include?(
|
97
|
+
Line.include?(absolute_x1, absolute_y1, absolute_x2, absolute_y2, x, y)
|
52
98
|
end
|
53
99
|
alias contain? include?
|
54
100
|
|
@@ -39,7 +39,7 @@ module Glimmer
|
|
39
39
|
|
40
40
|
# checks if shape contains the point denoted by x and y
|
41
41
|
def contain?(x, y)
|
42
|
-
shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.
|
42
|
+
shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.absolute_x, self.absolute_y, width, height)
|
43
43
|
shape_geometry.contains(x, y)
|
44
44
|
end
|
45
45
|
|
@@ -49,8 +49,8 @@ module Glimmer
|
|
49
49
|
contain?(x, y)
|
50
50
|
else
|
51
51
|
# give it some fuzz to allow a larger region around the drawn oval to accept including a point (helps with mouse clickability on a shape)
|
52
|
-
outer_shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.
|
53
|
-
inner_shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.
|
52
|
+
outer_shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.absolute_x - 3, self.absolute_y - 3, width + 6, height + 6)
|
53
|
+
inner_shape_geometry = java.awt.geom.Ellipse2D::Double.new(self.absolute_x + 3, self.absolute_y + 3, width - 6, height - 6)
|
54
54
|
outer_shape_geometry.contains(x, y) && !inner_shape_geometry.contains(x, y)
|
55
55
|
end
|
56
56
|
end
|
@@ -39,14 +39,9 @@ module Glimmer
|
|
39
39
|
|
40
40
|
def include?(x, y)
|
41
41
|
# give it some fuzz (helps makes mouse clicking easier)
|
42
|
-
x.to_i.between?(self.
|
42
|
+
x.to_i.between?(self.absolute_x.to_i - 2, self.absolute_x.to_i + 2) && y.to_i.between?(self.absolute_y.to_i - 2, self.absolute_y.to_i + 2)
|
43
43
|
end
|
44
44
|
alias contain? include?
|
45
|
-
|
46
|
-
def move_by(x_delta, y_delta)
|
47
|
-
self.x += x_delta
|
48
|
-
self.y += y_delta
|
49
|
-
end
|
50
45
|
end
|
51
46
|
end
|
52
47
|
end
|
@@ -37,6 +37,10 @@ module Glimmer
|
|
37
37
|
[:point_array]
|
38
38
|
end
|
39
39
|
|
40
|
+
def location_parameter_names
|
41
|
+
parameter_names
|
42
|
+
end
|
43
|
+
|
40
44
|
def point_count
|
41
45
|
point_array.count / 2
|
42
46
|
end
|
@@ -58,10 +62,47 @@ module Glimmer
|
|
58
62
|
x_array.zip(y_array)
|
59
63
|
end
|
60
64
|
|
65
|
+
# Logical x coordinate. Always assumes the first point in the polygon to be the x coordinate.
|
66
|
+
def x
|
67
|
+
x_array.first
|
68
|
+
end
|
69
|
+
|
70
|
+
# Logical y coordinate. Always assumes the first point in the polygon to be the y coordinate.
|
71
|
+
def y
|
72
|
+
y_array.first
|
73
|
+
end
|
74
|
+
|
75
|
+
def absolute_point_array
|
76
|
+
if parent.is_a?(Shape)
|
77
|
+
point_array.each_with_index.map do |coordinate, i|
|
78
|
+
if i.even?
|
79
|
+
parent.absolute_x + coordinate
|
80
|
+
else
|
81
|
+
parent.absolute_y + coordinate
|
82
|
+
end
|
83
|
+
end
|
84
|
+
else
|
85
|
+
point_array
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def absolute_x_array
|
90
|
+
absolute_point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
|
91
|
+
end
|
92
|
+
|
93
|
+
def absolute_y_array
|
94
|
+
absolute_point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
|
95
|
+
end
|
96
|
+
|
97
|
+
def absolute_point_xy_array
|
98
|
+
absolute_x_array.zip(absolute_y_array)
|
99
|
+
end
|
100
|
+
|
61
101
|
def include?(x, y)
|
62
|
-
shape_geometry = java.awt.Polygon.new(
|
102
|
+
shape_geometry = java.awt.Polygon.new(absolute_x_array.to_java(:int), absolute_y_array.to_java(:int), point_count)
|
63
103
|
shape_geometry.contains(x, y)
|
64
104
|
end
|
105
|
+
alias contain? include? # TODO make include do an outer/inner check of edge detection only
|
65
106
|
|
66
107
|
def move_by(x_delta, y_delta)
|
67
108
|
self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
|
@@ -37,10 +37,19 @@ module Glimmer
|
|
37
37
|
[:point_array]
|
38
38
|
end
|
39
39
|
|
40
|
+
def location_parameter_names
|
41
|
+
parameter_names
|
42
|
+
end
|
43
|
+
|
40
44
|
def point_count
|
41
45
|
point_array.count / 2
|
42
46
|
end
|
43
47
|
|
48
|
+
def [](index)
|
49
|
+
index = 0 if index == point_count
|
50
|
+
org.eclipse.swt.graphics.Point.new(point_array[index * 2], point_array[index * 2 + 1])
|
51
|
+
end
|
52
|
+
|
44
53
|
def x_array
|
45
54
|
point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
|
46
55
|
end
|
@@ -53,16 +62,48 @@ module Glimmer
|
|
53
62
|
x_array.zip(y_array)
|
54
63
|
end
|
55
64
|
|
56
|
-
|
57
|
-
|
58
|
-
|
65
|
+
# Logical x coordinate. Always assumes the first point in the polyline to be the x coordinate.
|
66
|
+
def x
|
67
|
+
x_array.first
|
68
|
+
end
|
69
|
+
|
70
|
+
# Logical y coordinate. Always assumes the first point in the polyline to be the y coordinate.
|
71
|
+
def y
|
72
|
+
y_array.first
|
59
73
|
end
|
60
74
|
|
75
|
+
def absolute_point_array
|
76
|
+
if parent.is_a?(Shape)
|
77
|
+
point_array.each_with_index.map do |coordinate, i|
|
78
|
+
if i.even?
|
79
|
+
parent.absolute_x + coordinate
|
80
|
+
else
|
81
|
+
parent.absolute_y + coordinate
|
82
|
+
end
|
83
|
+
end
|
84
|
+
else
|
85
|
+
point_array
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def absolute_x_array
|
90
|
+
absolute_point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
|
91
|
+
end
|
92
|
+
|
93
|
+
def absolute_y_array
|
94
|
+
absolute_point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
|
95
|
+
end
|
96
|
+
|
97
|
+
def absolute_point_xy_array
|
98
|
+
absolute_x_array.zip(absolute_y_array)
|
99
|
+
end
|
100
|
+
|
61
101
|
def include?(x, y)
|
62
|
-
comparison_lines =
|
102
|
+
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
|
63
103
|
comparison_lines.pop # ignore last pair since you don't want to compare last point with first point
|
64
104
|
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
|
65
105
|
end
|
106
|
+
alias contain? include?
|
66
107
|
|
67
108
|
def move_by(x_delta, y_delta)
|
68
109
|
self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
|
@@ -84,12 +84,16 @@ module Glimmer
|
|
84
84
|
[[x, y], [x + width, y], [x + width, y + height], [x, y + height]]
|
85
85
|
end
|
86
86
|
|
87
|
+
def absolute_point_xy_array
|
88
|
+
[[absolute_x, absolute_y], [absolute_x + width, absolute_y], [absolute_x + width, absolute_y + height], [absolute_x, absolute_y + height]]
|
89
|
+
end
|
90
|
+
|
87
91
|
# checks if drawn or filled rectangle includes the point denoted by x and y (if drawn, it only returns true if point lies on the edge)
|
88
92
|
def include?(x, y)
|
89
93
|
if filled?
|
90
94
|
contain?(x, y)
|
91
95
|
else
|
92
|
-
comparison_lines =
|
96
|
+
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
|
93
97
|
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
|
94
98
|
end
|
95
99
|
end
|
@@ -291,6 +291,22 @@ module Glimmer
|
|
291
291
|
@swt_widget.removeControlListener(listener.swt_listener)
|
292
292
|
end
|
293
293
|
end
|
294
|
+
|
295
|
+
def x
|
296
|
+
bounds.x
|
297
|
+
end
|
298
|
+
|
299
|
+
def y
|
300
|
+
bounds.y
|
301
|
+
end
|
302
|
+
|
303
|
+
def width
|
304
|
+
bounds.width
|
305
|
+
end
|
306
|
+
|
307
|
+
def height
|
308
|
+
bounds.height
|
309
|
+
end
|
294
310
|
|
295
311
|
# these work in tandem with the property_type_converters
|
296
312
|
# sometimes, they are specified in subclasses instead
|
@@ -19,6 +19,8 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
22
24
|
require_relative "contact_manager/contact_manager_presenter"
|
23
25
|
|
24
26
|
class ContactManager
|
data/samples/elaborate/login.rb
CHANGED
data/samples/elaborate/tetris.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
|
22
|
+
require 'glimmer-dsl-swt'
|
23
23
|
|
24
24
|
require_relative 'tetris/model/game'
|
25
25
|
|
@@ -28,6 +28,7 @@ require_relative 'tetris/view/score_lane'
|
|
28
28
|
require_relative 'tetris/view/high_score_dialog'
|
29
29
|
require_relative 'tetris/view/tetris_menu_bar'
|
30
30
|
|
31
|
+
# Tetris App View Custom Shell (represents `tetris` keyword)
|
31
32
|
class Tetris
|
32
33
|
include Glimmer::UI::CustomShell
|
33
34
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-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
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -19,6 +19,8 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
22
24
|
include Glimmer
|
23
25
|
|
24
26
|
shell {
|
@@ -32,21 +34,21 @@ shell {
|
|
32
34
|
grid_layout 2, false
|
33
35
|
layout_data :fill, :fill, true, true
|
34
36
|
label {text "First"}; text {text "Bullet"}
|
35
|
-
label {text "Last"}; text {text "Tooth"}
|
37
|
+
label {text "Last"}; text {text "Tooth"}
|
36
38
|
}
|
37
39
|
|
38
40
|
group {
|
39
41
|
layout_data :fill, :fill, true, true
|
40
42
|
text "Gender"
|
41
43
|
radio {text "Male"; selection true}
|
42
|
-
radio {text "Female"}
|
44
|
+
radio {text "Female"}
|
43
45
|
}
|
44
46
|
|
45
47
|
group {
|
46
48
|
layout_data :fill, :fill, true, true
|
47
49
|
text "Role"
|
48
50
|
check {text "Student"; selection true}
|
49
|
-
check {text "Employee"; selection true}
|
51
|
+
check {text "Employee"; selection true}
|
50
52
|
}
|
51
53
|
|
52
54
|
group {
|
@@ -59,11 +61,11 @@ shell {
|
|
59
61
|
button {
|
60
62
|
text "save"
|
61
63
|
layout_data :right, :center, true, true
|
62
|
-
on_widget_selected {
|
64
|
+
on_widget_selected {
|
63
65
|
message_box {
|
64
66
|
text 'Profile Saved!'
|
65
67
|
message 'User profile has been saved!'
|
66
|
-
}.open
|
68
|
+
}.open
|
67
69
|
}
|
68
70
|
}
|
69
71
|
|
@@ -19,6 +19,8 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require 'glimmer-dsl-swt'
|
23
|
+
|
22
24
|
class HelloCanvas
|
23
25
|
include Glimmer::UI::CustomShell
|
24
26
|
|
@@ -51,6 +53,18 @@ class HelloCanvas
|
|
51
53
|
}
|
52
54
|
rectangle(205, 50, 88, 96) {
|
53
55
|
foreground :yellow
|
56
|
+
3.times { |n|
|
57
|
+
line(45, 70 + n*10, 65 + n*10, 30 + n*10) {
|
58
|
+
foreground :yellow
|
59
|
+
}
|
60
|
+
}
|
61
|
+
10.times {|n|
|
62
|
+
point(15 + n*5, 50 + n*5) {
|
63
|
+
foreground :yellow
|
64
|
+
}
|
65
|
+
}
|
66
|
+
polyline(45, 60, 55, 20, 65, 60, 85, 80, 45, 60)
|
67
|
+
image(@image_object, 0, 5)
|
54
68
|
}
|
55
69
|
text('Picasso', 60, 80) {
|
56
70
|
background :yellow
|
@@ -67,18 +81,6 @@ class HelloCanvas
|
|
67
81
|
polygon(250, 210, 260, 170, 270, 210, 290, 230) {
|
68
82
|
background :dark_yellow
|
69
83
|
}
|
70
|
-
polyline(250, 110, 260, 70, 270, 110, 290, 130, 250, 110)
|
71
|
-
3.times { |n|
|
72
|
-
line(250, 120 + n*10, 270 + n*10, 80 + n*10) {
|
73
|
-
foreground :yellow
|
74
|
-
}
|
75
|
-
}
|
76
|
-
10.times {|n|
|
77
|
-
point(220 + n*5, 100 + n*5) {
|
78
|
-
foreground :yellow
|
79
|
-
}
|
80
|
-
}
|
81
|
-
image(@image_object, 205, 55)
|
82
84
|
|
83
85
|
menu {
|
84
86
|
menu_item {
|