glimmer-dsl-libui 0.0.13 → 0.0.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: 19ebb3b2df3f14388664e392c4fbac8b121c6adf5638e78ddf308c7455c76c02
4
- data.tar.gz: a631ed4518643c2d05ff39568f3fad815aa8729b01e1ee45ace9162bc9cf93be
3
+ metadata.gz: daf22d736dce460dde98ce6cb9d10d50433cce189b648b7b9f4fccd1a4e6cefc
4
+ data.tar.gz: 36f38bc99b47ae56d321986e9e27e3dfce18dacb3cc3f4722966c36ab329a896
5
5
  SHA512:
6
- metadata.gz: 9e0fccb89ce28c472c65cabc9ff1a6044cb19c3277e960e726ea7f642ccc2861f12b6c4ec1d31a562f7d05ce64a92dcb5696a544b9dd4a2ebad25e2cd82dd61b
7
- data.tar.gz: 4429a478c94b4105c079ddcda93b247271bae083a5b6c3b91e9c76c895a3273b27fced8d37262555b5139a0a19c98e63224eee3eb9ac44d89d379db151fa72ae
6
+ metadata.gz: 0fcd083428bfdb29db1428012a8dab67516ea5525e37aa5bdb0c7aa0b9679b78e3a01090b8ec20ca4d799b1ea48c41b0983d2570fd12a470246bb2b7fb7eae4c
7
+ data.tar.gz: b5824e2efefc6ccc319a029d4f5eadd976658c3c85bac6fe993ff6da4a9eb2cd5484ccea877b8557c49e2454ac8bb77599eb12219e1eff9fffddeda2489c67ee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.14
4
+
5
+ - New examples/grid.rb
6
+ - Support `grid` control and child attributes of `left`, `top`, `xspan`, `yspan`, `hexpand`, `halign`, `vexpand`, and `valign`
7
+ - Smart defaults for `grid` child attributes `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
8
+
3
9
  ## 0.0.13
4
10
 
5
11
  - Support examples/date_time_picker.rb
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.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.0.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
  [![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.13](#-glimmer-dsl-for-libui-0013)
46
+ - [Glimmer DSL for LibUI 0.0.14](#-glimmer-dsl-for-libui-0014)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -53,6 +53,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
53
53
  - [Extra Dialogs](#extra-dialogs)
54
54
  - [Extra Operations](#extra-operations)
55
55
  - [Smart Defaults and Conventions](#smart-defaults-and-conventions)
56
+ - [API Gotchas](#api-gotchas)
56
57
  - [Original API](#original-api)
57
58
  - [Glimmer Style Guide](#glimmer-style-guide)
58
59
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
@@ -66,6 +67,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
66
67
  - [Font Button](#font-button)
67
68
  - [Color Button](#color-button)
68
69
  - [Date Time Picker](#date-time-picker)
70
+ - [Grid](#grid)
69
71
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
70
72
  - [Help](#help)
71
73
  - [Issues](#issues)
@@ -153,7 +155,7 @@ gem install glimmer-dsl-libui
153
155
  Or install via Bundler `Gemfile`:
154
156
 
155
157
  ```ruby
156
- gem 'glimmer-dsl-libui', '~> 0.0.13'
158
+ gem 'glimmer-dsl-libui', '~> 0.0.14'
157
159
  ```
158
160
 
159
161
  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.
@@ -218,6 +220,7 @@ Control(Args) | Properties | Listeners
218
220
  `editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
219
221
  `entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
220
222
  `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`
223
+ `grid` | `padded` (Boolean) | None
221
224
  `group(text as String)` | `margined` (Boolean), `title` (`String`) | None
222
225
  `horizontal_box` | `padded` (Boolean) | None
223
226
  `horizontal_separator` | None | None
@@ -247,7 +250,15 @@ Control(Args) | Properties | Listeners
247
250
  - `parent` (`Fiddle::Pointer`)
248
251
  - `toplevel` [read-only] (Boolean)
249
252
  - `visible` (Boolean)
250
- - `stretchy` [dsl-only] (Boolean): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
253
+ - `stretchy` [dsl-only] (Boolean) [default=`true`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
254
+ - `left` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
255
+ - `top` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
256
+ - `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
257
+ - `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
258
+ - `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
259
+ - `halign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
260
+ - `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
261
+ - `valign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
251
262
 
252
263
  ### Common Control Operations
253
264
  - `destroy`
@@ -269,7 +280,7 @@ Control(Args) | Properties | Listeners
269
280
 
270
281
  ### Smart Defaults and Conventions
271
282
 
272
- - `horizontal_box` and `vertical_box` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
283
+ - `horizontal_box`, `vertical_box`, and `grid` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
273
284
  - `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
274
285
  - 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)
275
286
  - `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`)
@@ -286,6 +297,11 @@ Control(Args) | Properties | Listeners
286
297
  - When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
287
298
  - When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
288
299
  - 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
+ - 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
+
302
+ ### API Gotchas
303
+
304
+ There is no proper was 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`)
289
305
 
290
306
  ### Original API
291
307
 
@@ -1548,7 +1564,7 @@ UI.main
1548
1564
  UI.quit
1549
1565
  ```
1550
1566
 
1551
- New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1567
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1552
1568
 
1553
1569
  ```ruby
1554
1570
  require 'glimmer-dsl-libui'
@@ -1571,6 +1587,107 @@ window('Date Time Pickers', 300, 200) {
1571
1587
  }.show
1572
1588
  ```
1573
1589
 
1590
+ ### Grid
1591
+
1592
+ [examples/grid.rb](examples/grid.rb)
1593
+
1594
+ Run with this command from the root of the project if you cloned the project:
1595
+
1596
+ ```
1597
+ ruby -r './lib/glimmer-dsl-libui' examples/grid.rb
1598
+ ```
1599
+
1600
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
1601
+
1602
+ ```
1603
+ ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
1604
+ ```
1605
+
1606
+ Mac
1607
+
1608
+ ![glimmer-dsl-libui-mac-grid-spanning.png](images/glimmer-dsl-libui-mac-grid-spanning.png)
1609
+ ![glimmer-dsl-libui-mac-grid-expanding.png](images/glimmer-dsl-libui-mac-grid-expanding.png)
1610
+
1611
+ Linux
1612
+
1613
+ ![glimmer-dsl-libui-linux-grid-spanning.png](images/glimmer-dsl-libui-linux-grid-spanning.png)
1614
+ ![glimmer-dsl-libui-linux-grid-expanding.png](images/glimmer-dsl-libui-linux-grid-expanding.png)
1615
+
1616
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1617
+
1618
+ ```ruby
1619
+ require 'glimmer-dsl-libui'
1620
+
1621
+ include Glimmer
1622
+
1623
+ window('Grid') {
1624
+ tab {
1625
+ tab_item('Spanning') {
1626
+ grid {
1627
+ 4.times { |left_value|
1628
+ 4.times { |top_value|
1629
+ label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
1630
+ left left_value
1631
+ top top_value
1632
+ hexpand true
1633
+ vexpand true
1634
+ }
1635
+ }
1636
+ }
1637
+ label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
1638
+ left 0
1639
+ top 4
1640
+ xspan 2
1641
+ }
1642
+ label("(2, 4) xspan2\nyspan1 more text fits horizontally") {
1643
+ left 2
1644
+ top 4
1645
+ xspan 2
1646
+ }
1647
+ label("(0, 5) xspan1\nyspan2\nmore text\nfits vertically") {
1648
+ left 0
1649
+ top 5
1650
+ yspan 2
1651
+ }
1652
+ label("(0, 7) xspan1\nyspan2\nmore text\nfits vertically") {
1653
+ left 0
1654
+ top 7
1655
+ yspan 2
1656
+ }
1657
+ label("(1, 5) xspan3\nyspan4 a lot more text fits horizontally than before\nand\neven\na lot\nmore text\nfits vertically\nthan\nbefore") {
1658
+ left 1
1659
+ top 5
1660
+ xspan 3
1661
+ yspan 4
1662
+ }
1663
+ }
1664
+ }
1665
+ tab_item('Expanding') {
1666
+ grid {
1667
+ label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
1668
+ left 0
1669
+ top 0
1670
+ hexpand true
1671
+ vexpand true
1672
+ }
1673
+ label("(1, 0)") {
1674
+ left 1
1675
+ top 0
1676
+ }
1677
+ label("(0, 1)") {
1678
+ left 0
1679
+ top 1
1680
+ }
1681
+ label("(1, 1)") {
1682
+ left 1
1683
+ top 1
1684
+ }
1685
+ }
1686
+ }
1687
+ }
1688
+ }.show
1689
+ ```
1690
+
1574
1691
  ## Contributing to glimmer-dsl-libui
1575
1692
 
1576
1693
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
data/examples/grid.rb ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ window('Grid') {
8
+ tab {
9
+ tab_item('Spanning') {
10
+ grid {
11
+ 4.times { |left_value|
12
+ 4.times { |top_value|
13
+ label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
14
+ left left_value
15
+ top top_value
16
+ hexpand true
17
+ vexpand true
18
+ }
19
+ }
20
+ }
21
+ label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
22
+ left 0
23
+ top 4
24
+ xspan 2
25
+ }
26
+ label("(2, 4) xspan2\nyspan1 more text fits horizontally") {
27
+ left 2
28
+ top 4
29
+ xspan 2
30
+ }
31
+ label("(0, 5) xspan1\nyspan2\nmore text\nfits vertically") {
32
+ left 0
33
+ top 5
34
+ yspan 2
35
+ }
36
+ label("(0, 7) xspan1\nyspan2\nmore text\nfits vertically") {
37
+ left 0
38
+ top 7
39
+ yspan 2
40
+ }
41
+ label("(1, 5) xspan3\nyspan4 a lot more text fits horizontally than before\nand\neven\na lot\nmore text\nfits vertically\nthan\nbefore") {
42
+ left 1
43
+ top 5
44
+ xspan 3
45
+ yspan 4
46
+ }
47
+ }
48
+ }
49
+ tab_item('Expanding') {
50
+ grid {
51
+ label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
52
+ left 0
53
+ top 0
54
+ hexpand true
55
+ vexpand true
56
+ }
57
+ label("(1, 0)") {
58
+ left 1
59
+ top 0
60
+ }
61
+ label("(0, 1)") {
62
+ left 0
63
+ top 1
64
+ }
65
+ label("(1, 1)") {
66
+ left 1
67
+ top 1
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }.show
Binary file
@@ -0,0 +1,52 @@
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 GridProxy < ControlProxy
27
+ APPEND_PROPERTIES = %w[left top xspan yspan hexpand halign vexpand valign]
28
+
29
+ def post_initialize_child(child)
30
+ child.left = 0 if child.left.nil?
31
+ child.top = 0 if child.top.nil?
32
+ child.xspan = 1 if child.xspan.nil?
33
+ child.yspan = 1 if child.yspan.nil?
34
+ child.hexpand = false if child.hexpand.nil?
35
+ child.halign = 0 if child.halign.nil?
36
+ child.vexpand = false if child.vexpand.nil?
37
+ child.valign = 0 if child.valign.nil?
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
+ end
40
+
41
+ # Note that there is no proper destroy_child(child) method for GridProxy due to libui not offering any API for it (no grid_delete)
42
+
43
+ private
44
+
45
+ def build_control
46
+ super.tap do
47
+ self.padded = true
48
+ end
49
+ end
50
+ end
51
+ end
52
+ 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.0.13
4
+ version: 0.0.14
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/grid.rb
191
192
  - examples/meta_example.rb
192
193
  - examples/midi_player.rb
193
194
  - examples/simple_notepad.rb
@@ -211,6 +212,7 @@ files:
211
212
  - lib/glimmer/libui/date_time_picker_proxy.rb
212
213
  - lib/glimmer/libui/editable_combobox_proxy.rb
213
214
  - lib/glimmer/libui/font_button_proxy.rb
215
+ - lib/glimmer/libui/grid_proxy.rb
214
216
  - lib/glimmer/libui/group_proxy.rb
215
217
  - lib/glimmer/libui/horizontal_box_proxy.rb
216
218
  - lib/glimmer/libui/menu_item_proxy.rb