glimmer-dsl-swt 4.18.5.2 → 4.18.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +8 -10
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +93 -16
  6. data/docs/reference/GLIMMER_SAMPLES.md +32 -0
  7. data/glimmer-dsl-swt.gemspec +9 -3
  8. data/lib/glimmer/swt/custom/drawable.rb +8 -7
  9. data/lib/glimmer/swt/custom/shape.rb +416 -37
  10. data/lib/glimmer/swt/custom/shape/arc.rb +22 -4
  11. data/lib/glimmer/swt/custom/shape/cubic.rb +117 -0
  12. data/lib/glimmer/swt/custom/shape/image.rb +19 -6
  13. data/lib/glimmer/swt/custom/shape/line.rb +119 -1
  14. data/lib/glimmer/swt/custom/shape/oval.rb +3 -3
  15. data/lib/glimmer/swt/custom/shape/path.rb +211 -0
  16. data/lib/glimmer/swt/custom/shape/path_segment.rb +111 -0
  17. data/lib/glimmer/swt/custom/shape/point.rb +40 -4
  18. data/lib/glimmer/swt/custom/shape/polygon.rb +93 -3
  19. data/lib/glimmer/swt/custom/shape/polyline.rb +76 -4
  20. data/lib/glimmer/swt/custom/shape/quad.rb +113 -0
  21. data/lib/glimmer/swt/custom/shape/rectangle.rb +7 -2
  22. data/lib/glimmer/swt/custom/shape/text.rb +2 -4
  23. data/lib/glimmer/swt/dialog_proxy.rb +4 -0
  24. data/lib/glimmer/swt/proxy_properties.rb +1 -1
  25. data/lib/glimmer/swt/widget_proxy.rb +16 -0
  26. data/samples/elaborate/contact_manager.rb +2 -0
  27. data/samples/elaborate/login.rb +2 -0
  28. data/samples/elaborate/mandelbrot_fractal.rb +2 -1
  29. data/samples/elaborate/meta_sample.rb +1 -0
  30. data/samples/elaborate/stock_ticker.rb +229 -0
  31. data/samples/elaborate/tetris.rb +2 -1
  32. data/samples/elaborate/tic_tac_toe.rb +2 -0
  33. data/samples/elaborate/user_profile.rb +10 -8
  34. data/samples/hello/hello_browser.rb +2 -0
  35. data/samples/hello/hello_button.rb +2 -0
  36. data/samples/hello/hello_canvas.rb +40 -21
  37. data/samples/hello/hello_canvas_animation.rb +2 -0
  38. data/samples/hello/hello_canvas_path.rb +66 -0
  39. data/samples/hello/hello_canvas_transform.rb +2 -0
  40. data/samples/hello/hello_checkbox.rb +2 -0
  41. data/samples/hello/hello_checkbox_group.rb +2 -0
  42. data/samples/hello/hello_code_text.rb +2 -0
  43. data/samples/hello/hello_color_dialog.rb +2 -0
  44. data/samples/hello/hello_combo.rb +2 -0
  45. data/samples/hello/hello_computed.rb +2 -0
  46. data/samples/hello/hello_cursor.rb +2 -0
  47. data/samples/hello/hello_custom_shell.rb +1 -0
  48. data/samples/hello/hello_custom_widget.rb +2 -0
  49. data/samples/hello/hello_date_time.rb +2 -0
  50. data/samples/hello/hello_dialog.rb +2 -0
  51. data/samples/hello/hello_directory_dialog.rb +2 -0
  52. data/samples/hello/hello_drag_and_drop.rb +5 -3
  53. data/samples/hello/hello_expand_bar.rb +2 -0
  54. data/samples/hello/hello_file_dialog.rb +2 -0
  55. data/samples/hello/hello_font_dialog.rb +2 -0
  56. data/samples/hello/hello_group.rb +2 -0
  57. data/samples/hello/hello_link.rb +2 -0
  58. data/samples/hello/hello_list_multi_selection.rb +2 -0
  59. data/samples/hello/hello_list_single_selection.rb +2 -0
  60. data/samples/hello/hello_menu_bar.rb +2 -0
  61. data/samples/hello/hello_message_box.rb +2 -0
  62. data/samples/hello/hello_pop_up_context_menu.rb +2 -0
  63. data/samples/hello/hello_progress_bar.rb +2 -0
  64. data/samples/hello/hello_radio.rb +2 -0
  65. data/samples/hello/hello_radio_group.rb +2 -0
  66. data/samples/hello/hello_sash_form.rb +2 -0
  67. data/samples/hello/hello_spinner.rb +2 -0
  68. data/samples/hello/hello_styled_text.rb +19 -17
  69. data/samples/hello/hello_tab.rb +2 -0
  70. data/samples/hello/hello_table.rb +2 -0
  71. data/samples/hello/hello_world.rb +2 -0
  72. metadata +8 -2
@@ -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 {
@@ -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 HelloButton
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -19,13 +19,26 @@
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
 
25
27
  attr_accessor :selected_shape
28
+ attr_accessor :artist
26
29
 
27
30
  before_body {
28
31
  @image_object = image(File.expand_path('../../icons/scaffold_app.png', __dir__), width: 50)
32
+ @artist = ''
33
+ }
34
+
35
+ after_body {
36
+ Thread.new {
37
+ 'Picasso'.chars.each do |character|
38
+ sleep(1)
39
+ self.artist += character
40
+ end
41
+ }
29
42
  }
30
43
 
31
44
  body {
@@ -36,10 +49,36 @@ class HelloCanvas
36
49
  @canvas = canvas {
37
50
  background :yellow
38
51
  rectangle(0, 0, 220, 400) {
39
- background :red
52
+ background rgb(255, 0, 0)
40
53
  }
41
54
  rectangle(50, 20, 300, 150, 30, 50) {
42
55
  background :magenta
56
+ rectangle([:default, -70], :default, :default, [:default, 1]) {
57
+ foreground :cyan
58
+ text {
59
+ string bind(self, :artist)
60
+ x :default, 1 # add 1 pixel to default x (shape centered within parent horizontally)
61
+ y :default, 1 # add 1 pixel to default y (shape centered within parent vertically)
62
+ background :yellow
63
+ foreground :dark_magenta
64
+ font name: 'Courier', height: 30
65
+ }
66
+ }
67
+ rectangle(155, 30) { # width and height are assumed to be the default (calculated from children)
68
+ foreground :yellow
69
+ 3.times { |n|
70
+ line(45, 70 + n*10, 65 + n*10, 30 + n*10) {
71
+ foreground :yellow
72
+ }
73
+ }
74
+ 10.times {|n|
75
+ point(15 + n*5, 50 + n*5) {
76
+ foreground :yellow
77
+ }
78
+ }
79
+ polyline(45, 60, 55, 20, 65, 60, 85, 80, 45, 60)
80
+ image(@image_object, 0, 5)
81
+ }
43
82
  }
44
83
  rectangle(150, 200, 100, 70, true) {
45
84
  background :dark_magenta
@@ -49,14 +88,6 @@ class HelloCanvas
49
88
  background :magenta
50
89
  foreground :dark_blue
51
90
  }
52
- rectangle(205, 50, 88, 96) {
53
- foreground :yellow
54
- }
55
- text('Picasso', 60, 80) {
56
- background :yellow
57
- foreground :dark_magenta
58
- font name: 'Courier', height: 30
59
- }
60
91
  oval(110, 310, 100, 100) {
61
92
  # patterns provide a differnet way to make gradients
62
93
  background_pattern 0, 0, 105, 0, :yellow, rgb(128, 138, 248)
@@ -67,18 +98,6 @@ class HelloCanvas
67
98
  polygon(250, 210, 260, 170, 270, 210, 290, 230) {
68
99
  background :dark_yellow
69
100
  }
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
101
 
83
102
  menu {
84
103
  menu_item {
@@ -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 {
@@ -0,0 +1,66 @@
1
+ require 'glimmer-dsl-swt'
2
+
3
+ include Glimmer
4
+
5
+ shell {
6
+ text 'Hello, Canvas Path!'
7
+ minimum_size 800, 700
8
+ background :white
9
+
10
+ canvas {
11
+ background :white
12
+
13
+ text('line', 15, 200) {
14
+ foreground :red
15
+ }
16
+ @path1 = path {
17
+ antialias :on
18
+ foreground :red
19
+ }
20
+
21
+ text('quad', 15, 300) {
22
+ foreground :dark_green
23
+ }
24
+ @path2 = path {
25
+ antialias :on
26
+ foreground :dark_green
27
+ }
28
+
29
+ text('cubic', 15, 400) {
30
+ foreground :blue
31
+ }
32
+ @path3 = path {
33
+ antialias :on
34
+ foreground :blue
35
+ }
36
+ }
37
+
38
+ on_swt_show {
39
+ Thread.new {
40
+ y1 = y2 = y3 = 300
41
+ 800.times.each do |x|
42
+ x += 55
43
+ x1 = x - 2
44
+ x2 = x - 1
45
+ x3 = x
46
+ y1 = y3
47
+ y2 = y1
48
+ y3 = [[y3 + (rand*24 - 12), 0].max, 700].min
49
+ @path1.content {
50
+ line(x1, y1 - 100)
51
+ }
52
+ if x % 2 == 0
53
+ @path2.content {
54
+ quad(x1, y1, x2, y2)
55
+ }
56
+ end
57
+ if x % 3 == 0
58
+ @path3.content {
59
+ cubic(x1, y1 + 100, x2, y2 + 100, x3, y3 + 100)
60
+ }
61
+ end
62
+ sleep(0.01)
63
+ end
64
+ }
65
+ }
66
+ }.open
@@ -1,3 +1,5 @@
1
+ require 'glimmer-dsl-swt'
2
+
1
3
  include Glimmer
2
4
 
3
5
  glimmer_logo = File.expand_path('../../icons/scaffold_app.png', __dir__)
@@ -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 HelloCheckbox
23
25
  class Person
24
26
  attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
@@ -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
  # This sample demonstrates the use of a `checkbox_group` (aka `check_group`) in Glimmer, which provides terser syntax
23
25
  # than HelloCheckbox for representing multiple checkbox buttons (`button(:check)`) by relying on data-binding to
24
26
  # automatically spawn the `checkbox` widgets (`button(:check)`) based on available options on the model.
@@ -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 {
@@ -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 HelloColorDialog
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -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 HelloCombo
23
25
  class Person
24
26
  attr_accessor :country, :country_options
@@ -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 'hello_computed/contact'
23
25
 
24
26
  class HelloComputed
@@ -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 HelloCursor
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -19,6 +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
+ require 'glimmer-dsl-swt'
22
23
  require 'date'
23
24
 
24
25
  # This class declares an `email_shell` custom shell, aka custom window (by convention)
@@ -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
  # This class declares a `greeting_label` custom widget (by convention)
23
25
  class GreetingLabel
24
26
  include Glimmer::UI::CustomWidget
@@ -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 HelloDateTime
23
25
  class Person
24
26
  attr_accessor :date_of_birth
@@ -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 {
@@ -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 HelloDirectoryDialog
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -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
  class Location
23
25
  attr_accessor :country
24
26
 
@@ -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 HelloExpandBar
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -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 HelloFileDialog
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -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 HelloFontDialog
23
25
  include Glimmer::UI::CustomShell
24
26
 
@@ -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 HelloGroup
23
25
  class Person
24
26
  attr_accessor :male, :female, :child, :teen, :adult, :senior
@@ -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 { |main_shell|
@@ -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 HelloListMultiSelection
23
25
  class Person
24
26
  attr_accessor :provinces, :provinces_options
@@ -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 HelloListSingleSelection
23
25
  class Person
24
26
  attr_accessor :country, :country_options
@@ -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
  COLORS = [:white, :red, :yellow, :green, :blue, :magenta, :gray, :black]
@@ -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 {
@@ -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 {