glimmer-dsl-libui 0.4.12 → 0.4.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +111 -48
- data/VERSION +1 -1
- data/examples/basic_image.rb +5 -3
- data/examples/basic_image2.rb +1 -3
- data/examples/basic_image3.rb +3 -3
- data/examples/basic_image4.rb +0 -3
- data/examples/basic_image5.rb +0 -2
- data/examples/basic_table_button.rb +0 -1
- data/examples/cpu_percentage.rb +1 -1
- data/examples/editable_column_table.rb +5 -0
- data/examples/form_table.rb +10 -4
- data/examples/form_table2.rb +12 -6
- data/examples/form_table3.rb +9 -3
- data/examples/form_table4.rb +9 -3
- data/examples/form_table5.rb +9 -3
- data/examples/meta_example.rb +3 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/icons/blank.png +0 -0
- data/lib/glimmer/libui/attributed_string.rb +17 -8
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +17 -17
- data/lib/glimmer/libui/control_proxy/box.rb +1 -0
- data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +1 -29
- data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -0
- data/lib/glimmer/libui/control_proxy/image_proxy.rb +92 -10
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +18 -8
- data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +11 -2
- data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +2 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +2 -0
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +13 -11
- data/lib/glimmer/libui/control_proxy/text_proxy.rb +2 -0
- data/lib/glimmer/libui/control_proxy/window_proxy.rb +34 -35
- data/lib/glimmer/libui/control_proxy.rb +45 -9
- data/lib/glimmer/libui/shape.rb +1 -0
- data/lib/glimmer/libui.rb +1 -0
- 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: 8acbe91938a88381cab6203cca03222967f2cf9f8b9acce1b1cc9334b7dee8a6
|
4
|
+
data.tar.gz: a769546a4a2ecf9075c6161f8d2705c7a86c85f463c4c297cb9c7f45c8e90d72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80b750032c8d4c6605f8843ca3ff8cafee74e53c2b1f048c22fe23a830924966441a5c7c8818cca64e0526e3fb26d83f3339ab2b7c7133fa82cc5f5b5be43034
|
7
|
+
data.tar.gz: 81306b073aa159bbd8abc931032da52ac447d0626657bf7dfeff73b49083fb83a23de5e8fd4718dbea5c9209760af00e72cca29845a15735b7a9ff6370ae2340
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.16
|
4
|
+
|
5
|
+
- Upgrade to glimmer 2.5.1
|
6
|
+
- Fix issue on Windows with `table` having image column crashing when empty
|
7
|
+
|
8
|
+
## 0.4.15
|
9
|
+
|
10
|
+
- Support ability to attach multiple listeners on a control (e.g. multiple `on_changed {}` on `entry` or multiple `on_clicked` on `button`)
|
11
|
+
- Ensure clearing custom listeners on `#destroy` of a control
|
12
|
+
- Add `on_destroyed` as alias for `on_destroy` listener on `window`
|
13
|
+
- Avoid wasting time on `destroy` of a control (e.g. freeing resources) when the main window is getting destroyed, thus closing entire application instantaneously
|
14
|
+
- Have validation in examples/form_table.rb complain about nil values (no value entered)
|
15
|
+
- Fix Reset button in examples/meta_example.rb when on a version other than version 1
|
16
|
+
- Fix issue with calling `#destroy` on `open_type_features`
|
17
|
+
|
18
|
+
## 0.4.14
|
19
|
+
|
20
|
+
- Support passing width or height alone to `image` keyword, calculating the other dimension automatically while preserving original aspect ratio
|
21
|
+
- Support passing x and y coordinates to `image` keyword as 2nd and 3rd arguments of 5 arguments (file, x, y, width, height)
|
22
|
+
- Support passing x, y, width, height to `image` keyword as options kwargs
|
23
|
+
|
24
|
+
## 0.4.13
|
25
|
+
|
26
|
+
- Shorten height of examples/cpu_percentage.rb
|
27
|
+
- Optimize `table` `image` object by caching for multiple images sharing the same arguments
|
28
|
+
|
3
29
|
## 0.4.12
|
4
30
|
|
5
31
|
- Support `table` data-binding to model rows when utilizing dual-columns or triple-columns (e.g. columns having color and/or a checkbox in addition to text)
|
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.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.4.16
|
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
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -100,7 +100,7 @@ class FormTable
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def launch
|
103
|
-
window('Contacts', 600, 600) {
|
103
|
+
window('Contacts', 600, 600) {
|
104
104
|
margined true
|
105
105
|
|
106
106
|
vertical_box {
|
@@ -138,8 +138,8 @@ class FormTable
|
|
138
138
|
|
139
139
|
on_clicked do
|
140
140
|
new_row = [name, email, phone, city, state]
|
141
|
-
if new_row.include?('')
|
142
|
-
msg_box_error(
|
141
|
+
if new_row.map(&:to_s).include?('')
|
142
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
143
143
|
else
|
144
144
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to explicit data-binding
|
145
145
|
@unfiltered_contacts = @contacts.dup
|
@@ -180,10 +180,16 @@ class FormTable
|
|
180
180
|
text_column('State')
|
181
181
|
|
182
182
|
editable true
|
183
|
-
cell_rows <=> [self, :contacts] # explicit data-binding to
|
183
|
+
cell_rows <=> [self, :contacts] # explicit data-binding to self.contacts Modal Array, auto-inferring model attribute names from underscored table column names by convention
|
184
184
|
|
185
185
|
on_changed do |row, type, row_data|
|
186
186
|
puts "Row #{row} #{type}: #{row_data}"
|
187
|
+
$stdout.flush # for Windows
|
188
|
+
end
|
189
|
+
|
190
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
191
|
+
puts "Row #{row} edited: #{row_data}"
|
192
|
+
$stdout.flush # for Windows
|
187
193
|
end
|
188
194
|
}
|
189
195
|
}
|
@@ -500,7 +506,7 @@ gem install glimmer-dsl-libui
|
|
500
506
|
Or install via Bundler `Gemfile`:
|
501
507
|
|
502
508
|
```ruby
|
503
|
-
gem 'glimmer-dsl-libui', '~> 0.4.
|
509
|
+
gem 'glimmer-dsl-libui', '~> 0.4.16'
|
504
510
|
```
|
505
511
|
|
506
512
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -769,7 +775,7 @@ data = [
|
|
769
775
|
['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'],
|
770
776
|
]
|
771
777
|
|
772
|
-
window('Contacts', 600, 600) {
|
778
|
+
window('Contacts', 600, 600) {
|
773
779
|
margined true
|
774
780
|
|
775
781
|
vertical_box {
|
@@ -802,8 +808,8 @@ window('Contacts', 600, 600) { |w|
|
|
802
808
|
|
803
809
|
on_clicked do
|
804
810
|
new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
|
805
|
-
if new_row.include?('')
|
806
|
-
msg_box_error(
|
811
|
+
if new_row.map(&:to_s).include?('')
|
812
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
807
813
|
else
|
808
814
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
809
815
|
@unfiltered_data = data.dup
|
@@ -847,6 +853,12 @@ window('Contacts', 600, 600) { |w|
|
|
847
853
|
|
848
854
|
on_changed do |row, type, row_data|
|
849
855
|
puts "Row #{row} #{type}: #{row_data}"
|
856
|
+
$stdout.flush # for Windows
|
857
|
+
end
|
858
|
+
|
859
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
860
|
+
puts "Row #{row} edited: #{row_data}"
|
861
|
+
$stdout.flush # for Windows
|
850
862
|
end
|
851
863
|
}
|
852
864
|
}
|
@@ -933,9 +945,15 @@ Check [examples/basic_scrolling_area.rb](#basic-scrolling-area) for a more detai
|
|
933
945
|
|
934
946
|
#### Area Path Shapes
|
935
947
|
|
948
|
+
`area` can have geometric shapes drawn by adding `path` elements.
|
949
|
+
|
950
|
+
To add `path` shapes under an `area`, you can do so:
|
951
|
+
- Explicitly: by adding `path` under `area` and nesting shapes (e.g. `rectangle`) underneath that share the same `fill`/`stroke`/`transform` properties
|
952
|
+
- Implicitly: by adding shapes directly under `area` when the shapes have unique `fill`/`stroke`/`transform` properties ([Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) automatically constructs `path`s as intermediary parents for shapes directly added under `area`)
|
953
|
+
|
936
954
|
`path` can receive a `draw_fill_mode` argument that can accept values `:winding` or `:alternate` and defaults to `:winding`.
|
937
955
|
|
938
|
-
Available nested `path`
|
956
|
+
Available `path` shapes (that can be nested explicitly under `path` or implicitly under `area` directly):
|
939
957
|
- `rectangle(x as Numeric, y as Numeric, width as Numeric, height as Numeric)`
|
940
958
|
- `square(x as Numeric, y as Numeric, length as Numeric)`
|
941
959
|
- `arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)`
|
@@ -1021,7 +1039,8 @@ Given that it is very new and is not a [libui](https://github.com/andlabs/libui)
|
|
1021
1039
|
- It only supports the `.png` file format.
|
1022
1040
|
- [libui](https://github.com/andlabs/libui) pixel-by-pixel rendering performance is slow.
|
1023
1041
|
- Including an `image` inside an `area` `on_draw` listener improves performance due to not retaining pixel/line data in memory.
|
1024
|
-
- Supplying `width` and `height`
|
1042
|
+
- 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)`)
|
1043
|
+
- [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.
|
1025
1044
|
|
1026
1045
|
Currently, it is recommended to use `image` with very small `width` and `height` values only (e.g. 24x24).
|
1027
1046
|
|
@@ -1040,7 +1059,11 @@ include Glimmer
|
|
1040
1059
|
|
1041
1060
|
window('Basic Image', 96, 96) {
|
1042
1061
|
area {
|
1043
|
-
image(File.expand_path('icons/glimmer.png', __dir__),
|
1062
|
+
image(File.expand_path('icons/glimmer.png', __dir__), height: 96) # width is automatically calculated from height while preserving original aspect ratio
|
1063
|
+
# image(File.expand_path('icons/glimmer.png', __dir__), width: 96, height: 96) # you can specify both width and height options
|
1064
|
+
# image(File.expand_path('icons/glimmer.png', __dir__), 96, 96) # you can specify width, height as args
|
1065
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), 0, 0, 96, 96) # you can specify x, y, width, height args as alternative
|
1066
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), x: 0, y: 0, width: 96, height: 96) # you can specify x, y, width, height options as alternative
|
1044
1067
|
}
|
1045
1068
|
}.show
|
1046
1069
|
```
|
@@ -1072,6 +1095,8 @@ window('Basic Image', 96, 96) {
|
|
1072
1095
|
area {
|
1073
1096
|
image {
|
1074
1097
|
file File.expand_path('icons/glimmer.png', __dir__)
|
1098
|
+
# x 0 # default
|
1099
|
+
# y 0 # default
|
1075
1100
|
width 96
|
1076
1101
|
height 96
|
1077
1102
|
}
|
@@ -1327,13 +1352,16 @@ Note that `area`, `path`, and nested shapes are all truly declarative, meaning t
|
|
1327
1352
|
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1328
1353
|
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1329
1354
|
- All controls nested under a `horizontal_box`, `vertical_box`, and `form` have `stretchy` property (fill maximum space) as `true` by default (passed to `box_append`/`form_append` method)
|
1355
|
+
- If an event listener is repeated under a control (e.g. two `on_clicked {}` listeners under `button`), it does not overwrite the previous listener, yet it is added to an `Array` of listeners for the event. [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) provides multiple-event-listener support unlike [LibUI](https://github.com/kojix2/LibUI)
|
1330
1356
|
- `window` instatiation args can be left off, having the following defaults when unspecified: `title` as `''`, `width` as `190`, `height` as `150`, and `has_menubar` as `true`)
|
1331
1357
|
- `window` has an `on_closing` listener by default that quits application upon hitting the close button (can be overridden with a manual `on_closing` implementation that returns integer `0` for success)
|
1332
1358
|
- `group` has `title` property default to `''` if not specified in instantiation args, so it can be instantiated without args with `title` property specified in nested block (e.g. `group {title 'Address'; ...}`)
|
1333
1359
|
- `button`, `checkbox`, and `label` have `text` default to `''` if not specified in instantiation args, so they can be instantiated without args with `text` property specified in nested block (e.g. `button {text 'Greet'; on_clicked {puts 'Hello'}}`)
|
1334
1360
|
- `quit_menu_item` has an `on_clicked` listener by default that quits application upon selecting the quit menu item (can be overridden with a manual `on_clicked` implementation that returns integer `0` for success)
|
1335
1361
|
- If an `on_closing` listener was defined on `window` and it does not return an integer, default exit behavior is assumed (`window.destroy` is called followed by `LibUI.quit`, returning `0`).
|
1336
|
-
- If
|
1362
|
+
- 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.
|
1363
|
+
- 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`).
|
1364
|
+
- 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.
|
1337
1365
|
- All boolean property readers return `true` or `false` in Ruby instead of the [libui](https://github.com/andlabs/libui) original `0` or `1` in C.
|
1338
1366
|
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
1339
1367
|
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
|
@@ -1354,7 +1382,8 @@ Note that `area`, `path`, and nested shapes are all truly declarative, meaning t
|
|
1354
1382
|
- Automatically provide shifted `:key` characters in `area_key_event` provided in `area` key listeners `on_key_event`, `on_key_down`, and `on_key_up`
|
1355
1383
|
- `scrolling_area` `width` and `height` default to main window width and height if not specified.
|
1356
1384
|
- `scrolling_area` `#scroll_to` 3rd and 4th arguments (`width` and `height`) default to main window width and height if not specified.
|
1357
|
-
- `area` paths are specified declaratively with figures underneath (e.g. `rectangle`) and `area` draw listener is automatically generated
|
1385
|
+
- `area` paths are specified declaratively with shapes/figures underneath (e.g. `rectangle`), and `area` draw listener is automatically generated
|
1386
|
+
- `area` path shapes can be added directly under `area` without declaring `path` explicitly as a convenient shorthand
|
1358
1387
|
- Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
|
1359
1388
|
- Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
|
1360
1389
|
- Observe `text` and `string` properties for changes and automatically redraw containing area accordingly
|
@@ -1616,7 +1645,7 @@ class SomeTable
|
|
1616
1645
|
text_column('City')
|
1617
1646
|
text_column('State')
|
1618
1647
|
|
1619
|
-
cell_rows <=> [self, :contacts] # explicit data-binding to Model Array auto-inferring model attribute names from underscored table column names by convention
|
1648
|
+
cell_rows <=> [self, :contacts] # explicit data-binding to self.contacts Model Array, auto-inferring model attribute names from underscored table column names by convention
|
1620
1649
|
}
|
1621
1650
|
}.show
|
1622
1651
|
end
|
@@ -1767,6 +1796,7 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
|
|
1767
1796
|
|
1768
1797
|
- Never data-bind a control property to an attribute on the same view object with the same exact name (e.g. binding `entry` `text` property to `self` `text` attribute) as it would conflict with it. Instead, data-bind view property to an attribute with a different name on the view object or with the same name, but on a presenter or model object (e.g. data-bind `entry` `text` to `self` `legal_text` attribute or to `contract` model `text` attribute)
|
1769
1798
|
- Data-binding a property utilizes the control's listener associated with the property (e.g. `on_changed` for `entry` `text`), so you cannot hook into the listener directly anymore as that would negate data-binding. Instead, you can add an `after_write: ->(val) {}` option to perform something on trigger of the control listener instead.
|
1799
|
+
- Data-binding a View control to another View control directly is not a good idea. Instead, data-bind both View controls to the same Presenter/Model attribute, and that keeps them in sync while keeping the code decoupled.
|
1770
1800
|
|
1771
1801
|
### API Gotchas
|
1772
1802
|
|
@@ -3418,7 +3448,6 @@ class BasicTableButton
|
|
3418
3448
|
end
|
3419
3449
|
}
|
3420
3450
|
|
3421
|
-
|
3422
3451
|
cell_rows <= [self, :animals, column_attributes: {'Animal' => :name, 'Description' => :sound}]
|
3423
3452
|
|
3424
3453
|
# explicit unidirectional data-binding of table cell_rows to self.animals
|
@@ -4090,7 +4119,11 @@ window('Basic Image', 96, 96) {
|
|
4090
4119
|
# image pixel rendered. Check basic_image2.rb for a faster alternative using on_draw manually.
|
4091
4120
|
#
|
4092
4121
|
# It is recommended to pass width/height args to shrink image and achieve faster performance.
|
4093
|
-
image(File.expand_path('../icons/glimmer.png', __dir__),
|
4122
|
+
image(File.expand_path('../icons/glimmer.png', __dir__), height: 96) # width is automatically calculated from height while preserving original aspect ratio
|
4123
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), width: 96, height: 96) # you can specify both width, height options as alternative
|
4124
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), 96, 96) # you can specify width, height args as alternative
|
4125
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), 0, 0, 96, 96) # you can specify x, y, width, height args as alternative
|
4126
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), x: 0, y: 0, width: 96, height: 96) # you can specify x, y, width, height options as alternative
|
4094
4127
|
}
|
4095
4128
|
}.show
|
4096
4129
|
```
|
@@ -4098,8 +4131,6 @@ window('Basic Image', 96, 96) {
|
|
4098
4131
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (better performance via `on_draw`):
|
4099
4132
|
|
4100
4133
|
```ruby
|
4101
|
-
# frozen_string_literal: true
|
4102
|
-
|
4103
4134
|
require 'glimmer-dsl-libui'
|
4104
4135
|
|
4105
4136
|
include Glimmer
|
@@ -4107,7 +4138,7 @@ include Glimmer
|
|
4107
4138
|
window('Basic Image', 96, 96) {
|
4108
4139
|
area {
|
4109
4140
|
on_draw do |area_draw_params|
|
4110
|
-
image(File.expand_path('../icons/glimmer.png', __dir__),
|
4141
|
+
image(File.expand_path('../icons/glimmer.png', __dir__), height: 96)
|
4111
4142
|
end
|
4112
4143
|
}
|
4113
4144
|
}.show
|
@@ -4116,8 +4147,6 @@ window('Basic Image', 96, 96) {
|
|
4116
4147
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (explicit properties):
|
4117
4148
|
|
4118
4149
|
```ruby
|
4119
|
-
# frozen_string_literal: true
|
4120
|
-
|
4121
4150
|
require 'glimmer-dsl-libui'
|
4122
4151
|
|
4123
4152
|
include Glimmer
|
@@ -4134,7 +4163,9 @@ window('Basic Image', 96, 96) {
|
|
4134
4163
|
# It is recommended to pass width/height args to shrink image and achieve faster performance.
|
4135
4164
|
image {
|
4136
4165
|
file File.expand_path('../icons/glimmer.png', __dir__)
|
4137
|
-
|
4166
|
+
# x 0 # default
|
4167
|
+
# y 0 # default
|
4168
|
+
# width 96 # gets calculated from height while preserving original aspect ratio of 512x512
|
4138
4169
|
height 96
|
4139
4170
|
}
|
4140
4171
|
}
|
@@ -4144,8 +4175,6 @@ window('Basic Image', 96, 96) {
|
|
4144
4175
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 4 (better performance with `on_draw` when setting explicit properties):
|
4145
4176
|
|
4146
4177
|
```ruby
|
4147
|
-
# frozen_string_literal: true
|
4148
|
-
|
4149
4178
|
require 'glimmer-dsl-libui'
|
4150
4179
|
|
4151
4180
|
include Glimmer
|
@@ -4155,7 +4184,6 @@ window('Basic Image', 96, 96) {
|
|
4155
4184
|
on_draw do |area_draw_params|
|
4156
4185
|
image {
|
4157
4186
|
file File.expand_path('../icons/glimmer.png', __dir__)
|
4158
|
-
width 96
|
4159
4187
|
height 96
|
4160
4188
|
}
|
4161
4189
|
end
|
@@ -6023,7 +6051,7 @@ Glimmer::LibUI.timer(1) do
|
|
6023
6051
|
data[0][2] = cpu_percentage_value
|
6024
6052
|
end
|
6025
6053
|
|
6026
|
-
window('CPU Percentage', 400,
|
6054
|
+
window('CPU Percentage', 400, 50) {
|
6027
6055
|
vertical_box {
|
6028
6056
|
table {
|
6029
6057
|
text_column('Name')
|
@@ -6696,6 +6724,11 @@ window('Editable column animal sounds', 400, 200) {
|
|
6696
6724
|
}
|
6697
6725
|
|
6698
6726
|
cell_rows data
|
6727
|
+
|
6728
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
6729
|
+
puts "Row #{row} edited: #{row_data}"
|
6730
|
+
$stdout.flush
|
6731
|
+
end
|
6699
6732
|
}
|
6700
6733
|
}
|
6701
6734
|
|
@@ -6808,7 +6841,7 @@ class FormTable
|
|
6808
6841
|
end
|
6809
6842
|
|
6810
6843
|
def launch
|
6811
|
-
window('Contacts', 600, 600) {
|
6844
|
+
window('Contacts', 600, 600) {
|
6812
6845
|
margined true
|
6813
6846
|
|
6814
6847
|
vertical_box {
|
@@ -6846,8 +6879,8 @@ class FormTable
|
|
6846
6879
|
|
6847
6880
|
on_clicked do
|
6848
6881
|
new_row = [name, email, phone, city, state]
|
6849
|
-
if new_row.include?('')
|
6850
|
-
msg_box_error(
|
6882
|
+
if new_row.map(&:to_s).include?('')
|
6883
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
6851
6884
|
else
|
6852
6885
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to explicit data-binding
|
6853
6886
|
@unfiltered_contacts = @contacts.dup
|
@@ -6888,10 +6921,16 @@ class FormTable
|
|
6888
6921
|
text_column('State')
|
6889
6922
|
|
6890
6923
|
editable true
|
6891
|
-
cell_rows <=> [self, :contacts] # explicit data-binding to Model Array auto-inferring model attribute names from underscored table column names by convention
|
6924
|
+
cell_rows <=> [self, :contacts] # explicit data-binding to self.contacts Model Array, auto-inferring model attribute names from underscored table column names by convention
|
6892
6925
|
|
6893
6926
|
on_changed do |row, type, row_data|
|
6894
6927
|
puts "Row #{row} #{type}: #{row_data}"
|
6928
|
+
$stdout.flush # for Windows
|
6929
|
+
end
|
6930
|
+
|
6931
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
6932
|
+
puts "Row #{row} edited: #{row_data}"
|
6933
|
+
$stdout.flush # for Windows
|
6895
6934
|
end
|
6896
6935
|
}
|
6897
6936
|
}
|
@@ -6902,13 +6941,13 @@ end
|
|
6902
6941
|
FormTable.new.launch
|
6903
6942
|
```
|
6904
6943
|
|
6905
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with explicit [data-binding](#data-binding)):
|
6944
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (with explicit [data-binding](#data-binding)):
|
6906
6945
|
|
6907
6946
|
```ruby
|
6908
6947
|
require 'glimmer-dsl-libui'
|
6909
6948
|
|
6910
6949
|
class FormTable
|
6911
|
-
Contact = Struct.new(:name, :email, :phone, :city, :
|
6950
|
+
Contact = Struct.new(:name, :email, :phone, :city, :state_province)
|
6912
6951
|
|
6913
6952
|
include Glimmer
|
6914
6953
|
|
@@ -6925,7 +6964,7 @@ class FormTable
|
|
6925
6964
|
end
|
6926
6965
|
|
6927
6966
|
def launch
|
6928
|
-
window('Contacts', 600, 600) {
|
6967
|
+
window('Contacts', 600, 600) {
|
6929
6968
|
margined true
|
6930
6969
|
|
6931
6970
|
vertical_box {
|
@@ -6963,8 +7002,8 @@ class FormTable
|
|
6963
7002
|
|
6964
7003
|
on_clicked do
|
6965
7004
|
new_row = [name, email, phone, city, state]
|
6966
|
-
if new_row.include?('')
|
6967
|
-
msg_box_error(
|
7005
|
+
if new_row.map(&:to_s).include?('')
|
7006
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
6968
7007
|
else
|
6969
7008
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to implicit data-binding
|
6970
7009
|
@unfiltered_contacts = @contacts.dup
|
@@ -7002,13 +7041,19 @@ class FormTable
|
|
7002
7041
|
text_column('Email')
|
7003
7042
|
text_column('Phone')
|
7004
7043
|
text_column('City')
|
7005
|
-
text_column('State
|
7044
|
+
text_column('State')
|
7006
7045
|
|
7007
7046
|
editable true
|
7008
|
-
cell_rows <=> [self, :contacts, column_attributes: {'State
|
7047
|
+
cell_rows <=> [self, :contacts, column_attributes: {'State' => :state_province}] # explicit data-binding to Model Array with column_attributes mapping for a specific column
|
7009
7048
|
|
7010
7049
|
on_changed do |row, type, row_data|
|
7011
7050
|
puts "Row #{row} #{type}: #{row_data}"
|
7051
|
+
$stdout.flush # for Windows
|
7052
|
+
end
|
7053
|
+
|
7054
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
7055
|
+
puts "Row #{row} edited: #{row_data}"
|
7056
|
+
$stdout.flush # for Windows
|
7012
7057
|
end
|
7013
7058
|
}
|
7014
7059
|
}
|
@@ -7019,7 +7064,7 @@ end
|
|
7019
7064
|
FormTable.new.launch
|
7020
7065
|
```
|
7021
7066
|
|
7022
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with explicit [data-binding](#data-binding)):
|
7067
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (with explicit [data-binding](#data-binding)):
|
7023
7068
|
|
7024
7069
|
```ruby
|
7025
7070
|
|
@@ -7043,7 +7088,7 @@ class FormTable
|
|
7043
7088
|
end
|
7044
7089
|
|
7045
7090
|
def launch
|
7046
|
-
window('Contacts', 600, 600) {
|
7091
|
+
window('Contacts', 600, 600) {
|
7047
7092
|
margined true
|
7048
7093
|
|
7049
7094
|
vertical_box {
|
@@ -7081,8 +7126,8 @@ class FormTable
|
|
7081
7126
|
|
7082
7127
|
on_clicked do
|
7083
7128
|
new_row = [name, email, phone, city, state]
|
7084
|
-
if new_row.include?('')
|
7085
|
-
msg_box_error(
|
7129
|
+
if new_row.map(&:to_s).include?('')
|
7130
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
7086
7131
|
else
|
7087
7132
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to implicit data-binding
|
7088
7133
|
@unfiltered_contacts = @contacts.dup
|
@@ -7127,6 +7172,12 @@ class FormTable
|
|
7127
7172
|
|
7128
7173
|
on_changed do |row, type, row_data|
|
7129
7174
|
puts "Row #{row} #{type}: #{row_data}"
|
7175
|
+
$stdout.flush # for Windows
|
7176
|
+
end
|
7177
|
+
|
7178
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
7179
|
+
puts "Row #{row} edited: #{row_data}"
|
7180
|
+
$stdout.flush # for Windows
|
7130
7181
|
end
|
7131
7182
|
}
|
7132
7183
|
}
|
@@ -7158,7 +7209,7 @@ class FormTable
|
|
7158
7209
|
end
|
7159
7210
|
|
7160
7211
|
def launch
|
7161
|
-
window('Contacts', 600, 600) {
|
7212
|
+
window('Contacts', 600, 600) {
|
7162
7213
|
margined true
|
7163
7214
|
|
7164
7215
|
vertical_box {
|
@@ -7196,8 +7247,8 @@ class FormTable
|
|
7196
7247
|
|
7197
7248
|
on_clicked do
|
7198
7249
|
new_row = [name, email, phone, city, state]
|
7199
|
-
if new_row.include?('')
|
7200
|
-
msg_box_error(
|
7250
|
+
if new_row.map(&:to_s).include?('')
|
7251
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
7201
7252
|
else
|
7202
7253
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
7203
7254
|
@unfiltered_data = data.dup
|
@@ -7242,6 +7293,12 @@ class FormTable
|
|
7242
7293
|
|
7243
7294
|
on_changed do |row, type, row_data|
|
7244
7295
|
puts "Row #{row} #{type}: #{row_data}"
|
7296
|
+
$stdout.flush # for Windows
|
7297
|
+
end
|
7298
|
+
|
7299
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
7300
|
+
puts "Row #{row} edited: #{row_data}"
|
7301
|
+
$stdout.flush # for Windows
|
7245
7302
|
end
|
7246
7303
|
}
|
7247
7304
|
}
|
@@ -7267,7 +7324,7 @@ data = [
|
|
7267
7324
|
['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'],
|
7268
7325
|
]
|
7269
7326
|
|
7270
|
-
window('Contacts', 600, 600) {
|
7327
|
+
window('Contacts', 600, 600) {
|
7271
7328
|
margined true
|
7272
7329
|
|
7273
7330
|
vertical_box {
|
@@ -7300,8 +7357,8 @@ window('Contacts', 600, 600) { |w|
|
|
7300
7357
|
|
7301
7358
|
on_clicked do
|
7302
7359
|
new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
|
7303
|
-
if new_row.include?('')
|
7304
|
-
msg_box_error(
|
7360
|
+
if new_row.map(&:to_s).include?('')
|
7361
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
7305
7362
|
else
|
7306
7363
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
7307
7364
|
@unfiltered_data = data.dup
|
@@ -7345,6 +7402,12 @@ window('Contacts', 600, 600) { |w|
|
|
7345
7402
|
|
7346
7403
|
on_changed do |row, type, row_data|
|
7347
7404
|
puts "Row #{row} #{type}: #{row_data}"
|
7405
|
+
$stdout.flush # for Windows
|
7406
|
+
end
|
7407
|
+
|
7408
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
7409
|
+
puts "Row #{row} edited: #{row_data}"
|
7410
|
+
$stdout.flush # for Windows
|
7348
7411
|
end
|
7349
7412
|
}
|
7350
7413
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.16
|
data/examples/basic_image.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
|
5
3
|
include Glimmer
|
@@ -14,6 +12,10 @@ window('Basic Image', 96, 96) {
|
|
14
12
|
# image pixel rendered. Check basic_image2.rb for a faster alternative using on_draw manually.
|
15
13
|
#
|
16
14
|
# It is recommended to pass width/height args to shrink image and achieve faster performance.
|
17
|
-
image(File.expand_path('../icons/glimmer.png', __dir__),
|
15
|
+
image(File.expand_path('../icons/glimmer.png', __dir__), height: 96) # width is automatically calculated from height while preserving original aspect ratio
|
16
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), width: 96, height: 96) # you can specify both width, height options as alternative
|
17
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), 96, 96) # you can specify width, height args as alternative
|
18
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), 0, 0, 96, 96) # you can specify x, y, width, height args as alternative
|
19
|
+
# image(File.expand_path('../icons/glimmer.png', __dir__), x: 0, y: 0, width: 96, height: 96) # you can specify x, y, width, height options as alternative
|
18
20
|
}
|
19
21
|
}.show
|
data/examples/basic_image2.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
|
5
3
|
include Glimmer
|
@@ -7,7 +5,7 @@ include Glimmer
|
|
7
5
|
window('Basic Image', 96, 96) {
|
8
6
|
area {
|
9
7
|
on_draw do |area_draw_params|
|
10
|
-
image(File.expand_path('../icons/glimmer.png', __dir__),
|
8
|
+
image(File.expand_path('../icons/glimmer.png', __dir__), height: 96)
|
11
9
|
end
|
12
10
|
}
|
13
11
|
}.show
|
data/examples/basic_image3.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
|
5
3
|
include Glimmer
|
@@ -16,7 +14,9 @@ window('Basic Image', 96, 96) {
|
|
16
14
|
# It is recommended to pass width/height args to shrink image and achieve faster performance.
|
17
15
|
image {
|
18
16
|
file File.expand_path('../icons/glimmer.png', __dir__)
|
19
|
-
|
17
|
+
# x 0 # default
|
18
|
+
# y 0 # default
|
19
|
+
# width 96 # gets calculated from height while preserving original aspect ratio of 512x512
|
20
20
|
height 96
|
21
21
|
}
|
22
22
|
}
|
data/examples/basic_image4.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
|
5
3
|
include Glimmer
|
@@ -9,7 +7,6 @@ window('Basic Image', 96, 96) {
|
|
9
7
|
on_draw do |area_draw_params|
|
10
8
|
image {
|
11
9
|
file File.expand_path('../icons/glimmer.png', __dir__)
|
12
|
-
width 96
|
13
10
|
height 96
|
14
11
|
}
|
15
12
|
end
|
data/examples/basic_image5.rb
CHANGED
data/examples/cpu_percentage.rb
CHANGED