glimmer-dsl-libui 0.4.13 → 0.4.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +102 -47
- data/VERSION +1 -1
- data/bin/girb +0 -0
- 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/background_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +6 -28
- data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column.rb +7 -0
- data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -0
- data/lib/glimmer/libui/control_proxy/image_proxy.rb +77 -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 +25 -14
- 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
- data/lib/glimmer-dsl-libui.rb +6 -0
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fc87cc5cdac4adda4a307a3b38ec3255efdacd9a97a667c6840788be005ab80
|
4
|
+
data.tar.gz: 2d57256b28fb43d584949d9316ceaf70ca67999b918ebfca5898aef99f78add4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3490923e9e595407a17350f337f1a8128a59bba1d7b0b2ce2dde12c1425324b6ca8a7688a307290a79baece9eeda8f54bedb3c2e6eb59dbfc65d9702136b6271
|
7
|
+
data.tar.gz: f935b3d85c167e5697973e77a419ad2d929e3071a5013fba2dd3b04035b5da5d1e5623df10ceefb6535fed428b2f127f42373fb42b54853f61f0834031addb7f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.17
|
4
|
+
|
5
|
+
- Remove Windows workaround of always adding an extra row at the bottom of `table` as it is no longer necessary after adding a better workaround (on Windows, add & remove row just after constructing `table` to get rid of double-delete glitch)
|
6
|
+
- Improved parsing code of examples/cpu_percentage.rb for Windows to make it more resilient
|
7
|
+
- Upgrade to glimmer 2.5.3 to silently ignore frozen observables with `observe(*args, ignore_frozen: true)`
|
8
|
+
- Added equalizer gem dependency to properly provide equality methods for `Glimmer::LibUI::ControlProxy::ImageProxy`
|
9
|
+
|
10
|
+
## 0.4.16
|
11
|
+
|
12
|
+
- Upgrade to glimmer 2.5.1
|
13
|
+
- Fix issue on Windows with `table` having image column crashing when empty
|
14
|
+
|
15
|
+
## 0.4.15
|
16
|
+
|
17
|
+
- Support ability to attach multiple listeners on a control (e.g. multiple `on_changed {}` on `entry` or multiple `on_clicked` on `button`)
|
18
|
+
- Ensure clearing custom listeners on `#destroy` of a control
|
19
|
+
- Add `on_destroyed` as alias for `on_destroy` listener on `window`
|
20
|
+
- Avoid wasting time on `destroy` of a control (e.g. freeing resources) when the main window is getting destroyed, thus closing entire application instantaneously
|
21
|
+
- Have validation in examples/form_table.rb complain about nil values (no value entered)
|
22
|
+
- Fix Reset button in examples/meta_example.rb when on a version other than version 1
|
23
|
+
- Fix issue with calling `#destroy` on `open_type_features`
|
24
|
+
|
25
|
+
## 0.4.14
|
26
|
+
|
27
|
+
- Support passing width or height alone to `image` keyword, calculating the other dimension automatically while preserving original aspect ratio
|
28
|
+
- Support passing x and y coordinates to `image` keyword as 2nd and 3rd arguments of 5 arguments (file, x, y, width, height)
|
29
|
+
- Support passing x, y, width, height to `image` keyword as options kwargs
|
30
|
+
|
3
31
|
## 0.4.13
|
4
32
|
|
5
33
|
- Shorten height of examples/cpu_percentage.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.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.17
|
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.17'
|
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
|
}
|
@@ -1027,7 +1039,8 @@ Given that it is very new and is not a [libui](https://github.com/andlabs/libui)
|
|
1027
1039
|
- It only supports the `.png` file format.
|
1028
1040
|
- [libui](https://github.com/andlabs/libui) pixel-by-pixel rendering performance is slow.
|
1029
1041
|
- Including an `image` inside an `area` `on_draw` listener improves performance due to not retaining pixel/line data in memory.
|
1030
|
-
- 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.
|
1031
1044
|
|
1032
1045
|
Currently, it is recommended to use `image` with very small `width` and `height` values only (e.g. 24x24).
|
1033
1046
|
|
@@ -1046,7 +1059,11 @@ include Glimmer
|
|
1046
1059
|
|
1047
1060
|
window('Basic Image', 96, 96) {
|
1048
1061
|
area {
|
1049
|
-
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
|
1050
1067
|
}
|
1051
1068
|
}.show
|
1052
1069
|
```
|
@@ -1078,6 +1095,8 @@ window('Basic Image', 96, 96) {
|
|
1078
1095
|
area {
|
1079
1096
|
image {
|
1080
1097
|
file File.expand_path('icons/glimmer.png', __dir__)
|
1098
|
+
# x 0 # default
|
1099
|
+
# y 0 # default
|
1081
1100
|
width 96
|
1082
1101
|
height 96
|
1083
1102
|
}
|
@@ -1333,13 +1352,16 @@ Note that `area`, `path`, and nested shapes are all truly declarative, meaning t
|
|
1333
1352
|
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1334
1353
|
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1335
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)
|
1336
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`)
|
1337
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)
|
1338
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'; ...}`)
|
1339
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'}}`)
|
1340
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)
|
1341
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`).
|
1342
|
-
- 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.
|
1343
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.
|
1344
1366
|
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
1345
1367
|
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
|
@@ -1623,7 +1645,7 @@ class SomeTable
|
|
1623
1645
|
text_column('City')
|
1624
1646
|
text_column('State')
|
1625
1647
|
|
1626
|
-
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
|
1627
1649
|
}
|
1628
1650
|
}.show
|
1629
1651
|
end
|
@@ -1773,8 +1795,8 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
|
|
1773
1795
|
#### Data-Binding Gotchas
|
1774
1796
|
|
1775
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)
|
1776
|
-
- Data-binding a property utilizes the control's listener associated with the property (e.g. `on_changed` for `entry` `text`), so you
|
1777
|
-
- Data-binding a View control to another View control directly is not a good
|
1798
|
+
- Data-binding a property utilizes the control's listener associated with the property (e.g. `on_changed` for `entry` `text`), so although you can add another listener if you want ([Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) will happily add your listener to the list of listeners that will get notified by a certain event), sometimes it is recommended that you add an `after_read: ->(val) {}` or `after_write: ->(val) {}` block instead to perform something after data-binding reads from or writes to the Model attribute.
|
1799
|
+
- Data-binding a View control to another View control directly is not a good practice as it causes tight-coupling. Instead, data-bind both View controls to the same Presenter/Model attribute, and that keeps them in sync while keeping the code decoupled.
|
1778
1800
|
|
1779
1801
|
### API Gotchas
|
1780
1802
|
|
@@ -3426,7 +3448,6 @@ class BasicTableButton
|
|
3426
3448
|
end
|
3427
3449
|
}
|
3428
3450
|
|
3429
|
-
|
3430
3451
|
cell_rows <= [self, :animals, column_attributes: {'Animal' => :name, 'Description' => :sound}]
|
3431
3452
|
|
3432
3453
|
# explicit unidirectional data-binding of table cell_rows to self.animals
|
@@ -4098,7 +4119,11 @@ window('Basic Image', 96, 96) {
|
|
4098
4119
|
# image pixel rendered. Check basic_image2.rb for a faster alternative using on_draw manually.
|
4099
4120
|
#
|
4100
4121
|
# It is recommended to pass width/height args to shrink image and achieve faster performance.
|
4101
|
-
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
|
4102
4127
|
}
|
4103
4128
|
}.show
|
4104
4129
|
```
|
@@ -4106,8 +4131,6 @@ window('Basic Image', 96, 96) {
|
|
4106
4131
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (better performance via `on_draw`):
|
4107
4132
|
|
4108
4133
|
```ruby
|
4109
|
-
# frozen_string_literal: true
|
4110
|
-
|
4111
4134
|
require 'glimmer-dsl-libui'
|
4112
4135
|
|
4113
4136
|
include Glimmer
|
@@ -4115,7 +4138,7 @@ include Glimmer
|
|
4115
4138
|
window('Basic Image', 96, 96) {
|
4116
4139
|
area {
|
4117
4140
|
on_draw do |area_draw_params|
|
4118
|
-
image(File.expand_path('../icons/glimmer.png', __dir__),
|
4141
|
+
image(File.expand_path('../icons/glimmer.png', __dir__), height: 96)
|
4119
4142
|
end
|
4120
4143
|
}
|
4121
4144
|
}.show
|
@@ -4124,8 +4147,6 @@ window('Basic Image', 96, 96) {
|
|
4124
4147
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (explicit properties):
|
4125
4148
|
|
4126
4149
|
```ruby
|
4127
|
-
# frozen_string_literal: true
|
4128
|
-
|
4129
4150
|
require 'glimmer-dsl-libui'
|
4130
4151
|
|
4131
4152
|
include Glimmer
|
@@ -4142,7 +4163,9 @@ window('Basic Image', 96, 96) {
|
|
4142
4163
|
# It is recommended to pass width/height args to shrink image and achieve faster performance.
|
4143
4164
|
image {
|
4144
4165
|
file File.expand_path('../icons/glimmer.png', __dir__)
|
4145
|
-
|
4166
|
+
# x 0 # default
|
4167
|
+
# y 0 # default
|
4168
|
+
# width 96 # gets calculated from height while preserving original aspect ratio of 512x512
|
4146
4169
|
height 96
|
4147
4170
|
}
|
4148
4171
|
}
|
@@ -4152,8 +4175,6 @@ window('Basic Image', 96, 96) {
|
|
4152
4175
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 4 (better performance with `on_draw` when setting explicit properties):
|
4153
4176
|
|
4154
4177
|
```ruby
|
4155
|
-
# frozen_string_literal: true
|
4156
|
-
|
4157
4178
|
require 'glimmer-dsl-libui'
|
4158
4179
|
|
4159
4180
|
include Glimmer
|
@@ -4163,7 +4184,6 @@ window('Basic Image', 96, 96) {
|
|
4163
4184
|
on_draw do |area_draw_params|
|
4164
4185
|
image {
|
4165
4186
|
file File.expand_path('../icons/glimmer.png', __dir__)
|
4166
|
-
width 96
|
4167
4187
|
height 96
|
4168
4188
|
}
|
4169
4189
|
end
|
@@ -6704,6 +6724,11 @@ window('Editable column animal sounds', 400, 200) {
|
|
6704
6724
|
}
|
6705
6725
|
|
6706
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
|
6707
6732
|
}
|
6708
6733
|
}
|
6709
6734
|
|
@@ -6816,7 +6841,7 @@ class FormTable
|
|
6816
6841
|
end
|
6817
6842
|
|
6818
6843
|
def launch
|
6819
|
-
window('Contacts', 600, 600) {
|
6844
|
+
window('Contacts', 600, 600) {
|
6820
6845
|
margined true
|
6821
6846
|
|
6822
6847
|
vertical_box {
|
@@ -6854,8 +6879,8 @@ class FormTable
|
|
6854
6879
|
|
6855
6880
|
on_clicked do
|
6856
6881
|
new_row = [name, email, phone, city, state]
|
6857
|
-
if new_row.include?('')
|
6858
|
-
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.')
|
6859
6884
|
else
|
6860
6885
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to explicit data-binding
|
6861
6886
|
@unfiltered_contacts = @contacts.dup
|
@@ -6896,10 +6921,16 @@ class FormTable
|
|
6896
6921
|
text_column('State')
|
6897
6922
|
|
6898
6923
|
editable true
|
6899
|
-
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
|
6900
6925
|
|
6901
6926
|
on_changed do |row, type, row_data|
|
6902
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
|
6903
6934
|
end
|
6904
6935
|
}
|
6905
6936
|
}
|
@@ -6910,13 +6941,13 @@ end
|
|
6910
6941
|
FormTable.new.launch
|
6911
6942
|
```
|
6912
6943
|
|
6913
|
-
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)):
|
6914
6945
|
|
6915
6946
|
```ruby
|
6916
6947
|
require 'glimmer-dsl-libui'
|
6917
6948
|
|
6918
6949
|
class FormTable
|
6919
|
-
Contact = Struct.new(:name, :email, :phone, :city, :
|
6950
|
+
Contact = Struct.new(:name, :email, :phone, :city, :state_province)
|
6920
6951
|
|
6921
6952
|
include Glimmer
|
6922
6953
|
|
@@ -6933,7 +6964,7 @@ class FormTable
|
|
6933
6964
|
end
|
6934
6965
|
|
6935
6966
|
def launch
|
6936
|
-
window('Contacts', 600, 600) {
|
6967
|
+
window('Contacts', 600, 600) {
|
6937
6968
|
margined true
|
6938
6969
|
|
6939
6970
|
vertical_box {
|
@@ -6971,8 +7002,8 @@ class FormTable
|
|
6971
7002
|
|
6972
7003
|
on_clicked do
|
6973
7004
|
new_row = [name, email, phone, city, state]
|
6974
|
-
if new_row.include?('')
|
6975
|
-
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.')
|
6976
7007
|
else
|
6977
7008
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to implicit data-binding
|
6978
7009
|
@unfiltered_contacts = @contacts.dup
|
@@ -7010,13 +7041,19 @@ class FormTable
|
|
7010
7041
|
text_column('Email')
|
7011
7042
|
text_column('Phone')
|
7012
7043
|
text_column('City')
|
7013
|
-
text_column('State
|
7044
|
+
text_column('State')
|
7014
7045
|
|
7015
7046
|
editable true
|
7016
|
-
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
|
7017
7048
|
|
7018
7049
|
on_changed do |row, type, row_data|
|
7019
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
|
7020
7057
|
end
|
7021
7058
|
}
|
7022
7059
|
}
|
@@ -7027,7 +7064,7 @@ end
|
|
7027
7064
|
FormTable.new.launch
|
7028
7065
|
```
|
7029
7066
|
|
7030
|
-
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)):
|
7031
7068
|
|
7032
7069
|
```ruby
|
7033
7070
|
|
@@ -7051,7 +7088,7 @@ class FormTable
|
|
7051
7088
|
end
|
7052
7089
|
|
7053
7090
|
def launch
|
7054
|
-
window('Contacts', 600, 600) {
|
7091
|
+
window('Contacts', 600, 600) {
|
7055
7092
|
margined true
|
7056
7093
|
|
7057
7094
|
vertical_box {
|
@@ -7089,8 +7126,8 @@ class FormTable
|
|
7089
7126
|
|
7090
7127
|
on_clicked do
|
7091
7128
|
new_row = [name, email, phone, city, state]
|
7092
|
-
if new_row.include?('')
|
7093
|
-
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.')
|
7094
7131
|
else
|
7095
7132
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to implicit data-binding
|
7096
7133
|
@unfiltered_contacts = @contacts.dup
|
@@ -7135,6 +7172,12 @@ class FormTable
|
|
7135
7172
|
|
7136
7173
|
on_changed do |row, type, row_data|
|
7137
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
|
7138
7181
|
end
|
7139
7182
|
}
|
7140
7183
|
}
|
@@ -7166,7 +7209,7 @@ class FormTable
|
|
7166
7209
|
end
|
7167
7210
|
|
7168
7211
|
def launch
|
7169
|
-
window('Contacts', 600, 600) {
|
7212
|
+
window('Contacts', 600, 600) {
|
7170
7213
|
margined true
|
7171
7214
|
|
7172
7215
|
vertical_box {
|
@@ -7204,8 +7247,8 @@ class FormTable
|
|
7204
7247
|
|
7205
7248
|
on_clicked do
|
7206
7249
|
new_row = [name, email, phone, city, state]
|
7207
|
-
if new_row.include?('')
|
7208
|
-
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.')
|
7209
7252
|
else
|
7210
7253
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
7211
7254
|
@unfiltered_data = data.dup
|
@@ -7250,6 +7293,12 @@ class FormTable
|
|
7250
7293
|
|
7251
7294
|
on_changed do |row, type, row_data|
|
7252
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
|
7253
7302
|
end
|
7254
7303
|
}
|
7255
7304
|
}
|
@@ -7275,7 +7324,7 @@ data = [
|
|
7275
7324
|
['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'],
|
7276
7325
|
]
|
7277
7326
|
|
7278
|
-
window('Contacts', 600, 600) {
|
7327
|
+
window('Contacts', 600, 600) {
|
7279
7328
|
margined true
|
7280
7329
|
|
7281
7330
|
vertical_box {
|
@@ -7308,8 +7357,8 @@ window('Contacts', 600, 600) { |w|
|
|
7308
7357
|
|
7309
7358
|
on_clicked do
|
7310
7359
|
new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
|
7311
|
-
if new_row.include?('')
|
7312
|
-
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.')
|
7313
7362
|
else
|
7314
7363
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
7315
7364
|
@unfiltered_data = data.dup
|
@@ -7353,6 +7402,12 @@ window('Contacts', 600, 600) { |w|
|
|
7353
7402
|
|
7354
7403
|
on_changed do |row, type, row_data|
|
7355
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
|
7356
7411
|
end
|
7357
7412
|
}
|
7358
7413
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.17
|
data/bin/girb
CHANGED
File without changes
|
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
@@ -11,7 +11,7 @@ Glimmer::LibUI.timer(1) do
|
|
11
11
|
cpu_percentage_value = nil
|
12
12
|
if OS.windows?
|
13
13
|
cpu_percentage_raw_value = `wmic cpu get loadpercentage`
|
14
|
-
cpu_percentage_value = cpu_percentage_raw_value.split("\n")
|
14
|
+
cpu_percentage_value = cpu_percentage_raw_value.split("\n").map(&:strip).find {|l| l.match(/^\d+$/)}.to_i
|
15
15
|
elsif OS.mac?
|
16
16
|
cpu_percentage_value = `ps -A -o %cpu | awk '{s+=$1} END {print s}'`.to_i
|
17
17
|
elsif OS.linux?
|
data/examples/form_table.rb
CHANGED
@@ -18,7 +18,7 @@ class FormTable
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def launch
|
21
|
-
window('Contacts', 600, 600) {
|
21
|
+
window('Contacts', 600, 600) {
|
22
22
|
margined true
|
23
23
|
|
24
24
|
vertical_box {
|
@@ -56,8 +56,8 @@ class FormTable
|
|
56
56
|
|
57
57
|
on_clicked do
|
58
58
|
new_row = [name, email, phone, city, state]
|
59
|
-
if new_row.include?('')
|
60
|
-
msg_box_error(
|
59
|
+
if new_row.map(&:to_s).include?('')
|
60
|
+
msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
61
61
|
else
|
62
62
|
@contacts << Contact.new(*new_row) # automatically inserts a row into the table due to explicit data-binding
|
63
63
|
@unfiltered_contacts = @contacts.dup
|
@@ -98,10 +98,16 @@ class FormTable
|
|
98
98
|
text_column('State')
|
99
99
|
|
100
100
|
editable true
|
101
|
-
cell_rows <=> [self, :contacts] # explicit data-binding to Model Array
|
101
|
+
cell_rows <=> [self, :contacts] # explicit data-binding to self.contacts Model Array, auto-inferring model attribute names from underscored table column names by convention
|
102
102
|
|
103
103
|
on_changed do |row, type, row_data|
|
104
104
|
puts "Row #{row} #{type}: #{row_data}"
|
105
|
+
$stdout.flush # for Windows
|
106
|
+
end
|
107
|
+
|
108
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
109
|
+
puts "Row #{row} edited: #{row_data}"
|
110
|
+
$stdout.flush # for Windows
|
105
111
|
end
|
106
112
|
}
|
107
113
|
}
|