glimmer-dsl-libui 0.11.0 → 0.11.2

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: effb65102f9db3aa2977bac55edd4f67f91f1eafdae26403b8c044c714048a03
4
- data.tar.gz: 3923d80a19afd62a0220026f33720ee953ad166880e17d60883aed53f9977d86
3
+ metadata.gz: 664a95631db2e2b9bf943f9843c6954df9dc55ba335e51214d721b376969094c
4
+ data.tar.gz: 61bc5b8242902e1273296c74dd74b470930a38cf9c34af48e296e14a91dce2e2
5
5
  SHA512:
6
- metadata.gz: 6e123f42fd61ce49b126e7f51caf738e0c769eca12b177c879007cedaba6ec38974d16ca864e8d8922546f79cfe2dc8946056935684f0bab9d88892e425c5d79
7
- data.tar.gz: 8d0d79d7632e30568f747a3db5d9bbdef387e854f55e0cf6559a4d8d242075bc8c1836e00e2554a30eb5eded934bb23c267a764b127cfe768c39e679ff47671e
6
+ metadata.gz: 7045e3c06a6551286523e8f6564b6b57e86477d4c1693ba8b0852c4e259a69151caa0d945d05187cb9b1d0642274323dc6c5d7dcfe02e8481cc01f227a99e993
7
+ data.tar.gz: 5927641112ab6807a6f8f941f1e89d1927f85242bdadf79dd1ed9aa8d52f2707cf9607a702ed730a7f76f9594557fadb9f26415b4e87f6ee03b263740f013205
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.11.2
4
+
5
+ - Fix issue with getting error when nesting property content under custom controls/shapes/windows (fixes `examples/basic_custom_shape.rb`)
6
+
7
+ ## 0.11.1
8
+
9
+ - Refactor `examples/dynamic_form.rb`
10
+ - Freeze LibUI version at 0.1.2.pre because 0.1.3.pre has issues like preventing the ability to close window with CMD+Q shortcut by default on Mac
11
+
3
12
  ## 0.11.0
4
13
 
5
14
  - Control `content` data-binding to generate nested controls dynamically based on a model attribute change
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.0
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.2
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)
@@ -431,7 +431,7 @@ gem install glimmer-dsl-libui
431
431
  Or install via Bundler `Gemfile`:
432
432
 
433
433
  ```ruby
434
- gem 'glimmer-dsl-libui', '~> 0.11.0'
434
+ gem 'glimmer-dsl-libui', '~> 0.11.2'
435
435
  ```
436
436
 
437
437
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -636,6 +636,8 @@ Mac | Windows | Linux
636
636
 
637
637
  Application scaffolding enables automatically generating the directories/files of a new desktop GUI application that follows the MVC architecture and can be packaged as a Ruby gem that includes an executable script for running the app conveniently. It also ensures that software engineers follow the recommended Glimmer DSL for LibUI conventions and best practices. Application Scaffolding greatly improves software engineering productivity when building desktop applications with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui).
638
638
 
639
+ Application Scaffolding relies on the [juwelier](https://rubygems.org/gems/juwelier) Ruby gem, which expects having a local Git config (global settings in `~/.gitconfig`) of [`user.name`](https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git#setting-your-git-username-for-every-repository-on-your-computer), [`user.email`](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/setting-your-commit-email-address#setting-your-email-address-for-every-repository-on-your-computer), and `github.user`.
640
+
639
641
  Scaffold Glimmer DSL for LibUI application with this command:
640
642
 
641
643
  ```
@@ -1615,7 +1617,7 @@ box1.content {
1615
1617
  }
1616
1618
  ```
1617
1619
 
1618
- You can also use [data-binding](#data-binding) with content blocks to generate content dynamically based on changes in a model attribute. The only difference in syntax in this case would be to wrap the content with an explicit `content(*binding_args) { ... }` block that includes data-binding arguments for a model attribute.
1620
+ Content Data-Binding also allows you to use [data-binding](#data-binding) with content blocks to generate content dynamically based on changes in a model attribute. The only difference in syntax in this case would be to wrap the content with an explicit `content(*binding_args) { ... }` block (like `content(model, attribute) { somecontrols }` ) that includes data-binding arguments for a model attribute.
1619
1621
 
1620
1622
  Example:
1621
1623
 
@@ -1624,6 +1626,7 @@ form {
1624
1626
  stretchy false
1625
1627
 
1626
1628
  content(@user, :customizable_attributes) {
1629
+ # this content will be re-rendered whenever @user.customizable_attributes changes
1627
1630
  @user.customizable_attributes.each do |attribute|
1628
1631
  entry {
1629
1632
  label attribute.to_s.split('_').map(&:capitalize).join(' ')
@@ -2107,8 +2110,8 @@ Learn more in the [Paginated Refined Table](/docs/examples/GLIMMER-DSL-LIBUI-ADV
2107
2110
  ### Area API
2108
2111
 
2109
2112
  The `area` control is a canvas-like control for drawing paths that can be used in one of two ways:
2110
- - Declaratively via stable paths: useful for stable paths that will not change often later on. Simply nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are preserved across redraws assuming there would be relatively few stable paths (mostly for decorative reasons).
2111
- - Semi-declaratively via on_draw listener dynamic paths: useful for more dynamic paths that will definitely change very often. Open an `on_draw` listener block that receives an [`area_draw_params`](#area-draw-params) argument and nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are destroyed (thrown-away) at the end of drawing, thus having less memory overhead for drawing thousands of dynamic paths.
2113
+ - Retained Mode (declaratively via stable shape structures): useful for stable paths that will not change often later on. Simply nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are preserved across redraws assuming there would be relatively few stable paths (mostly for decorative reasons).
2114
+ - Immediate Mode (semi-declaratively via `on_draw` listener dynamic shapes): useful for more dynamic paths that will definitely change very often. Open an `on_draw` listener block that receives an [`area_draw_params`](#area-draw-params) argument and nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are destroyed (thrown-away) at the end of drawing, thus having less memory overhead for drawing thousands of dynamic paths.
2112
2115
 
2113
2116
  Note that when nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
2114
2117
 
@@ -2164,6 +2167,59 @@ window('Basic Area', 400, 400) {
2164
2167
 
2165
2168
  Check [examples/dynamic_area.rb](/docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md#dynamic-area) for a more detailed semi-declarative example.
2166
2169
 
2170
+ In Retained Mode, you can still generate `area` shapes dynamically by relying on Content Data-Binding.
2171
+
2172
+ ```ruby
2173
+ require 'glimmer-dsl-libui'
2174
+
2175
+ class LineCollection
2176
+ attr_accessor :line_count
2177
+
2178
+ def initialize
2179
+ @line_count = 3
2180
+ end
2181
+ end
2182
+
2183
+ class View
2184
+ include Glimmer::LibUI::Application
2185
+
2186
+ before_body do
2187
+ @line_collection = LineCollection.new
2188
+ end
2189
+
2190
+ body {
2191
+ window('Area Shapes - Line', 400, 400) {
2192
+ vertical_box {
2193
+ button('Generate Lines') {
2194
+ stretchy false
2195
+
2196
+ on_clicked do
2197
+ @line_collection.line_count = rand(3..10)
2198
+ end
2199
+ }
2200
+ area {
2201
+ content(@line_collection, :line_count) { # generated dynamically
2202
+ point_range = (50..350)
2203
+ color_range = (0..255)
2204
+ @line_collection.line_count.times do
2205
+ line(rand(point_range), rand(point_range), rand(point_range), rand(point_range)) {
2206
+ stroke rand(color_range), rand(color_range), rand(color_range), thickness: 3
2207
+ }
2208
+ end
2209
+ }
2210
+ }
2211
+ }
2212
+ }
2213
+ }
2214
+ end
2215
+
2216
+ View.launch
2217
+ ```
2218
+
2219
+ ![area shape content data-binding](/images/glimmer-dsl-libui-mac-area-shape-content-data-binding.png)
2220
+
2221
+ ![area shape content data-binding regenerated](/images/glimmer-dsl-libui-mac-area-shape-content-data-binding-regenerated.png)
2222
+
2167
2223
  #### Scrolling Area
2168
2224
 
2169
2225
  `scrolling_area(width as Numeric = main_window.width, height as Numeric = main_window.height)` is similar to `area`, but has the following additional methods:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.0
1
+ 0.11.2
@@ -9,6 +9,15 @@ class User
9
9
  # allow customizing all attributes by default
10
10
  self.customizable_attributes = ALL_ATTRIBUTES.dup
11
11
  end
12
+
13
+ def select_customizable_attribute(attribute, selected)
14
+ if selected
15
+ customizable_attributes.push(attribute)
16
+ else
17
+ customizable_attributes.delete(attribute)
18
+ end
19
+ customizable_attributes.sort_by! {|attribute| User::ALL_ATTRIBUTES.index(attribute)}
20
+ end
12
21
  end
13
22
 
14
23
  class DynamicForm
@@ -28,14 +37,7 @@ class DynamicForm
28
37
  checkbox(attribute.to_s) {
29
38
  checked <=> [@user, :customizable_attributes,
30
39
  on_read: -> (attributes) { @user.customizable_attributes.include?(attribute) },
31
- on_write: -> (checked_value) {
32
- if checked_value
33
- @user.customizable_attributes.push(attribute)
34
- else
35
- @user.customizable_attributes.delete(attribute)
36
- end
37
- @user.customizable_attributes.sort_by {|attribute| User::ALL_ATTRIBUTES.index(attribute)}
38
- },
40
+ on_write: -> (checked_value) { @user.select_customizable_attribute(attribute, checked_value) }
39
41
  ]
40
42
  }
41
43
  end
Binary file
@@ -52,6 +52,16 @@ 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
55
65
  end
56
66
 
57
67
  super_module_included do |klass|
@@ -233,16 +243,6 @@ module Glimmer
233
243
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
234
244
  !method(method_name)&.source_location&.first&.include?('glimmer/libui/control_proxy.rb')
235
245
  end
236
-
237
- # Returns content block if used as an attribute reader (no args)
238
- # Otherwise, if a block is passed, it adds it as content to this custom control
239
- def content(&block)
240
- if block_given?
241
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
242
- else
243
- @content
244
- end
245
- end
246
246
 
247
247
  private
248
248
 
@@ -52,6 +52,16 @@ 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
55
65
  end
56
66
 
57
67
  super_module_included do |klass|
@@ -230,16 +240,6 @@ module Glimmer
230
240
  !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
231
241
  !method(method_name)&.source_location&.first&.include?('glimmer/libui/shape.rb')
232
242
  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(&block)
237
- if block_given?
238
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
239
- else
240
- @content
241
- end
242
- end
243
243
 
244
244
  private
245
245
 
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.0
4
+ version: 0.11.2
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-05 00:00:00.000000000 Z
11
+ date: 2023-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -150,14 +150,14 @@ dependencies:
150
150
  name: libui
151
151
  requirement: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - "~>"
153
+ - - '='
154
154
  - !ruby/object:Gem::Version
155
155
  version: 0.1.2.pre
156
156
  type: :runtime
157
157
  prerelease: false
158
158
  version_requirements: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - "~>"
160
+ - - '='
161
161
  - !ruby/object:Gem::Version
162
162
  version: 0.1.2.pre
163
163
  - !ruby/object:Gem::Dependency
@@ -640,7 +640,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
640
640
  - !ruby/object:Gem::Version
641
641
  version: '0'
642
642
  requirements: []
643
- rubygems_version: 3.4.10
643
+ rubygems_version: 3.4.6
644
644
  signing_key:
645
645
  specification_version: 4
646
646
  summary: Glimmer DSL for LibUI (Fukuoka Award Winning Prerequisite-Free Ruby Desktop