glimmer-dsl-swt 4.18.5.5 → 4.18.7.0
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 +42 -0
- data/README.md +4 -4
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +95 -5
- data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +2 -0
- data/docs/reference/GLIMMER_SAMPLES.md +67 -0
- data/glimmer-dsl-swt.gemspec +18 -6
- data/lib/glimmer/dsl/swt/animation_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/custom_shape_expression.rb +61 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/expand_item_expression.rb +4 -4
- data/lib/glimmer/dsl/swt/image_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/multiply_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/transform_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
- data/lib/glimmer/swt/color_proxy.rb +1 -1
- data/lib/glimmer/swt/custom/shape.rb +173 -53
- data/lib/glimmer/swt/custom/shape/cubic.rb +118 -0
- data/lib/glimmer/swt/custom/shape/line.rb +47 -4
- data/lib/glimmer/swt/custom/shape/path.rb +240 -0
- data/lib/glimmer/swt/custom/shape/path_segment.rb +135 -0
- data/lib/glimmer/swt/custom/shape/point.rb +33 -0
- data/lib/glimmer/swt/custom/shape/polygon.rb +2 -2
- data/lib/glimmer/swt/custom/shape/quad.rb +114 -0
- data/lib/glimmer/swt/display_proxy.rb +1 -1
- data/lib/glimmer/swt/message_box_proxy.rb +1 -1
- data/lib/glimmer/swt/proxy_properties.rb +1 -1
- data/lib/glimmer/swt/shell_proxy.rb +1 -1
- data/lib/glimmer/swt/tab_folder_proxy.rb +52 -0
- data/lib/glimmer/swt/transform_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +1 -1
- data/lib/glimmer/ui/custom_shape.rb +281 -0
- data/samples/elaborate/mandelbrot_fractal.rb +1 -1
- data/samples/elaborate/stock_ticker.rb +214 -0
- data/samples/hello/hello_canvas.rb +3 -0
- data/samples/hello/hello_canvas_data_binding.rb +214 -0
- data/samples/hello/hello_canvas_path.rb +120 -0
- data/samples/hello/hello_custom_shape.rb +78 -0
- data/samples/hello/hello_shape.rb +71 -0
- metadata +16 -4
@@ -0,0 +1,120 @@
|
|
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
|
+
include Glimmer
|
25
|
+
|
26
|
+
shell {
|
27
|
+
grid_layout {
|
28
|
+
margin_width 0
|
29
|
+
margin_height 0
|
30
|
+
margin_top 5
|
31
|
+
}
|
32
|
+
text 'Hello, Canvas Path!'
|
33
|
+
minimum_size 800, 700
|
34
|
+
|
35
|
+
@button = button {
|
36
|
+
layout_data :center, :center, true, false
|
37
|
+
text 'Regenerate'
|
38
|
+
enabled false
|
39
|
+
|
40
|
+
on_widget_selected {
|
41
|
+
@regenerate = true
|
42
|
+
@button.enabled = false
|
43
|
+
}
|
44
|
+
}
|
45
|
+
canvas {
|
46
|
+
layout_data :fill, :fill, true, true
|
47
|
+
background :white
|
48
|
+
|
49
|
+
text('line', 15, 200) {
|
50
|
+
foreground :red
|
51
|
+
}
|
52
|
+
@path1 = path {
|
53
|
+
antialias :on
|
54
|
+
foreground :red
|
55
|
+
}
|
56
|
+
|
57
|
+
text('quad', 15, 300) {
|
58
|
+
foreground :dark_green
|
59
|
+
}
|
60
|
+
@path2 = path {
|
61
|
+
antialias :on
|
62
|
+
foreground :dark_green
|
63
|
+
}
|
64
|
+
|
65
|
+
text('cubic', 15, 400) {
|
66
|
+
foreground :blue
|
67
|
+
}
|
68
|
+
@path3 = path {
|
69
|
+
antialias :on
|
70
|
+
foreground :blue
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
on_swt_show {
|
75
|
+
@regenerate = true
|
76
|
+
@thread = Thread.new {
|
77
|
+
loop {
|
78
|
+
if @regenerate
|
79
|
+
@regenerate = false
|
80
|
+
@path1.clear
|
81
|
+
@path2.clear
|
82
|
+
@path3.clear
|
83
|
+
y1 = y2 = y3 = 300
|
84
|
+
700.times.each do |x|
|
85
|
+
x += 55
|
86
|
+
x1 = x - 2
|
87
|
+
x2 = x - 1
|
88
|
+
x3 = x
|
89
|
+
y1 = y3
|
90
|
+
y2 = y1
|
91
|
+
y3 = [[y3 + (rand*24 - 12), 0].max, 700].min
|
92
|
+
@path1.content {
|
93
|
+
line(x1, y1 - 100)
|
94
|
+
}
|
95
|
+
if x % 2 == 0
|
96
|
+
@path2.content {
|
97
|
+
quad(x1, y1, x2, y2)
|
98
|
+
}
|
99
|
+
end
|
100
|
+
if x % 3 == 0
|
101
|
+
@path3.content {
|
102
|
+
cubic(x1, y1 + 100, x2, y2 + 100, x3, y3 + 100)
|
103
|
+
}
|
104
|
+
end
|
105
|
+
sleep(0.01)
|
106
|
+
end
|
107
|
+
@button.enabled = true
|
108
|
+
end
|
109
|
+
sleep(0.1)
|
110
|
+
}
|
111
|
+
|
112
|
+
}
|
113
|
+
|
114
|
+
}
|
115
|
+
|
116
|
+
on_widget_disposed {
|
117
|
+
@thread.kill # safe to kill since data is in memory only
|
118
|
+
}
|
119
|
+
|
120
|
+
}.open
|
@@ -0,0 +1,78 @@
|
|
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
|
+
# Creates a class-based custom shape representing the `stick_figure` keyword by convention
|
25
|
+
class StickFigure
|
26
|
+
include Glimmer::UI::CustomShape
|
27
|
+
|
28
|
+
options :x, :y, :width, :height
|
29
|
+
|
30
|
+
before_body {
|
31
|
+
@head_width = width*0.2
|
32
|
+
@head_height = height*0.2
|
33
|
+
@trunk_height = height*0.4
|
34
|
+
@extremity_length = height*0.4
|
35
|
+
}
|
36
|
+
|
37
|
+
body {
|
38
|
+
shape(x + @head_width/2.0 + @extremity_length, y) {
|
39
|
+
oval(0, 0, @head_width, @head_height)
|
40
|
+
line(@head_width/2.0, @head_height, @head_width/2.0, @head_height + @trunk_height)
|
41
|
+
line(@head_width/2.0, @head_height + @trunk_height, @head_width/2.0 + @extremity_length, @head_height + @trunk_height + @extremity_length)
|
42
|
+
line(@head_width/2.0, @head_height + @trunk_height, @head_width/2.0 - @extremity_length, @head_height + @trunk_height + @extremity_length)
|
43
|
+
line(@head_width/2.0, @head_height*2, @head_width/2.0 + @extremity_length, @head_height + @trunk_height - @extremity_length)
|
44
|
+
line(@head_width/2.0, @head_height*2, @head_width/2.0 - @extremity_length, @head_height + @trunk_height - @extremity_length)
|
45
|
+
}
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
class HelloCustomShape
|
50
|
+
include Glimmer::UI::CustomShell
|
51
|
+
|
52
|
+
WIDTH = 220
|
53
|
+
HEIGHT = 235
|
54
|
+
|
55
|
+
body {
|
56
|
+
shell {
|
57
|
+
text 'Hello, Custom Shape!'
|
58
|
+
minimum_size WIDTH, HEIGHT
|
59
|
+
|
60
|
+
@canvas = canvas {
|
61
|
+
background :white
|
62
|
+
|
63
|
+
15.times { |n|
|
64
|
+
x_location = (rand*WIDTH/2).to_i%WIDTH + (rand*25).to_i
|
65
|
+
y_location = (rand*HEIGHT/2).to_i%HEIGHT + (rand*25).to_i
|
66
|
+
foreground_color = rgb(rand*255, rand*255, rand*255)
|
67
|
+
|
68
|
+
stick_figure(x: x_location, y: y_location, width: 50, height: 50) {
|
69
|
+
foreground foreground_color
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
HelloCustomShape.launch
|
78
|
+
|
@@ -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 HelloShape
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
body {
|
28
|
+
shell {
|
29
|
+
text 'Hello, Shape!'
|
30
|
+
minimum_size 200, 225
|
31
|
+
|
32
|
+
@canvas = canvas {
|
33
|
+
background :white
|
34
|
+
|
35
|
+
15.times { |n|
|
36
|
+
x_location = (rand*125).to_i%200 + (rand*25).to_i
|
37
|
+
y_location = (rand*125).to_i%200 + (rand*25).to_i
|
38
|
+
foreground_color = rgb(rand*255, rand*255, rand*255)
|
39
|
+
|
40
|
+
stick_figure(x_location, y_location, 50, 50) {
|
41
|
+
foreground foreground_color
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
# method-based custom shape using `shape` keyword as a composite shape containing nested shapes
|
49
|
+
def stick_figure(x, y, width, height, &block)
|
50
|
+
head_width = width*0.2
|
51
|
+
head_height = height*0.2
|
52
|
+
trunk_height = height*0.4
|
53
|
+
extremity_length = height*0.4
|
54
|
+
|
55
|
+
shape(x + head_width/2.0 + extremity_length, y) {
|
56
|
+
# common attributes go here before nested shapes
|
57
|
+
block.call # invoking content block (e.g. used from the outside to set foreground)
|
58
|
+
|
59
|
+
# nested shapes go here
|
60
|
+
oval(0, 0, head_width, head_height)
|
61
|
+
line(head_width/2.0, head_height, head_width/2.0, head_height + trunk_height)
|
62
|
+
line(head_width/2.0, head_height + trunk_height, head_width/2.0 + extremity_length, head_height + trunk_height + extremity_length)
|
63
|
+
line(head_width/2.0, head_height + trunk_height, head_width/2.0 - extremity_length, head_height + trunk_height + extremity_length)
|
64
|
+
line(head_width/2.0, head_height*2, head_width/2.0 + extremity_length, head_height + trunk_height - extremity_length)
|
65
|
+
line(head_width/2.0, head_height*2, head_width/2.0 - extremity_length, head_height + trunk_height - extremity_length)
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
HelloShape.launch
|
71
|
+
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.18.
|
4
|
+
version: 4.18.7.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-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 1.
|
18
|
+
version: 1.2.0
|
19
19
|
name: glimmer
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -385,6 +385,7 @@ files:
|
|
385
385
|
- lib/glimmer/dsl/swt/column_properties_expression.rb
|
386
386
|
- lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb
|
387
387
|
- lib/glimmer/dsl/swt/cursor_expression.rb
|
388
|
+
- lib/glimmer/dsl/swt/custom_shape_expression.rb
|
388
389
|
- lib/glimmer/dsl/swt/custom_widget_expression.rb
|
389
390
|
- lib/glimmer/dsl/swt/data_binding_expression.rb
|
390
391
|
- lib/glimmer/dsl/swt/dialog_expression.rb
|
@@ -434,13 +435,17 @@ files:
|
|
434
435
|
- lib/glimmer/swt/custom/radio_group.rb
|
435
436
|
- lib/glimmer/swt/custom/shape.rb
|
436
437
|
- lib/glimmer/swt/custom/shape/arc.rb
|
438
|
+
- lib/glimmer/swt/custom/shape/cubic.rb
|
437
439
|
- lib/glimmer/swt/custom/shape/focus.rb
|
438
440
|
- lib/glimmer/swt/custom/shape/image.rb
|
439
441
|
- lib/glimmer/swt/custom/shape/line.rb
|
440
442
|
- lib/glimmer/swt/custom/shape/oval.rb
|
443
|
+
- lib/glimmer/swt/custom/shape/path.rb
|
444
|
+
- lib/glimmer/swt/custom/shape/path_segment.rb
|
441
445
|
- lib/glimmer/swt/custom/shape/point.rb
|
442
446
|
- lib/glimmer/swt/custom/shape/polygon.rb
|
443
447
|
- lib/glimmer/swt/custom/shape/polyline.rb
|
448
|
+
- lib/glimmer/swt/custom/shape/quad.rb
|
444
449
|
- lib/glimmer/swt/custom/shape/rectangle.rb
|
445
450
|
- lib/glimmer/swt/custom/shape/text.rb
|
446
451
|
- lib/glimmer/swt/date_time_proxy.rb
|
@@ -463,6 +468,7 @@ files:
|
|
463
468
|
- lib/glimmer/swt/style_constantizable.rb
|
464
469
|
- lib/glimmer/swt/styled_text_proxy.rb
|
465
470
|
- lib/glimmer/swt/swt_proxy.rb
|
471
|
+
- lib/glimmer/swt/tab_folder_proxy.rb
|
466
472
|
- lib/glimmer/swt/tab_item_proxy.rb
|
467
473
|
- lib/glimmer/swt/table_column_proxy.rb
|
468
474
|
- lib/glimmer/swt/table_proxy.rb
|
@@ -471,6 +477,7 @@ files:
|
|
471
477
|
- lib/glimmer/swt/widget_listener_proxy.rb
|
472
478
|
- lib/glimmer/swt/widget_proxy.rb
|
473
479
|
- lib/glimmer/ui.rb
|
480
|
+
- lib/glimmer/ui/custom_shape.rb
|
474
481
|
- lib/glimmer/ui/custom_shell.rb
|
475
482
|
- lib/glimmer/ui/custom_widget.rb
|
476
483
|
- lib/glimmer/util/proc_tracker.rb
|
@@ -481,6 +488,7 @@ files:
|
|
481
488
|
- samples/elaborate/login.rb
|
482
489
|
- samples/elaborate/mandelbrot_fractal.rb
|
483
490
|
- samples/elaborate/meta_sample.rb
|
491
|
+
- samples/elaborate/stock_ticker.rb
|
484
492
|
- samples/elaborate/tetris.rb
|
485
493
|
- samples/elaborate/tetris/model/block.rb
|
486
494
|
- samples/elaborate/tetris/model/game.rb
|
@@ -499,6 +507,8 @@ files:
|
|
499
507
|
- samples/hello/hello_button.rb
|
500
508
|
- samples/hello/hello_canvas.rb
|
501
509
|
- samples/hello/hello_canvas_animation.rb
|
510
|
+
- samples/hello/hello_canvas_data_binding.rb
|
511
|
+
- samples/hello/hello_canvas_path.rb
|
502
512
|
- samples/hello/hello_canvas_transform.rb
|
503
513
|
- samples/hello/hello_checkbox.rb
|
504
514
|
- samples/hello/hello_checkbox_group.rb
|
@@ -508,6 +518,7 @@ files:
|
|
508
518
|
- samples/hello/hello_computed.rb
|
509
519
|
- samples/hello/hello_computed/contact.rb
|
510
520
|
- samples/hello/hello_cursor.rb
|
521
|
+
- samples/hello/hello_custom_shape.rb
|
511
522
|
- samples/hello/hello_custom_shell.rb
|
512
523
|
- samples/hello/hello_custom_widget.rb
|
513
524
|
- samples/hello/hello_date_time.rb
|
@@ -528,6 +539,7 @@ files:
|
|
528
539
|
- samples/hello/hello_radio.rb
|
529
540
|
- samples/hello/hello_radio_group.rb
|
530
541
|
- samples/hello/hello_sash_form.rb
|
542
|
+
- samples/hello/hello_shape.rb
|
531
543
|
- samples/hello/hello_spinner.rb
|
532
544
|
- samples/hello/hello_styled_text.rb
|
533
545
|
- samples/hello/hello_tab.rb
|