glimmer-dsl-swt 4.18.6.2 → 4.18.7.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 +34 -0
- data/README.md +4 -4
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +64 -6
- data/docs/reference/GLIMMER_SAMPLES.md +71 -0
- data/glimmer-dsl-swt.gemspec +16 -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/custom/shape.rb +473 -180
- data/lib/glimmer/swt/custom/shape/image.rb +7 -9
- data/lib/glimmer/swt/custom/shape/path.rb +38 -29
- data/lib/glimmer/swt/custom/shape/path_segment.rb +21 -19
- data/lib/glimmer/swt/custom/shape/polygon.rb +24 -8
- data/lib/glimmer/swt/custom/shape/polyline.rb +5 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +10 -19
- data/lib/glimmer/swt/display_proxy.rb +1 -1
- data/lib/glimmer/swt/message_box_proxy.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/meta_sample.rb +5 -5
- data/samples/elaborate/metronome.rb +177 -0
- data/samples/elaborate/stock_ticker.rb +0 -6
- data/samples/elaborate/tetris.rb +1 -12
- data/samples/elaborate/tetris/model/game.rb +3 -0
- data/samples/elaborate/tetris/view/bevel.rb +78 -0
- data/samples/elaborate/tetris/view/block.rb +6 -29
- data/samples/hello/hello_canvas.rb +3 -0
- data/samples/hello/hello_canvas_animation_data_binding.rb +66 -0
- data/samples/hello/hello_canvas_data_binding.rb +24 -3
- data/samples/hello/hello_canvas_path.rb +1 -1
- data/samples/hello/hello_custom_shape.rb +78 -0
- data/samples/hello/hello_shape.rb +71 -0
- data/samples/hello/hello_spinner.rb +7 -2
- data/sounds/metronome-down.wav +0 -0
- data/sounds/metronome-up.wav +0 -0
- metadata +14 -4
@@ -1,7 +1,28 @@
|
|
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
|
+
|
1
22
|
require 'glimmer-dsl-swt'
|
2
23
|
|
3
24
|
class HelloCanvasDataBinding
|
4
|
-
include Glimmer::GUI::CustomWindow
|
25
|
+
include Glimmer::GUI::CustomWindow # alias for Glimmer::UI::CustomShell
|
5
26
|
|
6
27
|
CANVAS_WIDTH = 300
|
7
28
|
CANVAS_HEIGHT = 300
|
@@ -13,7 +34,7 @@ class HelloCanvasDataBinding
|
|
13
34
|
end
|
14
35
|
|
15
36
|
def line_style_value_options
|
16
|
-
[:
|
37
|
+
[:solid, :dash, :dot, :dashdot, :dashdotdot]
|
17
38
|
end
|
18
39
|
|
19
40
|
before_body {
|
@@ -25,7 +46,7 @@ class HelloCanvasDataBinding
|
|
25
46
|
self.foreground_green = 128
|
26
47
|
self.foreground_blue = 228
|
27
48
|
self.line_width_value = 3
|
28
|
-
self.line_style_value = :
|
49
|
+
self.line_style_value = :dot
|
29
50
|
}
|
30
51
|
|
31
52
|
body {
|
@@ -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*15).to_i
|
65
|
+
y_location = (rand*HEIGHT/2).to_i%HEIGHT + (rand*15).to_i
|
66
|
+
foreground_color = rgb(rand*255, rand*255, rand*255)
|
67
|
+
|
68
|
+
stick_figure(x: x_location, y: y_location, width: 35+n*2, height: 35+n*2) {
|
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*15).to_i
|
37
|
+
y_location = (rand*125).to_i%200 + (rand*15).to_i
|
38
|
+
foreground_color = rgb(rand*255, rand*255, rand*255)
|
39
|
+
|
40
|
+
stick_figure(x_location, y_location, 35+n*2, 35+n*2) {
|
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
|
+
|
@@ -30,7 +30,7 @@ class HelloSpinner
|
|
30
30
|
|
31
31
|
before_body {
|
32
32
|
@person = Person.new
|
33
|
-
@person.donation = 500
|
33
|
+
@person.donation = 500 # in cents
|
34
34
|
}
|
35
35
|
|
36
36
|
body {
|
@@ -57,12 +57,17 @@ class HelloSpinner
|
|
57
57
|
|
58
58
|
spinner {
|
59
59
|
digits 2 # digits after the decimal point
|
60
|
-
minimum
|
60
|
+
minimum 100 # minimum value (including digits after the decimal point)
|
61
61
|
maximum 15000 # maximum value (including digits after the decimal point)
|
62
62
|
increment 500 # increment on up and down (including digits after the decimal point)
|
63
63
|
page_increment 5000 # page increment on page up and page down (including digits after the decimal point)
|
64
64
|
selection bind(@person, :donation) # selection must be set last if other properties are configured to ensure value is within bounds
|
65
65
|
}
|
66
|
+
|
67
|
+
label {
|
68
|
+
text bind(@person, :donation) {|value| "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}
|
69
|
+
}
|
70
|
+
|
66
71
|
}
|
67
72
|
}
|
68
73
|
}
|
Binary file
|
Binary file
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-09 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
|
@@ -467,6 +468,7 @@ files:
|
|
467
468
|
- lib/glimmer/swt/style_constantizable.rb
|
468
469
|
- lib/glimmer/swt/styled_text_proxy.rb
|
469
470
|
- lib/glimmer/swt/swt_proxy.rb
|
471
|
+
- lib/glimmer/swt/tab_folder_proxy.rb
|
470
472
|
- lib/glimmer/swt/tab_item_proxy.rb
|
471
473
|
- lib/glimmer/swt/table_column_proxy.rb
|
472
474
|
- lib/glimmer/swt/table_proxy.rb
|
@@ -475,6 +477,7 @@ files:
|
|
475
477
|
- lib/glimmer/swt/widget_listener_proxy.rb
|
476
478
|
- lib/glimmer/swt/widget_proxy.rb
|
477
479
|
- lib/glimmer/ui.rb
|
480
|
+
- lib/glimmer/ui/custom_shape.rb
|
478
481
|
- lib/glimmer/ui/custom_shell.rb
|
479
482
|
- lib/glimmer/ui/custom_widget.rb
|
480
483
|
- lib/glimmer/util/proc_tracker.rb
|
@@ -485,12 +488,14 @@ files:
|
|
485
488
|
- samples/elaborate/login.rb
|
486
489
|
- samples/elaborate/mandelbrot_fractal.rb
|
487
490
|
- samples/elaborate/meta_sample.rb
|
491
|
+
- samples/elaborate/metronome.rb
|
488
492
|
- samples/elaborate/stock_ticker.rb
|
489
493
|
- samples/elaborate/tetris.rb
|
490
494
|
- samples/elaborate/tetris/model/block.rb
|
491
495
|
- samples/elaborate/tetris/model/game.rb
|
492
496
|
- samples/elaborate/tetris/model/past_game.rb
|
493
497
|
- samples/elaborate/tetris/model/tetromino.rb
|
498
|
+
- samples/elaborate/tetris/view/bevel.rb
|
494
499
|
- samples/elaborate/tetris/view/block.rb
|
495
500
|
- samples/elaborate/tetris/view/high_score_dialog.rb
|
496
501
|
- samples/elaborate/tetris/view/playfield.rb
|
@@ -504,6 +509,7 @@ files:
|
|
504
509
|
- samples/hello/hello_button.rb
|
505
510
|
- samples/hello/hello_canvas.rb
|
506
511
|
- samples/hello/hello_canvas_animation.rb
|
512
|
+
- samples/hello/hello_canvas_animation_data_binding.rb
|
507
513
|
- samples/hello/hello_canvas_data_binding.rb
|
508
514
|
- samples/hello/hello_canvas_path.rb
|
509
515
|
- samples/hello/hello_canvas_transform.rb
|
@@ -515,6 +521,7 @@ files:
|
|
515
521
|
- samples/hello/hello_computed.rb
|
516
522
|
- samples/hello/hello_computed/contact.rb
|
517
523
|
- samples/hello/hello_cursor.rb
|
524
|
+
- samples/hello/hello_custom_shape.rb
|
518
525
|
- samples/hello/hello_custom_shell.rb
|
519
526
|
- samples/hello/hello_custom_widget.rb
|
520
527
|
- samples/hello/hello_date_time.rb
|
@@ -535,6 +542,7 @@ files:
|
|
535
542
|
- samples/hello/hello_radio.rb
|
536
543
|
- samples/hello/hello_radio_group.rb
|
537
544
|
- samples/hello/hello_sash_form.rb
|
545
|
+
- samples/hello/hello_shape.rb
|
538
546
|
- samples/hello/hello_spinner.rb
|
539
547
|
- samples/hello/hello_styled_text.rb
|
540
548
|
- samples/hello/hello_tab.rb
|
@@ -542,6 +550,8 @@ files:
|
|
542
550
|
- samples/hello/hello_table/baseball_park.png
|
543
551
|
- samples/hello/hello_tree.rb
|
544
552
|
- samples/hello/hello_world.rb
|
553
|
+
- sounds/metronome-down.wav
|
554
|
+
- sounds/metronome-up.wav
|
545
555
|
- vendor/swt/linux/swt.jar
|
546
556
|
- vendor/swt/mac/swt.jar
|
547
557
|
- vendor/swt/windows/swt.jar
|