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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +31 -24
- data/VERSION +1 -1
- data/examples/control_gallery.rb +0 -16
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/box.rb +8 -0
- data/lib/glimmer/libui/control_proxy.rb +17 -5
- data/lib/glimmer/libui/group_proxy.rb +8 -0
- data/lib/glimmer/libui/quit_menu_item_proxy.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db236ce703f8fbdab45930d36dca47f2303faf3405fd3bd037bbcab261b79245
|
4
|
+
data.tar.gz: ac097ae80240402e741d38b08f8b1c5e6941582c9e2b17fadf29d5c76971419d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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.
|
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` (`
|
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` (`
|
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
|
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
|
-
|
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.
|
1
|
+
0.0.7
|
data/examples/control_gallery.rb
CHANGED
@@ -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
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui/box.rb
CHANGED
@@ -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|
|
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
|
50
|
-
@@
|
51
|
-
@@
|
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.
|
197
|
+
self.class.all_control_proxies.delete(self)
|
186
198
|
end
|
187
199
|
|
188
200
|
private
|