glimmer-dsl-libui 0.0.6 → 0.0.7

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: 602cf477d5809c99e64e46f2e51a66f1610364a28402b568cc6fe97cf5666115
4
- data.tar.gz: 3a45bca62165d28c11d8f9ee9e0c281c986c499b9df9ffb889214cb4a2240974
3
+ metadata.gz: db236ce703f8fbdab45930d36dca47f2303faf3405fd3bd037bbcab261b79245
4
+ data.tar.gz: ac097ae80240402e741d38b08f8b1c5e6941582c9e2b17fadf29d5c76971419d
5
5
  SHA512:
6
- metadata.gz: 696a6c43d9b75fa8692d74121d6674dc0b3a040cf47401721007ed6a4865372a67dc46df96bdf63d167a2b3b5187c3ca4139a365fa7942d537f85ed6287f8908
7
- data.tar.gz: 1b9480211e41aa30fa51f3936d44b3597c5c30d535ccead178504bb7b9c3ed2f3dbc61ae838b81e2c6d2e3fe8a6e4d30a8406fdce81e800398972564699dff63
6
+ metadata.gz: d32551f5df4bd763f1c6cee6a52c706972658ee3507e5d619152672679a1b9f499653da26b2581d7d35cd92aa40439f956900681d5c9b8e1b233db71a32cb8bd
7
+ data.tar.gz: def3355ba0e07c7f72d1deede04233932cbb175e4142fe77d1e243b95eb960849e123e729f14be5d27a94a16bc4c4060d65c75df22c2c7f44cc2e87e2350db48
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.7
4
+
5
+ - Make `padded 1` the default in `horizontal_box` and `vertical_box` to achieve nicer looking GUI by default
6
+ - Make `margined 1` the default in `group` to achieve nicer looking GUI by default
7
+ - Destroy main window upon hitting quit on quit menu item
8
+ - Rename `ControlProxy::all_controls` to `ControlProxy::all_control_proxies` to more accurately describe its contents
9
+ - Add `ControlProxy::main_window_proxy` method to retrieve main window proxy
10
+ - Define a `#window_proxy` method on `ControlProxy` to retrieve `window` control proxy for any control
11
+
3
12
  ## 0.0.6
4
13
 
5
14
  - Make listener block provide Ruby proxy object as optional argument (not Fiddle pointer)
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.6
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.7
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)
@@ -32,7 +32,7 @@ window('hello world', 300, 200, 1).show
32
32
  ![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png)
33
33
  ![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
34
34
 
35
- NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is in early alpha mode (only supports included examples). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
35
+ NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is in early alpha mode (only supports included [examples](#examples)). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
36
36
 
37
37
  Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interested in:
38
38
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -43,14 +43,17 @@ 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.6](#-glimmer-dsl-for-libui-006)
46
+ - [Glimmer DSL for LibUI 0.0.7](#-glimmer-dsl-for-libui-007)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
50
50
  - [Supported Controls](#supported-controls)
51
51
  - [Common Control Properties](#common-control-properties)
52
52
  - [Common Control Operations](#common-control-operations)
53
+ - [Extra Dialogs](#extra-dialogs)
53
54
  - [Extra Operations](#extra-operations)
55
+ - [Smart Defaults and Conventions](#smart-defaults-and-conventions)
56
+ - [Original API](#original-api)
54
57
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
55
58
  - [Examples](#examples)
56
59
  - [Basic Window](#basic-window)
@@ -146,7 +149,7 @@ gem install glimmer-dsl-libui
146
149
  Or install via Bundler `Gemfile`:
147
150
 
148
151
  ```ruby
149
- gem 'glimmer-dsl-libui', '~> 0.0.6'
152
+ gem 'glimmer-dsl-libui', '~> 0.0.7'
150
153
  ```
151
154
 
152
155
  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.
@@ -207,10 +210,10 @@ Control(Args) | Properties | Listeners
207
210
  `combobox` | `items` (`Array` of `String`), `selected` (`1` or `0`) | `on_selected`
208
211
  `color_button` | `color` (r `Numeric`, g `Numeric`, b `Numeric`, a `Numeric`), `selected` (`1` or `0`) | `on_selected`
209
212
  `date_picker` | None | None
210
- `date_time_picker` | `time` (`UI::FFI::TM`) | `on_changed`
213
+ `date_time_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
211
214
  `editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
212
215
  `entry` | `read_only` (`1` or `0`), `text` (`String`) | `on_changed`
213
- `font_button` | `font` (`UI::FFI::FontDescriptor`) | `on_changed`
216
+ `font_button` | `font` (`LibUI::FFI::FontDescriptor`) | `on_changed`
214
217
  `group(text as String)` | `margined` (`1` or `0`), `title` (`String`) | None
215
218
  `horizontal_box` | `padded` (`1` or `0`) | None
216
219
  `horizontal_separator` | None | None
@@ -249,11 +252,31 @@ Control(Args) | Properties | Listeners
249
252
  - `hide`
250
253
  - `show`
251
254
 
252
- ### Extra Operations
255
+ ### Extra Dialogs
256
+
253
257
  - `open_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
254
258
  - `save_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
255
259
 
256
- To learn more about the [LibUI](https://github.com/kojix2/LibUI) API exposed through [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui), check out the [libui C headers](https://github.com/andlabs/libui/blob/master/ui.h)
260
+ ### Extra Operations
261
+
262
+ - `ControlProxy::all_control_proxies`: returns all instantiated control proxies in the application
263
+ - `ControlProxy::main_window_proxy`: returns the first window proxy instantiated in the application
264
+ - `ControlProxy#window_proxy`: returns the window proxy parent for a control
265
+
266
+ ### Smart Defaults and Conventions
267
+
268
+ - `horizontal_box` and `vertical_box` controls have `padded` as `1` upon instantiation to ensure more user-friendly GUI by default
269
+ - `group` controls have `margined` as `1` upon instantiation to ensure more user-friendly GUI by default
270
+ - All controls nested under a `horizontal_box` or `vertical_box` have `stretchy` property (passed to `box_append` method) as `1` by default (filling maximum space)
271
+ - `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)
272
+ - `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)
273
+ - 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`).
274
+ - 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`).
275
+
276
+ ### Original API
277
+
278
+ To learn more about the [LibUI](https://github.com/kojix2/LibUI) API exposed through [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui),
279
+ check out the [libui C headers](https://github.com/andlabs/libui/blob/master/ui.h)
257
280
 
258
281
  ## Girb (Glimmer IRB)
259
282
 
@@ -1077,17 +1100,9 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
1077
1100
  end
1078
1101
 
1079
1102
  vertical_box {
1080
- padded 1
1081
-
1082
1103
  horizontal_box {
1083
- padded 1
1084
-
1085
1104
  group('Basic Controls') {
1086
- margined 1
1087
-
1088
1105
  vertical_box {
1089
- padded 1
1090
-
1091
1106
  button('Button') {
1092
1107
  stretchy 0
1093
1108
 
@@ -1123,15 +1138,10 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
1123
1138
  }
1124
1139
 
1125
1140
  vertical_box {
1126
- padded 1
1127
-
1128
1141
  group('Numbers') {
1129
1142
  stretchy 0
1130
- margined 1
1131
1143
 
1132
1144
  vertical_box {
1133
- padded 1
1134
-
1135
1145
  spinbox(0, 100) {
1136
1146
  stretchy 0
1137
1147
  value 42
@@ -1157,11 +1167,8 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
1157
1167
 
1158
1168
  group('Lists') {
1159
1169
  stretchy 0
1160
- margined 1
1161
1170
 
1162
1171
  vertical_box {
1163
- padded 1
1164
-
1165
1172
  combobox {
1166
1173
  stretchy 0
1167
1174
  items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -50,17 +50,9 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
50
50
  end
51
51
 
52
52
  vertical_box {
53
- padded 1
54
-
55
53
  horizontal_box {
56
- padded 1
57
-
58
54
  group('Basic Controls') {
59
- margined 1
60
-
61
55
  vertical_box {
62
- padded 1
63
-
64
56
  button('Button') {
65
57
  stretchy 0
66
58
 
@@ -96,15 +88,10 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
96
88
  }
97
89
 
98
90
  vertical_box {
99
- padded 1
100
-
101
91
  group('Numbers') {
102
92
  stretchy 0
103
- margined 1
104
93
 
105
94
  vertical_box {
106
- padded 1
107
-
108
95
  spinbox(0, 100) {
109
96
  stretchy 0
110
97
  value 42
@@ -130,11 +117,8 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
130
117
 
131
118
  group('Lists') {
132
119
  stretchy 0
133
- margined 1
134
120
 
135
121
  vertical_box {
136
- padded 1
137
-
138
122
  combobox {
139
123
  stretchy 0
140
124
  items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
Binary file
@@ -32,6 +32,14 @@ module Glimmer
32
32
  def libui_api_keyword
33
33
  'box'
34
34
  end
35
+
36
+ private
37
+
38
+ def build_control
39
+ super.tap do
40
+ self.padded = 1
41
+ end
42
+ end
35
43
  end
36
44
  end
37
45
  end
@@ -33,7 +33,7 @@ module Glimmer
33
33
  end
34
34
 
35
35
  def create(keyword, parent, args, &block)
36
- widget_proxy_class(keyword).new(keyword, parent, args, &block).tap {|c| all_controls << c}
36
+ widget_proxy_class(keyword).new(keyword, parent, args, &block).tap {|c| all_control_proxies << c}
37
37
  end
38
38
 
39
39
  def widget_proxy_class(keyword)
@@ -46,9 +46,13 @@ module Glimmer
46
46
  end
47
47
 
48
48
  # autosave all controls in this array to avoid garbage collection
49
- def all_controls
50
- @@all_controls = [] unless defined?(@@all_controls)
51
- @@all_controls
49
+ def all_control_proxies
50
+ @@all_control_proxies = [] unless defined?(@@all_control_proxies)
51
+ @@all_control_proxies
52
+ end
53
+
54
+ def main_window_proxy
55
+ all_control_proxies.find {|c| c.is_a?(WindowProxy)}
52
56
  end
53
57
  end
54
58
 
@@ -77,6 +81,14 @@ module Glimmer
77
81
  def post_initialize_child(child)
78
82
  # No Op by default
79
83
  end
84
+
85
+ def window_proxy
86
+ found_proxy = self
87
+ until found_proxy.nil? || found_proxy.is_a?(WindowProxy)
88
+ found_proxy = found_proxy.parent_proxy
89
+ end
90
+ found_proxy
91
+ end
80
92
 
81
93
  def can_handle_listener?(listener_name)
82
94
  ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
@@ -182,7 +194,7 @@ module Glimmer
182
194
 
183
195
  def destroy
184
196
  send_to_libui('destroy')
185
- self.class.all_controls.delete(self)
197
+ self.class.all_control_proxies.delete(self)
186
198
  end
187
199
 
188
200
  private
@@ -30,6 +30,14 @@ module Glimmer
30
30
  def post_initialize_child(child)
31
31
  ::LibUI.group_set_child(@libui, child.libui)
32
32
  end
33
+
34
+ private
35
+
36
+ def build_control
37
+ super.tap do
38
+ self.margined = 1
39
+ end
40
+ end
33
41
  end
34
42
  end
35
43
  end
@@ -52,7 +52,7 @@ module Glimmer
52
52
  def build_control
53
53
  @libui = @parent_proxy.append_quit_item(*@args)
54
54
  handle_listener('on_clicked') do
55
- destroy
55
+ ControlProxy.main_window_proxy&.destroy
56
56
  ::LibUI.quit
57
57
  0
58
58
  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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh