glimmer-dsl-libui 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +67 -6
- data/VERSION +1 -1
- data/examples/form.rb +29 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/form_proxy.rb +54 -0
- data/lib/glimmer/libui/grid_proxy.rb +5 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45785cccb2a89070b2230fdae1c7418b48c6b8ac4682bf6ee0c2eb832f35bc1c
|
4
|
+
data.tar.gz: 0a5544bef68a214ddb4ed55eb4ff71efa5916ce8c7e2d0b1c6d8f36d5b5fbd6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08005e8f56a310c7b534bfafde7e958617ee483985f30facf02a62a015d860a6378e4f7d5399b37fa5a247ef899a7092c313f120d5599a72d288bd3781a43820'
|
7
|
+
data.tar.gz: befd92a20a6bc56c19049cfc385970bd8e113ae191c45ac3c3fffb513dd9140838229b79859392aed2e452d6e235d95059fe5d7847b3ac48cc5b4261aae50b26
|
data/CHANGELOG.md
CHANGED
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.0.
|
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.0.15
|
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
|
[![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
@@ -43,7 +43,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
43
43
|
|
44
44
|
## Table of Contents
|
45
45
|
|
46
|
-
- [Glimmer DSL for LibUI 0.0.
|
46
|
+
- [Glimmer DSL for LibUI 0.0.15](#-glimmer-dsl-for-libui-0015)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -68,6 +68,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
68
68
|
- [Color Button](#color-button)
|
69
69
|
- [Date Time Picker](#date-time-picker)
|
70
70
|
- [Grid](#grid)
|
71
|
+
- [Form](#form)
|
71
72
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
72
73
|
- [Help](#help)
|
73
74
|
- [Issues](#issues)
|
@@ -155,7 +156,7 @@ gem install glimmer-dsl-libui
|
|
155
156
|
Or install via Bundler `Gemfile`:
|
156
157
|
|
157
158
|
```ruby
|
158
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
159
|
+
gem 'glimmer-dsl-libui', '~> 0.0.15'
|
159
160
|
```
|
160
161
|
|
161
162
|
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.
|
@@ -220,6 +221,7 @@ Control(Args) | Properties | Listeners
|
|
220
221
|
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
221
222
|
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
222
223
|
`font_button` | `font` [read-only] (`Hash` of keys: `:family`, `:size`, `:weight`, `:italic`, `:stretch`), `family` as `String`, `size` as `Float`, `weight` as `Integer`, `italic` as `Integer`, `stretch` as `Integer` | `on_changed`
|
224
|
+
`form` | `padded` (Boolean) | None
|
223
225
|
`grid` | `padded` (Boolean) | None
|
224
226
|
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
225
227
|
`horizontal_box` | `padded` (Boolean) | None
|
@@ -250,7 +252,7 @@ Control(Args) | Properties | Listeners
|
|
250
252
|
- `parent` (`Fiddle::Pointer`)
|
251
253
|
- `toplevel` [read-only] (Boolean)
|
252
254
|
- `visible` (Boolean)
|
253
|
-
- `stretchy` [dsl-only] (Boolean) [default=`true`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `
|
255
|
+
- `stretchy` [dsl-only] (Boolean) [default=`true`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box`, `vertical_box`, or `form`
|
254
256
|
- `left` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
255
257
|
- `top` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
256
258
|
- `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
@@ -280,7 +282,7 @@ Control(Args) | Properties | Listeners
|
|
280
282
|
|
281
283
|
### Smart Defaults and Conventions
|
282
284
|
|
283
|
-
- `horizontal_box`, `vertical_box`, and `
|
285
|
+
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
284
286
|
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
285
287
|
- All controls nested under a `horizontal_box` or `vertical_box` have `stretchy` property (passed to `box_append` method) as `true` by default (filling maximum space)
|
286
288
|
- `window` constructor args can be left off and have the following defaults when unspecified: `title` as `'Glimmer'`, `width` as `150`, `height` as `150`, and `has_menubar` as `true`)
|
@@ -295,13 +297,14 @@ Control(Args) | Properties | Listeners
|
|
295
297
|
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destorying `color_button` controls
|
296
298
|
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
297
299
|
- When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
|
300
|
+
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
298
301
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
299
302
|
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
|
300
303
|
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
301
304
|
|
302
305
|
### API Gotchas
|
303
306
|
|
304
|
-
There is no proper
|
307
|
+
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`)
|
305
308
|
|
306
309
|
### Original API
|
307
310
|
|
@@ -1688,6 +1691,64 @@ window('Grid') {
|
|
1688
1691
|
}.show
|
1689
1692
|
```
|
1690
1693
|
|
1694
|
+
### Form
|
1695
|
+
|
1696
|
+
[examples/form.rb](examples/form.rb)
|
1697
|
+
|
1698
|
+
Run with this command from the root of the project if you cloned the project:
|
1699
|
+
|
1700
|
+
```
|
1701
|
+
ruby -r './lib/glimmer-dsl-libui' examples/form.rb
|
1702
|
+
```
|
1703
|
+
|
1704
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1705
|
+
|
1706
|
+
```
|
1707
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/form'"
|
1708
|
+
```
|
1709
|
+
|
1710
|
+
Mac
|
1711
|
+
|
1712
|
+
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png)
|
1713
|
+
![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png)
|
1714
|
+
|
1715
|
+
Linux
|
1716
|
+
|
1717
|
+
![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png)
|
1718
|
+
![glimmer-dsl-libui-linux-form-msg-box.png](images/glimmer-dsl-libui-linux-form-msg-box.png)
|
1719
|
+
|
1720
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1721
|
+
|
1722
|
+
```ruby
|
1723
|
+
require 'glimmer-dsl-libui'
|
1724
|
+
|
1725
|
+
include Glimmer
|
1726
|
+
|
1727
|
+
window('Form') { |w|
|
1728
|
+
margined true
|
1729
|
+
|
1730
|
+
vertical_box {
|
1731
|
+
form {
|
1732
|
+
@first_name_entry = entry {
|
1733
|
+
# stretchy true # Smart default option for appending to form
|
1734
|
+
label 'First Name'
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
@last_name_entry = entry {
|
1738
|
+
# stretchy true # Smart default option for appending to form
|
1739
|
+
label 'Last Name'
|
1740
|
+
}
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
button('Display Name') {
|
1744
|
+
on_clicked do
|
1745
|
+
msg_box(w, 'Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
|
1746
|
+
end
|
1747
|
+
}
|
1748
|
+
}
|
1749
|
+
}.show
|
1750
|
+
```
|
1751
|
+
|
1691
1752
|
## Contributing to glimmer-dsl-libui
|
1692
1753
|
|
1693
1754
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/examples/form.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('Form') { |w|
|
8
|
+
margined true
|
9
|
+
|
10
|
+
vertical_box {
|
11
|
+
form {
|
12
|
+
@first_name_entry = entry {
|
13
|
+
# stretchy true # Smart default option for appending to form
|
14
|
+
label 'First Name'
|
15
|
+
}
|
16
|
+
|
17
|
+
@last_name_entry = entry {
|
18
|
+
# stretchy true # Smart default option for appending to form
|
19
|
+
label 'Last Name'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
button('Display Name') {
|
24
|
+
on_clicked do
|
25
|
+
msg_box(w, 'Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
|
26
|
+
end
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}.show
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -0,0 +1,54 @@
|
|
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 FormProxy < ControlProxy
|
27
|
+
APPEND_PROPERTIES = %w[label stretchy]
|
28
|
+
|
29
|
+
def post_initialize_child(child)
|
30
|
+
child.label = '' if child.label.nil?
|
31
|
+
child.stretchy = true if child.stretchy.nil?
|
32
|
+
::LibUI.form_append(@libui, child.label, child.libui, ControlProxy.boolean_to_integer(child.stretchy))
|
33
|
+
children << child
|
34
|
+
end
|
35
|
+
|
36
|
+
def children
|
37
|
+
@children ||= []
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy_child(child)
|
41
|
+
::LibUI.send("form_delete", @libui, children.index(child))
|
42
|
+
ControlProxy.all_control_proxies.delete(child)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def build_control
|
48
|
+
super.tap do
|
49
|
+
self.padded = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -36,6 +36,11 @@ module Glimmer
|
|
36
36
|
child.vexpand = false if child.vexpand.nil?
|
37
37
|
child.valign = 0 if child.valign.nil?
|
38
38
|
::LibUI.grid_append(@libui, child.libui, child.left, child.top, child.xspan, child.yspan, ControlProxy.boolean_to_integer(child.hexpand), child.halign, ControlProxy.boolean_to_integer(child.vexpand), child.valign)
|
39
|
+
children << child
|
40
|
+
end
|
41
|
+
|
42
|
+
def children
|
43
|
+
@children ||= []
|
39
44
|
end
|
40
45
|
|
41
46
|
# Note that there is no proper destroy_child(child) method for GridProxy due to libui not offering any API for it (no grid_delete)
|
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.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- examples/control_gallery.rb
|
189
189
|
- examples/date_time_picker.rb
|
190
190
|
- examples/font_button.rb
|
191
|
+
- examples/form.rb
|
191
192
|
- examples/grid.rb
|
192
193
|
- examples/meta_example.rb
|
193
194
|
- examples/midi_player.rb
|
@@ -212,6 +213,7 @@ files:
|
|
212
213
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
213
214
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
214
215
|
- lib/glimmer/libui/font_button_proxy.rb
|
216
|
+
- lib/glimmer/libui/form_proxy.rb
|
215
217
|
- lib/glimmer/libui/grid_proxy.rb
|
216
218
|
- lib/glimmer/libui/group_proxy.rb
|
217
219
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|