glimmer-dsl-libui 0.7.4 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f7eb8d1c417de9910ff49f86592694558a3333f4840971f65be1232adf7408b
4
- data.tar.gz: 9cdf9733b7026aae945ec183ba4551ee2bbe120454c0a094c02a99bd5338069a
3
+ metadata.gz: a51c465651c0e505932930498ce9a827401b91a4d3cd4371a0b8dc58b8da8348
4
+ data.tar.gz: e422609e3e0400f8dc5ad55fd90f40040cc7a30cba33b66813b7adc14ff9b2ce
5
5
  SHA512:
6
- metadata.gz: 5a6c290b75e8301cadd8c837be2612dd4e653192577ea0c8f2493d4fa4a0b7198f2f8008c99d7adeef42320e5b4d86be339b37fe9ca588ee4cc9e22ad36c0a48
7
- data.tar.gz: b51a3e1e878b9adde67cc6670f682df5d7ab09a6678b8b16655fbcb0d5e3770b5119f867ea58c4b025a78e043ed56cd0309f86eccdec0b90d31c19b375a0007b
6
+ metadata.gz: d6bd5b18f925857c9505eef4b36d893ddcfe5b5bcc1203b4581d5cc91f5bd319527d1123584cb7a9730d28693d668fe877d00872afea1f828e08a2cc2fc91ebe
7
+ data.tar.gz: 34e80b9accde5252b992f8d1517f34fc74ca023f5ce7fcfa179bf311426c817cc0c89a863ff58157ea86e0f5c3f92653cbc8d7d7cef2ebaeb8cc3269a4186b27
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.6
4
+
5
+ - Fix issue with hearing "fonk" sound on every key press when handling `on_key_event`/`on_key_down`/`on_key_up` listeners (by returning expected `1` value if the listeners are handled properly or otherwise allowing the "fonk" sound to ring when the listeners are not handled)
6
+ - Update examples/tetris.rb with COMMAND+Q shortcut for quitting on the Mac and ALT+F4 shortcut for quitting on Windows/Linux
7
+
8
+ ## 0.7.5
9
+
10
+ - Fix [issue 46](https://github.com/AndyObtiva/glimmer-dsl-libui/issues/46) (GTK Error rendering table with zero initial elements), which happens when explicitly data-binding table cell_rows to an empty array
11
+
3
12
  ## 0.7.4
4
13
 
5
14
  - `table` `sortable` property (default: `true`) to enable automatic table sorting support when `cell_rows` is an `Array` (does not sort if `cell_rows` is a lazy enumerable)
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.7.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.7.6
2
2
  ## Prerequisite-Free Ruby Desktop Development GUI Library
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
@@ -10,15 +10,15 @@
10
10
 
11
11
  [**(Ruby Rogues Podcast Interview - Desktop Apps in Ruby ft. Andy)**](https://andymaleh.blogspot.com/2022/05/ruby-rogues-podcast-interview-desktop.html)
12
12
 
13
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a prerequisite-free [MRI Ruby](https://www.ruby-lang.org) desktop development GUI (Graphical User Interface) library. No need to pre-install any prerequisites. Just install the [gem](https://rubygems.org/gems/glimmer-dsl-libui) and have platform-independent native GUI that just works!
13
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/libui-ng/libui-ng) is a prerequisite-free [MRI Ruby](https://www.ruby-lang.org) desktop development GUI (Graphical User Interface) library. No need to pre-install any prerequisites. Just install the [gem](https://rubygems.org/gems/glimmer-dsl-libui) and have platform-independent native GUI that just works!
14
14
 
15
15
  Mac | Windows | Linux
16
16
  ----|---------|------
17
17
  ![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png) | ![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png) | ![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
18
18
 
19
- [LibUI](https://github.com/kojix2/LibUI) is a thin [Ruby](https://www.ruby-lang.org/en/) wrapper around [libui](https://github.com/andlabs/libui) (and newer [libui-ng](https://github.com/libui-ng/libui-ng)), a relatively new C GUI library that renders native controls on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
19
+ [LibUI](https://github.com/libui-ng/libui-ng) is a relatively new C GUI library that renders native controls on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
20
20
 
21
- The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) as opposed to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) or [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) is the fact that [SWT](https://www.eclipse.org/swt/) and [Tk](https://www.tcl.tk/) are more mature than mid-alpha [libui-ng](https://github.com/libui-ng/libui-ng) as GUI toolkits. Still, if there is only a need to build a small simple application, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) could be a good convenient choice due to having zero prerequisites beyond the dependencies included in the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui). Also, just like [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk), its apps start instantly and have a small memory footprint. [LibUI](https://github.com/kojix2/LibUI) is a promising new GUI toolkit that might prove quite worthy in the future.
21
+ The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) as opposed to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) or [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) is the fact that [SWT](https://www.eclipse.org/swt/) and [Tk](https://www.tcl.tk/) are more mature than mid-alpha [libui](https://github.com/libui-ng/libui-ng) as GUI toolkits. Still, if there is only a need to build a small simple application, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) could be a good convenient choice due to having zero prerequisites (beyond Ruby and the dependencies included in the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui)). Also, just like [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk), its apps start instantly and have a small memory footprint. [LibUI](https://github.com/kojix2/LibUI) is a promising new GUI toolkit that might prove quite worthy in the future.
22
22
 
23
23
  [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
24
24
  - [Declarative DSL syntax](#glimmer-gui-dsl-concepts) that visually maps to the GUI control hierarchy
@@ -544,7 +544,7 @@ gem install glimmer-dsl-libui
544
544
  Or install via Bundler `Gemfile`:
545
545
 
546
546
  ```ruby
547
- gem 'glimmer-dsl-libui', '~> 0.7.4'
547
+ gem 'glimmer-dsl-libui', '~> 0.7.6'
548
548
  ```
549
549
 
550
550
  Test that installation worked by running the [Meta-Example](#examples):
@@ -763,7 +763,7 @@ Keyword(Args) | Properties | Listeners
763
763
  - `valign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
764
764
 
765
765
  ### Common Control Operations
766
- - `destroy`
766
+ - `destroy` (note that for closing a `window`, in addition to calling `somewindow.destroy`, you also have to call `::LibUI.quit`)
767
767
  - `disable`
768
768
  - `enable`
769
769
  - `hide`
@@ -851,6 +851,11 @@ There are other properties that `table` supports:
851
851
  - `selection` (`Integer` or `Array` of `Integer`s): a single `Integer` row index for `:one` and `:zero_or_one` selection modes, or an `Array` of `Integer` row indexes if selection mode is `:zero_or_many`
852
852
  - `header_visible` (Boolean): shows or hides column headers
853
853
  - `sortable` (Boolean) [default: `true`]: enables automatic table sorting support
854
+ - `on_changed {|row, type, row_data| ...}`: triggered upon a change to a row that happens outside the table in the model
855
+ - `on_edited {|row, row_data| ...}`: triggered upon a change to a row that happens in the table GUI through editing.
856
+ - `on_row_clicked {|table, row| }`: triggered upon clicking a table row
857
+ - `on_row_double_clicked {|table, row| }`: triggered upon double-clicking a table row
858
+ - `on_selection_changed {|table, selection, added_selection, removed_selection| }`: triggered upon selecting a table row
854
859
 
855
860
  To handle `table` sorting manually, the following can be set inside a table column:
856
861
  - `sort_indicator` (`Symbol`): sets sort indicator to ascending or descending with the value being `:ascending`, `:descending`, `:asc`, `:desc`, `:a`, or `:d`
@@ -1942,7 +1947,7 @@ The [Observer Design Pattern](https://en.wikipedia.org/wiki/Observer_pattern) (a
1942
1947
 
1943
1948
  ![MVC - Model View Controller](https://developer.mozilla.org/en-US/docs/Glossary/MVC/model-view-controller-light-blue.png)
1944
1949
 
1945
- [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) supports the [Observer Design Pattern](https://en.wikipedia.org/wiki/Observer_pattern) via the `observe(model, attribute_or_key=nil)` keyword, which can observe `Object` models with attributes, `Hash`es with keys, and `Array`s. It automatically enhances objects as needed to support automatically notifying observers of changes via `observable#notify_observers(attribute_or_key = nil)` method:
1950
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) supports the [Observer Design Pattern](https://en.wikipedia.org/wiki/Observer_pattern) via control listeners in the View layer (e.g. `on_clicked` or `on_closing`) and via the `observe(model, attribute_or_key=nil)` keyword in the Model layer, which can observe `Object` models with attributes, `Hash`es with keys, and `Array`s. It automatically enhances objects as needed to support automatically notifying observers of changes via `observable#notify_observers(attribute_or_key = nil)` method:
1946
1951
  - `Object` becomes `Glimmer::DataBinding::ObservableModel`, which supports observing specified `Object` model attributes.
1947
1952
  - `Hash` becomes `Glimmer::DataBinding::ObservableHash`, which supports observing all `Hash` keys or a specific `Hash` key
1948
1953
  - `Array` becomes `Glimmer::DataBinding::ObservableArray`, which supports observing `Array` changes like those done with `push`, `<<`, `delete`, and `map!` methods (all mutation methods).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.4
1
+ 0.7.6
@@ -1506,6 +1506,8 @@ Mac | Windows | Linux
1506
1506
 
1507
1507
  ## Basic Table Selection
1508
1508
 
1509
+ [examples/basic_table_selection.rb](/examples/basic_table_selection.rb)
1510
+
1509
1511
  Run with this command from the root of the project if you cloned the project:
1510
1512
 
1511
1513
  ```
@@ -1524,14 +1526,18 @@ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_selection'"
1524
1526
  ![glimmer-dsl-libui-mac-basic-table-selection-none.png](/images/glimmer-dsl-libui-mac-basic-table-selection-none.png)
1525
1527
  ![glimmer-dsl-libui-mac-basic-table-selection-header-not-visible.png](/images/glimmer-dsl-libui-mac-basic-table-selection-header-not-visible.png)
1526
1528
 
1527
- Version 1 (without data-binding):
1529
+ Version 1 (automatic sorting and data-binding):
1528
1530
 
1529
1531
  [examples/basic_table_selection.rb](/examples/basic_table_selection.rb)
1530
1532
 
1531
- Version 2 (with data-binding):
1533
+ Version 2 (custom sorting and data-binding):
1532
1534
 
1533
1535
  [examples/basic_table_selection2.rb](/examples/basic_table_selection2.rb)
1534
1536
 
1537
+ Version 3 (custom sorting without data-binding):
1538
+
1539
+ [examples/basic_table_selection3.rb](/examples/basic_table_selection3.rb)
1540
+
1535
1541
  ## Basic Area
1536
1542
 
1537
1543
  [examples/basic_area.rb](/examples/basic_area.rb)
data/examples/tetris.rb CHANGED
@@ -292,6 +292,10 @@ class Tetris
292
292
  @game.rotate!(:right)
293
293
  in modifier: :control
294
294
  @game.rotate!(:left)
295
+ in modifiers: [:command], key: 'q'
296
+ exit(0) if OS.mac?
297
+ in modifiers: [:alt], ext_key: :f4
298
+ exit(0) unless OS.mac?
295
299
  else
296
300
  # Do Nothing
297
301
  end
Binary file
@@ -179,7 +179,7 @@ module Glimmer
179
179
  @area_handler.DragBroken = fiddle_closure_block_caller(0, [1, 1]) do |_, _|
180
180
  notify_custom_listeners('on_drag_broken')
181
181
  end
182
- @area_handler.KeyEvent = fiddle_closure_block_caller(0, [1, 1, 1]) do |_, _, area_key_event|
182
+ @area_handler.KeyEvent = fiddle_closure_block_caller(1, [1, 1, 1]) do |_, _, area_key_event|
183
183
  area_key_event = ::LibUI::FFI::AreaKeyEvent.new(area_key_event)
184
184
  area_key_event = area_key_event_hash(area_key_event)
185
185
  notify_custom_listeners('on_key_event', area_key_event)
@@ -188,6 +188,11 @@ module Glimmer
188
188
  else
189
189
  notify_custom_listeners('on_key_down', area_key_event)
190
190
  end
191
+ if handle_custom_listener('on_key_event').any? || handle_custom_listener('on_key_up').any? || handle_custom_listener('on_key_down').any?
192
+ 1
193
+ else
194
+ 0
195
+ end
191
196
  end
192
197
  @listeners_installed = true
193
198
  end
@@ -221,13 +226,14 @@ module Glimmer
221
226
 
222
227
  def area_key_event_hash(area_key_event)
223
228
  modifiers = modifiers_to_symbols(area_key_event.Modifiers)
229
+ modifier = modifiers_to_symbols(area_key_event.Modifier).first
224
230
  {
225
231
  key: key_to_char(area_key_event.Key, modifiers),
226
232
  key_value: area_key_event.Key,
227
233
  key_code: area_key_event.Key,
228
234
  ext_key: ext_key_to_symbol(area_key_event.ExtKey),
229
235
  ext_key_value: area_key_event.ExtKey,
230
- modifier: modifiers_to_symbols(area_key_event.Modifier).first,
236
+ modifier: modifier,
231
237
  modifiers: modifiers,
232
238
  up: Glimmer::LibUI.integer_to_boolean(area_key_event.Up),
233
239
  }
@@ -634,6 +634,7 @@ module Glimmer
634
634
  end
635
635
  end
636
636
  @cell_rows_observer_registration = @cell_rows_observer.observe(self, :cell_rows, recursive: true, ignore_frozen: true, attribute_writer_type: [:attribute=, :set_attribute])
637
+ @cell_rows_observer.call
637
638
  end
638
639
 
639
640
  def apply_windows_fix
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-22 00:00:00.000000000 Z
11
+ date: 2023-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -567,7 +567,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
567
567
  - !ruby/object:Gem::Version
568
568
  version: '0'
569
569
  requirements: []
570
- rubygems_version: 3.3.16
570
+ rubygems_version: 3.3.1
571
571
  signing_key:
572
572
  specification_version: 4
573
573
  summary: Glimmer DSL for LibUI