glimmer-dsl-opal 0.10.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +34 -27
  4. data/VERSION +1 -1
  5. data/lib/display.rb +3 -0
  6. data/lib/glimmer-dsl-opal.rb +1 -1
  7. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +1 -1
  8. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +15 -13
  9. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +55 -28
  10. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +2 -2
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +16 -14
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +14 -9
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +5 -5
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +16 -12
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +4 -4
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +6 -6
  20. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +18 -16
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +17 -12
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +4 -4
  25. data/lib/glimmer/data_binding/table_items_binding.rb +3 -2
  26. data/lib/glimmer/dsl/opal/bind_expression.rb +24 -25
  27. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +8 -8
  28. data/lib/glimmer/dsl/opal/dsl.rb +4 -0
  29. data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
  30. data/lib/glimmer/dsl/opal/property_expression.rb +2 -1
  31. data/lib/glimmer/dsl/opal/shape_expression.rb +26 -0
  32. data/lib/glimmer/dsl/opal/shell_expression.rb +1 -1
  33. data/lib/glimmer/dsl/opal/shine_data_binding_expression.rb +49 -0
  34. data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
  35. data/lib/glimmer/dsl/opal/widget_expression.rb +1 -1
  36. data/lib/glimmer/swt/combo_proxy.rb +1 -0
  37. data/lib/glimmer/swt/composite_proxy.rb +2 -0
  38. data/lib/glimmer/swt/dialog_proxy.rb +2 -5
  39. data/lib/glimmer/swt/display_proxy.rb +104 -10
  40. data/lib/glimmer/swt/grid_layout_proxy.rb +17 -17
  41. data/lib/glimmer/swt/layout_proxy.rb +23 -3
  42. data/lib/glimmer/swt/message_box_proxy.rb +4 -4
  43. data/lib/glimmer/swt/row_layout_proxy.rb +12 -3
  44. data/lib/glimmer/swt/table_proxy.rb +19 -3
  45. data/lib/glimmer/swt/widget_proxy.rb +3 -4
  46. data/lib/glimmer/ui/custom_shell.rb +22 -5
  47. data/lib/glimmer/ui/custom_widget.rb +11 -2
  48. data/lib/glimmer/util/proc_tracker.rb +5 -3
  49. metadata +11 -9
@@ -35,8 +35,8 @@ class TicTacToe
35
35
  (1..3).each { |column|
36
36
  button {
37
37
  layout_data :fill, :fill, true, true
38
- text bind(@tic_tac_toe_board[row, column], :sign)
39
- enabled bind(@tic_tac_toe_board[row, column], :empty)
38
+ text <= [@tic_tac_toe_board[row, column], :sign]
39
+ enabled <= [@tic_tac_toe_board[row, column], :empty]
40
40
  font style: :bold, height: 20
41
41
  on_widget_selected {
42
42
  @tic_tac_toe_board.mark(row, column)
@@ -33,7 +33,7 @@ class HelloButton
33
33
  text 'Hello, Button!'
34
34
 
35
35
  button {
36
- text bind(self, :count) {|value| "Click To Increment: #{value} "}
36
+ text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
37
37
 
38
38
  on_widget_selected {
39
39
  self.count += 1
@@ -24,10 +24,10 @@ class HelloCheckbox
24
24
  attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
25
25
 
26
26
  def initialize
27
- reset_activities
27
+ reset_activities!
28
28
  end
29
29
 
30
- def reset_activities
30
+ def reset_activities!
31
31
  self.skiing = false
32
32
  self.snowboarding = true
33
33
  self.snowmobiling = false
@@ -35,11 +35,13 @@ class HelloCheckbox
35
35
  end
36
36
  end
37
37
 
38
- include Glimmer
38
+ include Glimmer::UI::CustomShell
39
39
 
40
- def launch
41
- person = Person.new
42
-
40
+ before_body {
41
+ @person = Person.new
42
+ }
43
+
44
+ body {
43
45
  shell {
44
46
  text 'Hello, Checkbox!'
45
47
  row_layout :vertical
@@ -52,22 +54,22 @@ class HelloCheckbox
52
54
  composite {
53
55
  checkbox {
54
56
  text 'Skiing'
55
- selection bind(person, :skiing)
57
+ selection <=> [@person, :skiing]
56
58
  }
57
59
 
58
60
  checkbox {
59
61
  text 'Snowboarding'
60
- selection bind(person, :snowboarding)
62
+ selection <=> [@person, :snowboarding]
61
63
  }
62
64
 
63
65
  checkbox {
64
66
  text 'Snowmobiling'
65
- selection bind(person, :snowmobiling)
67
+ selection <=> [@person, :snowmobiling]
66
68
  }
67
69
 
68
70
  checkbox {
69
71
  text 'Snowshoeing'
70
- selection bind(person, :snowshoeing)
72
+ selection <=> [@person, :snowshoeing]
71
73
  }
72
74
  }
73
75
 
@@ -75,11 +77,11 @@ class HelloCheckbox
75
77
  text 'Reset Activities'
76
78
 
77
79
  on_widget_selected do
78
- person.reset_activities
80
+ @person.reset_activities!
79
81
  end
80
82
  }
81
- }.open
82
- end
83
+ }
84
+ }
83
85
  end
84
86
 
85
- HelloCheckbox.new.launch
87
+ HelloCheckbox.launch
@@ -19,6 +19,9 @@
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
+ # This sample demonstrates the use of a `checkbox_group` (aka `check_group`) in Glimmer, which provides terser syntax
23
+ # than HelloCheckbox for representing multiple checkbox buttons (`button(:check)`) by relying on data-binding to
24
+ # automatically spawn the `checkbox` widgets (`button(:check)`) based on available options on the model.
22
25
  class HelloCheckboxGroup
23
26
  class Person
24
27
  attr_accessor :activities
@@ -36,11 +39,13 @@ class HelloCheckboxGroup
36
39
  end
37
40
  end
38
41
 
39
- include Glimmer
42
+ include Glimmer::UI::CustomShell
40
43
 
41
- def launch
42
- person = Person.new
43
-
44
+ before_body {
45
+ @person = Person.new
46
+ }
47
+
48
+ body {
44
49
  shell {
45
50
  text 'Hello, Checkbox Group!'
46
51
  row_layout :vertical
@@ -51,18 +56,18 @@ class HelloCheckboxGroup
51
56
  }
52
57
 
53
58
  checkbox_group {
54
- selection bind(person, :activities)
59
+ selection <=> [@person, :activities]
55
60
  }
56
61
 
57
62
  button {
58
63
  text 'Reset Activities'
59
64
 
60
65
  on_widget_selected do
61
- person.reset_activities
66
+ @person.reset_activities
62
67
  end
63
68
  }
64
- }.open
65
- end
69
+ }
70
+ }
66
71
  end
67
72
 
68
- HelloCheckboxGroup.new.launch
73
+ HelloCheckboxGroup.launch
@@ -46,7 +46,7 @@ class HelloCombo
46
46
  text 'Hello, Combo!'
47
47
 
48
48
  combo(:read_only) {
49
- selection bind(person, :country)
49
+ selection <=> [person, :country]
50
50
  }
51
51
 
52
52
  button {
@@ -46,7 +46,7 @@ class HelloComputed
46
46
 
47
47
  label {text 'First &Name: '}
48
48
  text {
49
- text bind(@contact, :first_name)
49
+ text <=> [@contact, :first_name]
50
50
  layout_data {
51
51
  horizontal_alignment :fill
52
52
  grab_excess_horizontal_space true
@@ -55,7 +55,7 @@ class HelloComputed
55
55
 
56
56
  label {text '&Last Name: '}
57
57
  text {
58
- text bind(@contact, :last_name)
58
+ text <=> [@contact, :last_name]
59
59
  layout_data {
60
60
  horizontal_alignment :fill
61
61
  grab_excess_horizontal_space true
@@ -64,7 +64,7 @@ class HelloComputed
64
64
 
65
65
  label {text '&Year of Birth: '}
66
66
  text {
67
- text bind(@contact, :year_of_birth)
67
+ text <=> [@contact, :year_of_birth]
68
68
  layout_data {
69
69
  horizontal_alignment :fill
70
70
  grab_excess_horizontal_space true
@@ -73,7 +73,7 @@ class HelloComputed
73
73
 
74
74
  label {text 'Name: '}
75
75
  label {
76
- text bind(@contact, :name, computed_by: [:first_name, :last_name])
76
+ text <= [@contact, :name, computed_by: [:first_name, :last_name]]
77
77
  layout_data {
78
78
  horizontal_alignment :fill
79
79
  grab_excess_horizontal_space true
@@ -82,7 +82,7 @@ class HelloComputed
82
82
 
83
83
  label {text 'Age: '}
84
84
  label {
85
- text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
85
+ text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
86
86
  layout_data {
87
87
  horizontal_alignment :fill
88
88
  grab_excess_horizontal_space true
@@ -24,10 +24,11 @@ require 'date'
24
24
  # This class declares an `email_shell` custom shell, aka custom window (by convention)
25
25
  # Used to view an email message
26
26
  class EmailShell
27
+ # including Glimmer::UI::CustomShell enables declaring as an `email_shell` custom widget Glimmer GUI DSL keyword
27
28
  include Glimmer::UI::CustomShell
28
29
 
29
30
  # multiple options without default values
30
- options :date, :subject, :from, :message
31
+ options :parent_shell, :date, :subject, :from, :message
31
32
 
32
33
  # single option with default value
33
34
  option :to, default: '"John Irwin" <john.irwin@example.com>'
@@ -38,7 +39,7 @@ class EmailShell
38
39
 
39
40
  body {
40
41
  # pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
41
- shell(swt_style) {
42
+ shell(parent_shell, swt_style) {
42
43
  grid_layout(2, false)
43
44
 
44
45
  text subject
@@ -73,7 +74,7 @@ class EmailShell
73
74
 
74
75
  label {
75
76
  layout_data(:fill, :fill, true, true) {
76
- horizontal_span 2 #TODO implement
77
+ horizontal_span 2
77
78
  vertical_indent 10
78
79
  }
79
80
 
@@ -86,9 +87,8 @@ class EmailShell
86
87
  end
87
88
 
88
89
  class HelloCustomShell
89
- # including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `email_shell` custom widget
90
90
  include Glimmer
91
-
91
+
92
92
  Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
93
93
  EmailSystem = Struct.new(:emails, keyword_init: true)
94
94
 
@@ -106,7 +106,7 @@ class HelloCustomShell
106
106
  end
107
107
 
108
108
  def launch
109
- shell {
109
+ shell { |shell_proxy|
110
110
  grid_layout
111
111
 
112
112
  text 'Hello, Custom Shell!'
@@ -137,15 +137,19 @@ class HelloCustomShell
137
137
  width 360
138
138
  }
139
139
 
140
- items bind(@email_system, :emails), column_properties(:date, :subject, :from)
140
+ items <=> [@email_system, :emails, column_attributes: [:date, :subject, :from]]
141
141
 
142
142
  on_mouse_up { |event|
143
143
  email = event.table_item.get_data
144
- Thread.new do
145
- async_exec {
146
- email_shell(date: email.date, subject: email.subject, from: email.from, message: email.message).open
147
- }
148
- end
144
+
145
+ # open a custom email shell
146
+ email_shell(
147
+ parent_shell: shell_proxy,
148
+ date: email.date,
149
+ subject: email.subject,
150
+ from: email.from,
151
+ message: email.message
152
+ ).open
149
153
  }
150
154
  }
151
155
  }.open
@@ -55,7 +55,7 @@ class GreetingLabel
55
55
  label(swt_style) {
56
56
  text "#{greeting}, #{name}!"
57
57
  font @font
58
- foreground bind(self, :color)
58
+ foreground <= [self, :color]
59
59
  }
60
60
  }
61
61
 
@@ -42,19 +42,19 @@ class HelloDateTime
42
42
  }
43
43
 
44
44
  date { # alias for date_time(:date)
45
- date_time bind(person, :date_of_birth)
45
+ date_time <=> [person, :date_of_birth]
46
46
  }
47
47
 
48
48
  date_drop_down { # alias for date_time(:date, :drop_down)
49
- date_time bind(person, :date_of_birth)
49
+ date_time <=> [person, :date_of_birth]
50
50
  }
51
51
 
52
52
  time { # alias for date_time(:time)
53
- date_time bind(person, :date_of_birth)
53
+ date_time <=> [person, :date_of_birth]
54
54
  }
55
55
 
56
56
  calendar { # alias for date_time(:calendar)
57
- date_time bind(person, :date_of_birth)
57
+ date_time <=> [person, :date_of_birth]
58
58
  }
59
59
  }.open
60
60
  end
@@ -54,12 +54,12 @@ class HelloGroup
54
54
 
55
55
  radio {
56
56
  text 'Male'
57
- selection bind(person, :male)
57
+ selection <=> [person, :male]
58
58
  }
59
59
 
60
60
  radio {
61
61
  text 'Female'
62
- selection bind(person, :female)
62
+ selection <=> [person, :female]
63
63
  }
64
64
  }
65
65
 
@@ -71,22 +71,22 @@ class HelloGroup
71
71
 
72
72
  radio {
73
73
  text 'Child'
74
- selection bind(person, :child)
74
+ selection <=> [person, :child]
75
75
  }
76
76
 
77
77
  radio {
78
78
  text 'Teen'
79
- selection bind(person, :teen)
79
+ selection <=> [person, :teen]
80
80
  }
81
81
 
82
82
  radio {
83
83
  text 'Adult'
84
- selection bind(person, :adult)
84
+ selection <=> [person, :adult]
85
85
  }
86
86
 
87
87
  radio {
88
88
  text 'Senior'
89
- selection bind(person, :senior)
89
+ selection <=> [person, :senior]
90
90
  }
91
91
  }
92
92
 
@@ -59,7 +59,7 @@ class HelloListMultiSelection
59
59
  text 'Hello, List Multi Selection!'
60
60
 
61
61
  list(:multi) {
62
- selection bind(person, :provinces)
62
+ selection <=> [person, :provinces]
63
63
  }
64
64
 
65
65
  button {
@@ -44,7 +44,7 @@ class HelloListSingleSelection
44
44
  text 'Hello, List Single Selection!'
45
45
 
46
46
  list {
47
- selection bind(person, :country)
47
+ selection <=> [person, :country]
48
48
  }
49
49
 
50
50
  button {
@@ -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 <=> [@person, :male]
60
62
  }
61
63
 
62
64
  radio {
63
65
  text 'Female'
64
- selection bind(person, :female)
66
+ selection <=> [@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 <=> [@person, :child]
79
81
  }
80
82
 
81
83
  radio {
82
84
  text 'Teen'
83
- selection bind(person, :teen)
85
+ selection <=> [@person, :teen]
84
86
  }
85
87
 
86
88
  radio {
87
89
  text 'Adult'
88
- selection bind(person, :adult)
90
+ selection <=> [@person, :adult]
89
91
  }
90
92
 
91
93
  radio {
92
94
  text 'Senior'
93
- selection bind(person, :senior)
95
+ selection <=> [@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