glimmer-dsl-swt 4.18.4.11 → 4.18.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +7 -5
  4. data/VERSION +1 -1
  5. data/bin/glimmer +3 -3
  6. data/docs/reference/GLIMMER_CONFIGURATION.md +7 -3
  7. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +121 -5
  8. data/docs/reference/GLIMMER_SAMPLES.md +17 -4
  9. data/glimmer-dsl-swt.gemspec +19 -9
  10. data/lib/ext/glimmer/config.rb +3 -7
  11. data/lib/glimmer/data_binding/list_selection_binding.rb +13 -7
  12. data/lib/glimmer/data_binding/table_items_binding.rb +22 -17
  13. data/lib/glimmer/data_binding/tree_items_binding.rb +19 -15
  14. data/lib/glimmer/data_binding/widget_binding.rb +9 -27
  15. data/lib/glimmer/dsl/swt/auto_exec_expression.rb +36 -0
  16. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +9 -6
  17. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +16 -14
  18. data/lib/glimmer/dsl/swt/data_binding_expression.rb +1 -2
  19. data/lib/glimmer/dsl/swt/exec_expression.rb +1 -1
  20. data/lib/glimmer/dsl/swt/image_expression.rb +8 -1
  21. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +11 -8
  22. data/lib/glimmer/dsl/swt/pixel_expression.rb +1 -1
  23. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +8 -5
  24. data/lib/glimmer/dsl/swt/shape_expression.rb +1 -1
  25. data/lib/glimmer/dsl/swt/widget_expression.rb +4 -3
  26. data/lib/glimmer/launcher.rb +3 -0
  27. data/lib/glimmer/rake_task/scaffold.rb +3 -0
  28. data/lib/glimmer/swt/custom/code_text.rb +11 -11
  29. data/lib/glimmer/swt/custom/drawable.rb +4 -0
  30. data/lib/glimmer/swt/custom/shape.rb +129 -20
  31. data/lib/glimmer/swt/custom/shape/arc.rb +43 -0
  32. data/lib/glimmer/swt/custom/shape/focus.rb +43 -0
  33. data/lib/glimmer/swt/custom/shape/image.rb +86 -0
  34. data/lib/glimmer/swt/custom/shape/line.rb +58 -0
  35. data/lib/glimmer/swt/custom/shape/oval.rb +43 -0
  36. data/lib/glimmer/swt/custom/shape/point.rb +52 -0
  37. data/lib/glimmer/swt/custom/shape/polygon.rb +73 -0
  38. data/lib/glimmer/swt/custom/shape/polyline.rb +73 -0
  39. data/lib/glimmer/swt/custom/shape/rectangle.rb +87 -0
  40. data/lib/glimmer/swt/custom/shape/text.rb +73 -0
  41. data/lib/glimmer/swt/date_time_proxy.rb +9 -3
  42. data/lib/glimmer/swt/directory_dialog_proxy.rb +20 -18
  43. data/lib/glimmer/swt/display_proxy.rb +62 -2
  44. data/lib/glimmer/swt/expand_item_proxy.rb +18 -12
  45. data/lib/glimmer/swt/file_dialog_proxy.rb +20 -18
  46. data/lib/glimmer/swt/font_proxy.rb +1 -1
  47. data/lib/glimmer/swt/image_proxy.rb +1 -1
  48. data/lib/glimmer/swt/layout_data_proxy.rb +21 -15
  49. data/lib/glimmer/swt/layout_proxy.rb +19 -15
  50. data/lib/glimmer/swt/menu_proxy.rb +2 -2
  51. data/lib/glimmer/swt/message_box_proxy.rb +20 -7
  52. data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -2
  53. data/lib/glimmer/swt/shell_proxy.rb +94 -80
  54. data/lib/glimmer/swt/swt_proxy.rb +16 -0
  55. data/lib/glimmer/swt/tab_item_proxy.rb +5 -3
  56. data/lib/glimmer/swt/table_proxy.rb +32 -11
  57. data/lib/glimmer/swt/tree_proxy.rb +11 -16
  58. data/lib/glimmer/swt/widget_listener_proxy.rb +6 -2
  59. data/lib/glimmer/swt/widget_proxy.rb +200 -117
  60. data/lib/glimmer/ui.rb +5 -0
  61. data/lib/glimmer/ui/custom_shell.rb +11 -5
  62. data/lib/glimmer/ui/custom_widget.rb +4 -5
  63. data/samples/elaborate/contact_manager.rb +7 -7
  64. data/samples/elaborate/login.rb +25 -21
  65. data/samples/elaborate/mandelbrot_fractal.rb +3 -5
  66. data/samples/elaborate/tetris.rb +1 -0
  67. data/samples/elaborate/tic_tac_toe.rb +16 -14
  68. data/samples/elaborate/tic_tac_toe/board.rb +5 -5
  69. data/samples/elaborate/tic_tac_toe/cell.rb +5 -5
  70. data/samples/hello/hello_button.rb +7 -7
  71. data/samples/hello/hello_canvas.rb +43 -2
  72. data/samples/hello/hello_checkbox.rb +16 -14
  73. data/samples/hello/hello_checkbox_group.rb +11 -9
  74. data/samples/hello/hello_combo.rb +14 -12
  75. data/samples/hello/hello_computed.rb +7 -7
  76. data/samples/hello/hello_cursor.rb +2 -1
  77. data/samples/hello/hello_custom_shell.rb +17 -21
  78. data/samples/hello/hello_custom_widget.rb +4 -6
  79. data/samples/hello/hello_date_time.rb +14 -12
  80. data/samples/hello/hello_directory_dialog.rb +7 -7
  81. data/samples/hello/hello_expand_bar.rb +8 -8
  82. data/samples/hello/hello_file_dialog.rb +7 -7
  83. data/samples/hello/hello_group.rb +18 -16
  84. data/samples/hello/hello_list_multi_selection.rb +13 -11
  85. data/samples/hello/hello_list_single_selection.rb +13 -11
  86. data/samples/hello/hello_progress_bar.rb +3 -7
  87. data/samples/hello/hello_radio.rb +18 -16
  88. data/samples/hello/hello_radio_group.rb +14 -12
  89. data/samples/hello/hello_spinner.rb +7 -7
  90. data/samples/hello/hello_tab.rb +5 -5
  91. data/samples/hello/hello_table.rb +10 -5
  92. data/samples/hello/hello_tree.rb +485 -0
  93. metadata +17 -18
@@ -20,15 +20,15 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  class HelloFileDialog
23
- include Glimmer
23
+ include Glimmer::UI::CustomShell
24
24
 
25
25
  attr_accessor :selected_file
26
26
 
27
- def initialize
27
+ before_body {
28
28
  @selected_file = 'Please select a file.'
29
- end
29
+ }
30
30
 
31
- def launch
31
+ body {
32
32
  shell {
33
33
  minimum_size 400, 0
34
34
  grid_layout
@@ -53,8 +53,8 @@ class HelloFileDialog
53
53
  self.selected_file = file_dialog.open
54
54
  }
55
55
  }
56
- }.open
57
- end
56
+ }
57
+ }
58
58
  end
59
59
 
60
- HelloFileDialog.new.launch
60
+ HelloFileDialog.launch
@@ -24,10 +24,10 @@ class HelloGroup
24
24
  attr_accessor :male, :female, :child, :teen, :adult, :senior
25
25
 
26
26
  def initialize
27
- reset
27
+ reset!
28
28
  end
29
29
 
30
- def reset
30
+ def reset!
31
31
  self.male = nil
32
32
  self.female = nil
33
33
  self.child = nil
@@ -37,11 +37,13 @@ class HelloGroup
37
37
  end
38
38
  end
39
39
 
40
- include Glimmer
40
+ include Glimmer::UI::CustomShell
41
41
 
42
- def launch
43
- person = Person.new
44
-
42
+ before_body {
43
+ @person = Person.new
44
+ }
45
+
46
+ body {
45
47
  shell {
46
48
  text 'Hello, Group!'
47
49
  row_layout :vertical
@@ -54,12 +56,12 @@ class HelloGroup
54
56
 
55
57
  radio {
56
58
  text 'Male'
57
- selection bind(person, :male)
59
+ selection bind(@person, :male)
58
60
  }
59
61
 
60
62
  radio {
61
63
  text 'Female'
62
- selection bind(person, :female)
64
+ selection bind(@person, :female)
63
65
  }
64
66
  }
65
67
 
@@ -71,22 +73,22 @@ class HelloGroup
71
73
 
72
74
  radio {
73
75
  text 'Child'
74
- selection bind(person, :child)
76
+ selection bind(@person, :child)
75
77
  }
76
78
 
77
79
  radio {
78
80
  text 'Teen'
79
- selection bind(person, :teen)
81
+ selection bind(@person, :teen)
80
82
  }
81
83
 
82
84
  radio {
83
85
  text 'Adult'
84
- selection bind(person, :adult)
86
+ selection bind(@person, :adult)
85
87
  }
86
88
 
87
89
  radio {
88
90
  text 'Senior'
89
- selection bind(person, :senior)
91
+ selection bind(@person, :senior)
90
92
  }
91
93
  }
92
94
 
@@ -94,11 +96,11 @@ class HelloGroup
94
96
  text 'Reset'
95
97
 
96
98
  on_widget_selected do
97
- person.reset
99
+ @person.reset!
98
100
  end
99
101
  }
100
- }.open
101
- end
102
+ }
103
+ }
102
104
  end
103
105
 
104
- HelloGroup.new.launch
106
+ HelloGroup.launch
@@ -40,35 +40,37 @@ class HelloListMultiSelection
40
40
  'Saskatchewan',
41
41
  'Yukon'
42
42
  ]
43
- reset_provinces
43
+ reset_provinces!
44
44
  end
45
45
 
46
- def reset_provinces
46
+ def reset_provinces!
47
47
  self.provinces = ['Quebec', 'Manitoba', 'Alberta']
48
48
  end
49
49
  end
50
50
 
51
- include Glimmer
51
+ include Glimmer::UI::CustomShell
52
52
 
53
- def launch
54
- person = Person.new
55
-
53
+ before_body {
54
+ @person = Person.new
55
+ }
56
+
57
+ body {
56
58
  shell {
57
59
  grid_layout
58
60
 
59
61
  text 'Hello, List Multi Selection!'
60
62
 
61
63
  list(:multi) {
62
- selection bind(person, :provinces) # also binds to provinces_options by convention
64
+ selection bind(@person, :provinces) # also binds to provinces_options by convention
63
65
  }
64
66
 
65
67
  button {
66
68
  text 'Reset Selections To Default Values'
67
69
 
68
- on_widget_selected { person.reset_provinces }
70
+ on_widget_selected { @person.reset_provinces! }
69
71
  }
70
- }.open
71
- end
72
+ }
73
+ }
72
74
  end
73
75
 
74
- HelloListMultiSelection.new.launch
76
+ HelloListMultiSelection.launch
@@ -25,35 +25,37 @@ class HelloListSingleSelection
25
25
 
26
26
  def initialize
27
27
  self.country_options = ['', 'Canada', 'US', 'Mexico']
28
- reset_country
28
+ reset_country!
29
29
  end
30
30
 
31
- def reset_country
31
+ def reset_country!
32
32
  self.country = 'Canada'
33
33
  end
34
34
  end
35
35
 
36
- include Glimmer
36
+ include Glimmer::UI::CustomShell
37
37
 
38
- def launch
39
- person = Person.new
40
-
38
+ before_body {
39
+ @person = Person.new
40
+ }
41
+
42
+ body {
41
43
  shell {
42
44
  grid_layout
43
45
 
44
46
  text 'Hello, List Single Selection!'
45
47
 
46
48
  list {
47
- selection bind(person, :country) # also binds to country_options by convention
49
+ selection bind(@person, :country) # also binds to country_options by convention
48
50
  }
49
51
 
50
52
  button {
51
53
  text 'Reset Selection To Default Value'
52
54
 
53
- on_widget_selected { person.reset_country }
55
+ on_widget_selected { @person.reset_country! }
54
56
  }
55
- }.open
56
- end
57
+ }
58
+ }
57
59
  end
58
60
 
59
- HelloListSingleSelection.new.launch
61
+ HelloListSingleSelection.launch
@@ -20,7 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  class HelloProgressBar
23
- include Glimmer::UI::CustomWindow
23
+ include Glimmer::UI::CustomShell
24
24
 
25
25
  class ProgressModel
26
26
  attr_accessor :minimum, :maximum, :selection, :delay
@@ -110,13 +110,9 @@ class HelloProgressBar
110
110
  # (killing is not dangerous since it is only a thread about updating progress)
111
111
  @current_thread&.kill
112
112
  @current_thread = Thread.new {
113
- # GUI updates must happen in sync_exec calls.
114
- # Alternatively, add `sync_exec: true` to all the updated property `bind(...)` statements above
115
- sync_exec { @progress_model.selection = @progress_model.minimum }
113
+ @progress_model.selection = @progress_model.minimum
116
114
  (@progress_model.minimum..@progress_model.maximum).to_a.each do |n|
117
- sync_exec {
118
- @progress_model.selection = n
119
- }
115
+ @progress_model.selection = n
120
116
  sleep(@progress_model.delay)
121
117
  end
122
118
  }
@@ -24,10 +24,10 @@ class HelloRadio
24
24
  attr_accessor :male, :female, :child, :teen, :adult, :senior
25
25
 
26
26
  def initialize
27
- reset
27
+ reset!
28
28
  end
29
29
 
30
- def reset
30
+ def reset!
31
31
  self.male = nil
32
32
  self.female = nil
33
33
  self.child = nil
@@ -37,11 +37,13 @@ class HelloRadio
37
37
  end
38
38
  end
39
39
 
40
- include Glimmer
40
+ include Glimmer::UI::CustomShell
41
41
 
42
- def launch
43
- person = Person.new
44
-
42
+ before_body {
43
+ @person = Person.new
44
+ }
45
+
46
+ body {
45
47
  shell {
46
48
  text 'Hello, Radio!'
47
49
  row_layout :vertical
@@ -56,12 +58,12 @@ class HelloRadio
56
58
 
57
59
  radio {
58
60
  text 'Male'
59
- selection bind(person, :male)
61
+ selection bind(@person, :male)
60
62
  }
61
63
 
62
64
  radio {
63
65
  text 'Female'
64
- selection bind(person, :female)
66
+ selection bind(@person, :female)
65
67
  }
66
68
  }
67
69
 
@@ -75,22 +77,22 @@ class HelloRadio
75
77
 
76
78
  radio {
77
79
  text 'Child'
78
- selection bind(person, :child)
80
+ selection bind(@person, :child)
79
81
  }
80
82
 
81
83
  radio {
82
84
  text 'Teen'
83
- selection bind(person, :teen)
85
+ selection bind(@person, :teen)
84
86
  }
85
87
 
86
88
  radio {
87
89
  text 'Adult'
88
- selection bind(person, :adult)
90
+ selection bind(@person, :adult)
89
91
  }
90
92
 
91
93
  radio {
92
94
  text 'Senior'
93
- selection bind(person, :senior)
95
+ selection bind(@person, :senior)
94
96
  }
95
97
  }
96
98
 
@@ -98,11 +100,11 @@ class HelloRadio
98
100
  text 'Reset'
99
101
 
100
102
  on_widget_selected do
101
- person.reset
103
+ @person.reset!
102
104
  end
103
105
  }
104
- }.open
105
- end
106
+ }
107
+ }
106
108
  end
107
109
 
108
- HelloRadio.new.launch
110
+ HelloRadio.launch
@@ -27,7 +27,7 @@ class HelloRadioGroup
27
27
  attr_accessor :gender, :age_group
28
28
 
29
29
  def initialize
30
- reset
30
+ reset!
31
31
  end
32
32
 
33
33
  def gender_options
@@ -38,17 +38,19 @@ class HelloRadioGroup
38
38
  ['Child', 'Teen', 'Adult', 'Senior']
39
39
  end
40
40
 
41
- def reset
41
+ def reset!
42
42
  self.gender = nil
43
43
  self.age_group = 'Adult'
44
44
  end
45
45
  end
46
46
 
47
- include Glimmer
47
+ include Glimmer::UI::CustomShell
48
48
 
49
- def launch
50
- person = Person.new
51
-
49
+ before_body {
50
+ @person = Person.new
51
+ }
52
+
53
+ body {
52
54
  shell {
53
55
  text 'Hello, Radio Group!'
54
56
  row_layout :vertical
@@ -60,7 +62,7 @@ class HelloRadioGroup
60
62
 
61
63
  radio_group {
62
64
  row_layout :horizontal
63
- selection bind(person, :gender)
65
+ selection bind(@person, :gender)
64
66
  }
65
67
 
66
68
  label {
@@ -70,18 +72,18 @@ class HelloRadioGroup
70
72
 
71
73
  radio_group {
72
74
  row_layout :horizontal
73
- selection bind(person, :age_group)
75
+ selection bind(@person, :age_group)
74
76
  }
75
77
 
76
78
  button {
77
79
  text 'Reset'
78
80
 
79
81
  on_widget_selected do
80
- person.reset
82
+ @person.reset!
81
83
  end
82
84
  }
83
- }.open
84
- end
85
+ }
86
+ }
85
87
  end
86
88
 
87
- HelloRadioGroup.new.launch
89
+ HelloRadioGroup.launch
@@ -24,14 +24,14 @@ class HelloSpinner
24
24
  attr_accessor :donation
25
25
  end
26
26
 
27
- include Glimmer
27
+ include Glimmer::UI::CustomShell
28
28
 
29
- def initialize
29
+ before_body {
30
30
  @person = Person.new
31
31
  @person.donation = 500
32
- end
32
+ }
33
33
 
34
- def launch
34
+ body {
35
35
  shell {
36
36
  grid_layout
37
37
 
@@ -62,8 +62,8 @@ class HelloSpinner
62
62
  selection bind(@person, :donation) # selection must be set last if other properties are configured to ensure value is within bounds
63
63
  }
64
64
  }
65
- }.open
66
- end
65
+ }
66
+ }
67
67
  end
68
68
 
69
- HelloSpinner.new.launch
69
+ HelloSpinner.launch
@@ -20,9 +20,9 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  class HelloTab
23
- include Glimmer
23
+ include Glimmer::UI::CustomShell
24
24
 
25
- def launch
25
+ body {
26
26
  shell {
27
27
  text 'Hello, Tab!'
28
28
 
@@ -43,8 +43,8 @@ class HelloTab
43
43
  }
44
44
  }
45
45
  }
46
- }.open
47
- end
46
+ }
47
+ }
48
48
  end
49
49
 
50
- HelloTab.new.launch
50
+ HelloTab.launch