glimmer-dsl-swt 4.17.4.1 → 4.17.8.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -3
  3. data/README.md +267 -107
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +24 -5
  6. data/lib/glimmer/data_binding/tree_items_binding.rb +20 -2
  7. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +61 -0
  8. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +2 -0
  9. data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -0
  10. data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +48 -0
  11. data/lib/glimmer/dsl/swt/dsl.rb +2 -0
  12. data/lib/glimmer/dsl/swt/expand_item_expression.rb +60 -0
  13. data/lib/glimmer/dsl/swt/file_dialog_expression.rb +48 -0
  14. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +61 -0
  15. data/lib/glimmer/dsl/swt/shell_expression.rb +4 -4
  16. data/lib/glimmer/dsl/swt/widget_expression.rb +9 -8
  17. data/lib/glimmer/swt/custom/checkbox_group.rb +160 -0
  18. data/lib/glimmer/swt/custom/code_text.rb +25 -18
  19. data/lib/glimmer/swt/custom/radio_group.rb +155 -0
  20. data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
  21. data/lib/glimmer/swt/expand_item_proxy.rb +97 -0
  22. data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
  23. data/lib/glimmer/swt/image_proxy.rb +5 -0
  24. data/lib/glimmer/swt/menu_proxy.rb +5 -5
  25. data/lib/glimmer/swt/sash_form_proxy.rb +1 -1
  26. data/lib/glimmer/swt/shell_proxy.rb +6 -6
  27. data/lib/glimmer/swt/styled_text_proxy.rb +43 -0
  28. data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
  29. data/lib/glimmer/swt/widget_proxy.rb +86 -82
  30. data/lib/glimmer/ui/custom_shell.rb +4 -4
  31. data/lib/glimmer/ui/custom_widget.rb +3 -0
  32. data/samples/elaborate/meta_sample.rb +36 -31
  33. data/samples/hello/hello_checkbox.rb +85 -0
  34. data/samples/hello/hello_checkbox_group.rb +68 -0
  35. data/samples/hello/hello_combo.rb +12 -12
  36. data/samples/hello/hello_directory_dialog.rb +60 -0
  37. data/samples/hello/hello_expand_bar.rb +110 -0
  38. data/samples/hello/hello_file_dialog.rb +60 -0
  39. data/samples/hello/hello_list_multi_selection.rb +23 -23
  40. data/samples/hello/hello_list_single_selection.rb +18 -17
  41. data/samples/hello/hello_radio.rb +108 -0
  42. data/samples/hello/hello_radio_group.rb +84 -0
  43. data/samples/hello/hello_styled_text.rb +138 -0
  44. data/samples/hello/hello_world.rb +4 -4
  45. metadata +23 -4
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2020 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
@@ -64,4 +64,4 @@ module Glimmer
64
64
  end
65
65
  end
66
66
  end
67
- end
67
+ end
@@ -213,6 +213,7 @@ module Glimmer
213
213
  def has_instance_method?(method_name)
214
214
  respond_to?(method_name) and
215
215
  !swt_widget&.respond_to?(method_name) and
216
+ (method(method_name) rescue nil) and
216
217
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
217
218
  !method(method_name)&.source_location&.first&.include?('glimmer/swt/widget_proxy.rb')
218
219
  end
@@ -255,6 +256,8 @@ module Glimmer
255
256
  end
256
257
 
257
258
  def method_missing(method, *args, &block)
259
+ # TODO Consider supporting a glimmer error silencing option for methods defined here
260
+ # but fail the glimmer DSL for the right reason to avoid seeing noise in the log output
258
261
  if can_handle_observation_request?(method)
259
262
  handle_observation_request(method, &block)
260
263
  else
@@ -20,7 +20,7 @@ class Sample
20
20
  end
21
21
 
22
22
  def content
23
- @content ||= File.read(file)
23
+ @content = File.read(file)
24
24
  end
25
25
 
26
26
  def launch
@@ -58,12 +58,12 @@ class SampleDirectory
58
58
 
59
59
  def all_samples
60
60
  @all_samples ||= sample_directories.map(&:samples).reduce(:+)
61
- end
61
+ end
62
62
  end
63
63
 
64
64
  include Glimmer # used for observe syntax
65
65
 
66
- attr_accessor :file
66
+ attr_accessor :file, :selected_sample_name
67
67
 
68
68
  def initialize(file)
69
69
  self.file = file
@@ -92,7 +92,20 @@ class SampleDirectory
92
92
  end
93
93
  end
94
94
  @samples
95
- end
95
+ end
96
+
97
+ def selected_sample_name_options
98
+ samples.map(&:name)
99
+ end
100
+
101
+ def selected_sample_name=(selected_name)
102
+ @selected_sample_name = selected_name
103
+ unless selected_name.nil?
104
+ (self.class.sample_directories - [self]).each { |sample_dir| sample_dir.selected_sample_name = nil }
105
+ self.class.selected_sample = samples.detect { |sample| sample.name == @selected_sample_name }
106
+ end
107
+ end
108
+
96
109
  end
97
110
 
98
111
  class MetaSampleApplication
@@ -100,6 +113,7 @@ class MetaSampleApplication
100
113
 
101
114
  def launch
102
115
  shell {
116
+ minimum_size 1280, 768
103
117
  text 'Glimmer Meta-Sample (The Sample of Samples)'
104
118
 
105
119
  on_swt_show {
@@ -109,42 +123,33 @@ class MetaSampleApplication
109
123
  sash_form {
110
124
  composite {
111
125
  grid_layout 1, false
112
-
113
- scrolled_composite {
114
- layout_data(:fill, :fill, true, true)
115
126
 
116
- composite {
117
- SampleDirectory.sample_directories.each { |sample_directory|
118
- group {
119
- layout_data(:fill, :fill, true, true)
120
- grid_layout 2, false
121
- text sample_directory.name
122
- font height: 30
123
-
124
- sample_directory.samples.each { |sample|
125
- label_radio = radio {
126
- selection bind(sample, :selected)
127
- }
128
- label {
129
- text sample.name
130
- font height: 30
131
-
132
- on_mouse_up {
133
- sample.selected = true
134
- }
135
- }
127
+ expand_bar {
128
+ layout_data(:fill, :fill, true, true)
129
+ font height: 30
130
+
131
+ SampleDirectory.sample_directories.each { |sample_directory|
132
+ expand_item {
133
+ layout_data(:fill, :fill, true, true)
134
+ text "#{sample_directory.name} Samples"
135
+
136
+ radio_group { |radio_group_proxy|
137
+ row_layout(:vertical) {
138
+ fill true
136
139
  }
140
+ selection bind(sample_directory, :selected_sample_name)
141
+ font height: 24
137
142
  }
138
143
  }
139
144
  }
140
145
  }
141
146
 
142
147
  button {
143
- layout_data(:center, :center, false, false) {
144
- height_hint 150
148
+ layout_data(:fill, :center, true, false) {
149
+ height_hint 120
145
150
  }
146
151
  text 'Launch Sample'
147
- font height: 45
152
+ font height: 30
148
153
  on_widget_selected {
149
154
  SampleDirectory.selected_sample.launch
150
155
  }
@@ -157,7 +162,7 @@ class MetaSampleApplication
157
162
  caret nil
158
163
  }
159
164
 
160
- weights 1, 2
165
+ weights 4, 9
161
166
  }
162
167
  }.open
163
168
  end
@@ -0,0 +1,85 @@
1
+ # Copyright (c) 2007-2020 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
+ class HelloCheckbox
23
+ class Person
24
+ attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
25
+
26
+ def initialize
27
+ reset_activities
28
+ end
29
+
30
+ def reset_activities
31
+ self.skiing = false
32
+ self.snowboarding = true
33
+ self.snowmobiling = false
34
+ self.snowshoeing = false
35
+ end
36
+ end
37
+
38
+ include Glimmer
39
+
40
+ def launch
41
+ person = Person.new
42
+
43
+ shell {
44
+ text 'Hello, Checkbox!'
45
+ row_layout :vertical
46
+
47
+ label {
48
+ text 'Check all snow activities you are interested in:'
49
+ font style: :bold
50
+ }
51
+
52
+ composite {
53
+ checkbox {
54
+ text 'Skiing'
55
+ selection bind(person, :skiing)
56
+ }
57
+
58
+ checkbox {
59
+ text 'Snowboarding'
60
+ selection bind(person, :snowboarding)
61
+ }
62
+
63
+ checkbox {
64
+ text 'Snowmobiling'
65
+ selection bind(person, :snowmobiling)
66
+ }
67
+
68
+ checkbox {
69
+ text 'Snowshoeing'
70
+ selection bind(person, :snowshoeing)
71
+ }
72
+ }
73
+
74
+ button {
75
+ text 'Reset Activities'
76
+
77
+ on_widget_selected do
78
+ person.reset_activities
79
+ end
80
+ }
81
+ }.open
82
+ end
83
+ end
84
+
85
+ HelloCheckbox.new.launch
@@ -0,0 +1,68 @@
1
+ # Copyright (c) 2007-2020 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
+ class HelloCheckboxGroup
23
+ class Person
24
+ attr_accessor :activities
25
+
26
+ def initialize
27
+ reset_activities
28
+ end
29
+
30
+ def activities_options
31
+ ['Skiing', 'Snowboarding', 'Snowmobiling', 'Snowshoeing']
32
+ end
33
+
34
+ def reset_activities
35
+ self.activities = ['Snowboarding']
36
+ end
37
+ end
38
+
39
+ include Glimmer
40
+
41
+ def launch
42
+ person = Person.new
43
+
44
+ shell {
45
+ text 'Hello, Checkbox Group!'
46
+ row_layout :vertical
47
+
48
+ label {
49
+ text 'Check all snow activities you are interested in:'
50
+ font style: :bold
51
+ }
52
+
53
+ checkbox_group {
54
+ selection bind(person, :activities)
55
+ }
56
+
57
+ button {
58
+ text 'Reset Activities'
59
+
60
+ on_widget_selected do
61
+ person.reset_activities
62
+ end
63
+ }
64
+ }.open
65
+ end
66
+ end
67
+
68
+ HelloCheckboxGroup.new.launch
@@ -19,20 +19,20 @@
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
- class Person
23
- attr_accessor :country, :country_options
24
-
25
- def initialize
26
- self.country_options = ['', 'Canada', 'US', 'Mexico']
27
- reset_country
28
- end
29
-
30
- def reset_country
31
- self.country = 'Canada'
22
+ class HelloCombo
23
+ class Person
24
+ attr_accessor :country, :country_options
25
+
26
+ def initialize
27
+ self.country_options = ['', 'Canada', 'US', 'Mexico']
28
+ reset_country
29
+ end
30
+
31
+ def reset_country
32
+ self.country = 'Canada'
33
+ end
32
34
  end
33
- end
34
35
 
35
- class HelloCombo
36
36
  include Glimmer
37
37
 
38
38
  def launch
@@ -0,0 +1,60 @@
1
+ # Copyright (c) 2007-2020 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
+ class HelloDirectoryDialog
23
+ include Glimmer
24
+
25
+ attr_accessor :selected_directory
26
+
27
+ def initialize
28
+ @selected_directory = 'Please select a directory.'
29
+ end
30
+
31
+ def launch
32
+ shell {
33
+ minimum_size 400, 0
34
+ grid_layout
35
+
36
+ text 'Hello, Directory Dialog!'
37
+
38
+ label {
39
+ text 'Selected Directory:'
40
+ font height: 14, style: :bold
41
+ }
42
+
43
+ label {
44
+ layout_data :fill, :center, true, false
45
+ text bind(self, :selected_directory)
46
+ font height: 14
47
+ }
48
+
49
+ button {
50
+ text "Browse..."
51
+
52
+ on_widget_selected {
53
+ self.selected_directory = directory_dialog.open
54
+ }
55
+ }
56
+ }.open
57
+ end
58
+ end
59
+
60
+ HelloDirectoryDialog.new.launch
@@ -0,0 +1,110 @@
1
+ # Copyright (c) 2007-2020 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
+ class HelloExpandBar
23
+ include Glimmer
24
+
25
+ def launch
26
+ shell {
27
+ grid_layout(1, false) {
28
+ margin_width 0
29
+ margin_height 0
30
+ }
31
+ minimum_size 320, 240
32
+ text 'Hello, Expand Bar!'
33
+
34
+ @status_label = label(:center) {
35
+ text ' '
36
+ layout_data :fill, :center, true, false
37
+ font height: 24
38
+ }
39
+
40
+ expand_bar {
41
+ layout_data :fill, :fill, true, true
42
+
43
+ expand_item {
44
+ text 'Productivity'
45
+
46
+ button {
47
+ text 'Word Processing'
48
+ }
49
+ button {
50
+ text 'Spreadsheets'
51
+ }
52
+ button {
53
+ text 'Presentations'
54
+ }
55
+ button {
56
+ text 'Database'
57
+ }
58
+ composite # just filler
59
+ }
60
+
61
+ expand_item {
62
+ text 'Tools'
63
+
64
+ button {
65
+ text 'Calculator'
66
+ }
67
+ button {
68
+ text 'Unit Converter'
69
+ }
70
+ button {
71
+ text 'Currency Converter'
72
+ }
73
+ button {
74
+ text 'Scientific Calculator'
75
+ }
76
+ composite # just filler
77
+ }
78
+
79
+ expand_item {
80
+ text 'Reading'
81
+
82
+ button {
83
+ text 'eBooks'
84
+ }
85
+ button {
86
+ text 'News'
87
+ }
88
+ button {
89
+ text 'Blogs'
90
+ }
91
+ button {
92
+ text 'Papers'
93
+ }
94
+ composite # just filler
95
+ }
96
+
97
+ on_item_expanded { |expand_event|
98
+ @status_label.text = "#{expand_event.item.text} Expanded!"
99
+ }
100
+
101
+ on_item_collapsed { |expand_event|
102
+ @status_label.text = "#{expand_event.item.text} Collapsed!"
103
+ }
104
+
105
+ }
106
+ }.open
107
+ end
108
+ end
109
+
110
+ HelloExpandBar.new.launch