glimmer-dsl-libui 0.4.14 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +170 -60
  4. data/VERSION +1 -1
  5. data/bin/girb +0 -0
  6. data/examples/basic_table.rb +1 -1
  7. data/examples/basic_table_button.rb +0 -1
  8. data/examples/cpu_percentage.rb +1 -1
  9. data/examples/custom_draw_text.rb +14 -7
  10. data/examples/custom_draw_text2.rb +15 -8
  11. data/examples/editable_column_table.rb +5 -0
  12. data/examples/form_table.rb +9 -3
  13. data/examples/form_table2.rb +12 -6
  14. data/examples/form_table3.rb +9 -3
  15. data/examples/form_table4.rb +9 -3
  16. data/examples/form_table5.rb +9 -3
  17. data/examples/meta_example.rb +3 -1
  18. data/glimmer-dsl-libui.gemspec +0 -0
  19. data/icons/blank.png +0 -0
  20. data/lib/glimmer/dsl/libui/dsl.rb +1 -0
  21. data/lib/glimmer/dsl/libui/operation_expression.rb +47 -0
  22. data/lib/glimmer/dsl/libui/property_expression.rb +2 -2
  23. data/lib/glimmer/libui/attributed_string.rb +17 -8
  24. data/lib/glimmer/libui/control_proxy/area_proxy.rb +17 -17
  25. data/lib/glimmer/libui/control_proxy/box.rb +1 -0
  26. data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +6 -0
  27. data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +6 -28
  28. data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +6 -0
  29. data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +6 -0
  30. data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +6 -0
  31. data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +6 -0
  32. data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +6 -0
  33. data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +6 -0
  34. data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +6 -0
  35. data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +6 -0
  36. data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +6 -0
  37. data/lib/glimmer/libui/control_proxy/column.rb +7 -0
  38. data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -0
  39. data/lib/glimmer/libui/control_proxy/image_proxy.rb +3 -0
  40. data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +18 -9
  41. data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +11 -2
  42. data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +2 -0
  43. data/lib/glimmer/libui/control_proxy/path_proxy.rb +8 -4
  44. data/lib/glimmer/libui/control_proxy/table_proxy.rb +59 -34
  45. data/lib/glimmer/libui/control_proxy/text_proxy.rb +2 -0
  46. data/lib/glimmer/libui/control_proxy/window_proxy.rb +34 -35
  47. data/lib/glimmer/libui/control_proxy.rb +45 -9
  48. data/lib/glimmer/libui/data_bindable.rb +1 -1
  49. data/lib/glimmer/libui/shape.rb +1 -0
  50. data/lib/glimmer/libui.rb +1 -0
  51. data/lib/glimmer-dsl-libui.rb +6 -0
  52. metadata +21 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d51961908ec1315a42fe183bc79cbe86bc8d86e2dea9ac9a35d2dfaefaf3912d
4
- data.tar.gz: af6c03eb6d451816d32242c7f7d99ce3ed28755f363f3620faea2a590c3e0ea8
3
+ metadata.gz: 2d56a2500e640c9f34f29daddc718a1adee47564da205fc7aff171047f90581f
4
+ data.tar.gz: 0067be097b14cf452323ce2faf79c244f99b525b24bd400b248119d8e2b24be4
5
5
  SHA512:
6
- metadata.gz: cb828f87dfbc9c56fd15123ecb29a3c499f22c315ef6582d47c629353e444f16c2b0755b958abe8d77f0506ee25c1cffbafa0a682ea2bfb1e9d649fa49cb7e9f
7
- data.tar.gz: ff5f76d4c7868c28d223a95bff04a5a3b9cf01879eec9231a709afd2e67a6ce6bb2a4df8a8ccf41406a1cf69aaf7250a40c7c726952f8e8b8cc280b0e8e77175
6
+ metadata.gz: 5c954f84c3565d6c4dd2fe5262b5d34749ee5d5efc94f9cbb351d1924b442474089bbf731f8d418cae332f44ff215d0a21a54ceded566667b6e558109e28ea82
7
+ data.tar.gz: e0fcf189174a77fe48f80cbae8af6d0028092c4b19e1c653243845d194bd923e42fa5ae29f2a43cbe684106dfbc107eb6193af63d0e16e79fa5b40d8b383a47e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.4.18
4
+
5
+ - Support setting `table` `cell_rows` after the `table` definition completed (e.g. `@table.cell_rows = data` after `table {}` curly braces closed already)
6
+ - Support adding to `table` `cell_rows` piecemeal after the `table` definition completed (e.g. `data.each { |row| @table.cell_rows << row }` after `table {}` curly braces closed already)
7
+ - Support notifying observers of control property changes when calling the `set_attribute` version of attribute writers, not just `attribute=`
8
+ - Hide background field in examples/custom_draw_text.rb on Windows since it is not supported there
9
+ - Fix issue with `quit_menu_item` click resulting in a stack overflow on Windows
10
+
11
+ ## 0.4.17
12
+
13
+ - 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)
14
+ - Improved parsing code of examples/cpu_percentage.rb for Windows to make it more resilient
15
+ - Upgrade to glimmer 2.5.3 to silently ignore frozen observables with `observe(*args, ignore_frozen: true)`
16
+ - Added equalizer gem dependency to properly provide equality methods for `Glimmer::LibUI::ControlProxy::ImageProxy`
17
+
18
+ ## 0.4.16
19
+
20
+ - Upgrade to glimmer 2.5.1
21
+ - Fix issue on Windows with `table` having image column crashing when empty
22
+
23
+ ## 0.4.15
24
+
25
+ - Support ability to attach multiple listeners on a control (e.g. multiple `on_changed {}` on `entry` or multiple `on_clicked` on `button`)
26
+ - Ensure clearing custom listeners on `#destroy` of a control
27
+ - Add `on_destroyed` as alias for `on_destroy` listener on `window`
28
+ - Avoid wasting time on `destroy` of a control (e.g. freeing resources) when the main window is getting destroyed, thus closing entire application instantaneously
29
+ - Have validation in examples/form_table.rb complain about nil values (no value entered)
30
+ - Fix Reset button in examples/meta_example.rb when on a version other than version 1
31
+ - Fix issue with calling `#destroy` on `open_type_features`
32
+
3
33
  ## 0.4.14
4
34
 
5
35
  - Support passing width or height alone to `image` keyword, calculating the other dimension automatically while preserving original aspect ratio
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.14
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.18
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) { |w|
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(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
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
@@ -184,6 +184,12 @@ class FormTable
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.14'
509
+ gem 'glimmer-dsl-libui', '~> 0.4.18'
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) { |w|
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(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
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
  }
@@ -1340,13 +1352,16 @@ Note that `area`, `path`, and nested shapes are all truly declarative, meaning t
1340
1352
  - `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
1341
1353
  - `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
1342
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)
1343
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`)
1344
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)
1345
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'; ...}`)
1346
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'}}`)
1347
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)
1348
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`).
1349
- - If an `on_clicked` listener was defined on `quit_menu_item` and it does not return an integer, default exit behavior is assumed (`main_window.destroy` is called followed by `LibUI.quit`, returning `0`).
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.
1350
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.
1351
1366
  - All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
1352
1367
  - All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
@@ -1780,8 +1795,8 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
1780
1795
  #### Data-Binding Gotchas
1781
1796
 
1782
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)
1783
- - 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.
1784
- - 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.
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.
1785
1800
 
1786
1801
  ### API Gotchas
1787
1802
 
@@ -3433,7 +3448,6 @@ class BasicTableButton
3433
3448
  end
3434
3449
  }
3435
3450
 
3436
-
3437
3451
  cell_rows <= [self, :animals, column_attributes: {'Animal' => :name, 'Description' => :sound}]
3438
3452
 
3439
3453
  # explicit unidirectional data-binding of table cell_rows to self.animals
@@ -6025,7 +6039,7 @@ Glimmer::LibUI.timer(1) do
6025
6039
  cpu_percentage_value = nil
6026
6040
  if OS.windows?
6027
6041
  cpu_percentage_raw_value = `wmic cpu get loadpercentage`
6028
- cpu_percentage_value = cpu_percentage_raw_value.split("\n")[2].to_i
6042
+ cpu_percentage_value = cpu_percentage_raw_value.split("\n").map(&:strip).find {|l| l.match(/^\d+$/)}.to_i
6029
6043
  elsif OS.mac?
6030
6044
  cpu_percentage_value = `ps -A -o %cpu | awk '{s+=$1} END {print s}'`.to_i
6031
6045
  elsif OS.linux?
@@ -6096,6 +6110,7 @@ class CustomDrawText
6096
6110
  @string.font = fb.font
6097
6111
  end
6098
6112
  }
6113
+
6099
6114
  color_button { |cb|
6100
6115
  label 'Color'
6101
6116
 
@@ -6103,13 +6118,17 @@ class CustomDrawText
6103
6118
  @string.color = cb.color
6104
6119
  end
6105
6120
  }
6106
- color_button { |cb|
6107
- label 'Background'
6108
-
6109
- on_changed do
6110
- @string.background = cb.color
6111
- end
6112
- }
6121
+
6122
+ unless OS.windows?
6123
+ color_button { |cb|
6124
+ label 'Background'
6125
+
6126
+ on_changed do
6127
+ @string.background = cb.color
6128
+ end
6129
+ }
6130
+ end
6131
+
6113
6132
  combobox { |c|
6114
6133
  label 'Underline'
6115
6134
  items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
@@ -6119,12 +6138,36 @@ class CustomDrawText
6119
6138
  @string.underline = c.selected_item.underscore
6120
6139
  end
6121
6140
  }
6141
+
6142
+ combobox { |c|
6143
+ label 'Underline Built-In Color'
6144
+ items Glimmer::LibUI.enum_symbols(:underline_color).map(&:to_s).map(&:capitalize)
6145
+ selected 'Custom'
6146
+
6147
+ on_selected do
6148
+ @underline_custom_color_button.enabled = c.selected_item == 'Custom'
6149
+ if c.selected_item == 'Custom'
6150
+ @string.underline_color = @underline_custom_color_button.color
6151
+ else
6152
+ @string.underline_color = c.selected_item.underscore
6153
+ @underline_custom_color_button.color = :black
6154
+ end
6155
+ end
6156
+ }
6157
+
6158
+ @underline_custom_color_button = color_button {
6159
+ label 'Underline Custom Color'
6160
+
6161
+ on_changed do
6162
+ @string.underline_color = @underline_custom_color_button.color
6163
+ end
6164
+ }
6122
6165
  }
6123
6166
 
6124
6167
  area {
6125
- text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
6168
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
6126
6169
  # align :left # default alignment
6127
-
6170
+
6128
6171
  @string = string {
6129
6172
  ' At last Ygramul sensed that something was coming toward ' \
6130
6173
  'her. With the speed of lightning, she turned about, confronting ' \
@@ -6169,62 +6212,94 @@ require 'glimmer-dsl-libui'
6169
6212
  # The English version, translated by Ralph Manheim, was published in 1983.
6170
6213
  class CustomDrawText
6171
6214
  include Glimmer
6172
-
6215
+
6173
6216
  def launch
6174
6217
  window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
6175
6218
  margined true
6176
-
6219
+
6177
6220
  vertical_box {
6178
6221
  form {
6179
6222
  stretchy false
6180
-
6223
+
6181
6224
  font_button { |fb|
6182
6225
  label 'Font'
6183
-
6226
+
6184
6227
  on_changed do
6185
6228
  @font = fb.font
6186
6229
  @area.queue_redraw_all
6187
6230
  end
6188
6231
  }
6232
+
6189
6233
  color_button { |cb|
6190
6234
  label 'Color'
6191
-
6235
+
6192
6236
  on_changed do
6193
6237
  @color = cb.color
6194
6238
  @area.queue_redraw_all
6195
6239
  end
6196
6240
  }
6197
- color_button { |cb|
6198
- label 'Background'
6199
-
6200
- on_changed do
6201
- @background = cb.color
6202
- @area.queue_redraw_all
6203
- end
6204
- }
6241
+
6242
+ unless OS.windows?
6243
+ color_button { |cb|
6244
+ label 'Background'
6245
+
6246
+ on_changed do
6247
+ @background = cb.color
6248
+ @area.queue_redraw_all
6249
+ end
6250
+ }
6251
+ end
6252
+
6205
6253
  combobox { |c|
6206
6254
  label 'Underline'
6207
6255
  items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
6208
6256
  selected 'None'
6209
-
6257
+
6210
6258
  on_selected do
6211
6259
  @underline = c.selected_item.underscore
6212
6260
  @area.queue_redraw_all
6213
6261
  end
6214
6262
  }
6263
+
6264
+ combobox { |c|
6265
+ label 'Underline Built-In Color'
6266
+ items Glimmer::LibUI.enum_symbols(:underline_color).map(&:to_s).map(&:capitalize)
6267
+ selected 'Custom'
6268
+
6269
+ on_selected do
6270
+ @underline_custom_color_button.enabled = c.selected_item == 'Custom'
6271
+ if c.selected_item == 'Custom'
6272
+ @underline_color = @underline_custom_color_button.color
6273
+ else
6274
+ @underline_color = c.selected_item.underscore
6275
+ @underline_custom_color_button.color = :black
6276
+ end
6277
+ @area.queue_redraw_all
6278
+ end
6279
+ }
6280
+
6281
+ @underline_custom_color_button = color_button {
6282
+ label 'Underline Custom Color'
6283
+
6284
+ on_changed do
6285
+ @underline_color = @underline_custom_color_button.color
6286
+ @area.queue_redraw_all
6287
+ end
6288
+ }
6215
6289
  }
6216
-
6290
+
6217
6291
  @area = area {
6218
6292
  on_draw do |area_draw_params|
6219
- text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
6293
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
6220
6294
  # align :left # default alignment
6221
-
6295
+
6222
6296
  string {
6223
6297
  font @font
6224
6298
  color @color
6225
6299
  background @background
6226
6300
  underline @underline
6227
-
6301
+ underline_color @underline_color
6302
+
6228
6303
  ' At last Ygramul sensed that something was coming toward ' \
6229
6304
  'her. With the speed of lightning, she turned about, confronting ' \
6230
6305
  'Atreyu with an enormous steel-blue face. Her single eye had a ' \
@@ -6710,6 +6785,11 @@ window('Editable column animal sounds', 400, 200) {
6710
6785
  }
6711
6786
 
6712
6787
  cell_rows data
6788
+
6789
+ on_edited do |row, row_data| # only fires on direct table editing
6790
+ puts "Row #{row} edited: #{row_data}"
6791
+ $stdout.flush
6792
+ end
6713
6793
  }
6714
6794
  }
6715
6795
 
@@ -6822,7 +6902,7 @@ class FormTable
6822
6902
  end
6823
6903
 
6824
6904
  def launch
6825
- window('Contacts', 600, 600) { |w|
6905
+ window('Contacts', 600, 600) {
6826
6906
  margined true
6827
6907
 
6828
6908
  vertical_box {
@@ -6860,8 +6940,8 @@ class FormTable
6860
6940
 
6861
6941
  on_clicked do
6862
6942
  new_row = [name, email, phone, city, state]
6863
- if new_row.include?('')
6864
- msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
6943
+ if new_row.map(&:to_s).include?('')
6944
+ msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
6865
6945
  else
6866
6946
  @contacts << Contact.new(*new_row) # automatically inserts a row into the table due to explicit data-binding
6867
6947
  @unfiltered_contacts = @contacts.dup
@@ -6906,6 +6986,12 @@ class FormTable
6906
6986
 
6907
6987
  on_changed do |row, type, row_data|
6908
6988
  puts "Row #{row} #{type}: #{row_data}"
6989
+ $stdout.flush # for Windows
6990
+ end
6991
+
6992
+ on_edited do |row, row_data| # only fires on direct table editing
6993
+ puts "Row #{row} edited: #{row_data}"
6994
+ $stdout.flush # for Windows
6909
6995
  end
6910
6996
  }
6911
6997
  }
@@ -6916,13 +7002,13 @@ end
6916
7002
  FormTable.new.launch
6917
7003
  ```
6918
7004
 
6919
- New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with explicit [data-binding](#data-binding)):
7005
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (with explicit [data-binding](#data-binding)):
6920
7006
 
6921
7007
  ```ruby
6922
7008
  require 'glimmer-dsl-libui'
6923
7009
 
6924
7010
  class FormTable
6925
- Contact = Struct.new(:name, :email, :phone, :city, :state)
7011
+ Contact = Struct.new(:name, :email, :phone, :city, :state_province)
6926
7012
 
6927
7013
  include Glimmer
6928
7014
 
@@ -6939,7 +7025,7 @@ class FormTable
6939
7025
  end
6940
7026
 
6941
7027
  def launch
6942
- window('Contacts', 600, 600) { |w|
7028
+ window('Contacts', 600, 600) {
6943
7029
  margined true
6944
7030
 
6945
7031
  vertical_box {
@@ -6977,8 +7063,8 @@ class FormTable
6977
7063
 
6978
7064
  on_clicked do
6979
7065
  new_row = [name, email, phone, city, state]
6980
- if new_row.include?('')
6981
- msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7066
+ if new_row.map(&:to_s).include?('')
7067
+ msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
6982
7068
  else
6983
7069
  @contacts << Contact.new(*new_row) # automatically inserts a row into the table due to implicit data-binding
6984
7070
  @unfiltered_contacts = @contacts.dup
@@ -7016,13 +7102,19 @@ class FormTable
7016
7102
  text_column('Email')
7017
7103
  text_column('Phone')
7018
7104
  text_column('City')
7019
- text_column('State/Province')
7105
+ text_column('State')
7020
7106
 
7021
7107
  editable true
7022
- cell_rows <=> [self, :contacts, column_attributes: {'State/Province' => :state}] # explicit data-binding to Model Array with column_attributes mapping for a specific column
7108
+ cell_rows <=> [self, :contacts, column_attributes: {'State' => :state_province}] # explicit data-binding to Model Array with column_attributes mapping for a specific column
7023
7109
 
7024
7110
  on_changed do |row, type, row_data|
7025
7111
  puts "Row #{row} #{type}: #{row_data}"
7112
+ $stdout.flush # for Windows
7113
+ end
7114
+
7115
+ on_edited do |row, row_data| # only fires on direct table editing
7116
+ puts "Row #{row} edited: #{row_data}"
7117
+ $stdout.flush # for Windows
7026
7118
  end
7027
7119
  }
7028
7120
  }
@@ -7033,7 +7125,7 @@ end
7033
7125
  FormTable.new.launch
7034
7126
  ```
7035
7127
 
7036
- New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with explicit [data-binding](#data-binding)):
7128
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (with explicit [data-binding](#data-binding)):
7037
7129
 
7038
7130
  ```ruby
7039
7131
 
@@ -7057,7 +7149,7 @@ class FormTable
7057
7149
  end
7058
7150
 
7059
7151
  def launch
7060
- window('Contacts', 600, 600) { |w|
7152
+ window('Contacts', 600, 600) {
7061
7153
  margined true
7062
7154
 
7063
7155
  vertical_box {
@@ -7095,8 +7187,8 @@ class FormTable
7095
7187
 
7096
7188
  on_clicked do
7097
7189
  new_row = [name, email, phone, city, state]
7098
- if new_row.include?('')
7099
- msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7190
+ if new_row.map(&:to_s).include?('')
7191
+ msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7100
7192
  else
7101
7193
  @contacts << Contact.new(*new_row) # automatically inserts a row into the table due to implicit data-binding
7102
7194
  @unfiltered_contacts = @contacts.dup
@@ -7141,6 +7233,12 @@ class FormTable
7141
7233
 
7142
7234
  on_changed do |row, type, row_data|
7143
7235
  puts "Row #{row} #{type}: #{row_data}"
7236
+ $stdout.flush # for Windows
7237
+ end
7238
+
7239
+ on_edited do |row, row_data| # only fires on direct table editing
7240
+ puts "Row #{row} edited: #{row_data}"
7241
+ $stdout.flush # for Windows
7144
7242
  end
7145
7243
  }
7146
7244
  }
@@ -7172,7 +7270,7 @@ class FormTable
7172
7270
  end
7173
7271
 
7174
7272
  def launch
7175
- window('Contacts', 600, 600) { |w|
7273
+ window('Contacts', 600, 600) {
7176
7274
  margined true
7177
7275
 
7178
7276
  vertical_box {
@@ -7210,8 +7308,8 @@ class FormTable
7210
7308
 
7211
7309
  on_clicked do
7212
7310
  new_row = [name, email, phone, city, state]
7213
- if new_row.include?('')
7214
- msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7311
+ if new_row.map(&:to_s).include?('')
7312
+ msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7215
7313
  else
7216
7314
  data << new_row # automatically inserts a row into the table due to implicit data-binding
7217
7315
  @unfiltered_data = data.dup
@@ -7256,6 +7354,12 @@ class FormTable
7256
7354
 
7257
7355
  on_changed do |row, type, row_data|
7258
7356
  puts "Row #{row} #{type}: #{row_data}"
7357
+ $stdout.flush # for Windows
7358
+ end
7359
+
7360
+ on_edited do |row, row_data| # only fires on direct table editing
7361
+ puts "Row #{row} edited: #{row_data}"
7362
+ $stdout.flush # for Windows
7259
7363
  end
7260
7364
  }
7261
7365
  }
@@ -7281,7 +7385,7 @@ data = [
7281
7385
  ['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'],
7282
7386
  ]
7283
7387
 
7284
- window('Contacts', 600, 600) { |w|
7388
+ window('Contacts', 600, 600) {
7285
7389
  margined true
7286
7390
 
7287
7391
  vertical_box {
@@ -7314,8 +7418,8 @@ window('Contacts', 600, 600) { |w|
7314
7418
 
7315
7419
  on_clicked do
7316
7420
  new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
7317
- if new_row.include?('')
7318
- msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7421
+ if new_row.map(&:to_s).include?('')
7422
+ msg_box_error('Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
7319
7423
  else
7320
7424
  data << new_row # automatically inserts a row into the table due to implicit data-binding
7321
7425
  @unfiltered_data = data.dup
@@ -7359,6 +7463,12 @@ window('Contacts', 600, 600) { |w|
7359
7463
 
7360
7464
  on_changed do |row, type, row_data|
7361
7465
  puts "Row #{row} #{type}: #{row_data}"
7466
+ $stdout.flush # for Windows
7467
+ end
7468
+
7469
+ on_edited do |row, row_data| # only fires on direct table editing
7470
+ puts "Row #{row} edited: #{row_data}"
7471
+ $stdout.flush # for Windows
7362
7472
  end
7363
7473
  }
7364
7474
  }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.14
1
+ 0.4.18
data/bin/girb CHANGED
File without changes
@@ -17,7 +17,7 @@ window('Animal sounds', 300, 200) {
17
17
  table {
18
18
  text_column('Animal')
19
19
  text_column('Description')
20
-
20
+
21
21
  cell_rows data
22
22
  }
23
23
  }
@@ -41,7 +41,6 @@ class BasicTableButton
41
41
  end
42
42
  }
43
43
 
44
-
45
44
  cell_rows <= [self, :animals, column_attributes: {'Animal' => :name, 'Description' => :sound}]
46
45
 
47
46
  # explicit unidirectional data-binding of table cell_rows to self.animals
@@ -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")[2].to_i
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?
@@ -21,6 +21,7 @@ class CustomDrawText
21
21
  @string.font = fb.font
22
22
  end
23
23
  }
24
+
24
25
  color_button { |cb|
25
26
  label 'Color'
26
27
 
@@ -28,13 +29,17 @@ class CustomDrawText
28
29
  @string.color = cb.color
29
30
  end
30
31
  }
31
- color_button { |cb|
32
- label 'Background'
33
-
34
- on_changed do
35
- @string.background = cb.color
36
- end
37
- }
32
+
33
+ unless OS.windows?
34
+ color_button { |cb|
35
+ label 'Background'
36
+
37
+ on_changed do
38
+ @string.background = cb.color
39
+ end
40
+ }
41
+ end
42
+
38
43
  combobox { |c|
39
44
  label 'Underline'
40
45
  items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
@@ -44,6 +49,7 @@ class CustomDrawText
44
49
  @string.underline = c.selected_item.underscore
45
50
  end
46
51
  }
52
+
47
53
  combobox { |c|
48
54
  label 'Underline Built-In Color'
49
55
  items Glimmer::LibUI.enum_symbols(:underline_color).map(&:to_s).map(&:capitalize)
@@ -59,6 +65,7 @@ class CustomDrawText
59
65
  end
60
66
  end
61
67
  }
68
+
62
69
  @underline_custom_color_button = color_button {
63
70
  label 'Underline Custom Color'
64
71