glimmer-dsl-libui 0.0.23 → 0.0.24

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: 6e29a14b4e8c65eaaa7ffa9d1ef5a7e1d13a592cf5d1090e850525b8d9188450
4
- data.tar.gz: 37f077425a3627fddd8047a052fa55c43b8b907160ddb406a821757b544c5d97
3
+ metadata.gz: 48620214d8ee4d8658822fd623fbc35cacca3a65fdb9b50b9c0e594f37bce0ad
4
+ data.tar.gz: 595c65cc0ec5c8f94eea6b2aa542cd3f55870d537d3de4fa230b237e58a13835
5
5
  SHA512:
6
- metadata.gz: 2447933bbdce2b03660b8d9c4eb13736b4989eb2632288951ad836b3bd25f0e8fa7075d976b42da1df8a2495540302dd18c02c162abb08ab5a9cd5fad4c1378d
7
- data.tar.gz: f5018929934e70c3364f29ac124626ac1d9502e748e4b98ec1f44cdc5dae63e3baf7d856aa56dc50bb044e2909d040fff1c812ca66706bba4fa53fd92efdc97c
6
+ metadata.gz: 52bfdf8599bc77a418a96a3ed4e3e072c06c328a9597325d66b21419cfde80ade7475f3744870ad0413383d72154db9caea0158e5a2f82e2e7446f231b1eb800
7
+ data.tar.gz: b8f10cae326f757cf6fdbff6085db5d9302696109158046c19cca0d57aaad63f9d28e30509155e69fa3d26bcc48541e3276e04d21c27969425663177da32a3a5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.24
4
+
5
+ - New examples/basic_table_checkbox.rb
6
+ - Support table `checkbox_column`
7
+ - Improve support for table row deletion upon actual `cell_rows` deletion by handling multiple-row deletion not just single-row deletion
8
+
3
9
  ## 0.0.23
4
10
 
5
11
  - Have `image` not require `width` and `height` if it only has one `image_part` (defaults to `image_part` `width` and `height`)
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.0.23
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.0.24
2
2
  ## Prerequisite-Free Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
@@ -43,7 +43,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
43
43
 
44
44
  ## Table of Contents
45
45
 
46
- - [Glimmer DSL for LibUI 0.0.23](#-glimmer-dsl-for-libui-0023)
46
+ - [Glimmer DSL for LibUI 0.0.24](#-glimmer-dsl-for-libui-0024)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -75,6 +75,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
75
75
  - [Basic Table Image](#basic-table-image)
76
76
  - [Basic Table Image Text](#basic-table-image-text)
77
77
  - [Basic Table Button](#basic-table-button)
78
+ - [Basic Table Checkbox](#basic-table-checkbox)
78
79
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
79
80
  - [Help](#help)
80
81
  - [Issues](#issues)
@@ -162,7 +163,7 @@ gem install glimmer-dsl-libui
162
163
  Or install via Bundler `Gemfile`:
163
164
 
164
165
  ```ruby
165
- gem 'glimmer-dsl-libui', '~> 0.0.23'
166
+ gem 'glimmer-dsl-libui', '~> 0.0.24'
166
167
  ```
167
168
 
168
169
  Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
@@ -219,7 +220,9 @@ Control(Args) | Properties | Listeners
219
220
  ------------- | ---------- | ---------
220
221
  `about_menu_item` | None | `on_clicked`
221
222
  `button(text as String)` | `text` (`String`) | `on_clicked`
223
+ `button_column(name as String)` | `enabled` (Boolean) | None
222
224
  `checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
225
+ `checkbox_column(name as String)` | None | None
223
226
  `combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
224
227
  `color_button` | `color` (Array of `red` as `Float`, `green` as `Float`, `blue` as `Float`, `alpha` as `Float`), `red` as `Float`, `green` as `Float`, `blue` as `Float`, `alpha` as `Float` | `on_changed`
225
228
  `date_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
@@ -1810,7 +1813,7 @@ data = [
1810
1813
  %w[cat meow],
1811
1814
  %w[dog woof],
1812
1815
  %w[checken cock-a-doodle-doo],
1813
- %w[hourse neigh],
1816
+ %w[horse neigh],
1814
1817
  %w[cow moo]
1815
1818
  ]
1816
1819
 
@@ -1868,7 +1871,7 @@ data = [
1868
1871
  %w[cat meow],
1869
1872
  %w[dog woof],
1870
1873
  %w[chicken cock-a-doodle-doo],
1871
- %w[hourse neigh],
1874
+ %w[horse neigh],
1872
1875
  %w[cow moo]
1873
1876
  ]
1874
1877
 
@@ -1927,7 +1930,7 @@ data = [
1927
1930
  %w[cat meow],
1928
1931
  %w[dog woof],
1929
1932
  %w[chicken cock-a-doodle-doo],
1930
- %w[hourse neigh],
1933
+ %w[horse neigh],
1931
1934
  %w[cow moo]
1932
1935
  ]
1933
1936
 
@@ -1985,7 +1988,7 @@ data = [
1985
1988
  %w[cat calm meow],
1986
1989
  %w[dog loyal woof],
1987
1990
  %w[chicken bird cock-a-doodle-doo],
1988
- %w[hourse fast neigh],
1991
+ %w[horse fast neigh],
1989
1992
  %w[cow slow moo]
1990
1993
  ]
1991
1994
 
@@ -2281,7 +2284,7 @@ data = [
2281
2284
  %w[cat meow delete],
2282
2285
  %w[dog woof delete],
2283
2286
  %w[chicken cock-a-doodle-doo delete],
2284
- %w[hourse neigh delete],
2287
+ %w[horse neigh delete],
2285
2288
  %w[cow moo delete]
2286
2289
  ]
2287
2290
 
@@ -2302,6 +2305,58 @@ window('Animal sounds', 300, 200) {
2302
2305
  }.show
2303
2306
  ```
2304
2307
 
2308
+ ### Basic Table Checkbox
2309
+
2310
+ [examples/basic_table_checkbox.rb](examples/basic_table_checkbox.rb)
2311
+
2312
+ Run with this command from the root of the project if you cloned the project:
2313
+
2314
+ ```
2315
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox.rb
2316
+ ```
2317
+
2318
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2319
+
2320
+ ```
2321
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox'"
2322
+ ```
2323
+
2324
+ Mac
2325
+
2326
+ ![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
2327
+
2328
+ Linux
2329
+
2330
+ ![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
2331
+
2332
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2333
+
2334
+ ```ruby
2335
+ require 'glimmer-dsl-libui'
2336
+
2337
+ include Glimmer
2338
+
2339
+ data = [
2340
+ ['cat', 'meow', true],
2341
+ ['dog', 'woof', true],
2342
+ ['chicken', 'cock-a-doodle-doo', false],
2343
+ ['horse', 'neigh', true],
2344
+ ['cow', 'moo', true]
2345
+ ]
2346
+
2347
+ window('Animal sounds', 300, 200) {
2348
+ horizontal_box {
2349
+ table {
2350
+ text_column('Animal')
2351
+ text_column('Description')
2352
+ checkbox_column('Mammal')
2353
+
2354
+ cell_rows data
2355
+ }
2356
+ }
2357
+ }.show
2358
+ ```
2359
+
2305
2360
  ## Contributing to glimmer-dsl-libui
2306
2361
 
2307
2362
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.23
1
+ 0.0.24
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat meow],
9
9
  %w[dog woof],
10
10
  %w[chicken cock-a-doodle-doo],
11
- %w[hourse neigh],
11
+ %w[horse neigh],
12
12
  %w[cow moo]
13
13
  ]
14
14
 
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat meow delete],
9
9
  %w[dog woof delete],
10
10
  %w[chicken cock-a-doodle-doo delete],
11
- %w[hourse neigh delete],
11
+ %w[horse neigh delete],
12
12
  %w[cow moo delete]
13
13
  ]
14
14
 
@@ -26,8 +26,4 @@ window('Animal sounds', 300, 200) {
26
26
  cell_rows data # implicit data-binding
27
27
  }
28
28
  }
29
-
30
- on_closing do
31
- puts 'Bye Bye'
32
- end
33
29
  }.show
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ data = [
8
+ ['cat', 'meow', true],
9
+ ['dog', 'woof', true],
10
+ ['chicken', 'cock-a-doodle-doo', false],
11
+ ['horse', 'neigh', true],
12
+ ['cow', 'moo', true]
13
+ ]
14
+
15
+ window('Animal sounds', 300, 200) {
16
+ horizontal_box {
17
+ table {
18
+ text_column('Animal')
19
+ text_column('Description')
20
+ checkbox_column('Mammal')
21
+
22
+ cell_rows data
23
+ }
24
+ }
25
+ }.show
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat calm meow],
9
9
  %w[dog loyal woof],
10
10
  %w[chicken bird cock-a-doodle-doo],
11
- %w[hourse fast neigh],
11
+ %w[horse fast neigh],
12
12
  %w[cow slow moo]
13
13
  ]
14
14
 
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat meow],
9
9
  %w[dog woof],
10
10
  %w[chicken cock-a-doodle-doo],
11
- %w[hourse neigh],
11
+ %w[horse neigh],
12
12
  %w[cow moo]
13
13
  ]
14
14
 
Binary file
@@ -0,0 +1,42 @@
1
+ # Copyright (c) 2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/libui/control_proxy'
23
+ require 'glimmer/libui/column'
24
+ require 'glimmer/libui/editable_column'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ # Proxy for LibUI checkbox column objects
29
+ #
30
+ # Follows the Proxy Design Pattern
31
+ class CheckboxColumnProxy < ControlProxy
32
+ include Column
33
+ # include EditableColumn # TODO enable this once checkbox column becomes editable on macosx in C libui (currently has a bug)
34
+
35
+ private
36
+
37
+ def build_control
38
+ @parent_proxy.append_checkbox_column(name, column_index, -1)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -70,11 +70,10 @@ module Glimmer
70
70
  @cell_rows.tap do
71
71
  @last_cell_rows = @cell_rows.clone
72
72
  Glimmer::DataBinding::Observer.proc do
73
- if (@cell_rows.size == @last_cell_rows.size - 1) && @last_cell_rows & @cell_rows == @cell_rows
74
- _, row = @last_cell_rows.each_with_index.find do |row_data, row|
75
- !@cell_rows.include?(row_data)
73
+ if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
74
+ @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |index|
75
+ ::LibUI.table_model_row_deleted(model, index)
76
76
  end
77
- ::LibUI.table_model_row_deleted(model, row)
78
77
  end
79
78
  @last_cell_rows = @cell_rows.clone
80
79
  end.observe(self, :cell_rows)
@@ -112,8 +111,8 @@ module Glimmer
112
111
  0
113
112
  when ImageColumnProxy, ImageTextColumnProxy
114
113
  1
115
- # when CheckboxColumnProxy
116
- # 2
114
+ when CheckboxColumnProxy
115
+ 2
117
116
  # when CheckboxTextColumnProxy
118
117
  # 2
119
118
  # when ProgressBarColumnProxy
@@ -128,6 +127,8 @@ module Glimmer
128
127
  ::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
129
128
  when ImageColumnProxy, ImageTextColumnProxy
130
129
  ::LibUI.new_table_value_image((expanded_cell_rows[row] && (expanded_cell_rows[row][column].respond_to?(:libui) ? expanded_cell_rows[row][column].libui : expanded_cell_rows[row][column])))
130
+ when CheckboxColumnProxy
131
+ ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column] == 1 || expanded_cell_rows[row][column].to_s.strip.downcase == 'true' ? 1 : 0)))
131
132
  end
132
133
  end
133
134
  @model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
@@ -141,6 +142,10 @@ module Glimmer
141
142
  @cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
142
143
  when ButtonColumnProxy
143
144
  @columns[column].notify_listeners(:on_clicked, row)
145
+ when CheckboxColumnProxy
146
+ column = @columns[column].index
147
+ @cell_rows[row] ||= []
148
+ @cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
144
149
  end
145
150
  end
146
151
 
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.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-26 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.4
19
+ version: 2.1.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.4
26
+ version: 2.1.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: os
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +198,7 @@ files:
198
198
  - examples/basic_entry.rb
199
199
  - examples/basic_table.rb
200
200
  - examples/basic_table_button.rb
201
+ - examples/basic_table_checkbox.rb
201
202
  - examples/basic_table_image.rb
202
203
  - examples/basic_table_image_text.rb
203
204
  - examples/basic_window.rb
@@ -228,6 +229,7 @@ files:
228
229
  - lib/glimmer/libui/button_column_proxy.rb
229
230
  - lib/glimmer/libui/button_proxy.rb
230
231
  - lib/glimmer/libui/check_menu_item_proxy.rb
232
+ - lib/glimmer/libui/checkbox_column_proxy.rb
231
233
  - lib/glimmer/libui/checkbox_proxy.rb
232
234
  - lib/glimmer/libui/color_button_proxy.rb
233
235
  - lib/glimmer/libui/column.rb