glimmer-dsl-libui 0.0.5 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +259 -106
- 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 +37 -53
- data/examples/meta_example.rb +57 -0
- data/examples/midi_player.rb +2 -2
- data/examples/simple_notepad.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/tab_item_expression.rb +1 -1
- data/lib/glimmer/libui/box.rb +12 -2
- data/lib/glimmer/libui/combobox_proxy.rb +3 -2
- data/lib/glimmer/libui/control_proxy.rb +96 -26
- 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/editable_combobox_proxy.rb +3 -2
- data/lib/glimmer/libui/group_proxy.rb +8 -0
- 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 +4 -4
- data/lib/glimmer/libui/radio_buttons_proxy.rb +3 -2
- data/lib/glimmer/libui/tab_item_proxy.rb +4 -1
- data/lib/glimmer/libui/time_picker_proxy.rb +32 -0
- data/lib/glimmer/libui/window_proxy.rb +14 -2
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aa989bad8bba6c9e59285e38a699b7842eb7f089a976782ac75363debfd829e
|
4
|
+
data.tar.gz: '081812a749e0ab795dfafcac60b58ab639f50933580f5ed3e404354691dd3d94'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e189f2db6399f9f718a06ca68b82665c7d9b54031dc62a76af1a4bb056f1299f40fe9993940163594157bdfcd649635cc27967aaadb7b709286d0b630d9b584
|
7
|
+
data.tar.gz: 5289461f384cf3237add39dba3fba83448c117d63ca53ac8e5dcc0af33cb4683179e077a712e927615825fc226bf94b234b4088e45b3f8de6c7b97a0d480c3a4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.9
|
4
|
+
|
5
|
+
- Build a meta-example (example of examples)
|
6
|
+
|
7
|
+
## 0.0.8
|
8
|
+
|
9
|
+
- Add `?` suffixed aliases to all boolean property methods
|
10
|
+
- Make C bool properties return boolean in Ruby (not `1` or `0`)
|
11
|
+
- Support passing boolean values to C bool properties in addition to `1` or `0`
|
12
|
+
- Support passing boolean values to C bool constructor args in addition to `1` or `0`
|
13
|
+
- Update all examples to utilize booleans
|
14
|
+
- Make `window` properties `title`=`'Glimmer'`, `content_size`=`150`,`150` & `has_menubar`=`1` if not specified as args in constructor
|
15
|
+
- Have string properties (e.g. `text` and `title`) return `String` not fiddle pointer
|
16
|
+
|
17
|
+
## 0.0.7
|
18
|
+
|
19
|
+
- Make `padded 1` the default in `horizontal_box` and `vertical_box` to achieve nicer looking GUI by default
|
20
|
+
- Make `margined 1` the default in `group` to achieve nicer looking GUI by default
|
21
|
+
- Destroy main window upon hitting quit on quit menu item
|
22
|
+
- Rename `ControlProxy::all_controls` to `ControlProxy::all_control_proxies` to more accurately describe its contents
|
23
|
+
- Add `ControlProxy::main_window_proxy` method to retrieve main window proxy
|
24
|
+
- Define a `#window_proxy` method on `ControlProxy` to retrieve `window` control proxy for any control
|
25
|
+
|
26
|
+
## 0.0.6
|
27
|
+
|
28
|
+
- Make listener block provide Ruby proxy object as optional argument (not Fiddle pointer)
|
29
|
+
- 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)
|
30
|
+
- Support `non_wrapping_multiline_entry` propeties/operations via `LibUI.multiline_entry_*` methods (enhancing them to accept Ruby objects in addition to pointers)
|
31
|
+
- Support splatting `items` array for `radio_buttons`, `editable_combobox`, and `combobox` items
|
32
|
+
- Fix issue with `menu_item` `on_clicked` listeners crashing in examples/control_gallery.rb due to garbage collection
|
33
|
+
|
3
34
|
## 0.0.5
|
4
35
|
|
5
36
|
- 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.9
|
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)
|
5
5
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](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
|
|
@@ -17,7 +17,7 @@ The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/gl
|
|
17
17
|
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
18
18
|
- Custom Widget support
|
19
19
|
- Scaffolding for new custom widgets, apps, and gems
|
20
|
-
- Native-Executable packaging on Mac, Windows, and Linux
|
20
|
+
- Native-Executable packaging on Mac, Windows, and Linux.
|
21
21
|
|
22
22
|
Example:
|
23
23
|
|
@@ -26,13 +26,13 @@ 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
|
![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)
|
@@ -41,6 +41,37 @@ 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.9](#-glimmer-dsl-for-libui-009)
|
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 Dialogs](#extra-dialogs)
|
54
|
+
- [Extra Operations](#extra-operations)
|
55
|
+
- [Smart Defaults and Conventions](#smart-defaults-and-conventions)
|
56
|
+
- [Original API](#original-api)
|
57
|
+
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
58
|
+
- [Examples](#examples)
|
59
|
+
- [Basic Window](#basic-window)
|
60
|
+
- [Basic Button](#basic-button)
|
61
|
+
- [Basic Entry](#basic-entry)
|
62
|
+
- [Simple Notepad](#simple-notepad)
|
63
|
+
- [Midi Player](#midi-player)
|
64
|
+
- [Control Gallery](#control-gallery)
|
65
|
+
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
66
|
+
- [Help](#help)
|
67
|
+
- [Issues](#issues)
|
68
|
+
- [Chat](#chat)
|
69
|
+
- [Process](#process)
|
70
|
+
- [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
|
71
|
+
- [Change Log](#change-log)
|
72
|
+
- [Contributors](#contributors)
|
73
|
+
- [License](#license)
|
74
|
+
|
44
75
|
## Glimmer GUI DSL Concepts
|
45
76
|
|
46
77
|
The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for [LibUI](https://github.com/kojix2/LibUI) that:
|
@@ -51,8 +82,8 @@ The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for
|
|
51
82
|
- Requires the minimum amount of syntax needed to describe an app's GUI
|
52
83
|
|
53
84
|
The Glimmer GUI DSL follows these simple concepts in mapping from [LibUI](https://github.com/kojix2/LibUI) syntax:
|
54
|
-
- **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,
|
55
|
-
- **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}}`)
|
56
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.
|
57
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.
|
58
89
|
|
@@ -94,7 +125,7 @@ require 'glimmer-dsl-libui'
|
|
94
125
|
|
95
126
|
include Glimmer
|
96
127
|
|
97
|
-
window('hello world', 300, 200
|
128
|
+
window('hello world', 300, 200) { |w|
|
98
129
|
button('Button') {
|
99
130
|
on_clicked do
|
100
131
|
msg_box(w, 'Information', 'You clicked the button')
|
@@ -118,7 +149,7 @@ gem install glimmer-dsl-libui
|
|
118
149
|
Or install via Bundler `Gemfile`:
|
119
150
|
|
120
151
|
```ruby
|
121
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
152
|
+
gem 'glimmer-dsl-libui', '~> 0.0.9'
|
122
153
|
```
|
123
154
|
|
124
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.
|
@@ -132,7 +163,7 @@ class Application
|
|
132
163
|
include Glimmer
|
133
164
|
|
134
165
|
def launch
|
135
|
-
window('hello world', 300, 200
|
166
|
+
window('hello world', 300, 200) {
|
136
167
|
button('Button') {
|
137
168
|
on_clicked do
|
138
169
|
puts 'Button Clicked'
|
@@ -169,51 +200,87 @@ w = window('hello world', 300, 200, 1) # => #<Glimmer::LibUI::WindowProxy:0x0000
|
|
169
200
|
w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
|
170
201
|
```
|
171
202
|
|
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
|
-
|
201
|
-
|
203
|
+
### Supported Controls
|
204
|
+
|
205
|
+
Control(Args) | Properties | Listeners
|
206
|
+
------------- | ---------- | ---------
|
207
|
+
`about_menu_item` | None | `on_clicked`
|
208
|
+
`button(text as String)` | `text` (`String`) | `on_clicked`
|
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
|
+
`date_time_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
|
214
|
+
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
215
|
+
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
216
|
+
`font_button` | `font` (`LibUI::FFI::FontDescriptor`) | `on_changed`
|
217
|
+
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
218
|
+
`horizontal_box` | `padded` (Boolean) | None
|
219
|
+
`horizontal_separator` | None | None
|
220
|
+
`label(text as String)` | `text` (`String`) | None
|
221
|
+
`menu(text as String)` | None | None
|
222
|
+
`menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
|
223
|
+
`multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
224
|
+
`msg_box(window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
225
|
+
`msg_box_error(window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
226
|
+
`non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
227
|
+
`preferences_menu_item` | None | `on_clicked`
|
228
|
+
`progress_bar` | `value` (`Numeric`) | None
|
229
|
+
`quit_menu_item` | None | `on_clicked`
|
230
|
+
`radio_buttons` | `selected` (`Integer`) | `on_selected`
|
231
|
+
`slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
232
|
+
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
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
|
+
|
239
|
+
### Common Control Properties
|
240
|
+
- `enabled` (Boolean)
|
202
241
|
- `libui` (`Fiddle::Pointer`): returns wrapped [LibUI](https://github.com/kojix2/LibUI) object
|
203
242
|
- `parent_proxy` (`Glimmer::LibUI::ControlProxy` or subclass)
|
204
243
|
- `parent` (`Fiddle::Pointer`)
|
205
|
-
- `toplevel` [read-only] (
|
206
|
-
- `visible` (
|
207
|
-
- `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`
|
208
247
|
|
209
|
-
Common Control Operations
|
248
|
+
### Common Control Operations
|
210
249
|
- `destroy`
|
211
250
|
- `disable`
|
212
251
|
- `enable`
|
213
252
|
- `hide`
|
214
253
|
- `show`
|
215
254
|
|
216
|
-
|
255
|
+
### Extra Dialogs
|
256
|
+
|
257
|
+
- `open_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
258
|
+
- `save_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
259
|
+
|
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 `true` upon instantiation to ensure more user-friendly GUI by default
|
269
|
+
- `group` controls have `margined` as `true` 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 `true` 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`)
|
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)
|
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)
|
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`).
|
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.
|
279
|
+
|
280
|
+
### Original API
|
281
|
+
|
282
|
+
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),
|
283
|
+
check out the [libui C headers](https://github.com/andlabs/libui/blob/master/ui.h)
|
217
284
|
|
218
285
|
## Girb (Glimmer IRB)
|
219
286
|
|
@@ -229,7 +296,92 @@ Gotcha: On the Mac, when you close a window opened in `girb`, it remains open un
|
|
229
296
|
|
230
297
|
## Examples
|
231
298
|
|
232
|
-
These examples
|
299
|
+
These examples include reimplementions of the examples in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the [Glimmer GUI DSL](#glimmer-gui-dsl-concepts).
|
300
|
+
|
301
|
+
To browse all examples, simply launch the [Meta-Example](examples/meta_example.rb), which lists all examples and displays each example's code when selected.
|
302
|
+
|
303
|
+
[examples/meta_example.rb](examples/meta_example.rb)
|
304
|
+
|
305
|
+
Run with this command from the root of the project if you cloned the project:
|
306
|
+
|
307
|
+
```
|
308
|
+
ruby -r './lib/glimmer-dsl-libui' examples/meta_example.rb
|
309
|
+
```
|
310
|
+
|
311
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
312
|
+
|
313
|
+
```
|
314
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/meta_example'"
|
315
|
+
```
|
316
|
+
|
317
|
+
Mac
|
318
|
+
|
319
|
+
![glimmer-dsl-libui-mac-meta-example.png](images/glimmer-dsl-libui-mac-meta-example.png)
|
320
|
+
|
321
|
+
Linux
|
322
|
+
|
323
|
+
![glimmer-dsl-libui-linux-meta-example.png](images/glimmer-dsl-libui-linux-meta-example.png)
|
324
|
+
|
325
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
326
|
+
|
327
|
+
```ruby
|
328
|
+
require 'glimmer-dsl-libui'
|
329
|
+
require 'facets'
|
330
|
+
|
331
|
+
class MetaExample
|
332
|
+
include Glimmer
|
333
|
+
|
334
|
+
def examples
|
335
|
+
if @examples.nil?
|
336
|
+
example_files = Dir.glob(File.join(File.expand_path('.', __dir__), '**', '*.rb'))
|
337
|
+
example_file_names = example_files.map { |f| File.basename(f, '.rb') }
|
338
|
+
example_file_names = example_file_names.reject { |f| f == 'meta_example' }
|
339
|
+
@examples = example_file_names.map { |f| f.underscore.titlecase }
|
340
|
+
end
|
341
|
+
@examples
|
342
|
+
end
|
343
|
+
|
344
|
+
def file_path_for(example)
|
345
|
+
File.join(File.expand_path('.', __dir__), "#{example.underscore}.rb")
|
346
|
+
end
|
347
|
+
|
348
|
+
def launch
|
349
|
+
window('Meta-Example', 700, 500) { |w|
|
350
|
+
margined true
|
351
|
+
|
352
|
+
horizontal_box {
|
353
|
+
vertical_box {
|
354
|
+
@rbs = radio_buttons {
|
355
|
+
stretchy false
|
356
|
+
items examples
|
357
|
+
selected 0
|
358
|
+
|
359
|
+
on_selected do
|
360
|
+
@nwme.text = File.read(file_path_for(@examples[@rbs.selected]))
|
361
|
+
end
|
362
|
+
}
|
363
|
+
button('Launch') {
|
364
|
+
stretchy false
|
365
|
+
|
366
|
+
on_clicked do
|
367
|
+
system "ruby -r puts_debuggerer -r #{File.expand_path('../lib/glimmer-dsl-libui', __dir__)} #{file_path_for(@examples[@rbs.selected])}"
|
368
|
+
end
|
369
|
+
}
|
370
|
+
}
|
371
|
+
vertical_box {
|
372
|
+
@nwme = non_wrapping_multiline_entry {
|
373
|
+
read_only true
|
374
|
+
text File.read(file_path_for(@examples[@rbs.selected]))
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}.show
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
MetaExample.new.launch
|
383
|
+
```
|
384
|
+
|
233
385
|
|
234
386
|
### Basic Window
|
235
387
|
|
@@ -286,7 +438,7 @@ require 'glimmer-dsl-libui'
|
|
286
438
|
|
287
439
|
include Glimmer
|
288
440
|
|
289
|
-
window('hello world', 300, 200,
|
441
|
+
window('hello world', 300, 200, true) {
|
290
442
|
on_closing do
|
291
443
|
puts 'Bye Bye'
|
292
444
|
end
|
@@ -357,7 +509,7 @@ require 'glimmer-dsl-libui'
|
|
357
509
|
|
358
510
|
include Glimmer
|
359
511
|
|
360
|
-
window('hello world', 300, 200,
|
512
|
+
window('hello world', 300, 200, true) { |w|
|
361
513
|
button('Button') {
|
362
514
|
on_clicked do
|
363
515
|
msg_box(w, 'Information', 'You clicked the button')
|
@@ -370,6 +522,23 @@ window('hello world', 300, 200, 1) { |w|
|
|
370
522
|
}.show
|
371
523
|
```
|
372
524
|
|
525
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2:
|
526
|
+
|
527
|
+
```ruby
|
528
|
+
require 'glimmer-dsl-libui'
|
529
|
+
|
530
|
+
include Glimmer
|
531
|
+
|
532
|
+
window { # first 3 args can be set via properties with 4th arg has_menubar=true by default
|
533
|
+
title 'hello world'
|
534
|
+
content_size 300, 200
|
535
|
+
|
536
|
+
on_closing do
|
537
|
+
puts 'Bye Bye'
|
538
|
+
end
|
539
|
+
}.show
|
540
|
+
```
|
541
|
+
|
373
542
|
### Basic Entry
|
374
543
|
|
375
544
|
[examples/basic_entry.rb](examples/basic_entry.rb)
|
@@ -444,10 +613,10 @@ require 'glimmer-dsl-libui'
|
|
444
613
|
|
445
614
|
include Glimmer
|
446
615
|
|
447
|
-
window('Basic Entry', 300, 50
|
616
|
+
window('Basic Entry', 300, 50) { |w|
|
448
617
|
horizontal_box {
|
449
618
|
e = entry {
|
450
|
-
# stretchy
|
619
|
+
# stretchy true # Smart default option for appending to horizontal_box
|
451
620
|
|
452
621
|
on_changed do
|
453
622
|
puts e.text
|
@@ -456,7 +625,7 @@ window('Basic Entry', 300, 50, 1) { |w|
|
|
456
625
|
}
|
457
626
|
|
458
627
|
button('Button') {
|
459
|
-
stretchy
|
628
|
+
stretchy false
|
460
629
|
|
461
630
|
on_clicked do
|
462
631
|
text = e.text
|
@@ -530,7 +699,7 @@ require 'glimmer-dsl-libui'
|
|
530
699
|
|
531
700
|
include Glimmer
|
532
701
|
|
533
|
-
window('Notepad', 500, 300
|
702
|
+
window('Notepad', 500, 300) {
|
534
703
|
on_closing do
|
535
704
|
puts 'Bye Bye'
|
536
705
|
end
|
@@ -731,10 +900,10 @@ class TinyMidiPlayer
|
|
731
900
|
end
|
732
901
|
}
|
733
902
|
}
|
734
|
-
@main_window = window('Tiny Midi Player', 200, 50
|
903
|
+
@main_window = window('Tiny Midi Player', 200, 50) {
|
735
904
|
horizontal_box {
|
736
905
|
vertical_box {
|
737
|
-
stretchy
|
906
|
+
stretchy false
|
738
907
|
|
739
908
|
button('▶') {
|
740
909
|
on_clicked do
|
@@ -1018,8 +1187,8 @@ menu('File') {
|
|
1018
1187
|
menu('Edit') {
|
1019
1188
|
check_menu_item('Checkable Item_')
|
1020
1189
|
separator_menu_item
|
1021
|
-
menu_item('Disabled Item_') {
|
1022
|
-
enabled
|
1190
|
+
menu_item('Disabled Item_') {
|
1191
|
+
enabled false
|
1023
1192
|
}
|
1024
1193
|
}
|
1025
1194
|
|
@@ -1029,115 +1198,99 @@ menu('Help') {
|
|
1029
1198
|
about_menu_item # Can optionally contain an on_clicked listener
|
1030
1199
|
}
|
1031
1200
|
|
1032
|
-
MAIN_WINDOW = window('Control Gallery', 600, 500
|
1033
|
-
margined
|
1201
|
+
MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
1202
|
+
margined true
|
1034
1203
|
|
1035
1204
|
on_closing do
|
1036
1205
|
puts 'Bye Bye'
|
1037
1206
|
end
|
1038
1207
|
|
1039
|
-
vertical_box {
|
1040
|
-
padded 1
|
1041
|
-
|
1208
|
+
vertical_box {
|
1042
1209
|
horizontal_box {
|
1043
|
-
padded 1
|
1044
|
-
|
1045
1210
|
group('Basic Controls') {
|
1046
|
-
margined 1
|
1047
|
-
|
1048
1211
|
vertical_box {
|
1049
|
-
padded 1
|
1050
|
-
|
1051
1212
|
button('Button') {
|
1052
|
-
stretchy
|
1213
|
+
stretchy false
|
1053
1214
|
|
1054
1215
|
on_clicked do
|
1055
1216
|
msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
1056
1217
|
end
|
1057
1218
|
}
|
1058
1219
|
|
1059
|
-
checkbox('Checkbox') {
|
1060
|
-
stretchy
|
1220
|
+
checkbox('Checkbox') {
|
1221
|
+
stretchy false
|
1061
1222
|
|
1062
|
-
on_toggled do
|
1223
|
+
on_toggled do |c|
|
1063
1224
|
checked = c.checked == 1
|
1064
1225
|
MAIN_WINDOW.title = "Checkbox is #{checked}"
|
1065
1226
|
c.text = "I am the checkbox (#{checked})"
|
1066
1227
|
end
|
1067
1228
|
}
|
1068
1229
|
|
1069
|
-
label('Label') { stretchy
|
1230
|
+
label('Label') { stretchy false }
|
1070
1231
|
|
1071
|
-
horizontal_separator { stretchy
|
1232
|
+
horizontal_separator { stretchy false }
|
1072
1233
|
|
1073
|
-
date_picker { stretchy
|
1234
|
+
date_picker { stretchy false }
|
1074
1235
|
|
1075
|
-
time_picker { stretchy
|
1236
|
+
time_picker { stretchy false }
|
1076
1237
|
|
1077
|
-
date_time_picker { stretchy
|
1238
|
+
date_time_picker { stretchy false }
|
1078
1239
|
|
1079
|
-
font_button { stretchy
|
1240
|
+
font_button { stretchy false }
|
1080
1241
|
|
1081
|
-
color_button { stretchy
|
1242
|
+
color_button { stretchy false }
|
1082
1243
|
}
|
1083
1244
|
}
|
1084
1245
|
|
1085
1246
|
vertical_box {
|
1086
|
-
padded 1
|
1087
|
-
|
1088
1247
|
group('Numbers') {
|
1089
|
-
stretchy
|
1090
|
-
margined 1
|
1248
|
+
stretchy false
|
1091
1249
|
|
1092
1250
|
vertical_box {
|
1093
|
-
|
1094
|
-
|
1095
|
-
spinbox(0, 100) { |s|
|
1096
|
-
stretchy 0
|
1251
|
+
spinbox(0, 100) {
|
1252
|
+
stretchy false
|
1097
1253
|
value 42
|
1098
1254
|
|
1099
|
-
on_changed do
|
1255
|
+
on_changed do |s|
|
1100
1256
|
puts "New Spinbox value: #{s.value}"
|
1101
1257
|
end
|
1102
1258
|
}
|
1103
1259
|
|
1104
|
-
slider(0, 100) {
|
1105
|
-
stretchy
|
1260
|
+
slider(0, 100) {
|
1261
|
+
stretchy false
|
1106
1262
|
|
1107
|
-
on_changed do
|
1263
|
+
on_changed do |s|
|
1108
1264
|
v = s.value
|
1109
1265
|
puts "New Slider value: #{v}"
|
1110
1266
|
@progress_bar.value = v
|
1111
1267
|
end
|
1112
1268
|
}
|
1113
1269
|
|
1114
|
-
@progress_bar = progress_bar { stretchy
|
1270
|
+
@progress_bar = progress_bar { stretchy false }
|
1115
1271
|
}
|
1116
1272
|
}
|
1117
1273
|
|
1118
1274
|
group('Lists') {
|
1119
|
-
stretchy
|
1120
|
-
margined 1
|
1275
|
+
stretchy false
|
1121
1276
|
|
1122
1277
|
vertical_box {
|
1123
|
-
|
1278
|
+
combobox {
|
1279
|
+
stretchy false
|
1280
|
+
items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
|
1124
1281
|
|
1125
|
-
|
1126
|
-
stretchy 0
|
1127
|
-
items ['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
|
1128
|
-
|
1129
|
-
on_selected do
|
1282
|
+
on_selected do |c|
|
1130
1283
|
puts "New combobox selection: #{c.selected}"
|
1131
1284
|
end
|
1132
1285
|
}
|
1133
1286
|
|
1134
1287
|
editable_combobox {
|
1135
|
-
stretchy
|
1136
|
-
items
|
1288
|
+
stretchy false
|
1289
|
+
items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
|
1137
1290
|
}
|
1138
1291
|
|
1139
1292
|
radio_buttons {
|
1140
|
-
items
|
1293
|
+
items 'Radio Button 1', 'Radio Button 2', 'Radio Button 3' # also accepts a single array argument
|
1141
1294
|
}
|
1142
1295
|
}
|
1143
1296
|
}
|
@@ -1145,20 +1298,20 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
1145
1298
|
tab {
|
1146
1299
|
tab_item('Page 1') {
|
1147
1300
|
horizontal_box {
|
1148
|
-
entry {
|
1301
|
+
entry {
|
1149
1302
|
text 'Please enter your feelings'
|
1150
1303
|
|
1151
|
-
on_changed do
|
1304
|
+
on_changed do |e|
|
1152
1305
|
puts "Current textbox data: '#{e.text}'"
|
1153
1306
|
end
|
1154
1307
|
}
|
1155
1308
|
}
|
1156
1309
|
}
|
1157
|
-
|
1310
|
+
|
1158
1311
|
tab_item('Page 2') {
|
1159
1312
|
horizontal_box
|
1160
1313
|
}
|
1161
|
-
|
1314
|
+
|
1162
1315
|
tab_item('Page 3') {
|
1163
1316
|
horizontal_box
|
1164
1317
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|