glimmer-dsl-libui 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45785cccb2a89070b2230fdae1c7418b48c6b8ac4682bf6ee0c2eb832f35bc1c
4
- data.tar.gz: 0a5544bef68a214ddb4ed55eb4ff71efa5916ce8c7e2d0b1c6d8f36d5b5fbd6f
3
+ metadata.gz: 2ab738eba1965fffc98860a23a44f2e1ed15c0c426ba4d21bcbb3fc4812ecde5
4
+ data.tar.gz: 2d5c195882767b63d941d9b8bad8338bc5d5ce160e97f34a9f57f5631c833fac
5
5
  SHA512:
6
- metadata.gz: '08005e8f56a310c7b534bfafde7e958617ee483985f30facf02a62a015d860a6378e4f7d5399b37fa5a247ef899a7092c313f120d5599a72d288bd3781a43820'
7
- data.tar.gz: befd92a20a6bc56c19049cfc385970bd8e113ae191c45ac3c3fffb513dd9140838229b79859392aed2e452d6e235d95059fe5d7847b3ac48cc5b4261aae50b26
6
+ metadata.gz: 23e1de3b8f30f90abb605a351e6cd9302dd778da2e711f7c72c4ad39b267090bab324bd056ca3855c343781c53757af320ca67c0d4aacac4c6351f7cf4a646e8
7
+ data.tar.gz: 18f3d9b8d48bc15a342efeb38f6979e1b2516b5144a790876d931c28a2803da840f980d0d9b9cd4c96484817d4cf241d19b7b64c751229fa1ae6a236029545ac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.16
4
+
5
+ - Support ability to instantiate without args and set args as properties afterwards inside block (e.g. `window { title 'Greeter'; content_size 300, 400; button {text 'Greet'; on_clicked {puts 'Hi'}} }`)
6
+ - window (was supported before, but changed default title to empty string)
7
+ - button
8
+ - checkbox
9
+ - group
10
+ - label
11
+
3
12
  ## 0.0.15
4
13
 
5
14
  - New examples/form.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.15
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.16
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.15](#-glimmer-dsl-for-libui-0015)
46
+ - [Glimmer DSL for LibUI 0.0.16](#-glimmer-dsl-for-libui-0016)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -156,7 +156,7 @@ gem install glimmer-dsl-libui
156
156
  Or install via Bundler `Gemfile`:
157
157
 
158
158
  ```ruby
159
- gem 'glimmer-dsl-libui', '~> 0.0.15'
159
+ gem 'glimmer-dsl-libui', '~> 0.0.16'
160
160
  ```
161
161
 
162
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.
@@ -284,9 +284,11 @@ Control(Args) | Properties | Listeners
284
284
 
285
285
  - `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
286
286
  - `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
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)
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`)
287
+ - 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)
288
+ - `window` instatiation args can be left off, having the following defaults when unspecified: `title` as `''`, `width` as `150`, `height` as `150`, and `has_menubar` as `true`)
289
289
  - `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)
290
+ - `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'; ...}`)
291
+ - `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'}}`)
290
292
  - `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)
291
293
  - If an `on_closing` listener was defined on `window` and it does not return an integer, default exit behavior is assumed (`window.destroy` is called followed by `LibUI.quit`, returning `0`).
292
294
  - If an `on_clicked` listener was defined on `quit_menu_item` and it does not return an integer, default exit behavior is assumed (`main_window.destroy` is called followed by `LibUI.quit`, returning `0`).
@@ -674,7 +676,7 @@ window('Basic Entry', 300, 50) { |w|
674
676
  }
675
677
 
676
678
  button('Button') {
677
- stretchy false
679
+ stretchy false # stretchy property is available when control is nested under horizontal_box
678
680
 
679
681
  on_clicked do
680
682
  text = e.text
@@ -1730,13 +1732,11 @@ window('Form') { |w|
1730
1732
  vertical_box {
1731
1733
  form {
1732
1734
  @first_name_entry = entry {
1733
- # stretchy true # Smart default option for appending to form
1734
- label 'First Name'
1735
+ label 'First Name' # label property is available when control is nested under form
1735
1736
  }
1736
1737
 
1737
1738
  @last_name_entry = entry {
1738
- # stretchy true # Smart default option for appending to form
1739
- label 'Last Name'
1739
+ label 'Last Name' # label property is available when control is nested under form
1740
1740
  }
1741
1741
  }
1742
1742
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
@@ -16,7 +16,7 @@ window('Basic Entry', 300, 50) { |w|
16
16
  }
17
17
 
18
18
  button('Button') {
19
- stretchy false
19
+ stretchy false # stretchy property is available when control is nested under horizontal_box
20
20
 
21
21
  on_clicked do
22
22
  text = e.text
data/examples/form.rb CHANGED
@@ -10,13 +10,11 @@ window('Form') { |w|
10
10
  vertical_box {
11
11
  form {
12
12
  @first_name_entry = entry {
13
- # stretchy true # Smart default option for appending to form
14
- label 'First Name'
13
+ label 'First Name' # label property is available when control is nested under form
15
14
  }
16
15
 
17
16
  @last_name_entry = entry {
18
- # stretchy true # Smart default option for appending to form
19
- label 'Last Name'
17
+ label 'Last Name' # label property is available when control is nested under form
20
18
  }
21
19
  }
22
20
 
Binary file
@@ -0,0 +1,41 @@
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
+ # Proxy for LibUI button objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class ButtonProxy < ControlProxy
30
+ DEFAULT_TEXT = ''
31
+
32
+ private
33
+
34
+ def build_control
35
+ construction_args = @args.dup
36
+ construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
37
+ @libui = ControlProxy.new_control(@keyword, construction_args)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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
+ # Proxy for LibUI checkbox objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class CheckboxProxy < ControlProxy
30
+ DEFAULT_TEXT = ''
31
+
32
+ private
33
+
34
+ def build_control
35
+ construction_args = @args.dup
36
+ construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
37
+ @libui = ControlProxy.new_control(@keyword, construction_args)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -66,6 +66,10 @@ module Glimmer
66
66
  def menu_proxies
67
67
  all_control_proxies.select {|c| c.keyword == 'menu' }
68
68
  end
69
+
70
+ def new_control(keyword, args)
71
+ ::LibUI.send("new_#{keyword}", *args)
72
+ end
69
73
  end
70
74
 
71
75
  BOOLEAN_PROPERTIES = %w[
@@ -254,7 +258,7 @@ module Glimmer
254
258
 
255
259
  def build_control
256
260
  @libui = if ::LibUI.respond_to?("new_#{keyword}")
257
- ::LibUI.send("new_#{@keyword}", *@args)
261
+ ControlProxy.new_control(@keyword, @args)
258
262
  elsif ::LibUI.respond_to?(keyword)
259
263
  @args[0] = @args.first.libui if @args.first.is_a?(ControlProxy)
260
264
  ::LibUI.send(@keyword, *@args)
@@ -27,6 +27,8 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class GroupProxy < ControlProxy
30
+ DEFAULT_TITLE = ''
31
+
30
32
  def post_initialize_child(child)
31
33
  ::LibUI.group_set_child(@libui, child.libui)
32
34
  end
@@ -39,7 +41,10 @@ module Glimmer
39
41
  private
40
42
 
41
43
  def build_control
42
- super.tap do
44
+ construction_args = @args.dup
45
+ construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
46
+ @libui = ControlProxy.new_control(@keyword, construction_args)
47
+ @libui.tap do
43
48
  self.margined = true
44
49
  end
45
50
  end
@@ -0,0 +1,41 @@
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
+ # Proxy for LibUI label objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class LabelProxy < ControlProxy
30
+ DEFAULT_TEXT = ''
31
+
32
+ private
33
+
34
+ def build_control
35
+ construction_args = @args.dup
36
+ construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
37
+ @libui = ControlProxy.new_control(@keyword, construction_args)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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
+ # Proxy for LibUI menu objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class MenuProxy < ControlProxy
30
+ DEFAULT_TEXT = ''
31
+
32
+ private
33
+
34
+ def build_control
35
+ construction_args = @args.dup
36
+ construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
37
+ @libui = ControlProxy.new_control(@keyword, construction_args)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -27,7 +27,7 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class WindowProxy < ControlProxy
30
- DEFAULT_TITLE = 'Glimmer'
30
+ DEFAULT_TITLE = ''
31
31
  DEFAULT_WIDTH = 150
32
32
  DEFAULT_HEIGHT = 150
33
33
  DEFAULT_HAS_MENUBAR = 1
@@ -79,7 +79,7 @@ module Glimmer
79
79
  construction_args[2] = DEFAULT_HEIGHT if construction_args.size == 2
80
80
  construction_args[3] = DEFAULT_HAS_MENUBAR if construction_args.size == 3
81
81
  construction_args[3] = ControlProxy.boolean_to_integer(construction_args[3]) if construction_args.size == 4 && (construction_args[3].is_a?(TrueClass) || construction_args[3].is_a?(FalseClass))
82
- @libui = ::LibUI.send("new_window", *construction_args)
82
+ @libui = ControlProxy.new_control(@keyword, construction_args)
83
83
  @libui.tap do
84
84
  handle_listener('on_closing') do
85
85
  destroy
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.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-22 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -205,7 +205,9 @@ files:
205
205
  - lib/glimmer/dsl/libui/tab_item_expression.rb
206
206
  - lib/glimmer/libui/about_menu_item_proxy.rb
207
207
  - lib/glimmer/libui/box.rb
208
+ - lib/glimmer/libui/button_proxy.rb
208
209
  - lib/glimmer/libui/check_menu_item_proxy.rb
210
+ - lib/glimmer/libui/checkbox_proxy.rb
209
211
  - lib/glimmer/libui/color_button_proxy.rb
210
212
  - lib/glimmer/libui/combobox_proxy.rb
211
213
  - lib/glimmer/libui/control_proxy.rb
@@ -217,7 +219,9 @@ files:
217
219
  - lib/glimmer/libui/grid_proxy.rb
218
220
  - lib/glimmer/libui/group_proxy.rb
219
221
  - lib/glimmer/libui/horizontal_box_proxy.rb
222
+ - lib/glimmer/libui/label_proxy.rb
220
223
  - lib/glimmer/libui/menu_item_proxy.rb
224
+ - lib/glimmer/libui/menu_proxy.rb
221
225
  - lib/glimmer/libui/multiline_entry_proxy.rb
222
226
  - lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
223
227
  - lib/glimmer/libui/preferences_menu_item_proxy.rb