glimmer-dsl-libui 0.5.11 → 0.5.14

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: edec94cbcdfb5f8766a7b04c6c19719a8525d971349db5c3f2989b762cee2c56
4
- data.tar.gz: 60706b17b64dd6660a14dc46e31ec16039daa3074e4f3e3561061d20898271ff
3
+ metadata.gz: ff8ac26765985f2d93ed15a035403682dde9010f50af001cd55c0215f3128745
4
+ data.tar.gz: 243cf87d1941e447b794c5997b7695aa7ab5b87cb64e395ccaba2e28a6d7d923
5
5
  SHA512:
6
- metadata.gz: e08e7c05b971f6ff16213dbdf14f8809fe45aa8f8d8b2ba563468eaf2eb14867a6cce4552fe4ae897e2a475b19b59f8179eb18864f15981db3c55bbe2dddd724
7
- data.tar.gz: a96f5e238962f5998385046af93b2b5f101612e3626be7261de9373f7e106dd03fab044afe9bb2b5a7130f2b6e90ce900551a9ad209cddeb1fd2df59065edfca
6
+ metadata.gz: c916c2ba39da007082665789575009dc9e8140bd1910d512f15fccacaf4636143de2bc890fa77d6af1a91a4a7eba2cb938173005ac1a5b6f915837bc1005da11
7
+ data.tar.gz: 9b82de74cfd12131ef5d09429276b360d3c910b580323f98907b68e9e462d7996d84bfb0a4fd75bdc9fce06326b1b76ff3f8b8e65a21d920a57b167a1758ddd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.5.14
4
+
5
+ - Basic Child Window example
6
+ - Modify default window closing behavior to autodetect if the window is a child window (not the main window), and if closed, ensure that does not quit the app.
7
+ - Accept `true` and `false` as return values for `on_closing` window listener as aliases to `1` and `0`
8
+
9
+ ## 0.5.13
10
+
11
+ - Fix issue with rendering table content changes when having many rows
12
+
13
+ ## 0.5.12
14
+
15
+ - Upgrade `perfect-shape` gem to 1.0.5 to address Ruby 3.1 issue with `matrix` gem getting extracted from Ruby into a bundled gem
16
+
3
17
  ## 0.5.11
4
18
 
5
19
  - Upgrade to perfect-shape 1.0.4
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.5.11
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.5.14
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)
@@ -385,6 +385,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
385
385
  - [Examples](#examples)
386
386
  - [Basic Examples](#basic-examples)
387
387
  - [Basic Window](#basic-window)
388
+ - [Basic Child Window](#basic-child-window)
388
389
  - [Basic Button](#basic-button)
389
390
  - [Basic Entry](#basic-entry)
390
391
  - [Simple Notepad](#simple-notepad)
@@ -433,6 +434,9 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
433
434
  - [Manga2PDF](#manga2pdf)
434
435
  - [Befunge98 GUI](#befunge98-gui)
435
436
  - [i3off Gtk Ruby](#i3off-gtk-ruby)
437
+ - [Chess](#chess)
438
+ - [RubyCrumbler](#rubycrumbler)
439
+ - [Rubio-Radio](#rubio-radio)
436
440
  - [Process](#process)
437
441
  - [Resources](#resources)
438
442
  - [Help](#help)
@@ -579,7 +583,7 @@ gem install glimmer-dsl-libui
579
583
  Or install via Bundler `Gemfile`:
580
584
 
581
585
  ```ruby
582
- gem 'glimmer-dsl-libui', '~> 0.5.11'
586
+ gem 'glimmer-dsl-libui', '~> 0.5.14'
583
587
  ```
584
588
 
585
589
  Test that installation worked by running the [Meta-Example](#examples):
@@ -1613,7 +1617,7 @@ SpinnerExample.new.launch
1613
1617
  - 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)
1614
1618
  - 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)
1615
1619
  - `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`)
1616
- - `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)
1620
+ - `window` has an `on_closing` listener by default that quits application upon hitting close button if window is the main window, not a child window (the behavior can be overridden with a manual `on_closing` implementation that returns integer `1`/`true` for closing and `0`/`false` for remaining open).
1617
1621
  - `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'; ...}`)
1618
1622
  - `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'}}`)
1619
1623
  - `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)
@@ -1902,7 +1906,7 @@ Learn more from custom keyword usage in [Method-Based Custom Keyword](#method-ba
1902
1906
 
1903
1907
  The [Observer Design Pattern](https://en.wikipedia.org/wiki/Observer_pattern) (a.k.a. Observer Pattern) is fundamental to building GUIs (Graphical User Interfaces) following the [MVC (Model View Controller) Architectural Pattern](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) or any of its variations like [MVP (Model View Presenter)](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter). In the original Smalltalk-MVC, the View observes the Model for changes and updates itself accordingly.
1904
1908
 
1905
- ![MVC - Model View Controller](https://www.researchgate.net/profile/Danny-Weyns/publication/269303611/figure/fig2/AS:858133056462866@1581606272800/Smalltalk80-MVC-pattern-View-and-Controller-work-as-a-pair-allowing-the-user-to-interact.ppm)
1909
+ ![MVC - Model View Controller](https://developer.mozilla.org/en-US/docs/Glossary/MVC/model-view-controller-light-blue.png)
1906
1910
 
1907
1911
  [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:
1908
1912
  - `Object` becomes `Glimmer::DataBinding::ObservableModel`, which supports observing specified `Object` model attributes.
@@ -1933,7 +1937,7 @@ Data-binding automatically takes advantage of the [Observer Pattern](#observer-p
1933
1937
 
1934
1938
  Data-binding supports utilizing the [MVP (Model View Presenter)](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter) flavor of [MVC](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) by observing both the View and a Presenter for changes and updating the opposite side upon encountering them. This enables writing more decoupled cleaner code that keeps View code and Model code disentangled and highly maintainable. For example, check out the Snake game presenters for [Grid](/examples/snake/presenter/grid.rb) and [Cell](/examples/snake/presenter/cell.rb), which act as proxies for the actual Snake game models [Snake](/examples/snake/model/snake.rb) and [Apple](/examples/snake/model/apple.rb), mediating synchronization of data between them and the [Snake View GUI](/examples/snake.rb).
1935
1939
 
1936
- ![MVP](https://www.researchgate.net/profile/Gilles-Perrouin/publication/320249584/figure/fig8/AS:668260987068418@1536337243385/Model-view-presenter-architecture.png)
1940
+ ![MVP](https://upload.wikimedia.org/wikipedia/commons/d/dc/Model_View_Presenter_GUI_Design_Pattern.png)
1937
1941
 
1938
1942
  #### Bidirectional (Two-Way) Data-Binding
1939
1943
 
@@ -2201,7 +2205,6 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
2201
2205
  - There is no proper way to destroy `grid` children due to [libui](https://github.com/andlabs/libui) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`).
2202
2206
  - `table` `checkbox_column` checkbox editing only works on Linux and Windows (not Mac) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
2203
2207
  - `table` `checkbox_text_column` checkbox editing only works on Linux (not Mac or Windows) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
2204
- - `checkbox` only supports obtaining the `checked` property, but not updating it due to a current limitation in [libui](https://github.com/andlabs/libui).
2205
2208
  - `text` `align` property seems not to work on the Mac ([libui](https://github.com/andlabs/libui) has an [issue](https://github.com/andlabs/libui/pull/407) about it)
2206
2209
  - `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
2207
2210
  - `table` `progress_bar` column on Windows cannot be updated with a positive value if it started initially with `-1` (it ignores update to avoid crashing due to an issue in [libui](https://github.com/andlabs/libui) on Windows.
@@ -2209,7 +2212,6 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
2209
2212
  - It seems that [libui](https://github.com/andlabs/libui) does not support nesting multiple `area` controls under a `grid` as only the first one shows up in that scenario. To workaround that limitation, use a `vertical_box` with nested `horizontal_box`s instead to include multiple `area`s in a GUI.
2210
2213
  - As per the code of [examples/basic_transform.rb](#basic-transform), Windows requires different ordering of transforms than Mac and Linux.
2211
2214
  - `scrolling_area#scroll_to` does not seem to work on Windows and Linux, but works fine on Mac
2212
- - When creating/showing a window other than the main window and then closing the secondary window, the entire app closes. This is a current limitation to the windowing system that should be fixed with [child window support](https://github.com/andlabs/libui/issues/137) in [libui](https://github.com/andlabs/libui)
2213
2215
 
2214
2216
  ### Original API
2215
2217
 
@@ -2642,6 +2644,50 @@ window { # first 3 args can be set via properties with 4th arg has_menubar=true
2642
2644
  }.show
2643
2645
  ```
2644
2646
 
2647
+ #### Basic Child Window
2648
+
2649
+ [examples/basic_child_window.rb](examples/basic_child_window.rb)
2650
+
2651
+ Run with this command from the root of the project if you cloned the project:
2652
+
2653
+ ```
2654
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_child_window.rb
2655
+ ```
2656
+
2657
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2658
+
2659
+ ```
2660
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_child_window.rb'"
2661
+ ```
2662
+
2663
+ Mac | Windows | Linux
2664
+ ----|---------|------
2665
+ ![glimmer-dsl-libui-mac-basic-child-window.png](images/glimmer-dsl-libui-mac-basic-child-window.png) ![glimmer-dsl-libui-mac-basic-child-window-open.png](images/glimmer-dsl-libui-mac-basic-child-window-open.png) | ![glimmer-dsl-libui-windows-basic-child-window.png](images/glimmer-dsl-libui-windows-basic-child-window.png) ![glimmer-dsl-libui-windows-basic-child-window-open.png](images/glimmer-dsl-libui-windows-basic-child-window-open.png) | ![glimmer-dsl-libui-linux-basic-child-window.png](images/glimmer-dsl-libui-linux-basic-child-window.png) ![glimmer-dsl-libui-linux-basic-child-window-open.png](images/glimmer-dsl-libui-linux-basic-child-window-open.png)
2666
+
2667
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2668
+
2669
+ ```ruby
2670
+ require 'glimmer-dsl-libui'
2671
+
2672
+ include Glimmer
2673
+
2674
+ window('Main Window') {
2675
+ button('Spawn Child Window') {
2676
+ on_clicked do
2677
+ window('Child Window') {
2678
+ on_closing do
2679
+ puts 'Child window is closing'
2680
+ end
2681
+ }.show
2682
+ end
2683
+ }
2684
+
2685
+ on_closing do
2686
+ puts 'Main window is closing'
2687
+ end
2688
+ }.show
2689
+ ```
2690
+
2645
2691
  #### Basic Button
2646
2692
 
2647
2693
  [examples/basic_button.rb](examples/basic_button.rb)
@@ -11228,6 +11274,22 @@ https://github.com/iraamaro/i3off-gtk-ruby
11228
11274
 
11229
11275
  https://github.com/mikeweber/chess
11230
11276
 
11277
+ ### RubyCrumbler
11278
+
11279
+ NLP (Natural Language Processing) App
11280
+
11281
+ https://github.com/joh-ga/RubyCrumbler
11282
+
11283
+ MacOS | Windows | Linux
11284
+ | :---: | :---: | :---:
11285
+ ![mac_31](https://user-images.githubusercontent.com/72874215/159339948-b7ae1bf2-60c1-4dae-ac1a-4e13a6048ef0.gif)|![windows_4](https://user-images.githubusercontent.com/72874215/160242473-c38439be-0955-4e89-9f3f-b3d0567531fd.gif)|![rubycrumbler_linux](https://user-images.githubusercontent.com/72874215/160242460-99af1c8c-b43f-458d-bd69-1274a0bd9814.gif)
11286
+
11287
+ ### Rubio-Radio
11288
+
11289
+ https://github.com/kojix2/rubio-radio
11290
+
11291
+ ![rubio radio screenshot](https://user-images.githubusercontent.com/5798442/171986696-24bedc38-3811-4c62-a5ad-89c09d015c8a.png)
11292
+
11231
11293
  ## Process
11232
11294
 
11233
11295
  [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
@@ -11261,6 +11323,8 @@ These features have been planned or suggested. You might see them in a future ve
11261
11323
 
11262
11324
  ## Contributing
11263
11325
 
11326
+ If you would like to contribute to the project, please adhere to the [Open-Source Etiquette](https://github.com/AndyObtiva/open-source-etiquette) to ensure the best results.
11327
+
11264
11328
  - Check out the latest master to make sure the feature hasn't been
11265
11329
  implemented or the bug hasn't been fixed yet.
11266
11330
  - Check out the issue tracker to make sure someone already hasn't
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.11
1
+ 0.5.14
@@ -0,0 +1,19 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ include Glimmer
4
+
5
+ window('Main Window') {
6
+ button('Spawn Child Window') {
7
+ on_clicked do
8
+ window('Child Window') {
9
+ on_closing do
10
+ puts 'Child window is closing'
11
+ end
12
+ }.show
13
+ end
14
+ }
15
+
16
+ on_closing do
17
+ puts 'Main window is closing'
18
+ end
19
+ }.show
Binary file
@@ -303,19 +303,37 @@ module Glimmer
303
303
  def register_cell_rows_observer
304
304
  @cell_rows_observer = Glimmer::DataBinding::Observer.proc do |new_cell_rows|
305
305
  if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
306
- @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
307
- ::LibUI.table_model_row_deleted(model, row) if model && row
308
- notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
306
+ @last_cell_rows.each_with_index do |old_row_data, row|
307
+ if old_row_data != @cell_rows[row] && model
308
+ ::LibUI.table_model_row_changed(model, row)
309
+ notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
310
+ end
311
+ end
312
+ (@last_cell_rows.size - @cell_rows.size).times do |n|
313
+ row = @last_cell_rows.size - n - 1
314
+ if model
315
+ ::LibUI.table_model_row_deleted(model, row)
316
+ notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
317
+ end
309
318
  end
310
319
  elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
311
- @cell_rows.array_diff_indexes(@last_cell_rows).each do |row|
312
- ::LibUI.table_model_row_inserted(model, row) if model && row
313
- notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
320
+ (@cell_rows.size - @last_cell_rows.size).times do |n|
321
+ row = @last_cell_rows.size + n
322
+ if model
323
+ ::LibUI.table_model_row_inserted(model, row)
324
+ notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
325
+ end
326
+ end
327
+ @cell_rows.each_with_index do |new_row_data, row|
328
+ if new_row_data != @last_cell_rows[row] && model
329
+ ::LibUI.table_model_row_changed(model, row)
330
+ notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
331
+ end
314
332
  end
315
- else
333
+ elsif @cell_rows != @last_cell_rows
316
334
  @cell_rows.each_with_index do |new_row_data, row|
317
- if new_row_data != @last_cell_rows[row]
318
- ::LibUI.table_model_row_changed(model, row) if model && row
335
+ if new_row_data != @last_cell_rows[row] && model
336
+ ::LibUI.table_model_row_changed(model, row)
319
337
  notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
320
338
  end
321
339
  end
@@ -80,10 +80,14 @@ module Glimmer
80
80
  return_value = nil
81
81
  @on_closing_listeners.each do |l|
82
82
  return_value = l.call(self)
83
- break if return_value.is_a?(Numeric)
83
+ break if return_value.is_a?(Numeric) || return_value.is_a?(TrueClass) || return_value.is_a?(FalseClass)
84
84
  end
85
85
  if return_value.is_a?(Numeric)
86
86
  return_value
87
+ elsif return_value.is_a?(TrueClass) || return_value.is_a?(FalseClass)
88
+ return_value ? 1 : 0
89
+ elsif self != ControlProxy.main_window_proxy
90
+ 1
87
91
  else
88
92
  destroy
89
93
  ::LibUI.quit
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.5.11
4
+ version: 0.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-21 00:00:00.000000000 Z
11
+ date: 2022-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.4
33
+ version: 1.0.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.4
40
+ version: 1.0.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: super_module
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -285,6 +285,7 @@ files:
285
285
  - examples/basic_area3.rb
286
286
  - examples/basic_area4.rb
287
287
  - examples/basic_button.rb
288
+ - examples/basic_child_window.rb
288
289
  - examples/basic_code_area.rb
289
290
  - examples/basic_draw_text.rb
290
291
  - examples/basic_draw_text2.rb
@@ -511,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
511
512
  - !ruby/object:Gem::Version
512
513
  version: '0'
513
514
  requirements: []
514
- rubygems_version: 3.3.1
515
+ rubygems_version: 3.3.16
515
516
  signing_key:
516
517
  specification_version: 4
517
518
  summary: Glimmer DSL for LibUI