glimmer-dsl-libui 0.0.5 → 0.0.6
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +90 -50
- data/VERSION +1 -1
- data/examples/control_gallery.rb +17 -17
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/tab_item_expression.rb +1 -1
- data/lib/glimmer/libui/combobox_proxy.rb +3 -2
- data/lib/glimmer/libui/control_proxy.rb +20 -7
- data/lib/glimmer/libui/editable_combobox_proxy.rb +3 -2
- data/lib/glimmer/libui/multiline_entry_proxy.rb +35 -0
- data/lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb +32 -0
- data/lib/glimmer/libui/quit_menu_item_proxy.rb +3 -3
- data/lib/glimmer/libui/radio_buttons_proxy.rb +3 -2
- data/lib/glimmer/libui/tab_item_proxy.rb +3 -1
- data/lib/glimmer/libui/window_proxy.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 602cf477d5809c99e64e46f2e51a66f1610364a28402b568cc6fe97cf5666115
|
4
|
+
data.tar.gz: 3a45bca62165d28c11d8f9ee9e0c281c986c499b9df9ffb889214cb4a2240974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 696a6c43d9b75fa8692d74121d6674dc0b3a040cf47401721007ed6a4865372a67dc46df96bdf63d167a2b3b5187c3ca4139a365fa7942d537f85ed6287f8908
|
7
|
+
data.tar.gz: 1b9480211e41aa30fa51f3936d44b3597c5c30d535ccead178504bb7b9c3ed2f3dbc61ae838b81e2c6d2e3fe8a6e4d30a8406fdce81e800398972564699dff63
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.6
|
4
|
+
|
5
|
+
- Make listener block provide Ruby proxy object as optional argument (not Fiddle pointer)
|
6
|
+
- Handle `tab_item` scenario where it has an empty block or no block (auto-generate empty `horizontal_box` content as a smart default to avoid crashing)
|
7
|
+
- Support `non_wrapping_multiline_entry` propeties/operations via `LibUI.multiline_entry_*` methods (enhancing them to accept Ruby objects in addition to pointers)
|
8
|
+
- Support splatting `items` array for `radio_buttons`, `editable_combobox`, and `combobox` items
|
9
|
+
- Fix issue with `menu_item` `on_clicked` listeners crashing in examples/control_gallery.rb due to garbage collection
|
10
|
+
|
3
11
|
## 0.0.5
|
4
12
|
|
5
13
|
- Support examples/control_gallery.rb
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
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.6
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
5
5
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
6
6
|
|
7
|
-
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a prerequisite-free Ruby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent GUI that just works!
|
7
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a prerequisite-free Ruby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent native GUI that just works!
|
8
8
|
|
9
9
|
[LibUI](https://github.com/kojix2/LibUI) is a thin [Ruby](https://www.ruby-lang.org/en/) wrapper around [libui](https://github.com/andlabs/libui), a relatively new C GUI library that renders native widgets on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
|
10
10
|
|
@@ -41,6 +41,34 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
41
41
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
42
42
|
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
|
43
43
|
|
44
|
+
## Table of Contents
|
45
|
+
|
46
|
+
- [Glimmer DSL for LibUI 0.0.6](#-glimmer-dsl-for-libui-006)
|
47
|
+
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
|
+
- [Usage](#usage)
|
49
|
+
- [API](#api)
|
50
|
+
- [Supported Controls](#supported-controls)
|
51
|
+
- [Common Control Properties](#common-control-properties)
|
52
|
+
- [Common Control Operations](#common-control-operations)
|
53
|
+
- [Extra Operations](#extra-operations)
|
54
|
+
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
55
|
+
- [Examples](#examples)
|
56
|
+
- [Basic Window](#basic-window)
|
57
|
+
- [Basic Button](#basic-button)
|
58
|
+
- [Basic Entry](#basic-entry)
|
59
|
+
- [Simple Notepad](#simple-notepad)
|
60
|
+
- [Midi Player](#midi-player)
|
61
|
+
- [Control Gallery](#control-gallery)
|
62
|
+
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
63
|
+
- [Help](#help)
|
64
|
+
- [Issues](#issues)
|
65
|
+
- [Chat](#chat)
|
66
|
+
- [Process](#process)
|
67
|
+
- [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
|
68
|
+
- [Change Log](#change-log)
|
69
|
+
- [Contributors](#contributors)
|
70
|
+
- [License](#license)
|
71
|
+
|
44
72
|
## Glimmer GUI DSL Concepts
|
45
73
|
|
46
74
|
The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for [LibUI](https://github.com/kojix2/LibUI) that:
|
@@ -118,7 +146,7 @@ gem install glimmer-dsl-libui
|
|
118
146
|
Or install via Bundler `Gemfile`:
|
119
147
|
|
120
148
|
```ruby
|
121
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
149
|
+
gem 'glimmer-dsl-libui', '~> 0.0.6'
|
122
150
|
```
|
123
151
|
|
124
152
|
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.
|
@@ -169,35 +197,43 @@ w = window('hello world', 300, 200, 1) # => #<Glimmer::LibUI::WindowProxy:0x0000
|
|
169
197
|
w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
|
170
198
|
```
|
171
199
|
|
172
|
-
Supported Controls
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
200
|
+
### Supported Controls
|
201
|
+
|
202
|
+
Control(Args) | Properties | Listeners
|
203
|
+
------------- | ---------- | ---------
|
204
|
+
`about_menu_item` | None | `on_clicked`
|
205
|
+
`button(text as String)` | `text` (`String`) | `on_clicked`
|
206
|
+
`checkbox(text as String)` | `checked` (`1` or `0`), `text` (`String`) | `on_toggled`
|
207
|
+
`combobox` | `items` (`Array` of `String`), `selected` (`1` or `0`) | `on_selected`
|
208
|
+
`color_button` | `color` (r `Numeric`, g `Numeric`, b `Numeric`, a `Numeric`), `selected` (`1` or `0`) | `on_selected`
|
209
|
+
`date_picker` | None | None
|
210
|
+
`date_time_picker` | `time` (`UI::FFI::TM`) | `on_changed`
|
211
|
+
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
212
|
+
`entry` | `read_only` (`1` or `0`), `text` (`String`) | `on_changed`
|
213
|
+
`font_button` | `font` (`UI::FFI::FontDescriptor`) | `on_changed`
|
214
|
+
`group(text as String)` | `margined` (`1` or `0`), `title` (`String`) | None
|
215
|
+
`horizontal_box` | `padded` (`1` or `0`) | None
|
216
|
+
`horizontal_separator` | None | None
|
217
|
+
`label(text as String)` | `text` (`String`) | None
|
218
|
+
`menu(text as String)` | None | None
|
219
|
+
`menu_item(text as String)` | `checked` (`1` or `0`) | `on_clicked`
|
220
|
+
`multiline_entry` | `read_only` (`1` or `0`), `text` (`String`) | `on_changed`
|
221
|
+
`msg_box(window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
222
|
+
`msg_box_error(window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
223
|
+
`non_wrapping_multiline_entry` | `read_only` (`1` or `0`), `text` (`String`) | `on_changed`
|
224
|
+
`preferences_menu_item` | None | `on_clicked`
|
225
|
+
`progress_bar` | `value` (`Numeric`) | None
|
226
|
+
`quit_menu_item` | None | `on_clicked`
|
227
|
+
`radio_buttons` | `selected` (`1` or `0`) | `on_selected`
|
228
|
+
`slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
229
|
+
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
230
|
+
`tab` | `margined` (`1` or `0`), `num_pages` (`Integer`) | None
|
231
|
+
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (`1` or `0`), `name` [read-only] (`String`) | None
|
232
|
+
`time_picker` | None | None
|
233
|
+
`vertical_box` | `padded` (`1` or `0`) | None
|
234
|
+
`window(title as String, width as Integer, height as Integer, has_menubar as 1 or 0)` | `borderless` (`1` or `0`), `content_size` (width `Numeric`, height `Numeric`), `fullscreen` (`1` or `0`), `margined` (`1` or `0`), `title` (`String`) | `on_closing`, `on_content_size_changed`
|
235
|
+
|
236
|
+
### Common Control Properties
|
201
237
|
- `enabled` (`1` or `0`)
|
202
238
|
- `libui` (`Fiddle::Pointer`): returns wrapped [LibUI](https://github.com/kojix2/LibUI) object
|
203
239
|
- `parent_proxy` (`Glimmer::LibUI::ControlProxy` or subclass)
|
@@ -206,13 +242,17 @@ Common Control Properties:
|
|
206
242
|
- `visible` (`1` or `0`)
|
207
243
|
- `stretchy` [dsl-only] (`1` or `0`): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
|
208
244
|
|
209
|
-
Common Control Operations
|
245
|
+
### Common Control Operations
|
210
246
|
- `destroy`
|
211
247
|
- `disable`
|
212
248
|
- `enable`
|
213
249
|
- `hide`
|
214
250
|
- `show`
|
215
251
|
|
252
|
+
### Extra Operations
|
253
|
+
- `open_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
254
|
+
- `save_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
255
|
+
|
216
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)
|
217
257
|
|
218
258
|
## Girb (Glimmer IRB)
|
@@ -1018,7 +1058,7 @@ menu('File') {
|
|
1018
1058
|
menu('Edit') {
|
1019
1059
|
check_menu_item('Checkable Item_')
|
1020
1060
|
separator_menu_item
|
1021
|
-
menu_item('Disabled Item_') {
|
1061
|
+
menu_item('Disabled Item_') {
|
1022
1062
|
enabled 0
|
1023
1063
|
}
|
1024
1064
|
}
|
@@ -1036,7 +1076,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1036
1076
|
puts 'Bye Bye'
|
1037
1077
|
end
|
1038
1078
|
|
1039
|
-
vertical_box {
|
1079
|
+
vertical_box {
|
1040
1080
|
padded 1
|
1041
1081
|
|
1042
1082
|
horizontal_box {
|
@@ -1056,10 +1096,10 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1056
1096
|
end
|
1057
1097
|
}
|
1058
1098
|
|
1059
|
-
checkbox('Checkbox') {
|
1099
|
+
checkbox('Checkbox') {
|
1060
1100
|
stretchy 0
|
1061
1101
|
|
1062
|
-
on_toggled do
|
1102
|
+
on_toggled do |c|
|
1063
1103
|
checked = c.checked == 1
|
1064
1104
|
MAIN_WINDOW.title = "Checkbox is #{checked}"
|
1065
1105
|
c.text = "I am the checkbox (#{checked})"
|
@@ -1092,19 +1132,19 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1092
1132
|
vertical_box {
|
1093
1133
|
padded 1
|
1094
1134
|
|
1095
|
-
spinbox(0, 100) {
|
1135
|
+
spinbox(0, 100) {
|
1096
1136
|
stretchy 0
|
1097
1137
|
value 42
|
1098
1138
|
|
1099
|
-
on_changed do
|
1139
|
+
on_changed do |s|
|
1100
1140
|
puts "New Spinbox value: #{s.value}"
|
1101
1141
|
end
|
1102
1142
|
}
|
1103
1143
|
|
1104
|
-
slider(0, 100) {
|
1144
|
+
slider(0, 100) {
|
1105
1145
|
stretchy 0
|
1106
1146
|
|
1107
|
-
on_changed do
|
1147
|
+
on_changed do |s|
|
1108
1148
|
v = s.value
|
1109
1149
|
puts "New Slider value: #{v}"
|
1110
1150
|
@progress_bar.value = v
|
@@ -1122,22 +1162,22 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1122
1162
|
vertical_box {
|
1123
1163
|
padded 1
|
1124
1164
|
|
1125
|
-
combobox {
|
1165
|
+
combobox {
|
1126
1166
|
stretchy 0
|
1127
|
-
items
|
1167
|
+
items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
|
1128
1168
|
|
1129
|
-
on_selected do
|
1169
|
+
on_selected do |c|
|
1130
1170
|
puts "New combobox selection: #{c.selected}"
|
1131
1171
|
end
|
1132
1172
|
}
|
1133
1173
|
|
1134
1174
|
editable_combobox {
|
1135
1175
|
stretchy 0
|
1136
|
-
items
|
1176
|
+
items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
|
1137
1177
|
}
|
1138
1178
|
|
1139
1179
|
radio_buttons {
|
1140
|
-
items
|
1180
|
+
items 'Radio Button 1', 'Radio Button 2', 'Radio Button 3' # also accepts a single array argument
|
1141
1181
|
}
|
1142
1182
|
}
|
1143
1183
|
}
|
@@ -1145,20 +1185,20 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1145
1185
|
tab {
|
1146
1186
|
tab_item('Page 1') {
|
1147
1187
|
horizontal_box {
|
1148
|
-
entry {
|
1188
|
+
entry {
|
1149
1189
|
text 'Please enter your feelings'
|
1150
1190
|
|
1151
|
-
on_changed do
|
1191
|
+
on_changed do |e|
|
1152
1192
|
puts "Current textbox data: '#{e.text}'"
|
1153
1193
|
end
|
1154
1194
|
}
|
1155
1195
|
}
|
1156
1196
|
}
|
1157
|
-
|
1197
|
+
|
1158
1198
|
tab_item('Page 2') {
|
1159
1199
|
horizontal_box
|
1160
1200
|
}
|
1161
|
-
|
1201
|
+
|
1162
1202
|
tab_item('Page 3') {
|
1163
1203
|
horizontal_box
|
1164
1204
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/examples/control_gallery.rb
CHANGED
@@ -31,7 +31,7 @@ menu('File') {
|
|
31
31
|
menu('Edit') {
|
32
32
|
check_menu_item('Checkable Item_')
|
33
33
|
separator_menu_item
|
34
|
-
menu_item('Disabled Item_') {
|
34
|
+
menu_item('Disabled Item_') {
|
35
35
|
enabled 0
|
36
36
|
}
|
37
37
|
}
|
@@ -49,7 +49,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
49
49
|
puts 'Bye Bye'
|
50
50
|
end
|
51
51
|
|
52
|
-
vertical_box {
|
52
|
+
vertical_box {
|
53
53
|
padded 1
|
54
54
|
|
55
55
|
horizontal_box {
|
@@ -69,10 +69,10 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
69
69
|
end
|
70
70
|
}
|
71
71
|
|
72
|
-
checkbox('Checkbox') {
|
72
|
+
checkbox('Checkbox') {
|
73
73
|
stretchy 0
|
74
74
|
|
75
|
-
on_toggled do
|
75
|
+
on_toggled do |c|
|
76
76
|
checked = c.checked == 1
|
77
77
|
MAIN_WINDOW.title = "Checkbox is #{checked}"
|
78
78
|
c.text = "I am the checkbox (#{checked})"
|
@@ -105,19 +105,19 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
105
105
|
vertical_box {
|
106
106
|
padded 1
|
107
107
|
|
108
|
-
spinbox(0, 100) {
|
108
|
+
spinbox(0, 100) {
|
109
109
|
stretchy 0
|
110
110
|
value 42
|
111
111
|
|
112
|
-
on_changed do
|
112
|
+
on_changed do |s|
|
113
113
|
puts "New Spinbox value: #{s.value}"
|
114
114
|
end
|
115
115
|
}
|
116
116
|
|
117
|
-
slider(0, 100) {
|
117
|
+
slider(0, 100) {
|
118
118
|
stretchy 0
|
119
119
|
|
120
|
-
on_changed do
|
120
|
+
on_changed do |s|
|
121
121
|
v = s.value
|
122
122
|
puts "New Slider value: #{v}"
|
123
123
|
@progress_bar.value = v
|
@@ -135,22 +135,22 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
135
135
|
vertical_box {
|
136
136
|
padded 1
|
137
137
|
|
138
|
-
combobox {
|
138
|
+
combobox {
|
139
139
|
stretchy 0
|
140
|
-
items
|
140
|
+
items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
|
141
141
|
|
142
|
-
on_selected do
|
142
|
+
on_selected do |c|
|
143
143
|
puts "New combobox selection: #{c.selected}"
|
144
144
|
end
|
145
145
|
}
|
146
146
|
|
147
147
|
editable_combobox {
|
148
148
|
stretchy 0
|
149
|
-
items
|
149
|
+
items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
|
150
150
|
}
|
151
151
|
|
152
152
|
radio_buttons {
|
153
|
-
items
|
153
|
+
items 'Radio Button 1', 'Radio Button 2', 'Radio Button 3' # also accepts a single array argument
|
154
154
|
}
|
155
155
|
}
|
156
156
|
}
|
@@ -158,20 +158,20 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
158
158
|
tab {
|
159
159
|
tab_item('Page 1') {
|
160
160
|
horizontal_box {
|
161
|
-
entry {
|
161
|
+
entry {
|
162
162
|
text 'Please enter your feelings'
|
163
163
|
|
164
|
-
on_changed do
|
164
|
+
on_changed do |e|
|
165
165
|
puts "Current textbox data: '#{e.text}'"
|
166
166
|
end
|
167
167
|
}
|
168
168
|
}
|
169
169
|
}
|
170
|
-
|
170
|
+
|
171
171
|
tab_item('Page 2') {
|
172
172
|
horizontal_box
|
173
173
|
}
|
174
|
-
|
174
|
+
|
175
175
|
tab_item('Page 3') {
|
176
176
|
horizontal_box
|
177
177
|
}
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -27,7 +27,7 @@ module Glimmer
|
|
27
27
|
module Libui
|
28
28
|
class TabItemExpression < StaticExpression
|
29
29
|
def interpret(parent, keyword, *args, &block)
|
30
|
-
Glimmer::LibUI::TabItemProxy.
|
30
|
+
Glimmer::LibUI::TabItemProxy.create(keyword, parent, args, &block)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -27,8 +27,9 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class ComboboxProxy < ControlProxy
|
30
|
-
def items(values
|
31
|
-
if values.
|
30
|
+
def items(*values)
|
31
|
+
values = values.first if values.first.is_a?(Array)
|
32
|
+
if values.empty?
|
32
33
|
@values
|
33
34
|
else
|
34
35
|
@values = values
|
@@ -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)
|
36
|
+
widget_proxy_class(keyword).new(keyword, parent, args, &block).tap {|c| all_controls << c}
|
37
37
|
end
|
38
38
|
|
39
39
|
def widget_proxy_class(keyword)
|
@@ -44,6 +44,12 @@ module Glimmer
|
|
44
44
|
Glimmer::LibUI::ControlProxy
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
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
|
52
|
+
end
|
47
53
|
end
|
48
54
|
|
49
55
|
# libui returns the contained LibUI object
|
@@ -73,21 +79,23 @@ module Glimmer
|
|
73
79
|
end
|
74
80
|
|
75
81
|
def can_handle_listener?(listener_name)
|
76
|
-
::LibUI.respond_to?("
|
82
|
+
::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
|
83
|
+
::LibUI.respond_to?("control_#{listener_name}")
|
77
84
|
end
|
78
85
|
|
79
86
|
def handle_listener(listener_name, &listener)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
87
|
+
safe_listener = Proc.new { listener.call(self) }
|
88
|
+
if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
89
|
+
::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &safe_listener)
|
90
|
+
elsif ::LibUI.respond_to?("control_#{listener_name}")
|
91
|
+
::LibUI.send("control_#{listener_name}", @libui, &safe_listener)
|
84
92
|
end
|
85
93
|
end
|
86
94
|
|
87
95
|
def respond_to?(method_name, *args, &block)
|
88
96
|
respond_to_libui?(method_name, *args, &block) ||
|
89
97
|
(append_properties.include?(method_name.to_s) || append_properties.include?(method_name.to_s.sub(/=$/, ''))) ||
|
90
|
-
super
|
98
|
+
super(method_name, true)
|
91
99
|
end
|
92
100
|
|
93
101
|
def respond_to_libui?(method_name, *args, &block)
|
@@ -172,6 +180,11 @@ module Glimmer
|
|
172
180
|
alias set_visible visible
|
173
181
|
alias visible= visible
|
174
182
|
|
183
|
+
def destroy
|
184
|
+
send_to_libui('destroy')
|
185
|
+
self.class.all_controls.delete(self)
|
186
|
+
end
|
187
|
+
|
175
188
|
private
|
176
189
|
|
177
190
|
def build_control
|
@@ -27,8 +27,9 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class EditableComboboxProxy < ControlProxy
|
30
|
-
def items(values
|
31
|
-
if values.
|
30
|
+
def items(*values)
|
31
|
+
values = values.first if values.first.is_a?(Array)
|
32
|
+
if values.empty?
|
32
33
|
@values
|
33
34
|
else
|
34
35
|
@values = values
|
@@ -0,0 +1,35 @@
|
|
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 multiline entry objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class MultilineEntryProxy < ControlProxy
|
30
|
+
def libui_api_keyword
|
31
|
+
'multiline_entry'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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/multiline_entry_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI non wrapping multiline entry objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class NonWrappingMultilineEntryProxy < MultilineEntryProxy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -33,8 +33,8 @@ module Glimmer
|
|
33
33
|
|
34
34
|
def handle_listener(listener_name, &listener)
|
35
35
|
if listener_name == 'on_clicked'
|
36
|
-
default_behavior_listener = Proc.new do
|
37
|
-
return_value = listener.call
|
36
|
+
@default_behavior_listener = Proc.new do
|
37
|
+
return_value = listener.call(self)
|
38
38
|
if return_value.is_a?(Numeric)
|
39
39
|
return_value
|
40
40
|
else
|
@@ -43,8 +43,8 @@ module Glimmer
|
|
43
43
|
0
|
44
44
|
end
|
45
45
|
end
|
46
|
+
::LibUI.on_should_quit(&@default_behavior_listener)
|
46
47
|
end
|
47
|
-
::LibUI.on_should_quit(&default_behavior_listener)
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
@@ -27,8 +27,9 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class RadioButtonsProxy < ControlProxy
|
30
|
-
def items(values
|
31
|
-
if values.
|
30
|
+
def items(*values)
|
31
|
+
values = values.first if values.first.is_a?(Array)
|
32
|
+
if values.empty?
|
32
33
|
@values
|
33
34
|
else
|
34
35
|
@values = values
|
@@ -20,6 +20,7 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/libui/control_proxy'
|
23
|
+
require 'glimmer/libui/horizontal_box_proxy'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module LibUI
|
@@ -36,7 +37,7 @@ module Glimmer
|
|
36
37
|
@block = block
|
37
38
|
@enabled = 1
|
38
39
|
@index = @parent_proxy.num_pages
|
39
|
-
@content = @block
|
40
|
+
@content = @block&.call
|
40
41
|
build_control
|
41
42
|
end
|
42
43
|
|
@@ -57,6 +58,7 @@ module Glimmer
|
|
57
58
|
private
|
58
59
|
|
59
60
|
def build_control
|
61
|
+
@content = HorizontalBoxProxy.new('horizontal_box', @libui, []) if @content.nil?
|
60
62
|
@libui = @parent_proxy.append(name, @content.libui)
|
61
63
|
end
|
62
64
|
end
|
@@ -43,7 +43,7 @@ module Glimmer
|
|
43
43
|
def handle_listener(listener_name, &listener)
|
44
44
|
if listener_name == 'on_closing'
|
45
45
|
default_behavior_listener = Proc.new do
|
46
|
-
return_value = listener.call
|
46
|
+
return_value = listener.call(self)
|
47
47
|
if return_value.is_a?(Numeric)
|
48
48
|
return_value
|
49
49
|
else
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -143,8 +143,8 @@ dependencies:
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: 0.7.0
|
145
145
|
description: Prerequisite-Free Ruby Desktop Development GUI Library (no need to pre-install
|
146
|
-
any prerequisites. Just install the gem and have platform-independent GUI
|
147
|
-
works!)
|
146
|
+
any prerequisites. Just install the gem and have platform-independent native GUI
|
147
|
+
that just works!)
|
148
148
|
email: andy.am@gmail.com
|
149
149
|
executables:
|
150
150
|
- girb
|
@@ -185,6 +185,8 @@ files:
|
|
185
185
|
- lib/glimmer/libui/group_proxy.rb
|
186
186
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
187
187
|
- lib/glimmer/libui/menu_item_proxy.rb
|
188
|
+
- lib/glimmer/libui/multiline_entry_proxy.rb
|
189
|
+
- lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
|
188
190
|
- lib/glimmer/libui/preferences_menu_item_proxy.rb
|
189
191
|
- lib/glimmer/libui/quit_menu_item_proxy.rb
|
190
192
|
- lib/glimmer/libui/radio_buttons_proxy.rb
|