glimmer-dsl-libui 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +27 -7
- data/VERSION +1 -1
- data/examples/basic_table_checkbox_text.rb +1 -3
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/checkbox_column_proxy.rb +2 -2
- data/lib/glimmer/libui/checkbox_text_column_proxy.rb +34 -2
- data/lib/glimmer/libui/table_proxy.rb +8 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54faaec785d114536e8b747aa55f7d7bd043339e99f041722d60d70623a9b648
|
4
|
+
data.tar.gz: 9391f99834f34e2b878b2dbf41b7a8ff3f1ab58daf003acdf33a4f93a2e0777c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f2d65ebb19e77c5fab1e037c751af43635a03b07671c8e03ac507bf4e01c04e37c083ffe91a4b18796505801e0d77d84770d0aa13951785422db6ae3c11830f
|
7
|
+
data.tar.gz: 34965b3e01a55733b767dccb4356b4902627a55fd6843295c76fc473a4b049456c7ee59df12bfc9f61541668b763a394d1fb43955f057f6cc8f6a4f72a2ae6b3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.28
|
4
|
+
|
5
|
+
- Support automatic table row change when updating a row in `cell_rows` (e.g. `data[3] = ['new', 'row', 'cell', 'values']`)
|
6
|
+
- Support `editable` property for `checkbox_column` (checkbox editing only works in Windows due to a [libui](https://github.com/andlabs/libui) limitation)
|
7
|
+
- Support `editable`, `editable_checkbox`, and `editable_text` properties for `checkbox_text_column` (checkbox editing only works in Windows due to a [libui](https://github.com/andlabs/libui) limitation)
|
8
|
+
- Fix examples/basic_table_checkbox_text.rb by removing `editable` property
|
9
|
+
|
3
10
|
## 0.0.27
|
4
11
|
|
5
12
|
- New examples/form_table.rb
|
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.
|
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.28
|
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.
|
46
|
+
- [Glimmer DSL for LibUI 0.0.28](#-glimmer-dsl-for-libui-0028)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -52,6 +52,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
52
52
|
- [Common Control Operations](#common-control-operations)
|
53
53
|
- [Extra Dialogs](#extra-dialogs)
|
54
54
|
- [Extra Operations](#extra-operations)
|
55
|
+
- [Table API](#table-api)
|
55
56
|
- [Smart Defaults and Conventions](#smart-defaults-and-conventions)
|
56
57
|
- [API Gotchas](#api-gotchas)
|
57
58
|
- [Original API](#original-api)
|
@@ -166,7 +167,7 @@ gem install glimmer-dsl-libui
|
|
166
167
|
Or install via Bundler `Gemfile`:
|
167
168
|
|
168
169
|
```ruby
|
169
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
170
|
+
gem 'glimmer-dsl-libui', '~> 0.0.28'
|
170
171
|
```
|
171
172
|
|
172
173
|
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.
|
@@ -225,8 +226,8 @@ Control(Args) | Properties | Listeners
|
|
225
226
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
226
227
|
`button_column(name as String)` | `enabled` (Boolean) | None
|
227
228
|
`checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
|
228
|
-
`checkbox_column(name as String)` |
|
229
|
-
`checkbox_text_column(name as String)` | `editable` (Boolean) | None
|
229
|
+
`checkbox_column(name as String)` | `editable` (Boolean) [Windows-only due to a current libui limitation] | None
|
230
|
+
`checkbox_text_column(name as String)` | `editable` (Boolean) [Windows-only due to a current libui limitation], `editable_checkbox` (Boolean) [Windows-only due to a current libui limitation], `editable_text` (Boolean) | None
|
230
231
|
`combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
|
231
232
|
`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`
|
232
233
|
`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`
|
@@ -302,6 +303,24 @@ Control(Args) | Properties | Listeners
|
|
302
303
|
- `ControlProxy::main_window_proxy`: returns the first window proxy instantiated in the application
|
303
304
|
- `ControlProxy#window_proxy`: returns the window proxy parent for a control
|
304
305
|
|
306
|
+
### Table API
|
307
|
+
|
308
|
+
The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported Controls](#supported-controls)):
|
309
|
+
- `button_column`: expects `String` cell values
|
310
|
+
- `checkbox_column`: expects Boolean cell values
|
311
|
+
- `checkbox_text_column`: expects dual-element `Array` of Boolean and `String` cell values
|
312
|
+
- `image_column`: expects `image` cell values (produced by `image` and `image_part` keywords as per [Supported Controls](#supported-controls))
|
313
|
+
- `image_text_column`: expects dual-element `Array` of `image` and `String` cell values
|
314
|
+
- `text_column`: expects `String` cell values
|
315
|
+
- `progress_bar_column`: expects `Integer` cell values
|
316
|
+
|
317
|
+
Afterwards, it must declare its `cell_rows` array (`Array` of `Array`s of column cell values) and whether it is `editable` (Boolean) for all its columns.
|
318
|
+
|
319
|
+
Note that the `cell_rows` property declaration results in "implicit data-binding" between the `table` control and `Array` of `Arrays` (a new innovation) to provide convenience automatic support for:
|
320
|
+
- Deleting cell rows: Calling `Array#delete`, `Array#delete_at`, `Array#delete_if`, or any filtering/deletion `Array` method automatically deletes rows in actual `table` control
|
321
|
+
- Inserting cell rows: Calling `Array#<<`, `Array#push`, `Array#prepend`, or any insertion/addition `Array` method automatically inserts rows in actual `table` control
|
322
|
+
- Changing cell rows: Calling `Array#[]=`, `Array#map!`, or any update `Array` method automatically updates rows in actual `table` control
|
323
|
+
|
305
324
|
### Smart Defaults and Conventions
|
306
325
|
|
307
326
|
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
@@ -327,13 +346,14 @@ Control(Args) | Properties | Listeners
|
|
327
346
|
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
328
347
|
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
|
329
348
|
- Table model instances are automatically freed from memory after `window` is destroyed.
|
330
|
-
- Table `cell_rows` data has implicit data-binding to table cell values for deletion and
|
349
|
+
- Table `cell_rows` data has implicit data-binding to table cell values for deletion, insertion, and change (done by diffing `cell_rows` value before and after change and auto-informing `table` of deletions [`LibUI.table_model_row_deleted`], insertions [`LibUI.table_model_row_deleted`], and changes [`LibUI.table_model_row_changed`]). When deleting data rows from `cell_rows` array, then actual rows from the `table` are automatically deleted. When inserting data rows into `cell_rows` array, then actual `table` rows are automatically inserted. When updating data rows in `cell_rows` array, then actual `table` rows are automatically updated.
|
331
350
|
- `image` instances are automatically freed from memory after `window` is destroyed.
|
332
351
|
- `image` `width` and `height` can be left off if it has one `image_part` only as they default to the same `width` and `height` of the `image_part`
|
333
352
|
|
334
353
|
### API Gotchas
|
335
354
|
|
336
|
-
There is no proper way to destroy `grid` children due to [libui](https://github.com/andlabs/libui) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`)
|
355
|
+
- There is no proper way to destroy `grid` children due to [libui](https://github.com/andlabs/libui) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`).
|
356
|
+
- `table` `checkbox_column` and `checkbox_text_column` checkbox editing currently only works in Windows due to a current limitation in [libui](https://github.com/andlabs/libui).
|
337
357
|
|
338
358
|
### Original API
|
339
359
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.28
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -30,12 +30,12 @@ module Glimmer
|
|
30
30
|
# Follows the Proxy Design Pattern
|
31
31
|
class CheckboxColumnProxy < ControlProxy
|
32
32
|
include Column
|
33
|
-
|
33
|
+
include EditableColumn
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def build_control
|
38
|
-
@parent_proxy.append_checkbox_column(name, column_index,
|
38
|
+
@parent_proxy.append_checkbox_column(name, column_index, editable_value)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -32,12 +32,44 @@ module Glimmer
|
|
32
32
|
class CheckboxTextColumnProxy < ControlProxy
|
33
33
|
include Column
|
34
34
|
include DualColumn
|
35
|
-
include EditableColumn
|
35
|
+
include EditableColumn
|
36
36
|
|
37
|
+
def editable_checkbox(value = nil)
|
38
|
+
if value.nil?
|
39
|
+
@editable_checkbox = false if @editable_checkbox.nil?
|
40
|
+
@editable_checkbox
|
41
|
+
else
|
42
|
+
@editable_checkbox = !!value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
alias editable_checkbox= editable_checkbox
|
46
|
+
alias set_editable_checkbox editable_checkbox
|
47
|
+
alias editable_checkbox? editable_checkbox
|
48
|
+
|
49
|
+
def editable_text(value = nil)
|
50
|
+
if value.nil?
|
51
|
+
@editable_text = false if @editable_text.nil?
|
52
|
+
@editable_text
|
53
|
+
else
|
54
|
+
@editable_text = !!value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
alias editable_text= editable_text
|
58
|
+
alias set_editable_text editable_text
|
59
|
+
alias editable_text? editable_text
|
60
|
+
|
37
61
|
private
|
38
62
|
|
39
63
|
def build_control
|
40
|
-
@parent_proxy.append_checkbox_text_column(name, column_index,
|
64
|
+
@parent_proxy.append_checkbox_text_column(name, column_index, editable_checkbox_value, second_column_index, editable_text_value)
|
65
|
+
end
|
66
|
+
|
67
|
+
def editable_checkbox_value
|
68
|
+
(@parent_proxy.editable? || editable? || editable_checkbox?) ? -2 : -1
|
69
|
+
end
|
70
|
+
|
71
|
+
def editable_text_value
|
72
|
+
(@parent_proxy.editable? || editable? || editable_text?) ? -2 : -1
|
41
73
|
end
|
42
74
|
end
|
43
75
|
end
|
@@ -71,12 +71,16 @@ module Glimmer
|
|
71
71
|
@last_cell_rows = @cell_rows.clone
|
72
72
|
Glimmer::DataBinding::Observer.proc do
|
73
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 |
|
75
|
-
::LibUI.table_model_row_deleted(model,
|
74
|
+
@last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
|
75
|
+
::LibUI.table_model_row_deleted(model, row)
|
76
76
|
end
|
77
77
|
elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
|
78
|
-
@cell_rows.array_diff_indexes(@last_cell_rows).each do |
|
79
|
-
::LibUI.table_model_row_inserted(model,
|
78
|
+
@cell_rows.array_diff_indexes(@last_cell_rows).each do |row|
|
79
|
+
::LibUI.table_model_row_inserted(model, row)
|
80
|
+
end
|
81
|
+
else
|
82
|
+
@cell_rows.each_with_index do |new_row_data, row|
|
83
|
+
::LibUI.table_model_row_changed(model, row) if new_row_data != @last_cell_rows[row]
|
80
84
|
end
|
81
85
|
end
|
82
86
|
@last_cell_rows = @cell_rows.clone
|