glimmer-dsl-libui 0.11.0 → 0.11.1

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: 3089dc0655a6c58f1b514e61ee7994ad1e51949ac79556228832fea732302fea
4
+ data.tar.gz: edeada4eafa026c2f1f6c4d10d581d8e2c416d87c66f142e9225aa809c72322a
5
5
  SHA512:
6
- metadata.gz: 6e123f42fd61ce49b126e7f51caf738e0c769eca12b177c879007cedaba6ec38974d16ca864e8d8922546f79cfe2dc8946056935684f0bab9d88892e425c5d79
7
- data.tar.gz: 8d0d79d7632e30568f747a3db5d9bbdef387e854f55e0cf6559a4d8d242075bc8c1836e00e2554a30eb5eded934bb23c267a764b127cfe768c39e679ff47671e
6
+ metadata.gz: 1a3b4bb480862eee93488bc703c7a32f4c21e7d7a80c2668f262833d8eed3600d7b6169e2c3670666cb030cd94b547b3055df79289679f87618ff411cc8dc729
7
+ data.tar.gz: '0294d1117c0fbfec011f358d2570adb3ea78b95cd656e9b5803467d9eef8e7f9e6e8f615220a1b46c094779b634106ccd31965d00e9dc9365e305d710a5d7c4d'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.11.1
4
+
5
+ - Refactor `examples/dynamic_form.rb`
6
+ - 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
7
+
3
8
  ## 0.11.0
4
9
 
5
10
  - 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.1
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.1'
435
435
  ```
436
436
 
437
437
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -1615,7 +1615,7 @@ box1.content {
1615
1615
  }
1616
1616
  ```
1617
1617
 
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.
1618
+ 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
1619
 
1620
1620
  Example:
1621
1621
 
@@ -1624,6 +1624,7 @@ form {
1624
1624
  stretchy false
1625
1625
 
1626
1626
  content(@user, :customizable_attributes) {
1627
+ # this content will be re-rendered whenever @user.customizable_attributes changes
1627
1628
  @user.customizable_attributes.each do |attribute|
1628
1629
  entry {
1629
1630
  label attribute.to_s.split('_').map(&:capitalize).join(' ')
@@ -2107,8 +2108,8 @@ Learn more in the [Paginated Refined Table](/docs/examples/GLIMMER-DSL-LIBUI-ADV
2107
2108
  ### Area API
2108
2109
 
2109
2110
  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.
2111
+ - 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).
2112
+ - 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
2113
 
2113
2114
  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
2115
 
@@ -2164,6 +2165,59 @@ window('Basic Area', 400, 400) {
2164
2165
 
2165
2166
  Check [examples/dynamic_area.rb](/docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md#dynamic-area) for a more detailed semi-declarative example.
2166
2167
 
2168
+ In Retained Mode, you can still generate `area` shapes dynamically by relying on Content Data-Binding.
2169
+
2170
+ ```ruby
2171
+ require 'glimmer-dsl-libui'
2172
+
2173
+ class LineCollection
2174
+ attr_accessor :line_count
2175
+
2176
+ def initialize
2177
+ @line_count = 3
2178
+ end
2179
+ end
2180
+
2181
+ class View
2182
+ include Glimmer::LibUI::Application
2183
+
2184
+ before_body do
2185
+ @line_collection = LineCollection.new
2186
+ end
2187
+
2188
+ body {
2189
+ window('Area Shapes - Line', 400, 400) {
2190
+ vertical_box {
2191
+ button('Generate Lines') {
2192
+ stretchy false
2193
+
2194
+ on_clicked do
2195
+ @line_collection.line_count = rand(3..10)
2196
+ end
2197
+ }
2198
+ area {
2199
+ content(@line_collection, :line_count) { # generated dynamically
2200
+ point_range = (50..350)
2201
+ color_range = (0..255)
2202
+ @line_collection.line_count.times do
2203
+ line(rand(point_range), rand(point_range), rand(point_range), rand(point_range)) {
2204
+ stroke rand(color_range), rand(color_range), rand(color_range), thickness: 3
2205
+ }
2206
+ end
2207
+ }
2208
+ }
2209
+ }
2210
+ }
2211
+ }
2212
+ end
2213
+
2214
+ View.launch
2215
+ ```
2216
+
2217
+ ![area shape content data-binding](/images/glimmer-dsl-libui-mac-area-shape-content-data-binding.png)
2218
+
2219
+ ![area shape content data-binding regenerated](/images/glimmer-dsl-libui-mac-area-shape-content-data-binding-regenerated.png)
2220
+
2167
2221
  #### Scrolling Area
2168
2222
 
2169
2223
  `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.1
@@ -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
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.1
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