glimmer-dsl-swt 4.17.5.0 → 4.17.8.2

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -2
  3. data/README.md +250 -83
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +20 -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/file_dialog_expression.rb +48 -0
  13. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +61 -0
  14. data/lib/glimmer/dsl/swt/shell_expression.rb +3 -3
  15. data/lib/glimmer/dsl/swt/widget_expression.rb +8 -8
  16. data/lib/glimmer/swt/custom/checkbox_group.rb +181 -0
  17. data/lib/glimmer/swt/custom/code_text.rb +39 -31
  18. data/lib/glimmer/swt/custom/radio_group.rb +176 -0
  19. data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
  20. data/lib/glimmer/swt/expand_item_proxy.rb +0 -1
  21. data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
  22. data/lib/glimmer/swt/menu_proxy.rb +4 -4
  23. data/lib/glimmer/swt/shell_proxy.rb +5 -5
  24. data/lib/glimmer/swt/tab_item_proxy.rb +3 -3
  25. data/lib/glimmer/swt/widget_proxy.rb +27 -27
  26. data/lib/glimmer/ui/custom_shell.rb +3 -3
  27. data/lib/glimmer/ui/custom_widget.rb +3 -0
  28. data/samples/elaborate/meta_sample.rb +24 -19
  29. data/samples/hello/hello_checkbox.rb +85 -0
  30. data/samples/hello/hello_checkbox_group.rb +68 -0
  31. data/samples/hello/hello_combo.rb +12 -12
  32. data/samples/hello/hello_directory_dialog.rb +60 -0
  33. data/samples/hello/hello_expand_bar.rb +3 -1
  34. data/samples/hello/hello_file_dialog.rb +60 -0
  35. data/samples/hello/hello_group.rb +104 -0
  36. data/samples/hello/hello_list_multi_selection.rb +23 -23
  37. data/samples/hello/hello_list_single_selection.rb +18 -17
  38. data/samples/hello/hello_radio.rb +108 -0
  39. data/samples/hello/hello_radio_group.rb +84 -0
  40. data/samples/hello/hello_world.rb +3 -3
  41. metadata +19 -4
@@ -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
@@ -114,26 +127,18 @@ class MetaSampleApplication
114
127
  expand_bar {
115
128
  layout_data(:fill, :fill, true, true)
116
129
  font height: 30
117
-
130
+
118
131
  SampleDirectory.sample_directories.each { |sample_directory|
119
132
  expand_item {
120
133
  layout_data(:fill, :fill, true, true)
121
- grid_layout 2, false
122
134
  text "#{sample_directory.name} Samples"
123
135
 
124
- sample_directory.samples.each { |sample|
125
- label_radio = radio {
126
- selection bind(sample, :selected)
127
- }
128
- label {
129
- layout_data :fill, :center, true, false
130
- text sample.name
131
- font height: 24
132
-
133
- on_mouse_up {
134
- sample.selected = true
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
  }
@@ -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
@@ -55,6 +55,7 @@ class HelloExpandBar
55
55
  button {
56
56
  text 'Database'
57
57
  }
58
+ composite # just filler
58
59
  }
59
60
 
60
61
  expand_item {
@@ -72,6 +73,7 @@ class HelloExpandBar
72
73
  button {
73
74
  text 'Scientific Calculator'
74
75
  }
76
+ composite # just filler
75
77
  }
76
78
 
77
79
  expand_item {
@@ -89,6 +91,7 @@ class HelloExpandBar
89
91
  button {
90
92
  text 'Papers'
91
93
  }
94
+ composite # just filler
92
95
  }
93
96
 
94
97
  on_item_expanded { |expand_event|
@@ -99,7 +102,6 @@ class HelloExpandBar
99
102
  @status_label.text = "#{expand_event.item.text} Collapsed!"
100
103
  }
101
104
 
102
-
103
105
  }
104
106
  }.open
105
107
  end
@@ -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 HelloFileDialog
23
+ include Glimmer
24
+
25
+ attr_accessor :selected_file
26
+
27
+ def initialize
28
+ @selected_file = 'Please select a file.'
29
+ end
30
+
31
+ def launch
32
+ shell {
33
+ minimum_size 400, 0
34
+ grid_layout
35
+
36
+ text 'Hello, File Dialog!'
37
+
38
+ label {
39
+ text 'Selected File:'
40
+ font height: 14, style: :bold
41
+ }
42
+
43
+ label {
44
+ layout_data :fill, :center, true, false
45
+ text bind(self, :selected_file)
46
+ font height: 14
47
+ }
48
+
49
+ button {
50
+ text "Browse..."
51
+
52
+ on_widget_selected {
53
+ self.selected_file = file_dialog.open
54
+ }
55
+ }
56
+ }.open
57
+ end
58
+ end
59
+
60
+ HelloFileDialog.new.launch
@@ -0,0 +1,104 @@
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 HelloGroup
23
+ class Person
24
+ attr_accessor :male, :female, :child, :teen, :adult, :senior
25
+
26
+ def initialize
27
+ reset
28
+ end
29
+
30
+ def reset
31
+ self.male = nil
32
+ self.female = nil
33
+ self.child = nil
34
+ self.teen = nil
35
+ self.adult = true
36
+ self.senior = nil
37
+ end
38
+ end
39
+
40
+ include Glimmer
41
+
42
+ def launch
43
+ person = Person.new
44
+
45
+ shell {
46
+ text 'Hello, Radio!'
47
+ row_layout :vertical
48
+
49
+ group {
50
+ row_layout
51
+
52
+ text 'Gender'
53
+ font style: :bold
54
+
55
+ radio {
56
+ text 'Male'
57
+ selection bind(person, :male)
58
+ }
59
+
60
+ radio {
61
+ text 'Female'
62
+ selection bind(person, :female)
63
+ }
64
+ }
65
+
66
+ group {
67
+ row_layout
68
+
69
+ text 'Age Group'
70
+ font style: :bold
71
+
72
+ radio {
73
+ text 'Child'
74
+ selection bind(person, :child)
75
+ }
76
+
77
+ radio {
78
+ text 'Teen'
79
+ selection bind(person, :teen)
80
+ }
81
+
82
+ radio {
83
+ text 'Adult'
84
+ selection bind(person, :adult)
85
+ }
86
+
87
+ radio {
88
+ text 'Senior'
89
+ selection bind(person, :senior)
90
+ }
91
+ }
92
+
93
+ button {
94
+ text 'Reset'
95
+
96
+ on_widget_selected do
97
+ person.reset
98
+ end
99
+ }
100
+ }.open
101
+ end
102
+ end
103
+
104
+ HelloGroup.new.launch