glimmer-dsl-libui 0.5.13 → 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: 3ec966c5f1dcd6315fe94455e2a8257df7ed6274ada0d74419e53b9abeab99bb
4
- data.tar.gz: 5f1f410e8a239735c1188d4a7bdad00f9fed6e34ba71ba5c2ac65f01b8f49037
3
+ metadata.gz: ff8ac26765985f2d93ed15a035403682dde9010f50af001cd55c0215f3128745
4
+ data.tar.gz: 243cf87d1941e447b794c5997b7695aa7ab5b87cb64e395ccaba2e28a6d7d923
5
5
  SHA512:
6
- metadata.gz: 574718284c8933f27d088777e9ffd77a37922f3f51ec90e85026f1d86f572c84bea4d86141fc3b67bb5192769ac03e13dca791b3ce6b8d2ae88235008ba4cbcf
7
- data.tar.gz: 87656800ed048be0ffc15520e5988b911fac60bcdb73db16fd962e5820d2d2c948a08a14c1c22aaef4543623d8f2c803c7d10e0c106bc40c13942bddaf83cfda
6
+ metadata.gz: c916c2ba39da007082665789575009dc9e8140bd1910d512f15fccacaf4636143de2bc890fa77d6af1a91a4a7eba2cb938173005ac1a5b6f915837bc1005da11
7
+ data.tar.gz: 9b82de74cfd12131ef5d09429276b360d3c910b580323f98907b68e9e462d7996d84bfb0a4fd75bdc9fce06326b1b76ff3f8b8e65a21d920a57b167a1758ddd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.5.13
4
10
 
5
11
  - Fix issue with rendering table content changes when having many rows
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.13
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)
@@ -435,6 +436,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
435
436
  - [i3off Gtk Ruby](#i3off-gtk-ruby)
436
437
  - [Chess](#chess)
437
438
  - [RubyCrumbler](#rubycrumbler)
439
+ - [Rubio-Radio](#rubio-radio)
438
440
  - [Process](#process)
439
441
  - [Resources](#resources)
440
442
  - [Help](#help)
@@ -581,7 +583,7 @@ gem install glimmer-dsl-libui
581
583
  Or install via Bundler `Gemfile`:
582
584
 
583
585
  ```ruby
584
- gem 'glimmer-dsl-libui', '~> 0.5.13'
586
+ gem 'glimmer-dsl-libui', '~> 0.5.14'
585
587
  ```
586
588
 
587
589
  Test that installation worked by running the [Meta-Example](#examples):
@@ -1615,8 +1617,7 @@ SpinnerExample.new.launch
1615
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)
1616
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)
1617
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`)
1618
- - `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 `1` for closing and `0` for remaining open). When creating/showing a child window other than the main window and then closing it, the entire app closes by default unless you implement an `on_closing` listener on the secondary child window that returns `1` at the end.
1619
-
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).
1620
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'; ...}`)
1621
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'}}`)
1622
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)
@@ -1905,7 +1906,7 @@ Learn more from custom keyword usage in [Method-Based Custom Keyword](#method-ba
1905
1906
 
1906
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.
1907
1908
 
1908
- ![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)
1909
1910
 
1910
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:
1911
1912
  - `Object` becomes `Glimmer::DataBinding::ObservableModel`, which supports observing specified `Object` model attributes.
@@ -1936,7 +1937,7 @@ Data-binding automatically takes advantage of the [Observer Pattern](#observer-p
1936
1937
 
1937
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).
1938
1939
 
1939
- ![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)
1940
1941
 
1941
1942
  #### Bidirectional (Two-Way) Data-Binding
1942
1943
 
@@ -2643,6 +2644,50 @@ window { # first 3 args can be set via properties with 4th arg has_menubar=true
2643
2644
  }.show
2644
2645
  ```
2645
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
+
2646
2691
  #### Basic Button
2647
2692
 
2648
2693
  [examples/basic_button.rb](examples/basic_button.rb)
@@ -11239,6 +11284,12 @@ MacOS | Windows | Linux
11239
11284
  | :---: | :---: | :---:
11240
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)
11241
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
+
11242
11293
  ## Process
11243
11294
 
11244
11295
  [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.13
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
@@ -304,32 +304,36 @@ module Glimmer
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
306
  @last_cell_rows.each_with_index do |old_row_data, row|
307
- if old_row_data != @cell_rows[row]
308
- ::LibUI.table_model_row_changed(model, row) if model && row
307
+ if old_row_data != @cell_rows[row] && model
308
+ ::LibUI.table_model_row_changed(model, row)
309
309
  notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
310
310
  end
311
311
  end
312
312
  (@last_cell_rows.size - @cell_rows.size).times do |n|
313
313
  row = @last_cell_rows.size - n - 1
314
- ::LibUI.table_model_row_deleted(model, row) if model && row
315
- notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
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
316
318
  end
317
319
  elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
318
320
  (@cell_rows.size - @last_cell_rows.size).times do |n|
319
321
  row = @last_cell_rows.size + n
320
- ::LibUI.table_model_row_inserted(model, row) if model && row
321
- notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
322
+ if model
323
+ ::LibUI.table_model_row_inserted(model, row)
324
+ notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
325
+ end
322
326
  end
323
327
  @cell_rows.each_with_index do |new_row_data, row|
324
- if new_row_data != @last_cell_rows[row]
325
- ::LibUI.table_model_row_changed(model, row) if model && row
328
+ if new_row_data != @last_cell_rows[row] && model
329
+ ::LibUI.table_model_row_changed(model, row)
326
330
  notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
327
331
  end
328
332
  end
329
333
  elsif @cell_rows != @last_cell_rows
330
334
  @cell_rows.each_with_index do |new_row_data, row|
331
- if new_row_data != @last_cell_rows[row]
332
- ::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)
333
337
  notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
334
338
  end
335
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.13
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-06-17 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
@@ -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.3
515
+ rubygems_version: 3.3.16
515
516
  signing_key:
516
517
  specification_version: 4
517
518
  summary: Glimmer DSL for LibUI