glimmer-dsl-libui 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +20 -17
- data/VERSION +1 -1
- data/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md +12 -175
- data/examples/basic_table_selection.rb +179 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +5 -0
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +70 -1
- data/lib/glimmer/libui/control_proxy.rb +17 -13
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a247176e108fe8ba8dd7016b69bb0c6413e3b6c00c78aa068c28e70c11ec5330
|
4
|
+
data.tar.gz: 94aa3f51dd0576748ea09a9899d0f26f230457a315dce3a55ef5c4aa22ce4434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a2e9ef07ac5b946e871577be49c34e0b8e38dbc506d0787178d1f5c01d1fe3294c1656bcb0ede0e6b16323760d1f47688ee023251079b95bdfa55a4e805f936
|
7
|
+
data.tar.gz: 1d335aaa18baad73376426d7c8cdd4669a14e961b91f9c7cdf58f9427afde8cb1ab100b436fae24f72e9249e41f23aae8accb55679cfa23692b7ab62725d6a4a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.7.0
|
4
|
+
|
5
|
+
- Upgrade to libui v0.1.2.pre (including newer libui-ng with table selection API)
|
6
|
+
- `table` `on_row_clicked`, `on_row_double_clicked`, and `on_selection_changed` listeners
|
7
|
+
- `table` `selection` property (including `selection=` attribute writer)
|
8
|
+
- `table` `selection_mode` property supporting values: `:zero_or_many` , `:none` , `:zero_or_one` , and `:one`
|
9
|
+
- Support `radio_buttons` `selected` value of `nil`, treating as `-1` to clear selected radio button.
|
10
|
+
- `examples/basic_table_selection.rb`
|
11
|
+
|
3
12
|
## 0.6.2
|
4
13
|
|
5
14
|
- Fix issue with `examples/lazy_table.rb` not working in Windows due to error: block in `apply_windows_fix`: undefined method `<<` for `#:each`> (`NoMethodError`) `@cell_rows << new_row`
|
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.
|
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.7.0
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
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)
|
@@ -6,7 +6,9 @@
|
|
6
6
|
|
7
7
|
(**[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))
|
8
8
|
|
9
|
-
(**[
|
9
|
+
(**[***RubyConf 2022 Talk - Building Native GUI Apps in Ruby***](https://andymaleh.blogspot.com/2023/02/rubyconf-2022-talk-video-for-building.html)**)
|
10
|
+
|
11
|
+
[**(Ruby Rogues Podcast Interview - Desktop Apps in Ruby ft. Andy)**](https://andymaleh.blogspot.com/2022/05/ruby-rogues-podcast-interview-desktop.html)
|
10
12
|
|
11
13
|
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a prerequisite-free [MRI Ruby](https://www.ruby-lang.org) desktop development GUI (Graphical User Interface) library. No need to pre-install any prerequisites. Just install the [gem](https://rubygems.org/gems/glimmer-dsl-libui) and have platform-independent native GUI that just works!
|
12
14
|
|
@@ -14,9 +16,9 @@ Mac | Windows | Linux
|
|
14
16
|
----|---------|------
|
15
17
|
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png) | ![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png) | ![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
16
18
|
|
17
|
-
[LibUI](https://github.com/kojix2/LibUI) is a thin [Ruby](https://www.ruby-lang.org/en/) wrapper around [libui](https://github.com/andlabs/libui), a relatively new C GUI library that renders native controls on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
|
19
|
+
[LibUI](https://github.com/kojix2/LibUI) is a thin [Ruby](https://www.ruby-lang.org/en/) wrapper around [libui](https://github.com/andlabs/libui) (and newer [libui-ng](https://github.com/libui-ng/libui-ng)), a relatively new C GUI library that renders native controls on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
|
18
20
|
|
19
|
-
The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) as opposed to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) or [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) is the fact that [SWT](https://www.eclipse.org/swt/) and [Tk](https://www.tcl.tk/) are more mature than mid-alpha [libui](https://github.com/
|
21
|
+
The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) as opposed to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) or [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) is the fact that [SWT](https://www.eclipse.org/swt/) and [Tk](https://www.tcl.tk/) are more mature than mid-alpha [libui-ng](https://github.com/libui-ng/libui-ng) as GUI toolkits. Still, if there is only a need to build a small simple application, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) could be a good convenient choice due to having zero prerequisites beyond the dependencies included in the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui). Also, just like [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk), its apps start instantly and have a small memory footprint. [LibUI](https://github.com/kojix2/LibUI) is a promising new GUI toolkit that might prove quite worthy in the future.
|
20
22
|
|
21
23
|
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
|
22
24
|
- [Declarative DSL syntax](#glimmer-gui-dsl-concepts) that visually maps to the GUI control hierarchy
|
@@ -331,7 +333,7 @@ Mac | Windows | Linux
|
|
331
333
|
|
332
334
|
[![glimmer-dsl-libui-mac-tetris.gif](images/glimmer-dsl-libui-mac-tetris.gif)](/docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md#tetris)
|
333
335
|
|
334
|
-
NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is
|
336
|
+
NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is regularly catching up with changes in the C [libui-ng](https://github.com/libui-ng/libui-ng) library API and in beta mode. The C [libui-ng](https://github.com/libui-ng/libui-ng) is still mid-alpha, which is why [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) cannot be declared v1.0.0 yet. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. The more feedback and issues you report the better.
|
335
337
|
|
336
338
|
**[Glimmer](https://rubygems.org/gems/glimmer) DSL Comparison Table:**
|
337
339
|
DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
|
@@ -542,7 +544,7 @@ gem install glimmer-dsl-libui
|
|
542
544
|
Or install via Bundler `Gemfile`:
|
543
545
|
|
544
546
|
```ruby
|
545
|
-
gem 'glimmer-dsl-libui', '~> 0.
|
547
|
+
gem 'glimmer-dsl-libui', '~> 0.7.0'
|
546
548
|
```
|
547
549
|
|
548
550
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -734,7 +736,7 @@ Keyword(Args) | Properties | Listeners
|
|
734
736
|
`string(string = '')` | `font`, `color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `background` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `underline`, `underline_color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `open_type_features`, `string` (`String`) | None
|
735
737
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
736
738
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
737
|
-
`table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values for `text_column` cells or `Array` of `image`/`String` for `image_text_column`)), `editable` as Boolean | `on_changed {|row, type, row_data| ...}`, `on_edited {|row, row_data| ...}`
|
739
|
+
`table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values for `text_column` cells or `Array` of `image`/`String` for `image_text_column`)), `editable` as Boolean, `selection_mode` (`:zero_or_many` , `:none` , `:zero_or_one` , or `:one`), `selection` (`Integer` for row index or `Array` of multiple row indexes) | `on_changed {|row, type, row_data| ...}`, `on_edited {|row, row_data| ...}`, `on_row_clicked {|table, row| }`, `on_row_double_clicked {|table, row| }`, and `on_selection_changed {|table| }`
|
738
740
|
`text(x = 0 as Numeric, y = 0 as Numeric, width = area_width as Numeric)` | `align`, `default_font` | None
|
739
741
|
`text_column(name as String)` | `editable` (Boolean) | None
|
740
742
|
`text_color_column(name as String)` | `editable` (Boolean) | None
|
@@ -1114,7 +1116,7 @@ Mac | Windows | Linux
|
|
1114
1116
|
- `#bounding_box`: returns `Array` containing `[min_x, min_y, width, height]`
|
1115
1117
|
- `#contain?(*point, outline: false, distance_tolerance: 0)`: Returns if point (`[x, y]` `Array` or args) is inside the shape when `outline` is `false` or on the outline when `outline` is `true`. `distance_tolerance` is used when `outline` is `true` as a fuzz factor for declaring a point on the outline of the shape (e.g. helps users select a shape from its outline more easily).
|
1116
1118
|
- `#include?(*point)`: Returns if point (`[x, y]` `Array` or args) is inside the shape when filled (having `fill` value) or on the outline when stroked (not having `fill` value yet `stroke` value only)
|
1117
|
-
- `#perfect_shape`: returns [PerfectShape](https://github.com/AndyObtiva/perfect-shape) object matching the [libui](https://github.com/
|
1119
|
+
- `#perfect_shape`: returns [PerfectShape](https://github.com/AndyObtiva/perfect-shape) object matching the [libui-ng](https://github.com/libui-ng/libui-ng) shape.
|
1118
1120
|
- `#move_by(x_delta, y_delta)` (alias: `translate`): moves (translates) shape by x,y delta
|
1119
1121
|
- `#move(x, y)`: moves (translates) shape to x,y coordinates (in the top-left x,y corner of the shape)
|
1120
1122
|
- `#min_x`: minimum x coordinate of shape (of top-left corner)
|
@@ -1221,12 +1223,12 @@ Mac | Windows | Linux
|
|
1221
1223
|
|
1222
1224
|
**(ALPHA FEATURE)**
|
1223
1225
|
|
1224
|
-
[libui](https://github.com/
|
1226
|
+
[libui-ng](https://github.com/libui-ng/libui-ng) does not support `image` rendering outside of `table` yet.
|
1225
1227
|
However, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) adds a special `image(file as String path or web URL, width as Numeric, height as Numeric)` custom control that renders an image unto an `area` pixel by pixel (and when possible to optimize, line by line).
|
1226
1228
|
|
1227
|
-
Given that it is very new and is not a [libui](https://github.com/
|
1229
|
+
Given that it is very new and is not a [libui-ng](https://github.com/libui-ng/libui-ng)-native control, please keep these notes in mind:
|
1228
1230
|
- It only supports the `.png` file format.
|
1229
|
-
- [libui](https://github.com/
|
1231
|
+
- [libui-ng](https://github.com/libui-ng/libui-ng) pixel-by-pixel rendering performance is slow.
|
1230
1232
|
- Including an `image` inside an `area` `on_draw` listener improves performance due to not retaining pixel/line data in memory.
|
1231
1233
|
- Supplying `width` and `height` options greatly improves performance when shrinking image (e.g. `image('somefile.png', width: 24, height: 24)`). You can also supply one of the two dimensions, and the other one gets calculated automatically while preserving original aspect ratio (e.g. `image('somefile.png', height: 24)`)
|
1232
1234
|
- [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) lets you optionally specify `x` and `y` in addition to `file`, `width` and `height` (5 arguments total) to offset image location.
|
@@ -1641,9 +1643,9 @@ SpinnerExample.new.launch
|
|
1641
1643
|
- If multiple `on_closing` listeners were added for `window`, and none return an integer, they are all executed. On the other hand, if one of them returns an integer, it is counted as the final return value and stops the chain of listener execution.
|
1642
1644
|
- If an `on_clicked` listener was defined on `quit_menu_item` and it does not return an integer, default exit behavior is assumed (`quit_menu_item.destroy` and `main_window.destroy` are called followed by `LibUI.quit`, returning `0`).
|
1643
1645
|
- If multiple `on_clicked` listeners were added for `quit_menu_item`, and none return an integer, they are all executed. On the other hand, if one of them returns an integer, it is counted as the final return value and stops the chain of listener execution.
|
1644
|
-
- All boolean property readers return `true` or `false` in Ruby instead of the [libui](https://github.com/
|
1646
|
+
- All boolean property readers return `true` or `false` in Ruby instead of the [libui-ng](https://github.com/libui-ng/libui-ng) original `0` or `1` in C.
|
1645
1647
|
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
1646
|
-
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/
|
1648
|
+
- All string property readers return a `String` object in Ruby instead of the [libui-ng](https://github.com/libui-ng/libui-ng) Fiddle pointer object.
|
1647
1649
|
- Automatically allocate font descriptors upon instantiating `font_button` controls and free them when destroying `font_button` controls
|
1648
1650
|
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destroying `color_button` controls
|
1649
1651
|
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
@@ -1651,7 +1653,7 @@ SpinnerExample.new.launch
|
|
1651
1653
|
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
1652
1654
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
1653
1655
|
- When destroying a control that has a data-binding to a model attribute, the data-binding observer registration is automatically deregistered
|
1654
|
-
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/
|
1656
|
+
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui-ng](https://github.com/libui-ng/libui-ng) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
|
1655
1657
|
- Smart defaults for `grid` child properties are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`:fill`), `vexpand` (`false`), and `valign` (`:fill`)
|
1656
1658
|
- 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`)
|
1657
1659
|
- Table model instances are automatically freed from memory after `window` is destroyed.
|
@@ -2220,8 +2222,8 @@ Learn more from data-binding usage in [Login](/docs/examples/GLIMMER-DSL-LIBUI-A
|
|
2220
2222
|
|
2221
2223
|
### API Gotchas
|
2222
2224
|
|
2223
|
-
- There is no proper way to destroy `grid` children due to [libui](https://github.com/
|
2224
|
-
- `text` `align` property seems not to work on the Mac ([libui](https://github.com/
|
2225
|
+
- There is no proper way to destroy `grid` children due to [libui-ng](https://github.com/libui-ng/libui-ng) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`).
|
2226
|
+
- `text` `align` property seems not to work on the Mac ([libui-ng](https://github.com/libui-ng/libui-ng) has an [issue](https://github.com/andlabs/libui/pull/407) about it)
|
2225
2227
|
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
2226
2228
|
- `table` `progress_bar` column on Windows cannot be updated with a positive value if it started initially with `-1` (it ignores update to avoid crashing due to an issue in [libui](https://github.com/andlabs/libui) on Windows.
|
2227
2229
|
- `radio_buttons` on Linux has an issue where it always selects the first item even if you did not set its `selected` value or set it to `-1` (meaning unselected). It works correctly on Mac and Windows.
|
@@ -2668,13 +2670,14 @@ https://github.com/kojix2/htsgrid
|
|
2668
2670
|
- [Code Master Blog](https://andymaleh.blogspot.com/search/label/LibUI)
|
2669
2671
|
- [LibUI Ruby Bindings](https://github.com/kojix2/LibUI)
|
2670
2672
|
- [libui C Library](https://github.com/andlabs/libui)
|
2673
|
+
- [libui-ng C Library (Newer Maintained Fork)](https://github.com/libui-ng/libui-ng)
|
2671
2674
|
- [Go UI (Golang LibUI) API Documentation](https://pkg.go.dev/github.com/andlabs/ui)
|
2672
2675
|
|
2673
2676
|
## Help
|
2674
2677
|
|
2675
2678
|
### Issues
|
2676
2679
|
|
2677
|
-
If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-libui/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use [libui](https://github.com/
|
2680
|
+
If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-libui/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use [libui-ng](https://github.com/libui-ng/libui-ng) than what is possible with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-libui/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-libui/compare) on [GitHub](https://github.com). In the meantime, you may try older gem versions of [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) till you find one that works.
|
2678
2681
|
|
2679
2682
|
### Chat
|
2680
2683
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
@@ -18,6 +18,7 @@
|
|
18
18
|
- [Basic Table Checkbox Text](#basic-table-checkbox-text)
|
19
19
|
- [Basic Table Progress Bar](#basic-table-progress-bar)
|
20
20
|
- [Basic Table Color](#basic-table-color)
|
21
|
+
- [Basic Table Selection](#basic-table-selection)
|
21
22
|
- [Basic Area](#basic-area)
|
22
23
|
- [Basic Scrolling Area](#basic-scrolling-area)
|
23
24
|
- [Basic Image](#basic-image)
|
@@ -1497,190 +1498,26 @@ Mac | Windows | Linux
|
|
1497
1498
|
----|---------|------
|
1498
1499
|
![glimmer-dsl-libui-mac-basic-table-color.png](/images/glimmer-dsl-libui-mac-basic-table-color.png) | ![glimmer-dsl-libui-windows-basic-table-color.png](/images/glimmer-dsl-libui-windows-basic-table-color.png) | ![glimmer-dsl-libui-linux-basic-table-color.png](/images/glimmer-dsl-libui-linux-basic-table-color.png)
|
1499
1500
|
|
1500
|
-
|
1501
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with explicit [data-binding](#data-binding) to model rows using a presenter)
|
1501
1502
|
|
1502
|
-
|
1503
|
-
require 'glimmer-dsl-libui'
|
1504
|
-
|
1505
|
-
class BasicTableColor
|
1506
|
-
Animal = Struct.new(:name, :sound, :mammal)
|
1507
|
-
|
1508
|
-
class AnimalPresenter < Animal
|
1509
|
-
def name_color
|
1510
|
-
color = case name
|
1511
|
-
when 'cat'
|
1512
|
-
:red
|
1513
|
-
when 'dog'
|
1514
|
-
:yellow
|
1515
|
-
when 'chicken'
|
1516
|
-
:beige
|
1517
|
-
when 'horse'
|
1518
|
-
:purple
|
1519
|
-
when 'cow'
|
1520
|
-
:gray
|
1521
|
-
end
|
1522
|
-
[name, color]
|
1523
|
-
end
|
1524
|
-
|
1525
|
-
def sound_color
|
1526
|
-
color = case name
|
1527
|
-
when 'cat', 'chicken', 'cow'
|
1528
|
-
:blue
|
1529
|
-
when 'dog', 'horse'
|
1530
|
-
{r: 240, g: 32, b: 32}
|
1531
|
-
end
|
1532
|
-
[sound, color]
|
1533
|
-
end
|
1534
|
-
|
1535
|
-
def mammal_description_color
|
1536
|
-
color = case name
|
1537
|
-
when 'cat', 'dog', 'horse', 'cow'
|
1538
|
-
:green
|
1539
|
-
when 'chicken'
|
1540
|
-
:red
|
1541
|
-
end
|
1542
|
-
[mammal, 'mammal', color]
|
1543
|
-
end
|
1544
|
-
|
1545
|
-
def image_description_color
|
1546
|
-
color = case name
|
1547
|
-
when 'cat', 'dog', 'horse'
|
1548
|
-
:dark_blue
|
1549
|
-
when 'chicken'
|
1550
|
-
:beige
|
1551
|
-
when 'cow'
|
1552
|
-
:brown
|
1553
|
-
end
|
1554
|
-
[img, 'Glimmer', color]
|
1555
|
-
end
|
1556
|
-
|
1557
|
-
def img
|
1558
|
-
# scale image to 24x24 (can be passed as file path String only instead of Array to avoid scaling)
|
1559
|
-
[File.expand_path('../icons/glimmer.png', __dir__), 24, 24]
|
1560
|
-
end
|
1561
|
-
|
1562
|
-
def background_color
|
1563
|
-
case name
|
1564
|
-
when 'cat'
|
1565
|
-
{r: 255, g: 120, b: 0, a: 0.5}
|
1566
|
-
when 'dog'
|
1567
|
-
:skyblue
|
1568
|
-
when 'chicken'
|
1569
|
-
{r: 5, g: 120, b: 110}
|
1570
|
-
when 'horse'
|
1571
|
-
'#13a1fb'
|
1572
|
-
when 'cow'
|
1573
|
-
0x12ff02
|
1574
|
-
end
|
1575
|
-
end
|
1576
|
-
end
|
1577
|
-
|
1578
|
-
include Glimmer
|
1579
|
-
|
1580
|
-
attr_accessor :animals
|
1581
|
-
|
1582
|
-
def initialize
|
1583
|
-
@animals = [
|
1584
|
-
AnimalPresenter.new('cat', 'meow', true),
|
1585
|
-
AnimalPresenter.new('dog', 'woof', true),
|
1586
|
-
AnimalPresenter.new('chicken', 'cock-a-doodle-doo', false),
|
1587
|
-
AnimalPresenter.new('horse', 'neigh', true),
|
1588
|
-
AnimalPresenter.new('cow', 'moo', true),
|
1589
|
-
]
|
1590
|
-
end
|
1591
|
-
|
1592
|
-
def launch
|
1593
|
-
window('Animals', 500, 200) {
|
1594
|
-
horizontal_box {
|
1595
|
-
table {
|
1596
|
-
text_color_column('Animal')
|
1597
|
-
text_color_column('Sound')
|
1598
|
-
checkbox_text_color_column('Description')
|
1599
|
-
image_text_color_column('GUI')
|
1600
|
-
background_color_column # must always be the last column and always expects data-binding model attribute `background_color` when binding to Array of models
|
1601
|
-
|
1602
|
-
cell_rows <= [self, :animals, column_attributes: {'Animal' => :name_color, 'Sound' => :sound_color, 'Description' => :mammal_description_color, 'GUI' => :image_description_color}]
|
1603
|
-
}
|
1604
|
-
}
|
1605
|
-
}.show
|
1606
|
-
end
|
1607
|
-
end
|
1608
|
-
|
1609
|
-
BasicTableColor.new.launch
|
1610
|
-
```
|
1611
|
-
|
1612
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (with implicit [data-binding](#data-binding) to raw data rows):
|
1503
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (with implicit [data-binding](#data-binding) to raw data rows)
|
1613
1504
|
|
1614
|
-
|
1615
|
-
require 'glimmer-dsl-libui'
|
1505
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (with implicit [data-binding](#data-binding) to raw data rows and manual construction of [libui](https://github.com/andlabs/libui) `image` from `image_part`)
|
1616
1506
|
|
1617
|
-
|
1507
|
+
## Basic Table Selection
|
1618
1508
|
|
1619
|
-
|
1509
|
+
[examples/basic_table_selection.rb](/examples/basic_table_selection.rb)
|
1620
1510
|
|
1621
|
-
|
1622
|
-
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
1623
|
-
[['dog', :yellow] , ['woof', {r: 240, g: 32, b: 32}] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], :skyblue],
|
1624
|
-
[['chicken', :beige], ['cock-a-doodle-doo', :blue] , [false, 'mammal', :red] , [img, 'Glimmer', :beige], {r: 5, g: 120, b: 110}],
|
1625
|
-
[['horse', :purple] , ['neigh', {r: 240, g: 32, b: 32}], [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], '13a1fb'],
|
1626
|
-
[['cow', :gray] , ['moo', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :brown], 0x12ff02]
|
1627
|
-
]
|
1628
|
-
|
1629
|
-
window('Animals', 500, 200) {
|
1630
|
-
horizontal_box {
|
1631
|
-
table {
|
1632
|
-
text_color_column('Animal')
|
1633
|
-
text_color_column('Sound')
|
1634
|
-
checkbox_text_color_column('Description')
|
1635
|
-
image_text_color_column('GUI')
|
1636
|
-
background_color_column # must be the last column
|
1511
|
+
Run with this command from the root of the project if you cloned the project:
|
1637
1512
|
|
1638
|
-
|
1639
|
-
|
1640
|
-
}
|
1641
|
-
}.show
|
1513
|
+
```
|
1514
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_selection.rb
|
1642
1515
|
```
|
1643
1516
|
|
1644
|
-
|
1645
|
-
|
1646
|
-
```ruby
|
1647
|
-
require 'glimmer-dsl-libui'
|
1648
|
-
require 'chunky_png'
|
1649
|
-
|
1650
|
-
include Glimmer
|
1651
|
-
|
1652
|
-
f = File.open(File.expand_path('../icons/glimmer.png', __dir__))
|
1653
|
-
canvas = ChunkyPNG::Canvas.from_io(f)
|
1654
|
-
f.close
|
1655
|
-
canvas.resample_nearest_neighbor!(24, 24)
|
1656
|
-
data = canvas.to_rgba_stream
|
1657
|
-
width = canvas.width
|
1658
|
-
height = canvas.height
|
1659
|
-
img = image {
|
1660
|
-
image_part(data, width, height, width * 4)
|
1661
|
-
}
|
1662
|
-
|
1663
|
-
data = [
|
1664
|
-
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
1665
|
-
[['dog', :yellow] , ['woof', {r: 240, g: 32, b: 32}] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], :skyblue],
|
1666
|
-
[['chicken', :beige], ['cock-a-doodle-doo', :blue] , [false, 'mammal', :red] , [img, 'Glimmer', :beige], {r: 5, g: 120, b: 110}],
|
1667
|
-
[['horse', :purple] , ['neigh', {r: 240, g: 32, b: 32}], [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], '13a1fb'],
|
1668
|
-
[['cow', :gray] , ['moo', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :brown], 0x12ff02]
|
1669
|
-
]
|
1670
|
-
|
1671
|
-
window('Animals', 500, 200) {
|
1672
|
-
horizontal_box {
|
1673
|
-
table {
|
1674
|
-
text_color_column('Animal')
|
1675
|
-
text_color_column('Sound')
|
1676
|
-
checkbox_text_color_column('Description')
|
1677
|
-
image_text_color_column('GUI')
|
1678
|
-
background_color_column
|
1517
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1679
1518
|
|
1680
|
-
|
1681
|
-
|
1682
|
-
}
|
1683
|
-
}.show
|
1519
|
+
```
|
1520
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_selection'"
|
1684
1521
|
```
|
1685
1522
|
|
1686
1523
|
## Basic Area
|
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
|
3
|
+
class BasicTableSelection
|
4
|
+
include Glimmer::LibUI::Application
|
5
|
+
|
6
|
+
before_body do
|
7
|
+
@data = [
|
8
|
+
%w[cat meow],
|
9
|
+
%w[dog woof],
|
10
|
+
%w[chicken cock-a-doodle-doo],
|
11
|
+
%w[horse neigh],
|
12
|
+
%w[cow moo]
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
body {
|
17
|
+
window('Basic Table Selection', 400, 300) {
|
18
|
+
tab {
|
19
|
+
tab_item('One') {
|
20
|
+
vertical_box {
|
21
|
+
vertical_box {
|
22
|
+
stretchy false
|
23
|
+
|
24
|
+
@one_radio_buttons = radio_buttons {
|
25
|
+
items @data.size.times.map { |row| "Row #{row} Selection" }
|
26
|
+
|
27
|
+
on_selected do |rb|
|
28
|
+
@one_table.selection = [rb.selected]
|
29
|
+
end
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
@one_table = table {
|
34
|
+
text_column('Animal')
|
35
|
+
text_column('Description')
|
36
|
+
|
37
|
+
cell_rows @data
|
38
|
+
selection_mode :one # other values are :zero_or_many , :zero_or_one, :none
|
39
|
+
selection 2 # initial selection row index (could be nil too or just left off, defaulting to 0)
|
40
|
+
|
41
|
+
on_row_clicked do |t, row|
|
42
|
+
puts "Row Clicked: #{row}"
|
43
|
+
end
|
44
|
+
|
45
|
+
on_row_double_clicked do |t, row|
|
46
|
+
puts "Row Double Clicked: #{row}"
|
47
|
+
end
|
48
|
+
|
49
|
+
on_selection_changed do |t|
|
50
|
+
# selection is an array or nil if selection mode is zero_or_many
|
51
|
+
# otherwise, selection is a single index integer or nil when not selected
|
52
|
+
puts "Selection Changed: #{t.selection.inspect}"
|
53
|
+
@one_radio_buttons.selected = t.selection
|
54
|
+
end
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
tab_item('Zero-Or-One') {
|
60
|
+
vertical_box {
|
61
|
+
vertical_box {
|
62
|
+
stretchy false
|
63
|
+
|
64
|
+
@zero_or_one_radio_buttons = radio_buttons {
|
65
|
+
items @data.size.times.map { |row| "Row #{row} Selection" }
|
66
|
+
|
67
|
+
on_selected do |rb|
|
68
|
+
@zero_or_one_table.selection = [rb.selected]
|
69
|
+
end
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
@zero_or_one_table = table {
|
74
|
+
text_column('Animal')
|
75
|
+
text_column('Description')
|
76
|
+
|
77
|
+
cell_rows @data
|
78
|
+
selection_mode :zero_or_one # other values are :zero_or_many , :one, :none
|
79
|
+
# selection 0 # initial selection row index (could be nil too or just left off)
|
80
|
+
|
81
|
+
on_row_clicked do |t, row|
|
82
|
+
puts "Row Clicked: #{row}"
|
83
|
+
end
|
84
|
+
|
85
|
+
on_row_double_clicked do |t, row|
|
86
|
+
puts "Row Double Clicked: #{row}"
|
87
|
+
end
|
88
|
+
|
89
|
+
on_selection_changed do |t|
|
90
|
+
# selection is an array or nil if selection mode is zero_or_many
|
91
|
+
# otherwise, selection is a single index integer or nil when not selected
|
92
|
+
puts "Selection Changed: #{t.selection.inspect}"
|
93
|
+
@zero_or_one_radio_buttons.selected = t.selection
|
94
|
+
end
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
tab_item('Zero-Or-Many') {
|
100
|
+
vertical_box {
|
101
|
+
vertical_box {
|
102
|
+
stretchy false
|
103
|
+
|
104
|
+
@zero_or_many_checkboxes = @data.size.times.map do |row|
|
105
|
+
checkbox("Row #{row} Selection") {
|
106
|
+
on_toggled do |c|
|
107
|
+
table_selection = @zero_or_many_table.selection.to_a
|
108
|
+
if c.checked?
|
109
|
+
table_selection << row unless table_selection.include?(row)
|
110
|
+
else
|
111
|
+
table_selection.delete(row) if table_selection.include?(row)
|
112
|
+
end
|
113
|
+
@zero_or_many_table.selection = table_selection
|
114
|
+
end
|
115
|
+
}
|
116
|
+
end
|
117
|
+
}
|
118
|
+
|
119
|
+
@zero_or_many_table = table {
|
120
|
+
text_column('Animal')
|
121
|
+
text_column('Description')
|
122
|
+
|
123
|
+
cell_rows @data
|
124
|
+
selection_mode :zero_or_many # other values are :none , :zero_or_one , and :one
|
125
|
+
selection 0, 2, 4 # initial selection row indexes (could be empty array too or just left off)
|
126
|
+
|
127
|
+
on_row_clicked do |t, row|
|
128
|
+
puts "Row Clicked: #{row}"
|
129
|
+
end
|
130
|
+
|
131
|
+
on_row_double_clicked do |t, row|
|
132
|
+
puts "Row Double Clicked: #{row}"
|
133
|
+
end
|
134
|
+
|
135
|
+
on_selection_changed do |t|
|
136
|
+
# selection is an array or nil if selection mode is zero_or_many
|
137
|
+
# otherwise, selection is a single index integer or nil when not selected
|
138
|
+
puts "Selection Changed: #{t.selection.inspect}"
|
139
|
+
@zero_or_many_checkboxes.each { |cb| cb.checked = false }
|
140
|
+
t.selection&.each do |selected_row|
|
141
|
+
@zero_or_many_checkboxes[selected_row].checked = true
|
142
|
+
end
|
143
|
+
end
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
tab_item('None') {
|
149
|
+
vertical_box {
|
150
|
+
@none_table = table {
|
151
|
+
text_column('Animal')
|
152
|
+
text_column('Description')
|
153
|
+
|
154
|
+
cell_rows @data
|
155
|
+
selection_mode :none # other values are :zero_or_many , :zero_or_one, :one
|
156
|
+
|
157
|
+
on_row_clicked do |t, row|
|
158
|
+
puts "Row Clicked: #{row}"
|
159
|
+
end
|
160
|
+
|
161
|
+
on_row_double_clicked do |t, row|
|
162
|
+
puts "Row Double Clicked: #{row}"
|
163
|
+
end
|
164
|
+
|
165
|
+
on_selection_changed do |t|
|
166
|
+
# selection is an array or nil if selection mode is zero_or_many
|
167
|
+
# otherwise, selection is a single index integer or nil when not selected
|
168
|
+
puts "Selection Changed: #{t.selection.inspect}"
|
169
|
+
end
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
end
|
178
|
+
|
179
|
+
BasicTableSelection.launch
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -57,8 +57,12 @@ module Glimmer
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def post_add_content
|
60
|
-
build_control
|
60
|
+
build_control if !@content_added && @libui.nil?
|
61
61
|
super
|
62
|
+
# TODO consider automatically detecting what properties/listeners accumulated dynamically to avoid hardcoding code below
|
63
|
+
register_listeners
|
64
|
+
configure_selection_mode
|
65
|
+
configure_selection
|
62
66
|
end
|
63
67
|
|
64
68
|
def post_initialize_child(child)
|
@@ -129,6 +133,45 @@ module Glimmer
|
|
129
133
|
alias set_editable editable
|
130
134
|
alias editable? editable
|
131
135
|
|
136
|
+
def selection_mode(value = nil)
|
137
|
+
if value.nil?
|
138
|
+
@selection_mode
|
139
|
+
else
|
140
|
+
value = LibUI.enum_symbol_to_value(:table_selection_mode, value)
|
141
|
+
@selection_mode = value
|
142
|
+
end
|
143
|
+
end
|
144
|
+
alias selection_mode= selection_mode
|
145
|
+
|
146
|
+
def selection
|
147
|
+
return @selection if !@content_added
|
148
|
+
|
149
|
+
tsp = super
|
150
|
+
ts = ::LibUI::FFI::TableSelection.new(tsp)
|
151
|
+
if ts.NumRows > 0
|
152
|
+
selection_array = ts.Rows[0, Fiddle::SIZEOF_INT * ts.NumRows].unpack("i*")
|
153
|
+
selection_mode == ::LibUI::TableSelectionModeZeroOrMany ? selection_array : selection_array.first
|
154
|
+
end
|
155
|
+
ensure
|
156
|
+
::LibUI.free_table_selection(tsp)
|
157
|
+
end
|
158
|
+
|
159
|
+
def selection=(*value)
|
160
|
+
value = value.first if value.size == 1
|
161
|
+
@selection = value
|
162
|
+
return @selection if !@content_added
|
163
|
+
return if value.nil?
|
164
|
+
|
165
|
+
ts = ::LibUI::FFI::TableSelection.malloc
|
166
|
+
ts.NumRows = value.is_a?(Array) ? value.size : 1
|
167
|
+
ts.Rows = [value].flatten.pack('i*')
|
168
|
+
super(ts)
|
169
|
+
# TODO figure out why ensure block is not working (perhaps libui auto-frees that resource upon setting selection)
|
170
|
+
# Delete following code if not needed.
|
171
|
+
# ensure
|
172
|
+
# ::LibUI.free_table_selection(ts)
|
173
|
+
end
|
174
|
+
|
132
175
|
def column_attributes
|
133
176
|
@column_attributes ||= columns.select {|column| column.is_a?(Column)}.map(&:name).map(&:underscore)
|
134
177
|
end
|
@@ -178,6 +221,17 @@ module Glimmer
|
|
178
221
|
compound_columns.index(compound_column)
|
179
222
|
end
|
180
223
|
|
224
|
+
def handle_listener(listener_name, &listener)
|
225
|
+
# if content has been added, then you can register listeners immediately (without accumulation
|
226
|
+
if CUSTOM_LISTENER_NAMES.include?(listener_name.to_s) || @content_added
|
227
|
+
super
|
228
|
+
else
|
229
|
+
# if content is not added yet, then accumulate listeners to register later when table content is closed
|
230
|
+
@table_listeners ||= []
|
231
|
+
@table_listeners << [listener_name, listener]
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
181
235
|
private
|
182
236
|
|
183
237
|
# returns table cell for row and column (expanded)
|
@@ -517,6 +571,21 @@ module Glimmer
|
|
517
571
|
end
|
518
572
|
end
|
519
573
|
end
|
574
|
+
|
575
|
+
def register_listeners
|
576
|
+
# register accumulated listeners after table content is closed
|
577
|
+
@table_listeners&.each do |listener_name, listener|
|
578
|
+
handle_listener(listener_name, &listener)
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
def configure_selection_mode
|
583
|
+
send_to_libui('selection_mode=', @selection_mode)
|
584
|
+
end
|
585
|
+
|
586
|
+
def configure_selection
|
587
|
+
self.selection = @selection
|
588
|
+
end
|
520
589
|
end
|
521
590
|
end
|
522
591
|
end
|
@@ -167,18 +167,18 @@ module Glimmer
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def handle_listener(listener_name, &listener)
|
170
|
-
safe_listener = Proc.new { listener.call(self) }
|
170
|
+
safe_listener = Proc.new { |*args| listener.call(self, *args[1..-1]) }
|
171
171
|
if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
172
172
|
if listeners[listener_name].nil?
|
173
|
-
::LibUI.send("#{libui_api_keyword}_#{listener_name}",
|
174
|
-
listeners_for(listener_name).map { |listener| listener.call }.last
|
173
|
+
::LibUI.send("#{libui_api_keyword}_#{listener_name}", libui) do |*args|
|
174
|
+
listeners_for(listener_name).map { |listener| listener.call(*args) }.last
|
175
175
|
end
|
176
176
|
end
|
177
177
|
listeners_for(listener_name) << safe_listener
|
178
178
|
elsif ::LibUI.respond_to?("control_#{listener_name}")
|
179
179
|
if listeners[listener_name].nil?
|
180
|
-
::LibUI.send("control_#{listener_name}",
|
181
|
-
listeners_for(listener_name).map { |listener| listener.call }.last
|
180
|
+
::LibUI.send("control_#{listener_name}", libui) do |*args|
|
181
|
+
listeners_for(listener_name).map { |listener| listener.call(*args) }.last
|
182
182
|
end
|
183
183
|
end
|
184
184
|
listeners_for(listener_name) << safe_listener
|
@@ -272,32 +272,36 @@ module Glimmer
|
|
272
272
|
def send_to_libui(method_name, *args, &block)
|
273
273
|
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
274
274
|
property = method_name.to_s.sub(/\?$/, '')
|
275
|
-
value = ::LibUI.send("#{libui_api_keyword}_#{property}",
|
275
|
+
value = ::LibUI.send("#{libui_api_keyword}_#{property}", libui, *args)
|
276
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
277
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_get_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
278
|
+
property = method_name.to_s.sub(/\?$/, '')
|
279
|
+
value = ::LibUI.send("#{libui_api_keyword}_get_#{property}", libui, *args)
|
276
280
|
handle_string_property(property, handle_boolean_property(property, value))
|
277
281
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
278
282
|
property = method_name.to_s.sub(/=$/, '')
|
279
283
|
args[0] = Glimmer::LibUI.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
280
284
|
args[0] = '' if STRING_PROPERTIES.include?(property) && args.first == nil
|
281
285
|
if property.to_s == 'checked'
|
282
|
-
current_value = Glimmer::LibUI.integer_to_boolean(::LibUI.send("#{libui_api_keyword}_checked",
|
286
|
+
current_value = Glimmer::LibUI.integer_to_boolean(::LibUI.send("#{libui_api_keyword}_checked", libui), allow_nil: false)
|
283
287
|
new_value = Glimmer::LibUI.integer_to_boolean(args[0], allow_nil: false)
|
284
|
-
::LibUI.send("#{libui_api_keyword}_set_#{property}",
|
288
|
+
::LibUI.send("#{libui_api_keyword}_set_#{property}", libui, *args) if new_value != current_value
|
285
289
|
else
|
286
|
-
::LibUI.send("#{libui_api_keyword}_set_#{property}",
|
290
|
+
::LibUI.send("#{libui_api_keyword}_set_#{property}", libui, *args)
|
287
291
|
end
|
288
292
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
|
289
|
-
::LibUI.send("#{libui_api_keyword}_#{method_name}",
|
293
|
+
::LibUI.send("#{libui_api_keyword}_#{method_name}", libui, *args)
|
290
294
|
elsif ::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
291
295
|
property = method_name.to_s.sub(/\?$/, '')
|
292
|
-
value = ::LibUI.send("control_#{property}",
|
296
|
+
value = ::LibUI.send("control_#{property}", libui, *args)
|
293
297
|
handle_string_property(property, handle_boolean_property(property, value))
|
294
298
|
elsif ::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}")
|
295
299
|
property = method_name.to_s.sub(/=$/, '')
|
296
300
|
args[0] = Glimmer::LibUI.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
297
301
|
args[0] = '' if STRING_PROPERTIES.include?(property) && args.first == nil
|
298
|
-
::LibUI.send("control_set_#{method_name.to_s.sub(/=$/, '')}",
|
302
|
+
::LibUI.send("control_set_#{method_name.to_s.sub(/=$/, '')}", libui, *args)
|
299
303
|
elsif ::LibUI.respond_to?("control_#{method_name}") && !args.empty?
|
300
|
-
::LibUI.send("control_#{method_name}",
|
304
|
+
::LibUI.send("control_#{method_name}", libui, *args)
|
301
305
|
end
|
302
306
|
end
|
303
307
|
|
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.
|
4
|
+
version: 0.7.0
|
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
|
+
date: 2023-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.1.
|
95
|
+
version: 0.1.2.pre
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.1.
|
102
|
+
version: 0.1.2.pre
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: chunky_png
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -356,6 +356,7 @@ files:
|
|
356
356
|
- examples/basic_table_image_text2.rb
|
357
357
|
- examples/basic_table_image_text3.rb
|
358
358
|
- examples/basic_table_progress_bar.rb
|
359
|
+
- examples/basic_table_selection.rb
|
359
360
|
- examples/basic_transform.rb
|
360
361
|
- examples/basic_transform2.rb
|
361
362
|
- examples/basic_window.rb
|