glimmer-dsl-swt 4.18.6.3 → 4.18.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/README.md +4 -4
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_COMMAND.md +46 -3
  6. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +26 -3
  7. data/docs/reference/GLIMMER_SAMPLES.md +56 -0
  8. data/glimmer-dsl-swt.gemspec +15 -6
  9. data/lib/glimmer/dsl/swt/animation_expression.rb +1 -1
  10. data/lib/glimmer/dsl/swt/custom_shape_expression.rb +61 -0
  11. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
  12. data/lib/glimmer/dsl/swt/dsl.rb +1 -0
  13. data/lib/glimmer/dsl/swt/expand_item_expression.rb +4 -4
  14. data/lib/glimmer/dsl/swt/image_expression.rb +1 -1
  15. data/lib/glimmer/dsl/swt/multiply_expression.rb +1 -1
  16. data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
  17. data/lib/glimmer/dsl/swt/transform_expression.rb +1 -1
  18. data/lib/glimmer/dsl/swt/widget_expression.rb +1 -1
  19. data/lib/glimmer/rake_task.rb +36 -6
  20. data/lib/glimmer/rake_task/list.rb +8 -0
  21. data/lib/glimmer/rake_task/scaffold.rb +103 -0
  22. data/lib/glimmer/swt/custom/shape.rb +464 -181
  23. data/lib/glimmer/swt/custom/shape/image.rb +7 -9
  24. data/lib/glimmer/swt/custom/shape/path.rb +1 -5
  25. data/lib/glimmer/swt/custom/shape/polygon.rb +24 -8
  26. data/lib/glimmer/swt/custom/shape/polyline.rb +5 -0
  27. data/lib/glimmer/swt/custom/shape/rectangle.rb +10 -19
  28. data/lib/glimmer/swt/display_proxy.rb +1 -1
  29. data/lib/glimmer/swt/message_box_proxy.rb +1 -1
  30. data/lib/glimmer/swt/shell_proxy.rb +1 -1
  31. data/lib/glimmer/swt/transform_proxy.rb +1 -1
  32. data/lib/glimmer/swt/widget_proxy.rb +1 -1
  33. data/lib/glimmer/ui/custom_shape.rb +281 -0
  34. data/samples/elaborate/meta_sample.rb +5 -5
  35. data/samples/elaborate/metronome.rb +177 -0
  36. data/samples/elaborate/tetris.rb +1 -15
  37. data/samples/elaborate/tetris/model/game.rb +3 -0
  38. data/samples/elaborate/tetris/view/bevel.rb +81 -0
  39. data/samples/elaborate/tetris/view/block.rb +5 -30
  40. data/samples/hello/hello_canvas.rb +3 -0
  41. data/samples/hello/hello_canvas_animation_data_binding.rb +66 -0
  42. data/samples/hello/hello_canvas_data_binding.rb +1 -1
  43. data/samples/hello/hello_custom_shape.rb +78 -0
  44. data/samples/hello/hello_shape.rb +71 -0
  45. data/samples/hello/hello_spinner.rb +7 -2
  46. data/sounds/metronome-down.wav +0 -0
  47. data/sounds/metronome-up.wav +0 -0
  48. metadata +13 -4
@@ -22,7 +22,7 @@
22
22
  require 'glimmer-dsl-swt'
23
23
 
24
24
  class HelloCanvasDataBinding
25
- include Glimmer::GUI::CustomWindow
25
+ include Glimmer::GUI::CustomWindow # alias for Glimmer::UI::CustomShell
26
26
 
27
27
  CANVAS_WIDTH = 300
28
28
  CANVAS_HEIGHT = 300
@@ -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 500 # minimum value (including digits after the decimal point)
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.6.3
4
+ version: 4.18.7.4
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-03 00:00:00.000000000 Z
11
+ date: 2021-03-10 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.1.2
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.1.2
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
@@ -476,6 +477,7 @@ files:
476
477
  - lib/glimmer/swt/widget_listener_proxy.rb
477
478
  - lib/glimmer/swt/widget_proxy.rb
478
479
  - lib/glimmer/ui.rb
480
+ - lib/glimmer/ui/custom_shape.rb
479
481
  - lib/glimmer/ui/custom_shell.rb
480
482
  - lib/glimmer/ui/custom_widget.rb
481
483
  - lib/glimmer/util/proc_tracker.rb
@@ -486,12 +488,14 @@ files:
486
488
  - samples/elaborate/login.rb
487
489
  - samples/elaborate/mandelbrot_fractal.rb
488
490
  - samples/elaborate/meta_sample.rb
491
+ - samples/elaborate/metronome.rb
489
492
  - samples/elaborate/stock_ticker.rb
490
493
  - samples/elaborate/tetris.rb
491
494
  - samples/elaborate/tetris/model/block.rb
492
495
  - samples/elaborate/tetris/model/game.rb
493
496
  - samples/elaborate/tetris/model/past_game.rb
494
497
  - samples/elaborate/tetris/model/tetromino.rb
498
+ - samples/elaborate/tetris/view/bevel.rb
495
499
  - samples/elaborate/tetris/view/block.rb
496
500
  - samples/elaborate/tetris/view/high_score_dialog.rb
497
501
  - samples/elaborate/tetris/view/playfield.rb
@@ -505,6 +509,7 @@ files:
505
509
  - samples/hello/hello_button.rb
506
510
  - samples/hello/hello_canvas.rb
507
511
  - samples/hello/hello_canvas_animation.rb
512
+ - samples/hello/hello_canvas_animation_data_binding.rb
508
513
  - samples/hello/hello_canvas_data_binding.rb
509
514
  - samples/hello/hello_canvas_path.rb
510
515
  - samples/hello/hello_canvas_transform.rb
@@ -516,6 +521,7 @@ files:
516
521
  - samples/hello/hello_computed.rb
517
522
  - samples/hello/hello_computed/contact.rb
518
523
  - samples/hello/hello_cursor.rb
524
+ - samples/hello/hello_custom_shape.rb
519
525
  - samples/hello/hello_custom_shell.rb
520
526
  - samples/hello/hello_custom_widget.rb
521
527
  - samples/hello/hello_date_time.rb
@@ -536,6 +542,7 @@ files:
536
542
  - samples/hello/hello_radio.rb
537
543
  - samples/hello/hello_radio_group.rb
538
544
  - samples/hello/hello_sash_form.rb
545
+ - samples/hello/hello_shape.rb
539
546
  - samples/hello/hello_spinner.rb
540
547
  - samples/hello/hello_styled_text.rb
541
548
  - samples/hello/hello_tab.rb
@@ -543,6 +550,8 @@ files:
543
550
  - samples/hello/hello_table/baseball_park.png
544
551
  - samples/hello/hello_tree.rb
545
552
  - samples/hello/hello_world.rb
553
+ - sounds/metronome-down.wav
554
+ - sounds/metronome-up.wav
546
555
  - vendor/swt/linux/swt.jar
547
556
  - vendor/swt/mac/swt.jar
548
557
  - vendor/swt/windows/swt.jar