glimmer-dsl-libui 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +66 -16
- data/VERSION +1 -1
- data/examples/color_button.rb +18 -13
- data/examples/color_button2.rb +14 -0
- data/examples/font_button.rb +17 -12
- data/examples/font_button2.rb +18 -0
- data/examples/histogram.rb +1 -6
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +5 -0
- data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +4 -0
- data/lib/glimmer/libui/control_proxy/slider_proxy.rb +38 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f52b21e108a75ec59b380fa0d84cd116bb47423877575486ee5bc2647d7953
|
4
|
+
data.tar.gz: 2d7d9ab30e81bd1eb846dca3bddeb79509dab1e641c38b44d5d31914679ab49c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d90045f52bd836fc18ff4aff2bc096302101651bc006a144af9f80563e171ecd4d236e85ebbb064b53374a61946185fa9aef0946b493b0ca1df967670629ac5e
|
7
|
+
data.tar.gz: 491694ae1ccdbbb5b4c7e0e3bfa30beee648f9a579dfaaa13b35ee583a6551967c441078fa83857c0e886a2991662d83d952f79b73a39e27769262c0c77b822e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.6
|
4
|
+
|
5
|
+
- Support `slider` `value` bidirectional data-binding (with `<=>` sign)
|
6
|
+
- Support `color_button` `color` bidirectional data-binding (with `<=>` sign)
|
7
|
+
- Support `font_button` `font` write-only unidirectional data-binding (with `<=>` sign)
|
8
|
+
- Improve examples/color_button.rb with bidirectional data-binding for `color_button` `color`
|
9
|
+
- Improve examples/histogram.rb with bidirectional data-binding for `color_button` `color`
|
10
|
+
- Improve examples/font_button.rb with bidirectional data-binding for `font_button` `font`
|
11
|
+
|
3
12
|
## 0.4.5
|
4
13
|
|
5
14
|
- Support `spinbox` `value` bidirectional data-binding (with `<=>` sign)
|
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.6
|
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)
|
@@ -373,7 +373,7 @@ gem install glimmer-dsl-libui
|
|
373
373
|
Or install via Bundler `Gemfile`:
|
374
374
|
|
375
375
|
```ruby
|
376
|
-
gem 'glimmer-dsl-libui', '~> 0.4.
|
376
|
+
gem 'glimmer-dsl-libui', '~> 0.4.6'
|
377
377
|
```
|
378
378
|
|
379
379
|
Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
|
@@ -1382,11 +1382,14 @@ Data-binding supports utilizing the [MVP (Model View Presenter)](https://en.wiki
|
|
1382
1382
|
![MVP](https://www.researchgate.net/profile/Gilles-Perrouin/publication/320249584/figure/fig8/AS:668260987068418@1536337243385/Model-view-presenter-architecture.png)
|
1383
1383
|
|
1384
1384
|
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) supports bidirectional (two-way) data-binding of the following controls/properties via the `<=>` operator (indicating data is moving in both directions between View and Model):
|
1385
|
-
- `
|
1386
|
-
- `
|
1387
|
-
- `
|
1388
|
-
- `
|
1389
|
-
- `
|
1385
|
+
- `color_button`: `color`
|
1386
|
+
- `entry`: `text`
|
1387
|
+
- `font_button`: `font`
|
1388
|
+
- `multiline_entry`: `text`
|
1389
|
+
- `non_wrapping_multiline_entry`: `text`
|
1390
|
+
- `search_entry`: `text`
|
1391
|
+
- `slider`: `value`
|
1392
|
+
- `spinbox`: `value`
|
1390
1393
|
|
1391
1394
|
Example of bidirectional data-binding:
|
1392
1395
|
|
@@ -1875,7 +1878,7 @@ Example:
|
|
1875
1878
|
|
1876
1879
|
## Examples
|
1877
1880
|
|
1878
|
-
The following examples include reimplementions of the examples in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) as well as brand new examples.
|
1881
|
+
The following examples include reimplementions of the examples in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) (with and without data-binding) as well as brand new examples.
|
1879
1882
|
|
1880
1883
|
To browse all examples, simply launch the [Meta-Example](examples/meta_example.rb), which lists all examples and displays each example's code when selected. It also enables code editing to facilitate experimentation and learning.
|
1881
1884
|
|
@@ -2490,7 +2493,33 @@ UI.quit
|
|
2490
2493
|
|
2491
2494
|
```
|
2492
2495
|
|
2493
|
-
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2496
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with [data-binding](#data-binding)):
|
2497
|
+
|
2498
|
+
```ruby
|
2499
|
+
require 'glimmer-dsl-libui'
|
2500
|
+
|
2501
|
+
class FontButton
|
2502
|
+
include Glimmer
|
2503
|
+
|
2504
|
+
attr_accessor :font_descriptor
|
2505
|
+
|
2506
|
+
def launch
|
2507
|
+
window('hello world', 300, 200) {
|
2508
|
+
font_button {
|
2509
|
+
font <=> [self, :font_descriptor, after_write: -> { p font_descriptor }]
|
2510
|
+
}
|
2511
|
+
|
2512
|
+
on_closing do
|
2513
|
+
puts 'Bye Bye'
|
2514
|
+
end
|
2515
|
+
}.show
|
2516
|
+
end
|
2517
|
+
end
|
2518
|
+
|
2519
|
+
FontButton.new.launch
|
2520
|
+
```
|
2521
|
+
|
2522
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (without [data-binding](#data-binding)):
|
2494
2523
|
|
2495
2524
|
```ruby
|
2496
2525
|
require 'glimmer-dsl-libui'
|
@@ -2531,7 +2560,33 @@ Mac | Windows | Linux
|
|
2531
2560
|
----|---------|------
|
2532
2561
|
![glimmer-dsl-libui-mac-color-button.png](images/glimmer-dsl-libui-mac-color-button.png) ![glimmer-dsl-libui-mac-color-button-selection.png](images/glimmer-dsl-libui-mac-color-button-selection.png) | ![glimmer-dsl-libui-windows-color-button.png](images/glimmer-dsl-libui-windows-color-button.png) ![glimmer-dsl-libui-windows-color-button-selection.png](images/glimmer-dsl-libui-windows-color-button-selection.png) | ![glimmer-dsl-libui-linux-color-button.png](images/glimmer-dsl-libui-linux-color-button.png) ![glimmer-dsl-libui-linux-color-button-selection.png](images/glimmer-dsl-libui-linux-color-button-selection.png)
|
2533
2562
|
|
2534
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2563
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with [data-binding](#data-binding)):
|
2564
|
+
|
2565
|
+
```ruby
|
2566
|
+
require 'glimmer-dsl-libui'
|
2567
|
+
|
2568
|
+
class ColorButton
|
2569
|
+
include Glimmer
|
2570
|
+
|
2571
|
+
attr_accessor :selected_color
|
2572
|
+
|
2573
|
+
def initialize
|
2574
|
+
@selected_color = :blue
|
2575
|
+
end
|
2576
|
+
|
2577
|
+
def launch
|
2578
|
+
window('color button', 240) {
|
2579
|
+
color_button {
|
2580
|
+
color <=> [self, :selected_color, after_write: ->(color) {p color}]
|
2581
|
+
}
|
2582
|
+
}.show
|
2583
|
+
end
|
2584
|
+
end
|
2585
|
+
|
2586
|
+
ColorButton.new.launch
|
2587
|
+
```
|
2588
|
+
|
2589
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (without [data-binding](#data-binding)):
|
2535
2590
|
|
2536
2591
|
```ruby
|
2537
2592
|
require 'glimmer-dsl-libui'
|
@@ -6975,12 +7030,7 @@ class Histogram
|
|
6975
7030
|
|
6976
7031
|
color_button { |cb|
|
6977
7032
|
stretchy false
|
6978
|
-
color
|
6979
|
-
|
6980
|
-
on_changed do
|
6981
|
-
@histogram_color = cb.color
|
6982
|
-
@area.queue_redraw_all
|
6983
|
-
end
|
7033
|
+
color <=> [self, :histogram_color, after_write: -> { @area.queue_redraw_all }]
|
6984
7034
|
}
|
6985
7035
|
}
|
6986
7036
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.6
|
data/examples/color_button.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
|
5
|
-
|
3
|
+
class ColorButton
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
attr_accessor :selected_color
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@selected_color = :blue
|
10
|
+
end
|
11
|
+
|
12
|
+
def launch
|
13
|
+
window('color button', 240) {
|
14
|
+
color_button {
|
15
|
+
color <=> [self, :selected_color, after_write: ->(color) {p color}]
|
16
|
+
}
|
17
|
+
}.show
|
18
|
+
end
|
19
|
+
end
|
6
20
|
|
7
|
-
|
8
|
-
color_button { |cb|
|
9
|
-
color :blue
|
10
|
-
|
11
|
-
on_changed do
|
12
|
-
rgba = cb.color
|
13
|
-
p rgba
|
14
|
-
end
|
15
|
-
}
|
16
|
-
}.show
|
21
|
+
ColorButton.new.launch
|
data/examples/font_button.rb
CHANGED
@@ -2,17 +2,22 @@
|
|
2
2
|
|
3
3
|
require 'glimmer-dsl-libui'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
on_changed do
|
10
|
-
font_descriptor = fb.font
|
11
|
-
p font_descriptor
|
12
|
-
end
|
13
|
-
}
|
5
|
+
class FontButton
|
6
|
+
include Glimmer
|
7
|
+
|
8
|
+
attr_accessor :font_descriptor
|
14
9
|
|
15
|
-
|
16
|
-
|
10
|
+
def launch
|
11
|
+
window('hello world', 300, 200) {
|
12
|
+
font_button {
|
13
|
+
font <=> [self, :font_descriptor, after_write: -> { p font_descriptor }]
|
14
|
+
}
|
15
|
+
|
16
|
+
on_closing do
|
17
|
+
puts 'Bye Bye'
|
18
|
+
end
|
19
|
+
}.show
|
17
20
|
end
|
18
|
-
|
21
|
+
end
|
22
|
+
|
23
|
+
FontButton.new.launch
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('hello world', 300, 200) {
|
8
|
+
font_button { |fb|
|
9
|
+
on_changed do
|
10
|
+
font_descriptor = fb.font
|
11
|
+
p font_descriptor
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
on_closing do
|
16
|
+
puts 'Bye Bye'
|
17
|
+
end
|
18
|
+
}.show
|
data/examples/histogram.rb
CHANGED
@@ -71,12 +71,7 @@ class Histogram
|
|
71
71
|
|
72
72
|
color_button { |cb|
|
73
73
|
stretchy false
|
74
|
-
color
|
75
|
-
|
76
|
-
on_changed do
|
77
|
-
@histogram_color = cb.color
|
78
|
-
@area.queue_redraw_all
|
79
|
-
end
|
74
|
+
color <=> [self, :histogram_color, after_write: -> { @area.queue_redraw_all }]
|
80
75
|
}
|
81
76
|
}
|
82
77
|
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -113,6 +113,11 @@ module Glimmer
|
|
113
113
|
Fiddle.free @alpha unless @alpha.nil?
|
114
114
|
super
|
115
115
|
end
|
116
|
+
|
117
|
+
def data_bind(property, model_binding)
|
118
|
+
super
|
119
|
+
handle_listener('on_changed') { model_binding.call(color) } if property == 'color'
|
120
|
+
end
|
116
121
|
end
|
117
122
|
end
|
118
123
|
end
|
@@ -64,6 +64,10 @@ module Glimmer
|
|
64
64
|
::LibUI.free_font_button_font(@font_descriptor) unless @font_descriptor.nil?
|
65
65
|
super
|
66
66
|
end
|
67
|
+
|
68
|
+
def data_bind(property, model_binding)
|
69
|
+
handle_listener('on_changed') { model_binding.call(font) } if property == 'font'
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class ControlProxy
|
27
|
+
# Proxy for LibUI slider objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class SliderProxy < ControlProxy
|
31
|
+
def data_bind(property, model_binding)
|
32
|
+
super
|
33
|
+
handle_listener('on_changed') { model_binding.call(value) } if property == 'value'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- examples/basic_window2.rb
|
248
248
|
- examples/button_counter.rb
|
249
249
|
- examples/color_button.rb
|
250
|
+
- examples/color_button2.rb
|
250
251
|
- examples/color_the_circles.rb
|
251
252
|
- examples/control_gallery.rb
|
252
253
|
- examples/custom_draw_text.rb
|
@@ -259,6 +260,7 @@ files:
|
|
259
260
|
- examples/editable_column_table.rb
|
260
261
|
- examples/editable_table.rb
|
261
262
|
- examples/font_button.rb
|
263
|
+
- examples/font_button2.rb
|
262
264
|
- examples/form.rb
|
263
265
|
- examples/form2.rb
|
264
266
|
- examples/form_table.rb
|
@@ -370,6 +372,7 @@ files:
|
|
370
372
|
- lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb
|
371
373
|
- lib/glimmer/libui/control_proxy/path_proxy.rb
|
372
374
|
- lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb
|
375
|
+
- lib/glimmer/libui/control_proxy/slider_proxy.rb
|
373
376
|
- lib/glimmer/libui/control_proxy/spinbox_proxy.rb
|
374
377
|
- lib/glimmer/libui/control_proxy/tab_item_proxy.rb
|
375
378
|
- lib/glimmer/libui/control_proxy/table_proxy.rb
|