glimmer-dsl-libui 0.0.7 → 0.0.8
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 +10 -0
- data/README.md +76 -55
- data/VERSION +1 -1
- data/examples/basic_button.rb +1 -1
- data/examples/basic_entry.rb +3 -3
- data/examples/basic_window.rb +1 -1
- data/examples/basic_window2.rb +14 -0
- data/examples/control_gallery.rb +20 -20
- data/examples/midi_player.rb +2 -2
- data/examples/simple_notepad.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/box.rb +5 -3
- data/lib/glimmer/libui/control_proxy.rb +65 -20
- data/lib/glimmer/libui/date_picker_proxy.rb +32 -0
- data/lib/glimmer/libui/date_time_picker_proxy.rb +35 -0
- data/lib/glimmer/libui/group_proxy.rb +1 -1
- data/lib/glimmer/libui/tab_item_proxy.rb +1 -0
- data/lib/glimmer/libui/time_picker_proxy.rb +32 -0
- data/lib/glimmer/libui/window_proxy.rb +13 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5098a4f3a6ab5f314440a317cc77cc4d1c7fc65f2f190261d83710ffa9554dea
|
4
|
+
data.tar.gz: 7387058961fb36e05c598d8ef5c5e6ef109ce06eebac3626bed0628bc37511af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40f5597274951ddcf6b96d26923d2012b2a5d59cacbb53e384b14e2bf619609b11f3d9c035768dcf9a4e38fe2608106eee15e91e0b5f72f282d7e009f05ebacd
|
7
|
+
data.tar.gz: b8bfe79a0acb9def38d25682c04f17c8fcfebc44af81c12e20368654381e81ac902e29329470d2888d69fca0d1ebdd9ee505898164ef7dcc168281c349a06724
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.8
|
4
|
+
|
5
|
+
- Add `?` suffixed aliases to all boolean property methods
|
6
|
+
- Make C bool properties return boolean in Ruby (not `1` or `0`)
|
7
|
+
- Support passing boolean values to C bool properties in addition to `1` or `0`
|
8
|
+
- Support passing boolean values to C bool constructor args in addition to `1` or `0`
|
9
|
+
- Update all examples to utilize booleans
|
10
|
+
- Make `window` properties `title`=`'Glimmer'`, `content_size`=`150`,`150` & `has_menubar`=`1` if not specified as args in constructor
|
11
|
+
- Have string properties (e.g. `text` and `title`) return `String` not fiddle pointer
|
12
|
+
|
3
13
|
## 0.0.7
|
4
14
|
|
5
15
|
- Make `padded 1` the default in `horizontal_box` and `vertical_box` to achieve nicer looking GUI by default
|
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.8
|
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)
|
@@ -26,7 +26,7 @@ require 'glimmer-dsl-libui'
|
|
26
26
|
|
27
27
|
include Glimmer
|
28
28
|
|
29
|
-
window('hello world'
|
29
|
+
window('hello world').show
|
30
30
|
```
|
31
31
|
|
32
32
|

|
@@ -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.
|
46
|
+
- [Glimmer DSL for LibUI 0.0.8](#-glimmer-dsl-for-libui-008)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -82,8 +82,8 @@ The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for
|
|
82
82
|
- Requires the minimum amount of syntax needed to describe an app's GUI
|
83
83
|
|
84
84
|
The Glimmer GUI DSL follows these simple concepts in mapping from [LibUI](https://github.com/kojix2/LibUI) syntax:
|
85
|
-
- **Control**: [LibUI](https://github.com/kojix2/LibUI) controls may be declared by lower-case underscored name (aka keyword) (e.g. `window` or `button`). Behind the scenes, they are represented by keyword methods that map to corresponding `LibUI.new_keyword` methods receiving args (e.g. `window('hello world', 300, 200,
|
86
|
-
- **Content/Properties/Listeners Block**: Any keyword may be optionally followed by a Ruby curly-brace multi-line-block containing nested controls (content) and/or properties (attributes) (e.g. `window('hello world', 300, 200,
|
85
|
+
- **Control**: [LibUI](https://github.com/kojix2/LibUI) controls may be declared by lower-case underscored name (aka keyword) (e.g. `window` or `button`). Behind the scenes, they are represented by keyword methods that map to corresponding `LibUI.new_keyword` methods receiving args (e.g. `window('hello world', 300, 200, true)`).
|
86
|
+
- **Content/Properties/Listeners Block**: Any keyword may be optionally followed by a Ruby curly-brace multi-line-block containing nested controls (content) and/or properties (attributes) (e.g. `window('hello world', 300, 200, true) {button('greet')}`). It optionally receives one arg representing the control (e.g. `button('greet') {|b| on_clicked { puts b.text}}`)
|
87
87
|
- **Property**: Control properties may be declared inside keyword blocks with lower-case underscored name followed by property value args (e.g. `title "hello world"` inside `group`). Behind the scenes, properties correspond to `control_set_property` methods.
|
88
88
|
- **Listener**: Control listeners may be declared inside keyword blocks with listener lower-case underscored name beginning with `on_` and receiving required block handler (e.g. `on_clicked {puts 'clicked'}` inside `button`). Behind the scenes, listeners correspond to `control_on_event` methods.
|
89
89
|
|
@@ -125,7 +125,7 @@ require 'glimmer-dsl-libui'
|
|
125
125
|
|
126
126
|
include Glimmer
|
127
127
|
|
128
|
-
window('hello world', 300, 200
|
128
|
+
window('hello world', 300, 200) { |w|
|
129
129
|
button('Button') {
|
130
130
|
on_clicked do
|
131
131
|
msg_box(w, 'Information', 'You clicked the button')
|
@@ -149,7 +149,7 @@ gem install glimmer-dsl-libui
|
|
149
149
|
Or install via Bundler `Gemfile`:
|
150
150
|
|
151
151
|
```ruby
|
152
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
152
|
+
gem 'glimmer-dsl-libui', '~> 0.0.8'
|
153
153
|
```
|
154
154
|
|
155
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.
|
@@ -163,7 +163,7 @@ class Application
|
|
163
163
|
include Glimmer
|
164
164
|
|
165
165
|
def launch
|
166
|
-
window('hello world', 300, 200
|
166
|
+
window('hello world', 300, 200) {
|
167
167
|
button('Button') {
|
168
168
|
on_clicked do
|
169
169
|
puts 'Button Clicked'
|
@@ -206,44 +206,44 @@ Control(Args) | Properties | Listeners
|
|
206
206
|
------------- | ---------- | ---------
|
207
207
|
`about_menu_item` | None | `on_clicked`
|
208
208
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
209
|
-
`checkbox(text as String)` | `checked` (
|
210
|
-
`combobox` | `items` (`Array` of `String`), `selected` (`
|
211
|
-
`color_button` | `color` (r `Numeric`, g `Numeric`, b `Numeric`, a `Numeric`)
|
212
|
-
`date_picker` |
|
209
|
+
`checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
|
210
|
+
`combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
|
211
|
+
`color_button` | `color` (r `Numeric`, g `Numeric`, b `Numeric`, a `Numeric`) | `on_changed`
|
212
|
+
`date_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
|
213
213
|
`date_time_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
|
214
214
|
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
215
|
-
`entry` | `read_only` (
|
215
|
+
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
216
216
|
`font_button` | `font` (`LibUI::FFI::FontDescriptor`) | `on_changed`
|
217
|
-
`group(text as String)` | `margined` (
|
218
|
-
`horizontal_box` | `padded` (
|
217
|
+
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
218
|
+
`horizontal_box` | `padded` (Boolean) | None
|
219
219
|
`horizontal_separator` | None | None
|
220
220
|
`label(text as String)` | `text` (`String`) | None
|
221
221
|
`menu(text as String)` | None | None
|
222
|
-
`menu_item(text as String)` | `checked` (
|
223
|
-
`multiline_entry` | `read_only` (
|
222
|
+
`menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
|
223
|
+
`multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
224
224
|
`msg_box(window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
225
225
|
`msg_box_error(window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
226
|
-
`non_wrapping_multiline_entry` | `read_only` (
|
226
|
+
`non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
227
227
|
`preferences_menu_item` | None | `on_clicked`
|
228
228
|
`progress_bar` | `value` (`Numeric`) | None
|
229
229
|
`quit_menu_item` | None | `on_clicked`
|
230
|
-
`radio_buttons` | `selected` (`
|
230
|
+
`radio_buttons` | `selected` (`Integer`) | `on_selected`
|
231
231
|
`slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
232
232
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
233
|
-
`tab` | `margined` (
|
234
|
-
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (
|
235
|
-
`time_picker` |
|
236
|
-
`vertical_box` | `padded` (
|
237
|
-
`window(title as String, width as Integer, height as Integer, has_menubar as
|
233
|
+
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
234
|
+
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
235
|
+
`time_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
|
236
|
+
`vertical_box` | `padded` (Boolean) | None
|
237
|
+
`window(title as String, width as Integer, height as Integer, has_menubar as Boolean)` | `borderless` (Boolean), `content_size` (width `Numeric`, height `Numeric`), `fullscreen` (Boolean), `margined` (Boolean), `title` (`String`) | `on_closing`, `on_content_size_changed`
|
238
238
|
|
239
239
|
### Common Control Properties
|
240
|
-
- `enabled` (
|
240
|
+
- `enabled` (Boolean)
|
241
241
|
- `libui` (`Fiddle::Pointer`): returns wrapped [LibUI](https://github.com/kojix2/LibUI) object
|
242
242
|
- `parent_proxy` (`Glimmer::LibUI::ControlProxy` or subclass)
|
243
243
|
- `parent` (`Fiddle::Pointer`)
|
244
|
-
- `toplevel` [read-only] (
|
245
|
-
- `visible` (
|
246
|
-
- `stretchy` [dsl-only] (
|
244
|
+
- `toplevel` [read-only] (Boolean)
|
245
|
+
- `visible` (Boolean)
|
246
|
+
- `stretchy` [dsl-only] (Boolean): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
|
247
247
|
|
248
248
|
### Common Control Operations
|
249
249
|
- `destroy`
|
@@ -268,10 +268,14 @@ Control(Args) | Properties | Listeners
|
|
268
268
|
- `horizontal_box` and `vertical_box` controls have `padded` as `1` upon instantiation to ensure more user-friendly GUI by default
|
269
269
|
- `group` controls have `margined` as `1` upon instantiation to ensure more user-friendly GUI by default
|
270
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` 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`)
|
271
272
|
- `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
273
|
- `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
274
|
- 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
275
|
- 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`).
|
276
|
+
- All boolean property readers return `true` or `false` in Ruby instead of the [libui](https://github.com/andlabs/libui) original `0` or `1` in C.
|
277
|
+
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
278
|
+
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
|
275
279
|
|
276
280
|
### Original API
|
277
281
|
|
@@ -349,7 +353,7 @@ require 'glimmer-dsl-libui'
|
|
349
353
|
|
350
354
|
include Glimmer
|
351
355
|
|
352
|
-
window('hello world', 300, 200,
|
356
|
+
window('hello world', 300, 200, true) {
|
353
357
|
on_closing do
|
354
358
|
puts 'Bye Bye'
|
355
359
|
end
|
@@ -420,7 +424,7 @@ require 'glimmer-dsl-libui'
|
|
420
424
|
|
421
425
|
include Glimmer
|
422
426
|
|
423
|
-
window('hello world', 300, 200
|
427
|
+
window('hello world', 300, 200) { |w|
|
424
428
|
button('Button') {
|
425
429
|
on_clicked do
|
426
430
|
msg_box(w, 'Information', 'You clicked the button')
|
@@ -433,6 +437,23 @@ window('hello world', 300, 200, 1) { |w|
|
|
433
437
|
}.show
|
434
438
|
```
|
435
439
|
|
440
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2:
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
require 'glimmer-dsl-libui'
|
444
|
+
|
445
|
+
include Glimmer
|
446
|
+
|
447
|
+
window { # args can alternatively be set via properties with 4th arg has_menubar=true by default
|
448
|
+
title 'hello world'
|
449
|
+
content_size 300, 200
|
450
|
+
|
451
|
+
on_closing do
|
452
|
+
puts 'Bye Bye'
|
453
|
+
end
|
454
|
+
}.show
|
455
|
+
```
|
456
|
+
|
436
457
|
### Basic Entry
|
437
458
|
|
438
459
|
[examples/basic_entry.rb](examples/basic_entry.rb)
|
@@ -507,10 +528,10 @@ require 'glimmer-dsl-libui'
|
|
507
528
|
|
508
529
|
include Glimmer
|
509
530
|
|
510
|
-
window('Basic Entry', 300, 50
|
531
|
+
window('Basic Entry', 300, 50) { |w|
|
511
532
|
horizontal_box {
|
512
533
|
e = entry {
|
513
|
-
# stretchy
|
534
|
+
# stretchy true # Smart default option for appending to horizontal_box
|
514
535
|
|
515
536
|
on_changed do
|
516
537
|
puts e.text
|
@@ -519,7 +540,7 @@ window('Basic Entry', 300, 50, 1) { |w|
|
|
519
540
|
}
|
520
541
|
|
521
542
|
button('Button') {
|
522
|
-
stretchy
|
543
|
+
stretchy false
|
523
544
|
|
524
545
|
on_clicked do
|
525
546
|
text = e.text
|
@@ -593,7 +614,7 @@ require 'glimmer-dsl-libui'
|
|
593
614
|
|
594
615
|
include Glimmer
|
595
616
|
|
596
|
-
window('Notepad', 500, 300
|
617
|
+
window('Notepad', 500, 300) {
|
597
618
|
on_closing do
|
598
619
|
puts 'Bye Bye'
|
599
620
|
end
|
@@ -794,10 +815,10 @@ class TinyMidiPlayer
|
|
794
815
|
end
|
795
816
|
}
|
796
817
|
}
|
797
|
-
@main_window = window('Tiny Midi Player', 200, 50
|
818
|
+
@main_window = window('Tiny Midi Player', 200, 50) {
|
798
819
|
horizontal_box {
|
799
820
|
vertical_box {
|
800
|
-
stretchy
|
821
|
+
stretchy false
|
801
822
|
|
802
823
|
button('▶') {
|
803
824
|
on_clicked do
|
@@ -1082,7 +1103,7 @@ menu('Edit') {
|
|
1082
1103
|
check_menu_item('Checkable Item_')
|
1083
1104
|
separator_menu_item
|
1084
1105
|
menu_item('Disabled Item_') {
|
1085
|
-
enabled
|
1106
|
+
enabled false
|
1086
1107
|
}
|
1087
1108
|
}
|
1088
1109
|
|
@@ -1092,8 +1113,8 @@ menu('Help') {
|
|
1092
1113
|
about_menu_item # Can optionally contain an on_clicked listener
|
1093
1114
|
}
|
1094
1115
|
|
1095
|
-
MAIN_WINDOW = window('Control Gallery', 600, 500
|
1096
|
-
margined
|
1116
|
+
MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
1117
|
+
margined true
|
1097
1118
|
|
1098
1119
|
on_closing do
|
1099
1120
|
puts 'Bye Bye'
|
@@ -1104,7 +1125,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1104
1125
|
group('Basic Controls') {
|
1105
1126
|
vertical_box {
|
1106
1127
|
button('Button') {
|
1107
|
-
stretchy
|
1128
|
+
stretchy false
|
1108
1129
|
|
1109
1130
|
on_clicked do
|
1110
1131
|
msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
@@ -1112,7 +1133,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1112
1133
|
}
|
1113
1134
|
|
1114
1135
|
checkbox('Checkbox') {
|
1115
|
-
stretchy
|
1136
|
+
stretchy false
|
1116
1137
|
|
1117
1138
|
on_toggled do |c|
|
1118
1139
|
checked = c.checked == 1
|
@@ -1121,29 +1142,29 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1121
1142
|
end
|
1122
1143
|
}
|
1123
1144
|
|
1124
|
-
label('Label') { stretchy
|
1145
|
+
label('Label') { stretchy false }
|
1125
1146
|
|
1126
|
-
horizontal_separator { stretchy
|
1147
|
+
horizontal_separator { stretchy false }
|
1127
1148
|
|
1128
|
-
date_picker { stretchy
|
1149
|
+
date_picker { stretchy false }
|
1129
1150
|
|
1130
|
-
time_picker { stretchy
|
1151
|
+
time_picker { stretchy false }
|
1131
1152
|
|
1132
|
-
date_time_picker { stretchy
|
1153
|
+
date_time_picker { stretchy false }
|
1133
1154
|
|
1134
|
-
font_button { stretchy
|
1155
|
+
font_button { stretchy false }
|
1135
1156
|
|
1136
|
-
color_button { stretchy
|
1157
|
+
color_button { stretchy false }
|
1137
1158
|
}
|
1138
1159
|
}
|
1139
1160
|
|
1140
1161
|
vertical_box {
|
1141
1162
|
group('Numbers') {
|
1142
|
-
stretchy
|
1163
|
+
stretchy false
|
1143
1164
|
|
1144
1165
|
vertical_box {
|
1145
1166
|
spinbox(0, 100) {
|
1146
|
-
stretchy
|
1167
|
+
stretchy false
|
1147
1168
|
value 42
|
1148
1169
|
|
1149
1170
|
on_changed do |s|
|
@@ -1152,7 +1173,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1152
1173
|
}
|
1153
1174
|
|
1154
1175
|
slider(0, 100) {
|
1155
|
-
stretchy
|
1176
|
+
stretchy false
|
1156
1177
|
|
1157
1178
|
on_changed do |s|
|
1158
1179
|
v = s.value
|
@@ -1161,16 +1182,16 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1161
1182
|
end
|
1162
1183
|
}
|
1163
1184
|
|
1164
|
-
@progress_bar = progress_bar { stretchy
|
1185
|
+
@progress_bar = progress_bar { stretchy false }
|
1165
1186
|
}
|
1166
1187
|
}
|
1167
1188
|
|
1168
1189
|
group('Lists') {
|
1169
|
-
stretchy
|
1190
|
+
stretchy false
|
1170
1191
|
|
1171
1192
|
vertical_box {
|
1172
1193
|
combobox {
|
1173
|
-
stretchy
|
1194
|
+
stretchy false
|
1174
1195
|
items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
|
1175
1196
|
|
1176
1197
|
on_selected do |c|
|
@@ -1179,7 +1200,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1179
1200
|
}
|
1180
1201
|
|
1181
1202
|
editable_combobox {
|
1182
|
-
stretchy
|
1203
|
+
stretchy false
|
1183
1204
|
items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
|
1184
1205
|
}
|
1185
1206
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/examples/basic_button.rb
CHANGED
data/examples/basic_entry.rb
CHANGED
@@ -4,10 +4,10 @@ require 'glimmer-dsl-libui'
|
|
4
4
|
|
5
5
|
include Glimmer
|
6
6
|
|
7
|
-
window('Basic Entry', 300, 50
|
7
|
+
window('Basic Entry', 300, 50) { |w|
|
8
8
|
horizontal_box {
|
9
9
|
e = entry {
|
10
|
-
# stretchy
|
10
|
+
# stretchy true # Smart default option for appending to horizontal_box
|
11
11
|
|
12
12
|
on_changed do
|
13
13
|
puts e.text
|
@@ -16,7 +16,7 @@ window('Basic Entry', 300, 50, 1) { |w|
|
|
16
16
|
}
|
17
17
|
|
18
18
|
button('Button') {
|
19
|
-
stretchy
|
19
|
+
stretchy false
|
20
20
|
|
21
21
|
on_clicked do
|
22
22
|
text = e.text
|
data/examples/basic_window.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window { # args can alternatively be set via properties with 4th arg has_menubar=true by default
|
8
|
+
title 'hello world'
|
9
|
+
content_size 300, 200
|
10
|
+
|
11
|
+
on_closing do
|
12
|
+
puts 'Bye Bye'
|
13
|
+
end
|
14
|
+
}.show
|
data/examples/control_gallery.rb
CHANGED
@@ -32,7 +32,7 @@ menu('Edit') {
|
|
32
32
|
check_menu_item('Checkable Item_')
|
33
33
|
separator_menu_item
|
34
34
|
menu_item('Disabled Item_') {
|
35
|
-
enabled
|
35
|
+
enabled false
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
@@ -42,8 +42,8 @@ menu('Help') {
|
|
42
42
|
about_menu_item # Can optionally contain an on_clicked listener
|
43
43
|
}
|
44
44
|
|
45
|
-
MAIN_WINDOW = window('Control Gallery', 600, 500
|
46
|
-
margined
|
45
|
+
MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
46
|
+
margined true
|
47
47
|
|
48
48
|
on_closing do
|
49
49
|
puts 'Bye Bye'
|
@@ -54,7 +54,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
54
54
|
group('Basic Controls') {
|
55
55
|
vertical_box {
|
56
56
|
button('Button') {
|
57
|
-
stretchy
|
57
|
+
stretchy false
|
58
58
|
|
59
59
|
on_clicked do
|
60
60
|
msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
@@ -62,38 +62,38 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
62
62
|
}
|
63
63
|
|
64
64
|
checkbox('Checkbox') {
|
65
|
-
stretchy
|
65
|
+
stretchy false
|
66
66
|
|
67
67
|
on_toggled do |c|
|
68
|
-
checked = c.checked
|
68
|
+
checked = c.checked?
|
69
69
|
MAIN_WINDOW.title = "Checkbox is #{checked}"
|
70
70
|
c.text = "I am the checkbox (#{checked})"
|
71
71
|
end
|
72
72
|
}
|
73
73
|
|
74
|
-
label('Label') { stretchy
|
74
|
+
label('Label') { stretchy false }
|
75
75
|
|
76
|
-
horizontal_separator { stretchy
|
76
|
+
horizontal_separator { stretchy false }
|
77
77
|
|
78
|
-
date_picker { stretchy
|
78
|
+
date_picker { stretchy false }
|
79
79
|
|
80
|
-
time_picker { stretchy
|
80
|
+
time_picker { stretchy false }
|
81
81
|
|
82
|
-
date_time_picker { stretchy
|
82
|
+
date_time_picker { stretchy false }
|
83
83
|
|
84
|
-
font_button { stretchy
|
84
|
+
font_button { stretchy false }
|
85
85
|
|
86
|
-
color_button { stretchy
|
86
|
+
color_button { stretchy false }
|
87
87
|
}
|
88
88
|
}
|
89
89
|
|
90
90
|
vertical_box {
|
91
91
|
group('Numbers') {
|
92
|
-
stretchy
|
92
|
+
stretchy false
|
93
93
|
|
94
94
|
vertical_box {
|
95
95
|
spinbox(0, 100) {
|
96
|
-
stretchy
|
96
|
+
stretchy false
|
97
97
|
value 42
|
98
98
|
|
99
99
|
on_changed do |s|
|
@@ -102,7 +102,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
102
102
|
}
|
103
103
|
|
104
104
|
slider(0, 100) {
|
105
|
-
stretchy
|
105
|
+
stretchy false
|
106
106
|
|
107
107
|
on_changed do |s|
|
108
108
|
v = s.value
|
@@ -111,16 +111,16 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
111
111
|
end
|
112
112
|
}
|
113
113
|
|
114
|
-
@progress_bar = progress_bar { stretchy
|
114
|
+
@progress_bar = progress_bar { stretchy false }
|
115
115
|
}
|
116
116
|
}
|
117
117
|
|
118
118
|
group('Lists') {
|
119
|
-
stretchy
|
119
|
+
stretchy false
|
120
120
|
|
121
121
|
vertical_box {
|
122
122
|
combobox {
|
123
|
-
stretchy
|
123
|
+
stretchy false
|
124
124
|
items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
|
125
125
|
|
126
126
|
on_selected do |c|
|
@@ -129,7 +129,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
129
129
|
}
|
130
130
|
|
131
131
|
editable_combobox {
|
132
|
-
stretchy
|
132
|
+
stretchy false
|
133
133
|
items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
|
134
134
|
}
|
135
135
|
|
data/examples/midi_player.rb
CHANGED
@@ -56,10 +56,10 @@ class TinyMidiPlayer
|
|
56
56
|
end
|
57
57
|
}
|
58
58
|
}
|
59
|
-
@main_window = window('Tiny Midi Player', 200, 50
|
59
|
+
@main_window = window('Tiny Midi Player', 200, 50) {
|
60
60
|
horizontal_box {
|
61
61
|
vertical_box {
|
62
|
-
stretchy
|
62
|
+
stretchy false
|
63
63
|
|
64
64
|
button('▶') {
|
65
65
|
on_clicked do
|
data/examples/simple_notepad.rb
CHANGED
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui/box.rb
CHANGED
@@ -19,14 +19,16 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
22
24
|
module Glimmer
|
23
25
|
module LibUI
|
24
26
|
module Box
|
25
27
|
APPEND_PROPERTIES = %w[stretchy]
|
26
28
|
|
27
29
|
def post_initialize_child(child)
|
28
|
-
child.stretchy =
|
29
|
-
::LibUI.box_append(@libui, child.libui, child.stretchy)
|
30
|
+
child.stretchy = true if child.stretchy.nil?
|
31
|
+
::LibUI.box_append(@libui, child.libui, ControlProxy.boolean_to_integer(child.stretchy))
|
30
32
|
end
|
31
33
|
|
32
34
|
def libui_api_keyword
|
@@ -37,7 +39,7 @@ module Glimmer
|
|
37
39
|
|
38
40
|
def build_control
|
39
41
|
super.tap do
|
40
|
-
self.padded =
|
42
|
+
self.padded = true
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -54,8 +54,31 @@ module Glimmer
|
|
54
54
|
def main_window_proxy
|
55
55
|
all_control_proxies.find {|c| c.is_a?(WindowProxy)}
|
56
56
|
end
|
57
|
+
|
58
|
+
def integer_to_boolean(int)
|
59
|
+
int.nil? ? nil : int == 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def boolean_to_integer(bool)
|
63
|
+
bool.nil? ? nil : (bool ? 1 : 0)
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
67
|
+
BOOLEAN_PROPERTIES = %w[
|
68
|
+
padded
|
69
|
+
checked
|
70
|
+
enabled toplevel visible
|
71
|
+
read_only
|
72
|
+
margined
|
73
|
+
borderless fullscreen
|
74
|
+
stretchy
|
75
|
+
]
|
76
|
+
|
77
|
+
STRING_PROPERTIES = %w[
|
78
|
+
text
|
79
|
+
title
|
80
|
+
]
|
81
|
+
|
59
82
|
# libui returns the contained LibUI object
|
60
83
|
attr_reader :parent_proxy, :libui, :args, :keyword
|
61
84
|
|
@@ -64,11 +87,8 @@ module Glimmer
|
|
64
87
|
@parent_proxy = parent
|
65
88
|
@args = args
|
66
89
|
@block = block
|
67
|
-
@enabled =
|
90
|
+
@enabled = true
|
68
91
|
build_control
|
69
|
-
if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
|
70
|
-
@parent_proxy.class::APPEND_PROPERTIES
|
71
|
-
end
|
72
92
|
post_add_content if @block.nil?
|
73
93
|
end
|
74
94
|
|
@@ -106,21 +126,28 @@ module Glimmer
|
|
106
126
|
|
107
127
|
def respond_to?(method_name, *args, &block)
|
108
128
|
respond_to_libui?(method_name, *args, &block) ||
|
109
|
-
(
|
129
|
+
(
|
130
|
+
append_properties.include?(method_name.to_s) ||
|
131
|
+
(append_properties.include?(method_name.to_s.sub(/\?$/, '')) && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, ''))) ||
|
132
|
+
append_properties.include?(method_name.to_s.sub(/=$/, ''))
|
133
|
+
) ||
|
110
134
|
super(method_name, true)
|
111
135
|
end
|
112
136
|
|
113
137
|
def respond_to_libui?(method_name, *args, &block)
|
114
138
|
::LibUI.respond_to?("control_#{method_name}") ||
|
139
|
+
(::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) ||
|
140
|
+
::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}") ||
|
115
141
|
::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") ||
|
116
|
-
::LibUI.respond_to?("#{libui_api_keyword}
|
142
|
+
(::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) ||
|
117
143
|
::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
|
118
144
|
end
|
119
145
|
|
120
146
|
def method_missing(method_name, *args, &block)
|
121
147
|
if respond_to_libui?(method_name, *args, &block)
|
122
148
|
send_to_libui(method_name, *args, &block)
|
123
|
-
elsif
|
149
|
+
elsif append_properties.include?(method_name.to_s) ||
|
150
|
+
append_properties.include?(method_name.to_s.sub(/(=|\?)$/, ''))
|
124
151
|
append_property(method_name, *args)
|
125
152
|
else
|
126
153
|
super
|
@@ -128,17 +155,25 @@ module Glimmer
|
|
128
155
|
end
|
129
156
|
|
130
157
|
def send_to_libui(method_name, *args, &block)
|
131
|
-
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && args.empty?
|
132
|
-
|
133
|
-
|
134
|
-
|
158
|
+
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
159
|
+
property = method_name.to_s.sub(/\?$/, '')
|
160
|
+
value = ::LibUI.send("#{libui_api_keyword}_#{property}", @libui, *args)
|
161
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
135
162
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
136
|
-
|
137
|
-
|
138
|
-
::LibUI.send("#{libui_api_keyword}
|
163
|
+
property = method_name.to_s.sub(/=$/, '')
|
164
|
+
args[0] = ControlProxy.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
165
|
+
::LibUI.send("#{libui_api_keyword}_set_#{property}", @libui, *args)
|
139
166
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
|
140
167
|
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
141
|
-
elsif ::LibUI.respond_to?("control_#{method_name}")
|
168
|
+
elsif ::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
169
|
+
property = method_name.to_s.sub(/\?$/, '')
|
170
|
+
value = ::LibUI.send("control_#{method_name.to_s.sub(/\?$/, '')}", @libui, *args)
|
171
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
172
|
+
elsif ::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}")
|
173
|
+
property = method_name.to_s.sub(/=$/, '')
|
174
|
+
args[0] = ControlProxy.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
175
|
+
::LibUI.send("control_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
|
176
|
+
elsif ::LibUI.respond_to?("control_#{method_name}") && !args.empty?
|
142
177
|
::LibUI.send("control_#{method_name}", @libui, *args)
|
143
178
|
end
|
144
179
|
end
|
@@ -148,11 +183,13 @@ module Glimmer
|
|
148
183
|
end
|
149
184
|
|
150
185
|
def append_property(property, value = nil)
|
151
|
-
property = property.to_s.sub(
|
186
|
+
property = property.to_s.sub(/(=|\?)$/, '')
|
152
187
|
@append_property_hash ||= {}
|
153
188
|
if value.nil?
|
154
|
-
@append_property_hash[property]
|
189
|
+
value = @append_property_hash[property]
|
190
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
155
191
|
else
|
192
|
+
value = ControlProxy.boolean_to_integer(value) if BOOLEAN_PROPERTIES.include?(property) && (value.is_a?(TrueClass) || value.is_a?(FalseClass))
|
156
193
|
@append_property_hash[property] = value
|
157
194
|
end
|
158
195
|
end
|
@@ -165,7 +202,7 @@ module Glimmer
|
|
165
202
|
if value.nil?
|
166
203
|
@enabled
|
167
204
|
elsif value != @enabled
|
168
|
-
if value == 1
|
205
|
+
if value == 1 || value
|
169
206
|
send_to_libui('enable')
|
170
207
|
else
|
171
208
|
send_to_libui('disable')
|
@@ -181,7 +218,7 @@ module Glimmer
|
|
181
218
|
if value.nil?
|
182
219
|
current_value
|
183
220
|
elsif value != current_value
|
184
|
-
if value == 1
|
221
|
+
if value == 1 || value
|
185
222
|
send_to_libui('show')
|
186
223
|
else
|
187
224
|
send_to_libui('hide')
|
@@ -196,7 +233,7 @@ module Glimmer
|
|
196
233
|
send_to_libui('destroy')
|
197
234
|
self.class.all_control_proxies.delete(self)
|
198
235
|
end
|
199
|
-
|
236
|
+
|
200
237
|
private
|
201
238
|
|
202
239
|
def build_control
|
@@ -207,6 +244,14 @@ module Glimmer
|
|
207
244
|
::LibUI.send(@keyword, *@args)
|
208
245
|
end
|
209
246
|
end
|
247
|
+
|
248
|
+
def handle_boolean_property(property, value)
|
249
|
+
BOOLEAN_PROPERTIES.include?(property) ? ControlProxy.integer_to_boolean(value) : value
|
250
|
+
end
|
251
|
+
|
252
|
+
def handle_string_property(property, value)
|
253
|
+
STRING_PROPERTIES.include?(property) ? value.to_s : value
|
254
|
+
end
|
210
255
|
end
|
211
256
|
end
|
212
257
|
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/date_time_picker_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI date picker objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class DatePickerProxy < DateTimePickerProxy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -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 date time picker objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class DateTimePickerProxy < ControlProxy
|
30
|
+
def libui_api_keyword
|
31
|
+
'date_time_picker'
|
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/date_time_picker_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI time picker objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class TimePickerProxy < DateTimePickerProxy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -27,6 +27,11 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class WindowProxy < ControlProxy
|
30
|
+
DEFAULT_TITLE = 'Glimmer'
|
31
|
+
DEFAULT_WIDTH = 150
|
32
|
+
DEFAULT_HEIGHT = 150
|
33
|
+
DEFAULT_HAS_MENUBAR = 1
|
34
|
+
|
30
35
|
def post_initialize_child(child)
|
31
36
|
::LibUI.window_set_child(@libui, child.libui)
|
32
37
|
end
|
@@ -59,7 +64,14 @@ module Glimmer
|
|
59
64
|
private
|
60
65
|
|
61
66
|
def build_control
|
62
|
-
|
67
|
+
construction_args = @args.dup
|
68
|
+
construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
|
69
|
+
construction_args[1] = DEFAULT_WIDTH if construction_args.size == 1
|
70
|
+
construction_args[2] = DEFAULT_HEIGHT if construction_args.size == 2
|
71
|
+
construction_args[3] = DEFAULT_HAS_MENUBAR if construction_args.size == 3
|
72
|
+
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))
|
73
|
+
@libui = ::LibUI.send("new_window", *construction_args)
|
74
|
+
@libui.tap do
|
63
75
|
handle_listener('on_closing') do
|
64
76
|
destroy
|
65
77
|
::LibUI.quit
|
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.
|
4
|
+
version: 0.0.8
|
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-
|
11
|
+
date: 2021-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -142,9 +142,9 @@ dependencies:
|
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: 0.7.0
|
145
|
-
description: Prerequisite-Free Ruby Desktop Development GUI
|
146
|
-
any prerequisites. Just install the gem and have
|
147
|
-
that just works!)
|
145
|
+
description: Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development GUI
|
146
|
+
Library (no need to pre-install any prerequisites. Just install the gem and have
|
147
|
+
platform-independent native GUI that just works!)
|
148
148
|
email: andy.am@gmail.com
|
149
149
|
executables:
|
150
150
|
- girb
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- examples/basic_button.rb
|
164
164
|
- examples/basic_entry.rb
|
165
165
|
- examples/basic_window.rb
|
166
|
+
- examples/basic_window2.rb
|
166
167
|
- examples/control_gallery.rb
|
167
168
|
- examples/midi_player.rb
|
168
169
|
- examples/simple_notepad.rb
|
@@ -181,6 +182,8 @@ files:
|
|
181
182
|
- lib/glimmer/libui/check_menu_item_proxy.rb
|
182
183
|
- lib/glimmer/libui/combobox_proxy.rb
|
183
184
|
- lib/glimmer/libui/control_proxy.rb
|
185
|
+
- lib/glimmer/libui/date_picker_proxy.rb
|
186
|
+
- lib/glimmer/libui/date_time_picker_proxy.rb
|
184
187
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
185
188
|
- lib/glimmer/libui/group_proxy.rb
|
186
189
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
@@ -192,6 +195,7 @@ files:
|
|
192
195
|
- lib/glimmer/libui/radio_buttons_proxy.rb
|
193
196
|
- lib/glimmer/libui/separator_menu_item_proxy.rb
|
194
197
|
- lib/glimmer/libui/tab_item_proxy.rb
|
198
|
+
- lib/glimmer/libui/time_picker_proxy.rb
|
195
199
|
- lib/glimmer/libui/vertical_box_proxy.rb
|
196
200
|
- lib/glimmer/libui/window_proxy.rb
|
197
201
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-libui
|