glimmer-dsl-libui 0.1.8 → 0.2.0
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 +22 -0
- data/README.md +232 -20
- data/VERSION +1 -1
- data/examples/area_gallery.rb +12 -0
- data/examples/area_gallery2.rb +12 -0
- data/examples/area_gallery3.rb +12 -0
- data/examples/area_gallery4.rb +12 -0
- data/examples/control_gallery.rb +1 -1
- data/examples/form_table.rb +20 -0
- data/examples/grid.rb +38 -2
- data/examples/login.rb +45 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +40 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +37 -2
- data/lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb +36 -0
- data/lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb +36 -0
- data/lib/glimmer/libui/control_proxy/entry_proxy.rb +39 -0
- data/lib/glimmer/libui/control_proxy/grid_proxy.rb +12 -1
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +3 -30
- data/lib/glimmer/libui/control_proxy.rb +1 -0
- data/lib/glimmer/libui.rb +17 -0
- data/sounds/AlanWalker-Faded.mid +0 -0
- data/sounds/AlanWalker-SingMeToSleep.mid +0 -0
- data/sounds/CalvinHarris-Blame.mid +0 -0
- data/sounds/CalvinHarris-MyWay.mid +0 -0
- data/sounds/deadmau5-2448.mid +0 -0
- data/sounds/deadmau5-SoThereIWas.mid +0 -0
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffbecd89743bd4d6037a21613742b1d4817aed439bbdf67a32c86752c2c5f9f0
|
4
|
+
data.tar.gz: 6ad928e4ae5108c74fef25bac43e27c351453748d37596c9226b8bfd85aba032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f150724cb5f29130c9e347468d38da5e125c86193d12663206f64ffe627fc97f2b4f3977cdabab7d223dbf513561ed246c748f3696afb8c736f9e3cd55f17b5b
|
7
|
+
data.tar.gz: 19f493db469713670a630cae23302f12c8a46edfdd5b9726def28eb36d7e4341ae61562a399fde29bbeb82841e739db8b59d26517323c2db1960a7eac041d07b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.1.11
|
4
|
+
|
5
|
+
- New examples/login.rb
|
6
|
+
- Amend examples/form_table.rb with use of a `search_entry` to support table filtering
|
7
|
+
- Support `password_entry` control
|
8
|
+
- Support `search_entry` control
|
9
|
+
- Fix issue with setting control `enabled` property
|
10
|
+
|
11
|
+
## 0.1.10
|
12
|
+
|
13
|
+
- Upgrade to glimmer 2.2.1
|
14
|
+
- Add a 3rd tab to examples/grid.rb showcasing the halign and valign properties
|
15
|
+
- Support `grid` `halign`/`valign` symbol values of `:fill` (default), `:start`, `:center`, `:end`
|
16
|
+
- Add `key_value` to `area_key_event` `Hash`
|
17
|
+
- Add `ext_key_value` to `area_key_event` `Hash`
|
18
|
+
|
19
|
+
## 0.1.9
|
20
|
+
|
21
|
+
- Support `area` listener: `on_key_event`
|
22
|
+
- Support `area` listener: `on_key_down`
|
23
|
+
- Support `area` listener: `on_key_up`
|
24
|
+
|
3
25
|
## 0.1.8
|
4
26
|
|
5
27
|
- Support `area` listener: `on_mouse_event`
|
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.1.
|
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.1.11
|
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)
|
@@ -159,6 +159,18 @@ window('Area Gallery', 400, 400) {
|
|
159
159
|
on_mouse_exited do
|
160
160
|
puts 'exited'
|
161
161
|
end
|
162
|
+
|
163
|
+
on_key_event do |area_key_event|
|
164
|
+
p area_key_event
|
165
|
+
end
|
166
|
+
|
167
|
+
on_key_up do |area_key_event|
|
168
|
+
puts 'key up'
|
169
|
+
end
|
170
|
+
|
171
|
+
on_key_down do |area_key_event|
|
172
|
+
puts 'key down'
|
173
|
+
end
|
162
174
|
}
|
163
175
|
}.show
|
164
176
|
```
|
@@ -179,7 +191,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
179
191
|
|
180
192
|
## Table of Contents
|
181
193
|
|
182
|
-
- [Glimmer DSL for LibUI 0.1.
|
194
|
+
- [Glimmer DSL for LibUI 0.1.10](#-glimmer-dsl-for-libui-0111)
|
183
195
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
184
196
|
- [Usage](#usage)
|
185
197
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
@@ -222,6 +234,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
222
234
|
- [Area Gallery](#area-gallery)
|
223
235
|
- [Histogram](#histogram)
|
224
236
|
- [Basic Transform](#basic-transform)
|
237
|
+
- [Login](#login)
|
225
238
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
226
239
|
- [Help](#help)
|
227
240
|
- [Issues](#issues)
|
@@ -309,7 +322,7 @@ gem install glimmer-dsl-libui
|
|
309
322
|
Or install via Bundler `Gemfile`:
|
310
323
|
|
311
324
|
```ruby
|
312
|
-
gem 'glimmer-dsl-libui', '~> 0.1.
|
325
|
+
gem 'glimmer-dsl-libui', '~> 0.1.10'
|
313
326
|
```
|
314
327
|
|
315
328
|
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.
|
@@ -383,7 +396,7 @@ w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0
|
|
383
396
|
Control(Args) | Properties | Listeners
|
384
397
|
------------- | ---------- | ---------
|
385
398
|
`about_menu_item` | None | `on_clicked`
|
386
|
-
`area` | None | `on_draw(area_draw_params)`, `on_mouse_event(area_mouse_event)`, `on_mouse_down(area_mouse_event)`, `on_mouse_up(area_mouse_event)`, `on_mouse_drag_started(area_mouse_event)`, `on_mouse_dragged(area_mouse_event)`, `on_mouse_dropped(area_mouse_event)`, `on_mouse_entered`, `on_mouse_exited`
|
399
|
+
`area` | None | `on_draw(area_draw_params)`, `on_mouse_event(area_mouse_event)`, `on_mouse_down(area_mouse_event)`, `on_mouse_up(area_mouse_event)`, `on_mouse_drag_started(area_mouse_event)`, `on_mouse_dragged(area_mouse_event)`, `on_mouse_dropped(area_mouse_event)`, `on_mouse_entered`, `on_mouse_exited`, `on_key_event(area_key_event)`, `on_key_down(area_key_event)`, `on_key_up(area_key_event)`
|
387
400
|
`arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)` | `x_center` (`Numeric`), `y_center` (`Numeric`), `radius` (`Numeric`), `start_angle` (`Numeric`), `sweep` (`Numeric`), `is_negative` (Boolean) | None
|
388
401
|
`bezier(c1_x as Numeric, c1_y as Numeric, c2_x as Numeric, c2_y as Numeric, end_x as Numeric, end_y as Numeric)` | `c1_x` (`Numeric`), `c1_y` (`Numeric`), `c2_x` (`Numeric`), `c2_y` (`Numeric`), `end_x` (`Numeric`), `end_y` (`Numeric`) | None
|
389
402
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
@@ -417,6 +430,7 @@ Control(Args) | Properties | Listeners
|
|
417
430
|
`msg_box(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
418
431
|
`msg_box_error(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
419
432
|
`non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
433
|
+
`password_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
420
434
|
`path(draw_fill_mode = :winding)` | `fill` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`), `stroke` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, `:cap` as (`:round`, `:square`, `:flat`), `:join` as (`:miter`, `:round`, `:bevel`), `:thickness` as `Numeric`, `:miter_limit` as `Numeric`, `:dashes` as `Array` of `Numeric` ) | None
|
421
435
|
`preferences_menu_item` | None | `on_clicked`
|
422
436
|
`progress_bar` | `value` (`Numeric`) | None
|
@@ -424,6 +438,7 @@ Control(Args) | Properties | Listeners
|
|
424
438
|
`quit_menu_item` | None | `on_clicked`
|
425
439
|
`radio_buttons` | `selected` (`Integer`) | `on_selected`
|
426
440
|
`rectangle(x as Numeric, y as Numeric, width as Numeric, height as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `width` (`Numeric`), `height` (`Numeric`) | None
|
441
|
+
`search_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
427
442
|
`slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
428
443
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
429
444
|
`square(x as Numeric, y as Numeric, length as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `length` (`Numeric`) | None
|
@@ -433,6 +448,7 @@ Control(Args) | Properties | Listeners
|
|
433
448
|
`text_column(name as String)` | `editable` (Boolean) | None
|
434
449
|
`time_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`) | `on_changed`
|
435
450
|
`vertical_box` | `padded` (Boolean) | None
|
451
|
+
`vertical_separator` | None | None
|
436
452
|
`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`, `on_destroy`
|
437
453
|
|
438
454
|
### Common Control Properties
|
@@ -448,9 +464,9 @@ Control(Args) | Properties | Listeners
|
|
448
464
|
- `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
449
465
|
- `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
450
466
|
- `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
451
|
-
- `halign` [dsl-only] (`
|
467
|
+
- `halign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
452
468
|
- `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
453
|
-
- `valign` [dsl-only] (`
|
469
|
+
- `valign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
454
470
|
|
455
471
|
### Common Control Operations
|
456
472
|
- `destroy`
|
@@ -645,18 +661,21 @@ The `area_draw_params` argument for `on_draw` block is a hash consisting of the
|
|
645
661
|
In general, it is recommended to use declarative stable paths whenever feasible since they require less code and simpler maintenance. But, in more advanced cases, semi-declarative dynamic paths could be used instead, especially if there are thousands of dynamic paths that need maximum performance and low memory footprint.
|
646
662
|
|
647
663
|
`area` supported mouse listeners are:
|
648
|
-
- `
|
649
|
-
- `
|
650
|
-
- `
|
651
|
-
- `
|
652
|
-
- `
|
653
|
-
- `
|
664
|
+
- `on_key_event {|area_key_event| ...}`: general catch-all key event (recommend using fine-grained key events below instead)
|
665
|
+
- `on_key_down {|area_key_event| ...}`
|
666
|
+
- `on_key_up {|area_key_event| ...}`
|
667
|
+
- `on_mouse_event {|area_mouse_event| ...}`: general catch-all mouse event (recommend using fine-grained mouse events below instead)
|
668
|
+
- `on_mouse_down {|area_mouse_event| ...}`
|
669
|
+
- `on_mouse_up {|area_mouse_event| ...}`
|
670
|
+
- `on_mouse_drag_started {|area_mouse_event| ...}`
|
671
|
+
- `on_mouse_dragged {|area_mouse_event| ...}`
|
672
|
+
- `on_mouse_dropped {|area_mouse_event| ...}`
|
654
673
|
- `on_mouse_entered {...}`
|
655
674
|
- `on_mouse_exited {...}`
|
656
675
|
- `on_mouse_crossed {|left| ...}` (NOT RECOMMENDED; it does what `on_mouse_entered` and `on_mouse_exited` do by returning a `left` argument indicating if mouse left `area`)
|
657
676
|
- `on_drag_broken {...}` (NOT RECOMMENDED; varies per platforms; use `on_mouse_dropped` instead)
|
658
677
|
|
659
|
-
The `area_mouse_event` argument for mouse events that receive it (e.g. `on_mouse_up`, `on_mouse_dragged`) consist of the following keys:
|
678
|
+
The `area_mouse_event` `Hash` argument for mouse events that receive it (e.g. `on_mouse_up`, `on_mouse_dragged`) consist of the following hash keys:
|
660
679
|
- `:x`: mouse x location in relation to area's top-left-corner
|
661
680
|
- `:y`: mouse y location in relation to area's top-left-corner
|
662
681
|
- `:area_width`: area current width
|
@@ -667,6 +686,15 @@ The `area_mouse_event` argument for mouse events that receive it (e.g. `on_mouse
|
|
667
686
|
- `:modifers`: `Array` of `Symbol`s from one of the following: `[:command, :shift, :alt, :control]`
|
668
687
|
- `:held`: mouse held button during dragging (e.g. `1` is left button, `4` is right button)
|
669
688
|
|
689
|
+
The `area_key_event` `Hash` argument for keyboard events that receive it (e.g. `on_key_up`, `on_key_down`) consist of the following hash keys:
|
690
|
+
- `:key`: key character (`String`)
|
691
|
+
- `:key_value`: key value (`Integer`). Useful in rare cases for numeric processing of keys instead of dealing with as `:key` character `String`
|
692
|
+
- `:ext_key`: non-character extra key (`Symbol`) from `Glimmer::LibUI.enum_symbols(:ext_key)` such as `:left`, `:right`, `:escape`, `:insert`
|
693
|
+
- `:ext_key_value`: non-character extra key value (`Integer`). Useful in rare cases for numeric processing of extra keys instead of dealing with as `:ext_key` `Symbol`
|
694
|
+
- `:modifier`: modifier key pressed alone (e.g. `:shift` or `:control`)
|
695
|
+
- `:modifiers`: modifier keys pressed simultaneously with `:key`, `:ext_key`, or `:modifier`
|
696
|
+
- `:up`: indicates if key has been released or not (Boolean)
|
697
|
+
|
670
698
|
Note that when nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
|
671
699
|
|
672
700
|
To redraw an `area`, you may call the `#queue_redraw_all` method, or simply `#redraw`.
|
@@ -764,7 +792,7 @@ Check [Histogram](#histogram) example for use of hex colors.
|
|
764
792
|
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
765
793
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
766
794
|
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
|
767
|
-
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`
|
795
|
+
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`:fill`), `vexpand` (`false`), and `valign` (`:fill`)
|
768
796
|
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
|
769
797
|
- Table model instances are automatically freed from memory after `window` is destroyed.
|
770
798
|
- Table `cell_rows` data has implicit data-binding to table cell values for deletion, insertion, and change (done by diffing `cell_rows` value before and after change and auto-informing `table` of deletions [`LibUI.table_model_row_deleted`], insertions [`LibUI.table_model_row_deleted`], and changes [`LibUI.table_model_row_changed`]). When deleting data rows from `cell_rows` array, then actual rows from the `table` are automatically deleted. When inserting data rows into `cell_rows` array, then actual `table` rows are automatically inserted. When updating data rows in `cell_rows` array, then actual `table` rows are automatically updated.
|
@@ -2075,13 +2103,15 @@ ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
|
|
2075
2103
|
|
2076
2104
|
Mac
|
2077
2105
|
|
2078
|
-

|
2107
|
+

|
2108
|
+

|
2080
2109
|
|
2081
2110
|
Linux
|
2082
2111
|
|
2083
|
-

|
2113
|
+

|
2114
|
+

|
2085
2115
|
|
2086
2116
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2087
2117
|
|
@@ -2092,7 +2122,7 @@ include Glimmer
|
|
2092
2122
|
|
2093
2123
|
window('Grid') {
|
2094
2124
|
tab {
|
2095
|
-
tab_item('
|
2125
|
+
tab_item('Span') {
|
2096
2126
|
grid {
|
2097
2127
|
4.times { |top_value|
|
2098
2128
|
4.times { |left_value|
|
@@ -2132,7 +2162,7 @@ window('Grid') {
|
|
2132
2162
|
}
|
2133
2163
|
}
|
2134
2164
|
}
|
2135
|
-
tab_item('
|
2165
|
+
tab_item('Expand') {
|
2136
2166
|
grid {
|
2137
2167
|
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
2138
2168
|
left 0
|
@@ -2154,6 +2184,42 @@ window('Grid') {
|
|
2154
2184
|
}
|
2155
2185
|
}
|
2156
2186
|
}
|
2187
|
+
tab_item('Align') {
|
2188
|
+
grid {
|
2189
|
+
label("(0, 0) halign/valign fill\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
2190
|
+
left 0
|
2191
|
+
top 0
|
2192
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2193
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2194
|
+
halign :fill
|
2195
|
+
valign :fill
|
2196
|
+
}
|
2197
|
+
label("(1, 0) halign/valign start") {
|
2198
|
+
left 1
|
2199
|
+
top 0
|
2200
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2201
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2202
|
+
halign :start
|
2203
|
+
valign :start
|
2204
|
+
}
|
2205
|
+
label("(0, 1) halign/valign center") {
|
2206
|
+
left 0
|
2207
|
+
top 1
|
2208
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2209
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2210
|
+
halign :center
|
2211
|
+
valign :center
|
2212
|
+
}
|
2213
|
+
label("(1, 1) halign/valign end") {
|
2214
|
+
left 1
|
2215
|
+
top 1
|
2216
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2217
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2218
|
+
halign :end
|
2219
|
+
valign :end
|
2220
|
+
}
|
2221
|
+
}
|
2222
|
+
}
|
2157
2223
|
}
|
2158
2224
|
}.show
|
2159
2225
|
```
|
@@ -2933,15 +2999,19 @@ Mac
|
|
2933
2999
|
|
2934
3000
|

|
2935
3001
|

|
3002
|
+

|
2936
3003
|
|
2937
3004
|
Linux
|
2938
3005
|
|
2939
3006
|

|
2940
3007
|

|
3008
|
+

|
2941
3009
|
|
2942
3010
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2943
3011
|
|
2944
3012
|
```ruby
|
3013
|
+
# frozen_string_literal: true
|
3014
|
+
|
2945
3015
|
require 'glimmer-dsl-libui'
|
2946
3016
|
|
2947
3017
|
include Glimmer
|
@@ -2987,6 +3057,7 @@ window('Contacts', 600, 600) { |w|
|
|
2987
3057
|
msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
2988
3058
|
else
|
2989
3059
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
3060
|
+
@unfiltered_data = data.dup
|
2990
3061
|
@name_entry.text = ''
|
2991
3062
|
@email_entry.text = ''
|
2992
3063
|
@phone_entry.text = ''
|
@@ -2996,6 +3067,25 @@ window('Contacts', 600, 600) { |w|
|
|
2996
3067
|
end
|
2997
3068
|
}
|
2998
3069
|
|
3070
|
+
search_entry { |se|
|
3071
|
+
stretchy false
|
3072
|
+
|
3073
|
+
on_changed do
|
3074
|
+
filter_value = se.text
|
3075
|
+
@unfiltered_data ||= data.dup
|
3076
|
+
# Unfilter first to remove any previous filters
|
3077
|
+
data.replace(@unfiltered_data) # affects table indirectly through implicit data-binding
|
3078
|
+
# Now, apply filter if entered
|
3079
|
+
unless filter_value.empty?
|
3080
|
+
data.filter! do |row_data| # affects table indirectly through implicit data-binding
|
3081
|
+
row_data.any? do |cell|
|
3082
|
+
cell.to_s.downcase.include?(filter_value.downcase)
|
3083
|
+
end
|
3084
|
+
end
|
3085
|
+
end
|
3086
|
+
end
|
3087
|
+
}
|
3088
|
+
|
2999
3089
|
table {
|
3000
3090
|
text_column('Name')
|
3001
3091
|
text_column('Email')
|
@@ -3474,6 +3564,18 @@ window('Area Gallery', 400, 400) {
|
|
3474
3564
|
on_mouse_exited do
|
3475
3565
|
puts 'exited'
|
3476
3566
|
end
|
3567
|
+
|
3568
|
+
on_key_event do |area_key_event|
|
3569
|
+
p area_key_event
|
3570
|
+
end
|
3571
|
+
|
3572
|
+
on_key_up do |area_key_event|
|
3573
|
+
puts 'key up'
|
3574
|
+
end
|
3575
|
+
|
3576
|
+
on_key_down do |area_key_event|
|
3577
|
+
puts 'key down'
|
3578
|
+
end
|
3477
3579
|
}
|
3478
3580
|
}.show
|
3479
3581
|
```
|
@@ -3626,6 +3728,18 @@ window('Area Gallery', 400, 400) {
|
|
3626
3728
|
on_mouse_exited do
|
3627
3729
|
puts 'exited'
|
3628
3730
|
end
|
3731
|
+
|
3732
|
+
on_key_event do |area_key_event|
|
3733
|
+
p area_key_event
|
3734
|
+
end
|
3735
|
+
|
3736
|
+
on_key_up do |area_key_event|
|
3737
|
+
puts 'key up'
|
3738
|
+
end
|
3739
|
+
|
3740
|
+
on_key_down do |area_key_event|
|
3741
|
+
puts 'key down'
|
3742
|
+
end
|
3629
3743
|
}
|
3630
3744
|
}.show
|
3631
3745
|
```
|
@@ -3719,6 +3833,18 @@ window('Area Gallery', 400, 400) {
|
|
3719
3833
|
on_mouse_exited do
|
3720
3834
|
puts 'exited'
|
3721
3835
|
end
|
3836
|
+
|
3837
|
+
on_key_event do |area_key_event|
|
3838
|
+
p area_key_event
|
3839
|
+
end
|
3840
|
+
|
3841
|
+
on_key_up do |area_key_event|
|
3842
|
+
puts 'key up'
|
3843
|
+
end
|
3844
|
+
|
3845
|
+
on_key_down do |area_key_event|
|
3846
|
+
puts 'key down'
|
3847
|
+
end
|
3722
3848
|
}
|
3723
3849
|
}.show
|
3724
3850
|
```
|
@@ -3873,6 +3999,18 @@ window('Area Gallery', 400, 400) {
|
|
3873
3999
|
on_mouse_exited do
|
3874
4000
|
puts 'exited'
|
3875
4001
|
end
|
4002
|
+
|
4003
|
+
on_key_event do |area_key_event|
|
4004
|
+
p area_key_event
|
4005
|
+
end
|
4006
|
+
|
4007
|
+
on_key_up do |area_key_event|
|
4008
|
+
puts 'key up'
|
4009
|
+
end
|
4010
|
+
|
4011
|
+
on_key_down do |area_key_event|
|
4012
|
+
puts 'key down'
|
4013
|
+
end
|
3876
4014
|
}
|
3877
4015
|
}.show
|
3878
4016
|
```
|
@@ -4274,6 +4412,80 @@ window('Basic Transform', 350, 350) {
|
|
4274
4412
|
}.show
|
4275
4413
|
```
|
4276
4414
|
|
4415
|
+
### Login
|
4416
|
+
|
4417
|
+
[examples/login.rb](examples/login.rb)
|
4418
|
+
|
4419
|
+
Run with this command from the root of the project if you cloned the project:
|
4420
|
+
|
4421
|
+
```
|
4422
|
+
ruby -r './lib/glimmer-dsl-libui' examples/login.rb
|
4423
|
+
```
|
4424
|
+
|
4425
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
4426
|
+
|
4427
|
+
```
|
4428
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/login'"
|
4429
|
+
```
|
4430
|
+
|
4431
|
+
Mac
|
4432
|
+
|
4433
|
+

|
4434
|
+

|
4435
|
+
|
4436
|
+
Linux
|
4437
|
+
|
4438
|
+

|
4439
|
+

|
4440
|
+
|
4441
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
4442
|
+
|
4443
|
+
```ruby
|
4444
|
+
require 'glimmer-dsl-libui'
|
4445
|
+
|
4446
|
+
include Glimmer
|
4447
|
+
|
4448
|
+
window('Login') {
|
4449
|
+
margined true
|
4450
|
+
|
4451
|
+
vertical_box {
|
4452
|
+
form {
|
4453
|
+
@username_entry = entry {
|
4454
|
+
label 'Username:'
|
4455
|
+
}
|
4456
|
+
|
4457
|
+
@password_entry = password_entry {
|
4458
|
+
label 'Password:'
|
4459
|
+
}
|
4460
|
+
}
|
4461
|
+
|
4462
|
+
horizontal_box {
|
4463
|
+
@login_button = button('Login') {
|
4464
|
+
on_clicked do
|
4465
|
+
@username_entry.enabled = false
|
4466
|
+
@password_entry.enabled = false
|
4467
|
+
@login_button.enabled = false
|
4468
|
+
@logout_button.enabled = true
|
4469
|
+
end
|
4470
|
+
}
|
4471
|
+
|
4472
|
+
@logout_button = button('Logout') {
|
4473
|
+
enabled false
|
4474
|
+
|
4475
|
+
on_clicked do
|
4476
|
+
@username_entry.text = ''
|
4477
|
+
@password_entry.text = ''
|
4478
|
+
@username_entry.enabled = true
|
4479
|
+
@password_entry.enabled = true
|
4480
|
+
@login_button.enabled = true
|
4481
|
+
@logout_button.enabled = false
|
4482
|
+
end
|
4483
|
+
}
|
4484
|
+
}
|
4485
|
+
}
|
4486
|
+
}.show
|
4487
|
+
```
|
4488
|
+
|
4277
4489
|
## Contributing to glimmer-dsl-libui
|
4278
4490
|
|
4279
4491
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
data/examples/area_gallery.rb
CHANGED
@@ -82,5 +82,17 @@ window('Area Gallery', 400, 400) {
|
|
82
82
|
on_mouse_exited do
|
83
83
|
puts 'exited'
|
84
84
|
end
|
85
|
+
|
86
|
+
on_key_event do |area_key_event|
|
87
|
+
p area_key_event
|
88
|
+
end
|
89
|
+
|
90
|
+
on_key_up do |area_key_event|
|
91
|
+
puts 'key up'
|
92
|
+
end
|
93
|
+
|
94
|
+
on_key_down do |area_key_event|
|
95
|
+
puts 'key down'
|
96
|
+
end
|
85
97
|
}
|
86
98
|
}.show
|
data/examples/area_gallery2.rb
CHANGED
@@ -143,5 +143,17 @@ window('Area Gallery', 400, 400) {
|
|
143
143
|
on_mouse_exited do
|
144
144
|
puts 'exited'
|
145
145
|
end
|
146
|
+
|
147
|
+
on_key_event do |area_key_event|
|
148
|
+
p area_key_event
|
149
|
+
end
|
150
|
+
|
151
|
+
on_key_up do |area_key_event|
|
152
|
+
puts 'key up'
|
153
|
+
end
|
154
|
+
|
155
|
+
on_key_down do |area_key_event|
|
156
|
+
puts 'key down'
|
157
|
+
end
|
146
158
|
}
|
147
159
|
}.show
|
data/examples/area_gallery3.rb
CHANGED
@@ -84,5 +84,17 @@ window('Area Gallery', 400, 400) {
|
|
84
84
|
on_mouse_exited do
|
85
85
|
puts 'exited'
|
86
86
|
end
|
87
|
+
|
88
|
+
on_key_event do |area_key_event|
|
89
|
+
p area_key_event
|
90
|
+
end
|
91
|
+
|
92
|
+
on_key_up do |area_key_event|
|
93
|
+
puts 'key up'
|
94
|
+
end
|
95
|
+
|
96
|
+
on_key_down do |area_key_event|
|
97
|
+
puts 'key down'
|
98
|
+
end
|
87
99
|
}
|
88
100
|
}.show
|
data/examples/area_gallery4.rb
CHANGED
@@ -145,5 +145,17 @@ window('Area Gallery', 400, 400) {
|
|
145
145
|
on_mouse_exited do
|
146
146
|
puts 'exited'
|
147
147
|
end
|
148
|
+
|
149
|
+
on_key_event do |area_key_event|
|
150
|
+
p area_key_event
|
151
|
+
end
|
152
|
+
|
153
|
+
on_key_up do |area_key_event|
|
154
|
+
puts 'key up'
|
155
|
+
end
|
156
|
+
|
157
|
+
on_key_down do |area_key_event|
|
158
|
+
puts 'key down'
|
159
|
+
end
|
148
160
|
}
|
149
161
|
}.show
|
data/examples/control_gallery.rb
CHANGED
data/examples/form_table.rb
CHANGED
@@ -45,6 +45,7 @@ window('Contacts', 600, 600) { |w|
|
|
45
45
|
msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
46
46
|
else
|
47
47
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
48
|
+
@unfiltered_data = data.dup
|
48
49
|
@name_entry.text = ''
|
49
50
|
@email_entry.text = ''
|
50
51
|
@phone_entry.text = ''
|
@@ -54,6 +55,25 @@ window('Contacts', 600, 600) { |w|
|
|
54
55
|
end
|
55
56
|
}
|
56
57
|
|
58
|
+
search_entry { |se|
|
59
|
+
stretchy false
|
60
|
+
|
61
|
+
on_changed do
|
62
|
+
filter_value = se.text
|
63
|
+
@unfiltered_data ||= data.dup
|
64
|
+
# Unfilter first to remove any previous filters
|
65
|
+
data.replace(@unfiltered_data) # affects table indirectly through implicit data-binding
|
66
|
+
# Now, apply filter if entered
|
67
|
+
unless filter_value.empty?
|
68
|
+
data.filter! do |row_data| # affects table indirectly through implicit data-binding
|
69
|
+
row_data.any? do |cell|
|
70
|
+
cell.to_s.downcase.include?(filter_value.downcase)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
57
77
|
table {
|
58
78
|
text_column('Name')
|
59
79
|
text_column('Email')
|
data/examples/grid.rb
CHANGED
@@ -6,7 +6,7 @@ include Glimmer
|
|
6
6
|
|
7
7
|
window('Grid') {
|
8
8
|
tab {
|
9
|
-
tab_item('
|
9
|
+
tab_item('Span') {
|
10
10
|
grid {
|
11
11
|
4.times { |top_value|
|
12
12
|
4.times { |left_value|
|
@@ -46,7 +46,7 @@ window('Grid') {
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
}
|
49
|
-
tab_item('
|
49
|
+
tab_item('Expand') {
|
50
50
|
grid {
|
51
51
|
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
52
52
|
left 0
|
@@ -68,5 +68,41 @@ window('Grid') {
|
|
68
68
|
}
|
69
69
|
}
|
70
70
|
}
|
71
|
+
tab_item('Align') {
|
72
|
+
grid {
|
73
|
+
label("(0, 0) halign/valign fill\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
74
|
+
left 0
|
75
|
+
top 0
|
76
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
77
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
78
|
+
halign :fill
|
79
|
+
valign :fill
|
80
|
+
}
|
81
|
+
label("(1, 0) halign/valign start") {
|
82
|
+
left 1
|
83
|
+
top 0
|
84
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
85
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
86
|
+
halign :start
|
87
|
+
valign :start
|
88
|
+
}
|
89
|
+
label("(0, 1) halign/valign center") {
|
90
|
+
left 0
|
91
|
+
top 1
|
92
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
93
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
94
|
+
halign :center
|
95
|
+
valign :center
|
96
|
+
}
|
97
|
+
label("(1, 1) halign/valign end") {
|
98
|
+
left 1
|
99
|
+
top 1
|
100
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
101
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
102
|
+
halign :end
|
103
|
+
valign :end
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
71
107
|
}
|
72
108
|
}.show
|
data/examples/login.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('Login') {
|
8
|
+
margined true
|
9
|
+
|
10
|
+
vertical_box {
|
11
|
+
form {
|
12
|
+
@username_entry = entry {
|
13
|
+
label 'Username:'
|
14
|
+
}
|
15
|
+
|
16
|
+
@password_entry = password_entry {
|
17
|
+
label 'Password:'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
horizontal_box {
|
22
|
+
@login_button = button('Login') {
|
23
|
+
on_clicked do
|
24
|
+
@username_entry.enabled = false
|
25
|
+
@password_entry.enabled = false
|
26
|
+
@login_button.enabled = false
|
27
|
+
@logout_button.enabled = true
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
31
|
+
@logout_button = button('Logout') {
|
32
|
+
enabled false
|
33
|
+
|
34
|
+
on_clicked do
|
35
|
+
@username_entry.text = ''
|
36
|
+
@password_entry.text = ''
|
37
|
+
@username_entry.enabled = true
|
38
|
+
@password_entry.enabled = true
|
39
|
+
@login_button.enabled = true
|
40
|
+
@logout_button.enabled = false
|
41
|
+
end
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}.show
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -0,0 +1,40 @@
|
|
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/area_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class ControlProxy
|
27
|
+
class AreaProxy < ControlProxy
|
28
|
+
# Proxy for LibUI scrolling area objects
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern
|
31
|
+
class ScrollingAreaProxy < AreaProxy
|
32
|
+
def build_control
|
33
|
+
@area_handler = ::LibUI::FFI::AreaHandler.malloc
|
34
|
+
@libui = ::LibUI.new_scrolling_area(@area_handler, *@args)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -36,7 +36,7 @@ module Glimmer
|
|
36
36
|
attr_accessor :current_area_draw_params
|
37
37
|
end
|
38
38
|
|
39
|
-
LISTENERS = ['on_draw', 'on_mouse_event', 'on_mouse_move', 'on_mouse_down', 'on_mouse_up', 'on_mouse_drag_start', 'on_mouse_drag', 'on_mouse_drop', 'on_mouse_crossed', 'on_mouse_enter', 'on_mouse_exit', 'on_drag_broken']
|
39
|
+
LISTENERS = ['on_draw', 'on_mouse_event', 'on_mouse_move', 'on_mouse_down', 'on_mouse_up', 'on_mouse_drag_start', 'on_mouse_drag', 'on_mouse_drop', 'on_mouse_crossed', 'on_mouse_enter', 'on_mouse_exit', 'on_drag_broken', 'on_key_event', 'on_key_down', 'on_key_up']
|
40
40
|
LISTENER_ALIASES = {
|
41
41
|
on_drawn: 'on_draw',
|
42
42
|
on_mouse_moved: 'on_mouse_move',
|
@@ -55,6 +55,10 @@ module Glimmer
|
|
55
55
|
|
56
56
|
attr_reader :area_handler
|
57
57
|
|
58
|
+
def libui_api_keyword
|
59
|
+
'area'
|
60
|
+
end
|
61
|
+
|
58
62
|
def post_add_content
|
59
63
|
super
|
60
64
|
install_listeners
|
@@ -110,7 +114,16 @@ module Glimmer
|
|
110
114
|
@area_handler.DragBroken = fiddle_closure_block_caller(0, [1, 1]) do |_, _|
|
111
115
|
on_drag_broken.each { |listener| listener.call }
|
112
116
|
end
|
113
|
-
@area_handler.KeyEvent = fiddle_closure_block_caller(0, [
|
117
|
+
@area_handler.KeyEvent = fiddle_closure_block_caller(0, [1, 1, 1]) do |_, _, area_key_event|
|
118
|
+
area_key_event = ::LibUI::FFI::AreaKeyEvent.new(area_key_event)
|
119
|
+
area_key_event = area_key_event_hash(area_key_event)
|
120
|
+
on_key_event.each { |listener| listener.call(area_key_event) }
|
121
|
+
if area_key_event[:up]
|
122
|
+
on_key_up.each { |listener| listener.call(area_key_event) }
|
123
|
+
else
|
124
|
+
on_key_down.each { |listener| listener.call(area_key_event) }
|
125
|
+
end
|
126
|
+
end
|
114
127
|
end
|
115
128
|
|
116
129
|
def area_draw_params_hash(area_draw_params)
|
@@ -139,6 +152,26 @@ module Glimmer
|
|
139
152
|
}
|
140
153
|
end
|
141
154
|
|
155
|
+
def area_key_event_hash(area_key_event)
|
156
|
+
{
|
157
|
+
key: key_to_char(area_key_event.Key),
|
158
|
+
key_value: area_key_event.Key,
|
159
|
+
ext_key: ext_key_to_symbol(area_key_event.ExtKey),
|
160
|
+
ext_key_value: area_key_event.ExtKey,
|
161
|
+
modifier: modifiers_to_symbols(area_key_event.Modifier).first,
|
162
|
+
modifiers: modifiers_to_symbols(area_key_event.Modifiers),
|
163
|
+
up: Glimmer::LibUI.integer_to_boolean(area_key_event.Up),
|
164
|
+
}
|
165
|
+
end
|
166
|
+
|
167
|
+
def key_to_char(key)
|
168
|
+
key.chr if key > 0
|
169
|
+
end
|
170
|
+
|
171
|
+
def ext_key_to_symbol(ext_key_value)
|
172
|
+
Glimmer::LibUI.enum_symbols(:ext_key)[ext_key_value - 1].to_s.to_sym if ext_key_value > 0
|
173
|
+
end
|
174
|
+
|
142
175
|
def modifiers_to_symbols(modifiers_value)
|
143
176
|
symbols = []
|
144
177
|
modifiers_value = extract_symbol_from_modifiers_value(modifiers_value, symbols: symbols) while modifiers_value > 0
|
@@ -164,3 +197,5 @@ module Glimmer
|
|
164
197
|
end
|
165
198
|
end
|
166
199
|
end
|
200
|
+
|
201
|
+
Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
|
@@ -0,0 +1,36 @@
|
|
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/entry_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class ControlProxy
|
27
|
+
class EntryProxy < ControlProxy
|
28
|
+
# Proxy for LibUI password entry objects
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern
|
31
|
+
class PasswordEntryProxy < EntryProxy
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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/entry_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class ControlProxy
|
27
|
+
class EntryProxy < ControlProxy
|
28
|
+
# Proxy for LibUI search entry objects
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern
|
31
|
+
class SearchEntryProxy < EntryProxy
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
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
|
+
class ControlProxy
|
27
|
+
# Proxy for LibUI entry objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class EntryProxy < ControlProxy
|
31
|
+
def libui_api_keyword
|
32
|
+
'entry'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
|
@@ -36,7 +36,18 @@ module Glimmer
|
|
36
36
|
child.halign = 0 if child.halign.nil?
|
37
37
|
child.vexpand = false if child.vexpand.nil?
|
38
38
|
child.valign = 0 if child.valign.nil?
|
39
|
-
::LibUI.grid_append(
|
39
|
+
::LibUI.grid_append(
|
40
|
+
@libui,
|
41
|
+
child.libui,
|
42
|
+
child.left,
|
43
|
+
child.top,
|
44
|
+
child.xspan,
|
45
|
+
child.yspan,
|
46
|
+
Glimmer::LibUI.boolean_to_integer(child.hexpand),
|
47
|
+
Glimmer::LibUI.enum_symbol_to_value(:align, child.halign),
|
48
|
+
Glimmer::LibUI.boolean_to_integer(child.vexpand),
|
49
|
+
Glimmer::LibUI.enum_symbol_to_value(:align, child.valign)
|
50
|
+
)
|
40
51
|
children << child
|
41
52
|
end
|
42
53
|
|
@@ -128,25 +128,11 @@ module Glimmer
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def draw_line_cap
|
131
|
-
|
132
|
-
when 'round'
|
133
|
-
1
|
134
|
-
when 'square'
|
135
|
-
2
|
136
|
-
else # 'flat'
|
137
|
-
0
|
138
|
-
end
|
131
|
+
Glimmer::LibUI.enum_symbol_to_value(:draw_line_cap, @stroke && @stroke[:cap])
|
139
132
|
end
|
140
133
|
|
141
134
|
def draw_line_join
|
142
|
-
|
143
|
-
when 'round'
|
144
|
-
1
|
145
|
-
when 'bevel'
|
146
|
-
2
|
147
|
-
else # 'miter'
|
148
|
-
0
|
149
|
-
end
|
135
|
+
Glimmer::LibUI.enum_symbol_to_value(:draw_line_join, @stroke && @stroke[:join])
|
150
136
|
end
|
151
137
|
|
152
138
|
def destroy
|
@@ -165,20 +151,7 @@ module Glimmer
|
|
165
151
|
end
|
166
152
|
|
167
153
|
def init_draw_brush(draw_brush, draw_brush_args)
|
168
|
-
|
169
|
-
when Integer
|
170
|
-
draw_brush.Type = draw_brush_args[:type]
|
171
|
-
when :solid, 'solid'
|
172
|
-
draw_brush.Type = 0
|
173
|
-
when :linear_gradient, 'linear_gradient'
|
174
|
-
draw_brush.Type = 1
|
175
|
-
when :radial_gradient, 'radial_gradient'
|
176
|
-
draw_brush.Type = 2
|
177
|
-
when :image, 'image'
|
178
|
-
draw_brush.Type = 3
|
179
|
-
else
|
180
|
-
draw_brush.Type = 0
|
181
|
-
end
|
154
|
+
draw_brush.Type = Glimmer::LibUI.enum_symbol_to_value(:draw_brush_type, draw_brush_args[:type])
|
182
155
|
draw_brush.R = (draw_brush_args[:r] || draw_brush_args[:red]).to_f / 255.0
|
183
156
|
draw_brush.G = (draw_brush_args[:g] || draw_brush_args[:green]).to_f / 255.0
|
184
157
|
draw_brush.B = (draw_brush_args[:b] || draw_brush_args[:blue]).to_f / 255.0
|
data/lib/glimmer/libui.rb
CHANGED
@@ -87,6 +87,23 @@ module Glimmer
|
|
87
87
|
end
|
88
88
|
value
|
89
89
|
end
|
90
|
+
|
91
|
+
# Returns ruby underscored symbols for enum values starting with enum name (camelcase, e.g. 'ext_key')
|
92
|
+
def enum_symbols(enum_name)
|
93
|
+
enum_name = enum_name.to_s.underscore.to_sym
|
94
|
+
@enum_symbols ||= {}
|
95
|
+
@enum_symbols[enum_name] ||= ::LibUI.constants.select { |c| c.to_s.start_with?(enum_name.to_s.camelcase(:upper)) }.map { |c| c.to_s.underscore.sub("#{enum_name}_", '').to_sym }
|
96
|
+
end
|
97
|
+
|
98
|
+
def enum_symbol_to_value(enum_name, enum_symbol, default_index: 0)
|
99
|
+
if enum_symbol.is_a?(Integer)
|
100
|
+
enum_symbol
|
101
|
+
elsif enum_symbols(enum_name).include?(enum_symbol.to_s.to_sym)
|
102
|
+
::LibUI.const_get("#{enum_name}_#{enum_symbol}".camelcase(:upper))
|
103
|
+
else
|
104
|
+
enum_symbol_to_value(enum_name, enum_symbols(enum_name)[default_index])
|
105
|
+
end
|
106
|
+
end
|
90
107
|
end
|
91
108
|
end
|
92
109
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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.
|
4
|
+
version: 0.2.0
|
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-10-
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2.
|
26
|
+
version: 2.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: os
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.0.
|
67
|
+
version: 0.0.11
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.0.
|
74
|
+
version: 0.0.11
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: juwelier
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- examples/form_table.rb
|
239
239
|
- examples/grid.rb
|
240
240
|
- examples/histogram.rb
|
241
|
+
- examples/login.rb
|
241
242
|
- examples/meta_example.rb
|
242
243
|
- examples/midi_player.rb
|
243
244
|
- examples/simple_notepad.rb
|
@@ -256,6 +257,7 @@ files:
|
|
256
257
|
- lib/glimmer/libui.rb
|
257
258
|
- lib/glimmer/libui/control_proxy.rb
|
258
259
|
- lib/glimmer/libui/control_proxy/area_proxy.rb
|
260
|
+
- lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb
|
259
261
|
- lib/glimmer/libui/control_proxy/box.rb
|
260
262
|
- lib/glimmer/libui/control_proxy/box/horizontal_box_proxy.rb
|
261
263
|
- lib/glimmer/libui/control_proxy/box/vertical_box_proxy.rb
|
@@ -278,6 +280,9 @@ files:
|
|
278
280
|
- lib/glimmer/libui/control_proxy/editable_column.rb
|
279
281
|
- lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb
|
280
282
|
- lib/glimmer/libui/control_proxy/enableable_column.rb
|
283
|
+
- lib/glimmer/libui/control_proxy/entry_proxy.rb
|
284
|
+
- lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb
|
285
|
+
- lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb
|
281
286
|
- lib/glimmer/libui/control_proxy/font_button_proxy.rb
|
282
287
|
- lib/glimmer/libui/control_proxy/form_proxy.rb
|
283
288
|
- lib/glimmer/libui/control_proxy/grid_proxy.rb
|
@@ -312,6 +317,12 @@ files:
|
|
312
317
|
- lib/glimmer/libui/shape/line.rb
|
313
318
|
- lib/glimmer/libui/shape/rectangle.rb
|
314
319
|
- lib/glimmer/libui/shape/square.rb
|
320
|
+
- sounds/AlanWalker-Faded.mid
|
321
|
+
- sounds/AlanWalker-SingMeToSleep.mid
|
322
|
+
- sounds/CalvinHarris-Blame.mid
|
323
|
+
- sounds/CalvinHarris-MyWay.mid
|
324
|
+
- sounds/deadmau5-2448.mid
|
325
|
+
- sounds/deadmau5-SoThereIWas.mid
|
315
326
|
homepage: http://github.com/AndyObtiva/glimmer-dsl-libui
|
316
327
|
licenses:
|
317
328
|
- MIT
|