glimmer-dsl-opal 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a5328b8fd90117a9774e990256d5650ab8c15cd2745a29a466384261a1ead8a
4
- data.tar.gz: 2cfceae33c796f8aea84036dba490aa55ca94b5f7785c0c2f75dbc5e27535259
3
+ metadata.gz: d4c1b8623cfb624fda19e969ff546ad75a41d32331c9c5c3cabd267a74c96b62
4
+ data.tar.gz: 4b84ff762bbc5cecc3eefbf4e0dbd7f95501658523751e2a2936405974a662a6
5
5
  SHA512:
6
- metadata.gz: e574405ade34c331a168a3dd2814112269dff90a72d58678f06246d94246e2a1c7bfc7e56163df61c2805fc58764a5da48687273ce98ce5c10cf27cf52fb5d51
7
- data.tar.gz: 297d37971d6939413fa2dd2535169b486a7c5332395f34b5d2f2c0697f41fce67c61c613dba83575b88e5904ef128354f5846e9e7e96963aa065f93050f2476d
6
+ metadata.gz: da478774923d89f49c1fbc050f9234f24a728781dddc7f38a1790795efdf5f1d9228982859e6027fd4e90d3ad61d8254275df4882a9453c61f0bbfcf16c7e089
7
+ data.tar.gz: f8a46956d0caf08f7ab94bb183e02131acd808f4e17d084d961e15c79ea044c9dc16cb20a436e94ea63a26446cc6ce6b5467878634c04960a8464b38ee26666d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.13.0
4
+
5
+ - Support Shine data-binding syntax in custom widgets
6
+ - Update Hello, Checkbox!, Hello, Checkbox Group!, Hello, Radio! and Hello, Radio Group! to utilize Shine data-binding syntax from latest glimmer-dsl-swt
7
+
3
8
  ## 0.12.0
4
9
 
5
10
  - Support CustomShell.launch opening in the same window if no other shell is open or DisplayProxy.open_custom_shells_in_current_window = true is set
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal 0.12.0 (Pure Ruby Web GUI)
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal 0.13.0 (Pure Ruby Web GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
3
3
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
@@ -141,7 +141,7 @@ Hello, Table! Game Booked
141
141
 
142
142
  NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
143
143
 
144
- **Alpha Version** 0.12.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
144
+ **Alpha Version** 0.13.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
145
145
 
146
146
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
147
147
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -151,7 +151,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
151
151
 
152
152
  ## Table of Contents
153
153
 
154
- - [Glimmer DSL for Opal 0.12.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0110-pure-ruby-web-gui)
154
+ - [Glimmer DSL for Opal 0.13.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0130-pure-ruby-web-gui)
155
155
  - [Principles](#principles)
156
156
  - [Background](#background)
157
157
  - [Pre-requisites](#pre-requisites)
@@ -252,7 +252,7 @@ Add the following to `Gemfile`:
252
252
  gem 'opal-rails', '~> 1.1.2'
253
253
  gem 'opal-async', '~> 1.2.0'
254
254
  gem 'opal-jquery', '~> 0.4.4'
255
- gem 'glimmer-dsl-opal', '~> 0.12.0'
255
+ gem 'glimmer-dsl-opal', '~> 0.13.0'
256
256
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
257
257
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
258
258
 
@@ -1294,7 +1294,7 @@ class HelloRadioGroup
1294
1294
 
1295
1295
  radio_group {
1296
1296
  row_layout :horizontal
1297
- selection bind(person, :gender)
1297
+ selection <=> [person, :gender]
1298
1298
  }
1299
1299
 
1300
1300
  label {
@@ -1304,7 +1304,7 @@ class HelloRadioGroup
1304
1304
 
1305
1305
  radio_group {
1306
1306
  row_layout :horizontal
1307
- selection bind(person, :age_group)
1307
+ selection <=> [person, :age_group]
1308
1308
  }
1309
1309
 
1310
1310
  button {
@@ -1383,12 +1383,12 @@ class HelloGroup
1383
1383
 
1384
1384
  radio {
1385
1385
  text 'Male'
1386
- selection bind(person, :male)
1386
+ selection <=> [person, :male]
1387
1387
  }
1388
1388
 
1389
1389
  radio {
1390
1390
  text 'Female'
1391
- selection bind(person, :female)
1391
+ selection <=> [person, :female]
1392
1392
  }
1393
1393
  }
1394
1394
 
@@ -1585,7 +1585,7 @@ class HelloCheckboxGroup
1585
1585
  }
1586
1586
 
1587
1587
  checkbox_group {
1588
- selection bind(person, :activities)
1588
+ selection <=> [person, :activities]
1589
1589
  }
1590
1590
 
1591
1591
  button {
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.0
1
+ 0.13.0
@@ -84,7 +84,7 @@ if RUBY_ENGINE == 'opal'
84
84
  Element.alias_native :select
85
85
  Element.alias_native :dialog
86
86
 
87
- Glimmer::Config.loop_max_count = 300 # TODO disable
87
+ Glimmer::Config.loop_max_count = 250 # TODO disable
88
88
 
89
89
  original_logger_level = Glimmer::Config.logger.level
90
90
  Glimmer::Config.logger = Glimmer::Config::OpalLogger.new(STDOUT)
@@ -1,5 +1,3 @@
1
- require 'glimmer-dsl-swt'
2
-
3
1
  require_relative "contact_manager/contact_manager_presenter"
4
2
 
5
3
  class ContactManager
@@ -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 <=> [person, :skiing]
57
+ selection <=> [@person, :skiing]
56
58
  }
57
59
 
58
60
  checkbox {
59
61
  text 'Snowboarding'
60
- selection <=> [person, :snowboarding]
62
+ selection <=> [@person, :snowboarding]
61
63
  }
62
64
 
63
65
  checkbox {
64
66
  text 'Snowmobiling'
65
- selection <=> [person, :snowmobiling]
67
+ selection <=> [@person, :snowmobiling]
66
68
  }
67
69
 
68
70
  checkbox {
69
71
  text 'Snowshoeing'
70
- selection <=> [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
@@ -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!'
@@ -141,11 +141,15 @@ class HelloCustomShell
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
 
@@ -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 <=> [person, :male]
61
+ selection <=> [@person, :male]
60
62
  }
61
63
 
62
64
  radio {
63
65
  text 'Female'
64
- selection <=> [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 <=> [person, :child]
80
+ selection <=> [@person, :child]
79
81
  }
80
82
 
81
83
  radio {
82
84
  text 'Teen'
83
- selection <=> [person, :teen]
85
+ selection <=> [@person, :teen]
84
86
  }
85
87
 
86
88
  radio {
87
89
  text 'Adult'
88
- selection <=> [person, :adult]
90
+ selection <=> [@person, :adult]
89
91
  }
90
92
 
91
93
  radio {
92
94
  text 'Senior'
93
- selection <=> [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
@@ -19,12 +19,15 @@
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 `radio_group` in Glimmer, which provides terser syntax
23
+ # than HelloRadio for representing multiple radio buttons by relying on data-binding to
24
+ # automatically spawn the `radio` widgets based on available options on the model.
22
25
  class HelloRadioGroup
23
26
  class Person
24
27
  attr_accessor :gender, :age_group
25
28
 
26
29
  def initialize
27
- reset
30
+ reset!
28
31
  end
29
32
 
30
33
  def gender_options
@@ -35,17 +38,19 @@ class HelloRadioGroup
35
38
  ['Child', 'Teen', 'Adult', 'Senior']
36
39
  end
37
40
 
38
- def reset
41
+ def reset!
39
42
  self.gender = nil
40
43
  self.age_group = 'Adult'
41
44
  end
42
45
  end
43
46
 
44
- include Glimmer
47
+ include Glimmer::UI::CustomShell
45
48
 
46
- def launch
47
- person = Person.new
48
-
49
+ before_body {
50
+ @person = Person.new
51
+ }
52
+
53
+ body {
49
54
  shell {
50
55
  text 'Hello, Radio Group!'
51
56
  row_layout :vertical
@@ -57,7 +62,7 @@ class HelloRadioGroup
57
62
 
58
63
  radio_group {
59
64
  row_layout :horizontal
60
- selection bind(person, :gender)
65
+ selection <=> [@person, :gender]
61
66
  }
62
67
 
63
68
  label {
@@ -67,18 +72,18 @@ class HelloRadioGroup
67
72
 
68
73
  radio_group {
69
74
  row_layout :horizontal
70
- selection bind(person, :age_group)
75
+ selection <=> [@person, :age_group]
71
76
  }
72
77
 
73
78
  button {
74
79
  text 'Reset'
75
80
 
76
81
  on_widget_selected do
77
- person.reset
82
+ @person.reset!
78
83
  end
79
84
  }
80
- }.open
81
- end
85
+ }
86
+ }
82
87
  end
83
88
 
84
- HelloRadioGroup.new.launch
89
+ HelloRadioGroup.launch
@@ -196,7 +196,7 @@ class HelloTable
196
196
 
197
197
  combo(:read_only) {
198
198
  layout_data :center, :center, true, false
199
- selection bind(BaseballGame, :playoff_type)
199
+ selection <=> [BaseballGame, :playoff_type]
200
200
  font height: 16
201
201
  }
202
202
 
@@ -263,7 +263,7 @@ class HelloTable
263
263
  text 'Book Selected Game'
264
264
  layout_data :center, :center, true, false
265
265
  font height: 16
266
- enabled bind(BaseballGame, :selected_game)
266
+ enabled <=> [BaseballGame, :selected_game]
267
267
 
268
268
  on_widget_selected {
269
269
  book_selected_game
@@ -87,8 +87,8 @@ module Glimmer
87
87
 
88
88
  def add_content(parent, keyword, *args, &block)
89
89
  return unless parent.is_a?(Glimmer::UI::CustomWidget)
90
- # TODO consider avoiding source_location
91
- if block.source_location == parent.content&.__getobj__.source_location
90
+ # TODO consider avoiding source_location since it does not work in Opal
91
+ if block.source_location && (block.source_location == parent.content&.__getobj__&.source_location)
92
92
  parent.content.call(parent) unless parent.content.called?
93
93
  else
94
94
  super
@@ -83,6 +83,16 @@ module Glimmer
83
83
  @after_body_blocks ||= []
84
84
  @after_body_blocks << block
85
85
  end
86
+
87
+ def keyword
88
+ self.name.underscore.gsub('::', '__')
89
+ end
90
+
91
+ # Returns shortcut keyword to use for this custom widget (keyword minus namespace)
92
+ def shortcut_keyword
93
+ self.name.underscore.gsub('::', '__').split('__').last
94
+ end
95
+
86
96
  end
87
97
 
88
98
  class << self
@@ -143,7 +153,6 @@ module Glimmer
143
153
  def reset_custom_widget_namespaces
144
154
  @custom_widget_namespaces = Set[Object, Glimmer::UI]
145
155
  end
146
-
147
156
  end
148
157
  # <- end of class methods
149
158
 
@@ -259,7 +268,7 @@ module Glimmer
259
268
  # Otherwise, if a block is passed, it adds it as content to this custom widget
260
269
  def content(&block)
261
270
  if block_given?
262
- body_root.content(&block)
271
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::CustomWidgetExpression.new, self.class.keyword, &block)
263
272
  else
264
273
  @content
265
274
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2021-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer