glimmer-dsl-libui 0.11.3 → 0.11.5

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: 9be2fa52f18acfaf245110441ec7c6d728cffd361f995b71f58a8e9e235c0846
4
- data.tar.gz: b6f3cd15b385edc1839ff0da45cd22677723f1b8a91d947ad773a23a317f88bf
3
+ metadata.gz: 4c7045c2016a37ef9423c6d3e8f2a8480b0b1590e98afc56a2587a4a7d304e30
4
+ data.tar.gz: 41699750c28cb881e8c9335280c01836044e89ef31964ec149e052155662ea3c
5
5
  SHA512:
6
- metadata.gz: 6f6ad39350772e169b0500fcb727567d884c5fab0f06945eb7e25a20c45322083d70f7b9ad8b636b7dfef12ede12afce87dce480e819567a414ad20dbf77904c
7
- data.tar.gz: 25eabc97ed6588b7ba74d97bd352bb80a41afbcecb2e4f8d7f26f101753b81062fcfc2503d61292997ee82f856d8a5bc0b3786fd227b8a6f248da36d40a82aac
6
+ metadata.gz: 076d9bc4874bd8328110afd687aa334da3408e9b7dd87937bb7e8eec84591b872bf09e977327de91c27f67e8d342bc4a70e764f87ad61d00fce30bd2cf4daa99
7
+ data.tar.gz: 640f1392dd961fb5387d04bddada7baef42120ae75d91a6ee362be928ce89966f52688887b996986fb46ed08c5b434d863f726cf56fff5b6ade52bf2a45f087c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.11.5
4
+
5
+ - Support table explicit data-binding with a model attribute that returns an Enumerator (instead of an Array)
6
+
7
+ ## 0.11.4
8
+
9
+ - Fix issue with Content Data-Binding not working
10
+ - Fix issue with not successfully processing layout properties (e.g. `stretchy`) when nested under custom controls/windows
11
+
3
12
  ## 0.11.3
4
13
 
5
14
  - Support nesting `on_mouse_*` listeners under `text`
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 LibUI 0.11.3
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 LibUI 0.11.5
2
2
  ## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
@@ -8,6 +8,8 @@
8
8
 
9
9
  (**[Fukuoka Ruby Award Competition 2022 Special Award Winner](https://andymaleh.blogspot.com/2022/02/glimmer-dsl-for-libui-wins-fukuoka-ruby.html)** [[Award Announcement]](http://www.digitalfukuoka.jp/topics/187?locale=ja))
10
10
 
11
+ (**[***RubyConf 2023 Workshop - How To Build Desktop Applications in Ruby***](https://github.com/AndyObtiva/how-to-build-desktop-applications-in-ruby)**)
12
+
11
13
  (**[***RubyConf 2022 Talk - Building Native GUI Apps in Ruby***](https://andymaleh.blogspot.com/2023/02/rubyconf-2022-talk-video-for-building.html)**)
12
14
 
13
15
  [**(Ruby Rogues Podcast Interview - Desktop Apps in Ruby ft. Andy)**](https://andymaleh.blogspot.com/2022/05/ruby-rogues-podcast-interview-desktop.html)
@@ -431,7 +433,7 @@ gem install glimmer-dsl-libui
431
433
  Or install via Bundler `Gemfile`:
432
434
 
433
435
  ```ruby
434
- gem 'glimmer-dsl-libui', '~> 0.11.3'
436
+ gem 'glimmer-dsl-libui', '~> 0.11.5'
435
437
  ```
436
438
 
437
439
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -463,7 +465,9 @@ Afterwards, to access the Glimmer GUI DSL:
463
465
 
464
466
  You may learn more about the different options above with basic examples in the following subsections: [Experimentation Usage](#experimentation-usage), [Prototyping Usage](#prototyping-usage), [Serious Usage](#serious-usage).
465
467
 
466
- If you are new to [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) (beginner), after going through the subsections below, check out the RubyConf 2022 talk ["Building Native GUI Apps in Ruby"](https://andymaleh.blogspot.com/2023/02/rubyconf-2022-talk-video-for-building.html), [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts), [Glimmer Command](#glimmer-command) (just the basics, how to run an app, and how to run examples to start), [Girb](#girb-glimmer-irb) and [Examples](#examples) to quickly learn through copy/paste. It is very important for beginners to go through all the [Examples](#examples) from the most basic to the most advanced while reading the README topics that relate to the examples. You may refer to the [API](#api) on once you have gotten your feet wet with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) and need more detailed reference information.
468
+ If you are new to [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) (beginner), after going through the subsections below, check out the RubyConf 2022 talk ["Building Native GUI Apps in Ruby"](https://andymaleh.blogspot.com/2023/02/rubyconf-2022-talk-video-for-building.html), [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts), [Glimmer Command](#glimmer-command) (just the basics, how to run an app, and how to run examples to start), [Girb](#girb-glimmer-irb) and [Examples](#examples) to quickly learn through copy/paste. It is very important for beginners to go through all the [Examples](#examples) from the most basic to the most advanced while reading the README topics that relate to the examples. Alternatively, beginners can learn from the RubyConf 2023 workshop ["How To Build Desktop Applications in Ruby"](https://github.com/AndyObtiva/how-to-build-desktop-applications-in-ruby), which includes 27 step-by-step exercises. You may refer to the [API](#api) once you have gotten your feet wet with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) and need a more detailed reference.
469
+
470
+ If you encounter any issues with the documentation, get stuck with code you do not understand, or notice some out-of-date information, you may contact the project maintainers on the [Glimmer Gitter Chat](https://app.gitter.im/#/room/#AndyObtiva_glimmer:gitter.im). Also, this could be your opportunity to be a good steward of Open-Source Software by contributing a documentation fix in a GitHub Pull Request or reporting a GitHub Issue at least.
467
471
 
468
472
  ### Experimentation Usage
469
473
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.3
1
+ 0.11.5
@@ -59,7 +59,9 @@ class DynamicForm
59
59
 
60
60
  button('Summarize') {
61
61
  on_clicked do
62
- summary = @user.customizable_attributes.map { |attribute| @user.send(attribute) }.join(', ')
62
+ user_attribute_values = @user.customizable_attributes.map { |attribute| @user.send(attribute) }
63
+ non_blank_user_attribute_values = user_attribute_values.map(&:to_s).reject(&:empty?)
64
+ summary = non_blank_user_attribute_values.join(', ')
63
65
  msg_box('Summary', summary)
64
66
  end
65
67
  }
Binary file
@@ -19,12 +19,12 @@
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
- require 'glimmer/dsl/static_expression'
22
+ require 'glimmer/dsl/expression'
23
23
 
24
24
  module Glimmer
25
25
  module DSL
26
26
  module Libui
27
- class ContentExpression < StaticExpression
27
+ class ContentExpression < Expression
28
28
  def can_interpret?(parent, keyword, *args, &block)
29
29
  keyword == 'content' &&
30
30
  block_given? &&
@@ -38,7 +38,8 @@ module Glimmer
38
38
  end
39
39
 
40
40
  def add_content(parent, keyword, *args, &block)
41
- options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
41
+ options = args.last.is_a?(Hash) ? args.last : {}
42
+ options[:post_add_content] = true if !options.include?(:post_add_content)
42
43
  super
43
44
  parent&.post_add_content if options[:post_add_content]
44
45
  end
@@ -44,7 +44,8 @@ module Glimmer
44
44
  end
45
45
 
46
46
  def add_content(custom_control, keyword, *args, &block)
47
- options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
47
+ options = args.last.is_a?(Hash) ? args.last : {}
48
+ options[:post_add_content] = true if !options.include?(:post_add_content)
48
49
  # TODO consider avoiding source_location
49
50
  if block.source_location == custom_control.content&.__getobj__&.source_location
50
51
  custom_control.content.call(custom_control) unless custom_control.content.called?
@@ -43,7 +43,8 @@ module Glimmer
43
43
  end
44
44
 
45
45
  def add_content(custom_shape, keyword, *args, &block)
46
- options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
46
+ options = args.last.is_a?(Hash) ? args.last : {}
47
+ options[:post_add_content] = true if !options.include?(:post_add_content)
47
48
  # TODO consider avoiding source_location
48
49
  if block.source_location == custom_shape.content&.__getobj__&.source_location
49
50
  custom_shape.content.call(custom_shape) unless custom_shape.content.called?
@@ -48,7 +48,8 @@ module Glimmer
48
48
  end
49
49
 
50
50
  def add_content(parent, keyword, *args, &block)
51
- options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
51
+ options = args.last.is_a?(Hash) ? args.last : {}
52
+ options[:post_add_content] = true if !options.include?(:post_add_content)
52
53
  super
53
54
  parent&.post_add_content if options[:post_add_content]
54
55
  end
@@ -28,7 +28,8 @@ module Glimmer
28
28
  module Libui
29
29
  class ShineDataBindingExpression < Expression
30
30
  def can_interpret?(parent, keyword, *args, &block)
31
- args.size == 0 and
31
+ keyword != 'content' and
32
+ args.size == 0 and
32
33
  block.nil? and
33
34
  parent.respond_to?(keyword, *args, &block)
34
35
  end
@@ -46,7 +46,8 @@ module Glimmer
46
46
  end
47
47
 
48
48
  def add_content(parent, keyword, *args, &block)
49
- options = args.last.is_a?(Hash) ? args.last : {post_add_content: true}
49
+ options = args.last.is_a?(Hash) ? args.last : {}
50
+ options[:post_add_content] = true if !options.include?(:post_add_content)
50
51
  parent&.post_add_content(block) if options[:post_add_content]
51
52
  end
52
53
  end
@@ -243,7 +243,11 @@ module Glimmer
243
243
  model_attribute_observer = model_attribute_observer_registration = nil
244
244
  model_attribute_observer = Glimmer::DataBinding::Observer.proc do
245
245
  new_value = model_binding.evaluate_property
246
- if model_binding.binding_options[:column_attributes] || (!new_value.nil? && (!new_value.is_a?(String) || !new_value.empty?) && (!new_value.is_a?(Array) || !new_value.first.is_a?(Array)))
246
+ if !new_value.is_a?(Enumerator) &&
247
+ (
248
+ model_binding.binding_options[:column_attributes] ||
249
+ (!new_value.nil? && (!new_value.is_a?(String) || !new_value.empty?) && (!new_value.is_a?(Array) || !new_value.first.is_a?(Array)))
250
+ )
247
251
  @model_attribute_array_observer_registration&.deregister
248
252
  @model_attribute_array_observer_registration = model_attribute_observer.observe(new_value, column_attributes, ignore_frozen: true, attribute_writer_type: [:attribute=, :set_attribute])
249
253
  model_attribute_observer.add_dependent(model_attribute_observer_registration => @model_attribute_array_observer_registration)
@@ -142,7 +142,10 @@ module Glimmer
142
142
  # Subclasses may override to perform post add_content work (normally must call super)
143
143
  def post_add_content
144
144
  unless @content_added
145
- @parent_proxy&.post_initialize_child(self)
145
+ if CustomControl.custom_controls_being_interpreted.last.nil? ||
146
+ CustomControl.custom_controls_being_interpreted.last.parent_proxy != @parent_proxy
147
+ @parent_proxy&.post_initialize_child(self)
148
+ end
146
149
  @content_added = true
147
150
  end
148
151
  end
@@ -52,16 +52,6 @@ module Glimmer
52
52
  result ||= can_handle_listener?(method_name)
53
53
  result ||= @body_root.respond_to?(method_name, *args, &block)
54
54
  end
55
-
56
- # Returns content block if used as an attribute reader (no args)
57
- # Otherwise, if a block is passed, it adds it as content to this custom control
58
- def content(&block)
59
- if block_given?
60
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
61
- else
62
- @content
63
- end
64
- end
65
55
  end
66
56
 
67
57
  super_module_included do |klass|
@@ -193,11 +183,16 @@ module Glimmer
193
183
  def after_body(&block)
194
184
  @after_body_block = block
195
185
  end
186
+
187
+ def custom_controls_being_interpreted
188
+ @custom_controls_being_interpreted ||= []
189
+ end
196
190
  end
197
191
 
198
192
  attr_reader :body_root, :libui, :parent, :parent_proxy, :args, :keyword, :content, :options
199
193
 
200
194
  def initialize(keyword, parent, args, options, &content)
195
+ CustomControl.custom_controls_being_interpreted << self
201
196
  @parent_proxy = @parent = parent
202
197
  options ||= {}
203
198
  @options = self.class.options.merge(options)
@@ -220,7 +215,8 @@ module Glimmer
220
215
  end
221
216
 
222
217
  def post_add_content
223
- # No Op by default
218
+ @parent_proxy&.post_initialize_child(@body_root)
219
+ Glimmer::LibUI::CustomControl.custom_controls_being_interpreted.pop
224
220
  end
225
221
 
226
222
  def observer_registrations
@@ -243,6 +239,21 @@ module Glimmer
243
239
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
244
240
  !method(method_name)&.source_location&.first&.include?('glimmer/libui/control_proxy.rb')
245
241
  end
242
+
243
+ # Returns content block if used as an attribute reader (no args)
244
+ # Otherwise, if a block is passed, it adds it as content to this custom control
245
+ def content(*args, &block)
246
+ if args.empty?
247
+ if block_given?
248
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
249
+ else
250
+ @content
251
+ end
252
+ else
253
+ # delegate to GUI DSL ContentExpression
254
+ super
255
+ end
256
+ end
246
257
 
247
258
  private
248
259
 
@@ -52,16 +52,6 @@ module Glimmer
52
52
  result ||= can_handle_listener?(method_name)
53
53
  result ||= @body_root.respond_to?(method_name, *args, &block)
54
54
  end
55
-
56
- # Returns content block if used as an attribute reader (no args)
57
- # Otherwise, if a block is passed, it adds it as content to this custom shape
58
- def content(&block)
59
- if block_given?
60
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
61
- else
62
- @content
63
- end
64
- end
65
55
  end
66
56
 
67
57
  super_module_included do |klass|
@@ -240,6 +230,21 @@ module Glimmer
240
230
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
241
231
  !method(method_name)&.source_location&.first&.include?('glimmer/libui/shape.rb')
242
232
  end
233
+
234
+ # Returns content block if used as an attribute reader (no args)
235
+ # Otherwise, if a block is passed, it adds it as content to this custom shape
236
+ def content(*args, &block)
237
+ if args.empty?
238
+ if block_given?
239
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
240
+ else
241
+ @content
242
+ end
243
+ else
244
+ # delegate to GUI DSL ContentExpression
245
+ super
246
+ end
247
+ end
243
248
 
244
249
  private
245
250
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-18 00:00:00.000000000 Z
11
+ date: 2023-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer