glimmer-dsl-libui 0.1.6 → 0.1.10
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 +32 -0
- data/README.md +341 -24
- data/VERSION +1 -1
- data/examples/area_gallery.rb +50 -2
- data/examples/area_gallery2.rb +50 -2
- data/examples/area_gallery3.rb +50 -2
- data/examples/area_gallery4.rb +50 -2
- data/examples/grid.rb +38 -2
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +105 -27
- data/lib/glimmer/libui/control_proxy/grid_proxy.rb +12 -1
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +13 -19
- data/lib/glimmer/libui/control_proxy.rb +33 -1
- data/lib/glimmer/libui.rb +17 -0
- data/lib/glimmer-dsl-libui.rb +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 748bd2b706f088ec5e69da3567dac4b59085b374507f9e3dd5e4a2b0432895a0
|
4
|
+
data.tar.gz: 8ff551d013d3d7524698c3ceaf7c5176e190e5ff6ca3bb8189de56a90fc2b3a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2cff96b2dfe600c675feb491e9f396fb436b67430fa72dafd2ae88b69f06027a5cef250d18aa9872ed4329782e6ce7da14d78506e9786b8fc62426c9f985455
|
7
|
+
data.tar.gz: c6b565cf1aba0f603c1233a8411a4ad25f78821f832f0576cf97cad7ebf9b06a0b8f1b3d83200a79da5d998fa5849d10e47b2e9257069dc0fdfe6a1cfdb6b57f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.1.10
|
4
|
+
|
5
|
+
- Upgrade to glimmer 2.2.1
|
6
|
+
- Add a 3rd tab to examples/grid.rb showcasing the halign and valign properties
|
7
|
+
- Support `grid` `halign`/`valign` symbol values of `:fill` (default), `:start`, `:center`, `:end`
|
8
|
+
- Add `key_value` to `area_key_event` `Hash`
|
9
|
+
- Add `ext_key_value` to `area_key_event` `Hash`
|
10
|
+
|
11
|
+
## 0.1.9
|
12
|
+
|
13
|
+
- Support `area` listener: `on_key_event`
|
14
|
+
- Support `area` listener: `on_key_down`
|
15
|
+
- Support `area` listener: `on_key_up`
|
16
|
+
|
17
|
+
## 0.1.8
|
18
|
+
|
19
|
+
- Support `area` listener: `on_mouse_event`
|
20
|
+
- Support `area` listener: `on_mouse_down`
|
21
|
+
- Support `area` listener: `on_mouse_up`
|
22
|
+
- Support `area` listener: `on_mouse_drag_start`
|
23
|
+
- Support `area` listener: `on_mouse_drag`
|
24
|
+
- Support `area` listener: `on_mouse_drop`
|
25
|
+
- Support `area` listener: `on_mouse_crossed`
|
26
|
+
- Support `area` listener: `on_mouse_enter`
|
27
|
+
- Support `area` listener: `on_mouse_exit`
|
28
|
+
- Support `area` listener: `on_drag_broken`
|
29
|
+
|
30
|
+
## 0.1.7
|
31
|
+
|
32
|
+
- Support `stroke` `:dashes` and use in examples/area_gallery.rb
|
33
|
+
- Support symbol values for draw_line_cap (`:round`, `:square`, `:flat`) and draw_line_join (`:miter`, `:round`, `:bevel`) and draw_fill_mode (`:winding` and `:alternate`)
|
34
|
+
|
3
35
|
## 0.1.6
|
4
36
|
|
5
37
|
- Update default `window` `width` to `190`
|
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.10
|
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)
|
@@ -115,14 +115,62 @@ window('Area Gallery', 400, 400) {
|
|
115
115
|
}
|
116
116
|
|
117
117
|
fill r: 202, g: 102, b: 204, a: 0.5
|
118
|
-
stroke
|
118
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
119
119
|
}
|
120
120
|
path { # declarative stable path
|
121
121
|
arc(200, 200, 90, 0, 360, false)
|
122
122
|
|
123
123
|
fill r: 202, g: 102, b: 204, a: 0.5
|
124
|
-
stroke
|
124
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
125
125
|
}
|
126
|
+
|
127
|
+
on_mouse_event do |area_mouse_event|
|
128
|
+
p area_mouse_event
|
129
|
+
end
|
130
|
+
|
131
|
+
on_mouse_moved do |area_mouse_event|
|
132
|
+
puts 'moved'
|
133
|
+
end
|
134
|
+
|
135
|
+
on_mouse_down do |area_mouse_event|
|
136
|
+
puts 'mouse down'
|
137
|
+
end
|
138
|
+
|
139
|
+
on_mouse_up do |area_mouse_event|
|
140
|
+
puts 'mouse up'
|
141
|
+
end
|
142
|
+
|
143
|
+
on_mouse_drag_started do |area_mouse_event|
|
144
|
+
puts 'drag started'
|
145
|
+
end
|
146
|
+
|
147
|
+
on_mouse_dragged do |area_mouse_event|
|
148
|
+
puts 'dragged'
|
149
|
+
end
|
150
|
+
|
151
|
+
on_mouse_dropped do |area_mouse_event|
|
152
|
+
puts 'dropped'
|
153
|
+
end
|
154
|
+
|
155
|
+
on_mouse_entered do
|
156
|
+
puts 'entered'
|
157
|
+
end
|
158
|
+
|
159
|
+
on_mouse_exited do
|
160
|
+
puts 'exited'
|
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
|
126
174
|
}
|
127
175
|
}.show
|
128
176
|
```
|
@@ -143,7 +191,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
143
191
|
|
144
192
|
## Table of Contents
|
145
193
|
|
146
|
-
- [Glimmer DSL for LibUI 0.1.
|
194
|
+
- [Glimmer DSL for LibUI 0.1.10](#-glimmer-dsl-for-libui-0110)
|
147
195
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
148
196
|
- [Usage](#usage)
|
149
197
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
@@ -273,7 +321,7 @@ gem install glimmer-dsl-libui
|
|
273
321
|
Or install via Bundler `Gemfile`:
|
274
322
|
|
275
323
|
```ruby
|
276
|
-
gem 'glimmer-dsl-libui', '~> 0.1.
|
324
|
+
gem 'glimmer-dsl-libui', '~> 0.1.10'
|
277
325
|
```
|
278
326
|
|
279
327
|
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.
|
@@ -347,7 +395,7 @@ w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0
|
|
347
395
|
Control(Args) | Properties | Listeners
|
348
396
|
------------- | ---------- | ---------
|
349
397
|
`about_menu_item` | None | `on_clicked`
|
350
|
-
`area` | None | `on_draw`
|
398
|
+
`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)`
|
351
399
|
`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
|
352
400
|
`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
|
353
401
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
@@ -381,7 +429,7 @@ Control(Args) | Properties | Listeners
|
|
381
429
|
`msg_box(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
382
430
|
`msg_box_error(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
383
431
|
`non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
384
|
-
`path` | `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
|
432
|
+
`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
|
385
433
|
`preferences_menu_item` | None | `on_clicked`
|
386
434
|
`progress_bar` | `value` (`Numeric`) | None
|
387
435
|
`progress_bar_column(name as String)` | None | None
|
@@ -412,9 +460,9 @@ Control(Args) | Properties | Listeners
|
|
412
460
|
- `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
413
461
|
- `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
414
462
|
- `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
415
|
-
- `halign` [dsl-only] (`
|
463
|
+
- `halign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
416
464
|
- `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
417
|
-
- `valign` [dsl-only] (`
|
465
|
+
- `valign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
418
466
|
|
419
467
|
### Common Control Operations
|
420
468
|
- `destroy`
|
@@ -585,6 +633,8 @@ window('Basic Area', 400, 400) {
|
|
585
633
|
|
586
634
|
Check [examples/dynamic_area.rb](#dynamic-area) for a more detailed semi-declarative example.
|
587
635
|
|
636
|
+
`path` can receive a `draw_fill_mode` argument that can accept values `:winding` or `:alternate` and defaults to `:winding`.
|
637
|
+
|
588
638
|
Available nested `path` shapes:
|
589
639
|
- `rectangle(x as Numeric, y as Numeric, width as Numeric, height as Numeric)`
|
590
640
|
- `square(x as Numeric, y as Numeric, length as Numeric)`
|
@@ -606,6 +656,41 @@ The `area_draw_params` argument for `on_draw` block is a hash consisting of the
|
|
606
656
|
|
607
657
|
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.
|
608
658
|
|
659
|
+
`area` supported mouse listeners are:
|
660
|
+
- `on_key_event {|area_key_event| ...}`: general catch-all key event (recommend using fine-grained key events below instead)
|
661
|
+
- `on_key_down {|area_key_event| ...}`
|
662
|
+
- `on_key_up {|area_key_event| ...}`
|
663
|
+
- `on_mouse_event {|area_mouse_event| ...}`: general catch-all mouse event (recommend using fine-grained mouse events below instead)
|
664
|
+
- `on_mouse_down {|area_mouse_event| ...}`
|
665
|
+
- `on_mouse_up {|area_mouse_event| ...}`
|
666
|
+
- `on_mouse_drag_started {|area_mouse_event| ...}`
|
667
|
+
- `on_mouse_dragged {|area_mouse_event| ...}`
|
668
|
+
- `on_mouse_dropped {|area_mouse_event| ...}`
|
669
|
+
- `on_mouse_entered {...}`
|
670
|
+
- `on_mouse_exited {...}`
|
671
|
+
- `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`)
|
672
|
+
- `on_drag_broken {...}` (NOT RECOMMENDED; varies per platforms; use `on_mouse_dropped` instead)
|
673
|
+
|
674
|
+
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:
|
675
|
+
- `:x`: mouse x location in relation to area's top-left-corner
|
676
|
+
- `:y`: mouse y location in relation to area's top-left-corner
|
677
|
+
- `:area_width`: area current width
|
678
|
+
- `:area_height`: area current height
|
679
|
+
- `:down`: mouse pressed button (e.g. `1` is left button, `3` is right button)
|
680
|
+
- `:up`: mouse depressed button (e.g. `1` is left button, `3` is right button)
|
681
|
+
- `:count`: count of mouse clicks (e.g. `2` for double-click, `1` for single-click)
|
682
|
+
- `:modifers`: `Array` of `Symbol`s from one of the following: `[:command, :shift, :alt, :control]`
|
683
|
+
- `:held`: mouse held button during dragging (e.g. `1` is left button, `4` is right button)
|
684
|
+
|
685
|
+
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:
|
686
|
+
- `:key`: key character (`String`)
|
687
|
+
- `:key_value`: key value (`Integer`). Useful in rare cases for numeric processing of keys instead of dealing with as `:key` character `String`
|
688
|
+
- `:ext_key`: non-character extra key (`Symbol`) from `Glimmer::LibUI.enum_symbols(:ext_key)` such as `:left`, `:right`, `:escape`, `:insert`
|
689
|
+
- `: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`
|
690
|
+
- `:modifier`: modifier key pressed alone (e.g. `:shift` or `:control`)
|
691
|
+
- `:modifiers`: modifier keys pressed simultaneously with `:key`, `:ext_key`, or `:modifier`
|
692
|
+
- `:up`: indicates if key has been released or not (Boolean)
|
693
|
+
|
609
694
|
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.
|
610
695
|
|
611
696
|
To redraw an `area`, you may call the `#queue_redraw_all` method, or simply `#redraw`.
|
@@ -703,7 +788,7 @@ Check [Histogram](#histogram) example for use of hex colors.
|
|
703
788
|
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
704
789
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
705
790
|
- 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`
|
706
|
-
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`
|
791
|
+
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`:fill`), `vexpand` (`false`), and `valign` (`:fill`)
|
707
792
|
- 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`)
|
708
793
|
- Table model instances are automatically freed from memory after `window` is destroyed.
|
709
794
|
- 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.
|
@@ -744,6 +829,8 @@ The following examples include reimplementions of the examples in the [LibUI](ht
|
|
744
829
|
|
745
830
|
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. It also enables code editing to facilitate experimentation and learning.
|
746
831
|
|
832
|
+
(note that for examples that emit output to terminal/command-line via `p` or `puts`, you must run them directly to see output)
|
833
|
+
|
747
834
|
[examples/meta_example.rb](examples/meta_example.rb)
|
748
835
|
|
749
836
|
Run with this command from the root of the project if you cloned the project:
|
@@ -2012,13 +2099,15 @@ ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
|
|
2012
2099
|
|
2013
2100
|
Mac
|
2014
2101
|
|
2015
|
-

|
2103
|
+

|
2104
|
+

|
2017
2105
|
|
2018
2106
|
Linux
|
2019
2107
|
|
2020
|
-

|
2109
|
+

|
2110
|
+

|
2022
2111
|
|
2023
2112
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2024
2113
|
|
@@ -2029,7 +2118,7 @@ include Glimmer
|
|
2029
2118
|
|
2030
2119
|
window('Grid') {
|
2031
2120
|
tab {
|
2032
|
-
tab_item('
|
2121
|
+
tab_item('Span') {
|
2033
2122
|
grid {
|
2034
2123
|
4.times { |top_value|
|
2035
2124
|
4.times { |left_value|
|
@@ -2069,7 +2158,7 @@ window('Grid') {
|
|
2069
2158
|
}
|
2070
2159
|
}
|
2071
2160
|
}
|
2072
|
-
tab_item('
|
2161
|
+
tab_item('Expand') {
|
2073
2162
|
grid {
|
2074
2163
|
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
2075
2164
|
left 0
|
@@ -2091,6 +2180,42 @@ window('Grid') {
|
|
2091
2180
|
}
|
2092
2181
|
}
|
2093
2182
|
}
|
2183
|
+
tab_item('Align') {
|
2184
|
+
grid {
|
2185
|
+
label("(0, 0) halign/valign fill\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
2186
|
+
left 0
|
2187
|
+
top 0
|
2188
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2189
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2190
|
+
halign :fill
|
2191
|
+
valign :fill
|
2192
|
+
}
|
2193
|
+
label("(1, 0) halign/valign start") {
|
2194
|
+
left 1
|
2195
|
+
top 0
|
2196
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2197
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2198
|
+
halign :start
|
2199
|
+
valign :start
|
2200
|
+
}
|
2201
|
+
label("(0, 1) halign/valign center") {
|
2202
|
+
left 0
|
2203
|
+
top 1
|
2204
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2205
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2206
|
+
halign :center
|
2207
|
+
valign :center
|
2208
|
+
}
|
2209
|
+
label("(1, 1) halign/valign end") {
|
2210
|
+
left 1
|
2211
|
+
top 1
|
2212
|
+
hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2213
|
+
vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
|
2214
|
+
halign :end
|
2215
|
+
valign :end
|
2216
|
+
}
|
2217
|
+
}
|
2218
|
+
}
|
2094
2219
|
}
|
2095
2220
|
}.show
|
2096
2221
|
```
|
@@ -3367,14 +3492,62 @@ window('Area Gallery', 400, 400) {
|
|
3367
3492
|
}
|
3368
3493
|
|
3369
3494
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3370
|
-
stroke
|
3495
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
3371
3496
|
}
|
3372
3497
|
path { # declarative stable path
|
3373
3498
|
arc(200, 200, 90, 0, 360, false)
|
3374
3499
|
|
3375
3500
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3376
|
-
stroke
|
3501
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
3377
3502
|
}
|
3503
|
+
|
3504
|
+
on_mouse_event do |area_mouse_event|
|
3505
|
+
p area_mouse_event
|
3506
|
+
end
|
3507
|
+
|
3508
|
+
on_mouse_moved do |area_mouse_event|
|
3509
|
+
puts 'moved'
|
3510
|
+
end
|
3511
|
+
|
3512
|
+
on_mouse_down do |area_mouse_event|
|
3513
|
+
puts 'mouse down'
|
3514
|
+
end
|
3515
|
+
|
3516
|
+
on_mouse_up do |area_mouse_event|
|
3517
|
+
puts 'mouse up'
|
3518
|
+
end
|
3519
|
+
|
3520
|
+
on_mouse_drag_started do |area_mouse_event|
|
3521
|
+
puts 'drag started'
|
3522
|
+
end
|
3523
|
+
|
3524
|
+
on_mouse_dragged do |area_mouse_event|
|
3525
|
+
puts 'dragged'
|
3526
|
+
end
|
3527
|
+
|
3528
|
+
on_mouse_dropped do |area_mouse_event|
|
3529
|
+
puts 'dropped'
|
3530
|
+
end
|
3531
|
+
|
3532
|
+
on_mouse_entered do
|
3533
|
+
puts 'entered'
|
3534
|
+
end
|
3535
|
+
|
3536
|
+
on_mouse_exited do
|
3537
|
+
puts 'exited'
|
3538
|
+
end
|
3539
|
+
|
3540
|
+
on_key_event do |area_key_event|
|
3541
|
+
p area_key_event
|
3542
|
+
end
|
3543
|
+
|
3544
|
+
on_key_up do |area_key_event|
|
3545
|
+
puts 'key up'
|
3546
|
+
end
|
3547
|
+
|
3548
|
+
on_key_down do |area_key_event|
|
3549
|
+
puts 'key down'
|
3550
|
+
end
|
3378
3551
|
}
|
3379
3552
|
}.show
|
3380
3553
|
```
|
@@ -3476,7 +3649,7 @@ window('Area Gallery', 400, 400) {
|
|
3476
3649
|
}
|
3477
3650
|
|
3478
3651
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3479
|
-
stroke
|
3652
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
3480
3653
|
}
|
3481
3654
|
path { # declarative stable path
|
3482
3655
|
arc {
|
@@ -3489,8 +3662,56 @@ window('Area Gallery', 400, 400) {
|
|
3489
3662
|
}
|
3490
3663
|
|
3491
3664
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3492
|
-
stroke
|
3665
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
3493
3666
|
}
|
3667
|
+
|
3668
|
+
on_mouse_event do |area_mouse_event|
|
3669
|
+
p area_mouse_event
|
3670
|
+
end
|
3671
|
+
|
3672
|
+
on_mouse_moved do |area_mouse_event|
|
3673
|
+
puts 'moved'
|
3674
|
+
end
|
3675
|
+
|
3676
|
+
on_mouse_down do |area_mouse_event|
|
3677
|
+
puts 'mouse down'
|
3678
|
+
end
|
3679
|
+
|
3680
|
+
on_mouse_up do |area_mouse_event|
|
3681
|
+
puts 'mouse up'
|
3682
|
+
end
|
3683
|
+
|
3684
|
+
on_mouse_drag_started do |area_mouse_event|
|
3685
|
+
puts 'drag started'
|
3686
|
+
end
|
3687
|
+
|
3688
|
+
on_mouse_dragged do |area_mouse_event|
|
3689
|
+
puts 'dragged'
|
3690
|
+
end
|
3691
|
+
|
3692
|
+
on_mouse_dropped do |area_mouse_event|
|
3693
|
+
puts 'dropped'
|
3694
|
+
end
|
3695
|
+
|
3696
|
+
on_mouse_entered do
|
3697
|
+
puts 'entered'
|
3698
|
+
end
|
3699
|
+
|
3700
|
+
on_mouse_exited do
|
3701
|
+
puts 'exited'
|
3702
|
+
end
|
3703
|
+
|
3704
|
+
on_key_event do |area_key_event|
|
3705
|
+
p area_key_event
|
3706
|
+
end
|
3707
|
+
|
3708
|
+
on_key_up do |area_key_event|
|
3709
|
+
puts 'key up'
|
3710
|
+
end
|
3711
|
+
|
3712
|
+
on_key_down do |area_key_event|
|
3713
|
+
puts 'key down'
|
3714
|
+
end
|
3494
3715
|
}
|
3495
3716
|
}.show
|
3496
3717
|
```
|
@@ -3539,15 +3760,63 @@ window('Area Gallery', 400, 400) {
|
|
3539
3760
|
}
|
3540
3761
|
|
3541
3762
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3542
|
-
stroke
|
3763
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
3543
3764
|
}
|
3544
3765
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
3545
3766
|
arc(200, 200, 90, 0, 360, false)
|
3546
3767
|
|
3547
3768
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3548
|
-
stroke
|
3769
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
3549
3770
|
}
|
3550
3771
|
end
|
3772
|
+
|
3773
|
+
on_mouse_event do |area_mouse_event|
|
3774
|
+
p area_mouse_event
|
3775
|
+
end
|
3776
|
+
|
3777
|
+
on_mouse_moved do |area_mouse_event|
|
3778
|
+
puts 'moved'
|
3779
|
+
end
|
3780
|
+
|
3781
|
+
on_mouse_down do |area_mouse_event|
|
3782
|
+
puts 'mouse down'
|
3783
|
+
end
|
3784
|
+
|
3785
|
+
on_mouse_up do |area_mouse_event|
|
3786
|
+
puts 'mouse up'
|
3787
|
+
end
|
3788
|
+
|
3789
|
+
on_mouse_drag_started do |area_mouse_event|
|
3790
|
+
puts 'drag started'
|
3791
|
+
end
|
3792
|
+
|
3793
|
+
on_mouse_dragged do |area_mouse_event|
|
3794
|
+
puts 'dragged'
|
3795
|
+
end
|
3796
|
+
|
3797
|
+
on_mouse_dropped do |area_mouse_event|
|
3798
|
+
puts 'dropped'
|
3799
|
+
end
|
3800
|
+
|
3801
|
+
on_mouse_entered do
|
3802
|
+
puts 'entered'
|
3803
|
+
end
|
3804
|
+
|
3805
|
+
on_mouse_exited do
|
3806
|
+
puts 'exited'
|
3807
|
+
end
|
3808
|
+
|
3809
|
+
on_key_event do |area_key_event|
|
3810
|
+
p area_key_event
|
3811
|
+
end
|
3812
|
+
|
3813
|
+
on_key_up do |area_key_event|
|
3814
|
+
puts 'key up'
|
3815
|
+
end
|
3816
|
+
|
3817
|
+
on_key_down do |area_key_event|
|
3818
|
+
puts 'key down'
|
3819
|
+
end
|
3551
3820
|
}
|
3552
3821
|
}.show
|
3553
3822
|
```
|
@@ -3650,7 +3919,7 @@ window('Area Gallery', 400, 400) {
|
|
3650
3919
|
}
|
3651
3920
|
|
3652
3921
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3653
|
-
stroke
|
3922
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
3654
3923
|
}
|
3655
3924
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
3656
3925
|
arc {
|
@@ -3663,9 +3932,57 @@ window('Area Gallery', 400, 400) {
|
|
3663
3932
|
}
|
3664
3933
|
|
3665
3934
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3666
|
-
stroke
|
3935
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
3667
3936
|
}
|
3668
3937
|
end
|
3938
|
+
|
3939
|
+
on_mouse_event do |area_mouse_event|
|
3940
|
+
p area_mouse_event
|
3941
|
+
end
|
3942
|
+
|
3943
|
+
on_mouse_moved do |area_mouse_event|
|
3944
|
+
puts 'moved'
|
3945
|
+
end
|
3946
|
+
|
3947
|
+
on_mouse_down do |area_mouse_event|
|
3948
|
+
puts 'mouse down'
|
3949
|
+
end
|
3950
|
+
|
3951
|
+
on_mouse_up do |area_mouse_event|
|
3952
|
+
puts 'mouse up'
|
3953
|
+
end
|
3954
|
+
|
3955
|
+
on_mouse_drag_started do |area_mouse_event|
|
3956
|
+
puts 'drag started'
|
3957
|
+
end
|
3958
|
+
|
3959
|
+
on_mouse_dragged do |area_mouse_event|
|
3960
|
+
puts 'dragged'
|
3961
|
+
end
|
3962
|
+
|
3963
|
+
on_mouse_dropped do |area_mouse_event|
|
3964
|
+
puts 'dropped'
|
3965
|
+
end
|
3966
|
+
|
3967
|
+
on_mouse_entered do
|
3968
|
+
puts 'entered'
|
3969
|
+
end
|
3970
|
+
|
3971
|
+
on_mouse_exited do
|
3972
|
+
puts 'exited'
|
3973
|
+
end
|
3974
|
+
|
3975
|
+
on_key_event do |area_key_event|
|
3976
|
+
p area_key_event
|
3977
|
+
end
|
3978
|
+
|
3979
|
+
on_key_up do |area_key_event|
|
3980
|
+
puts 'key up'
|
3981
|
+
end
|
3982
|
+
|
3983
|
+
on_key_down do |area_key_event|
|
3984
|
+
puts 'key down'
|
3985
|
+
end
|
3669
3986
|
}
|
3670
3987
|
}.show
|
3671
3988
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
data/examples/area_gallery.rb
CHANGED
@@ -38,13 +38,61 @@ window('Area Gallery', 400, 400) {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
fill r: 202, g: 102, b: 204, a: 0.5
|
41
|
-
stroke
|
41
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
42
42
|
}
|
43
43
|
path { # declarative stable path
|
44
44
|
arc(200, 200, 90, 0, 360, false)
|
45
45
|
|
46
46
|
fill r: 202, g: 102, b: 204, a: 0.5
|
47
|
-
stroke
|
47
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
48
48
|
}
|
49
|
+
|
50
|
+
on_mouse_event do |area_mouse_event|
|
51
|
+
p area_mouse_event
|
52
|
+
end
|
53
|
+
|
54
|
+
on_mouse_moved do |area_mouse_event|
|
55
|
+
puts 'moved'
|
56
|
+
end
|
57
|
+
|
58
|
+
on_mouse_down do |area_mouse_event|
|
59
|
+
puts 'mouse down'
|
60
|
+
end
|
61
|
+
|
62
|
+
on_mouse_up do |area_mouse_event|
|
63
|
+
puts 'mouse up'
|
64
|
+
end
|
65
|
+
|
66
|
+
on_mouse_drag_started do |area_mouse_event|
|
67
|
+
puts 'drag started'
|
68
|
+
end
|
69
|
+
|
70
|
+
on_mouse_dragged do |area_mouse_event|
|
71
|
+
puts 'dragged'
|
72
|
+
end
|
73
|
+
|
74
|
+
on_mouse_dropped do |area_mouse_event|
|
75
|
+
puts 'dropped'
|
76
|
+
end
|
77
|
+
|
78
|
+
on_mouse_entered do
|
79
|
+
puts 'entered'
|
80
|
+
end
|
81
|
+
|
82
|
+
on_mouse_exited do
|
83
|
+
puts 'exited'
|
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
|
49
97
|
}
|
50
98
|
}.show
|
data/examples/area_gallery2.rb
CHANGED
@@ -92,7 +92,7 @@ window('Area Gallery', 400, 400) {
|
|
92
92
|
}
|
93
93
|
|
94
94
|
fill r: 202, g: 102, b: 204, a: 0.5
|
95
|
-
stroke
|
95
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
96
96
|
}
|
97
97
|
path { # declarative stable path
|
98
98
|
arc {
|
@@ -105,7 +105,55 @@ window('Area Gallery', 400, 400) {
|
|
105
105
|
}
|
106
106
|
|
107
107
|
fill r: 202, g: 102, b: 204, a: 0.5
|
108
|
-
stroke
|
108
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
109
109
|
}
|
110
|
+
|
111
|
+
on_mouse_event do |area_mouse_event|
|
112
|
+
p area_mouse_event
|
113
|
+
end
|
114
|
+
|
115
|
+
on_mouse_moved do |area_mouse_event|
|
116
|
+
puts 'moved'
|
117
|
+
end
|
118
|
+
|
119
|
+
on_mouse_down do |area_mouse_event|
|
120
|
+
puts 'mouse down'
|
121
|
+
end
|
122
|
+
|
123
|
+
on_mouse_up do |area_mouse_event|
|
124
|
+
puts 'mouse up'
|
125
|
+
end
|
126
|
+
|
127
|
+
on_mouse_drag_started do |area_mouse_event|
|
128
|
+
puts 'drag started'
|
129
|
+
end
|
130
|
+
|
131
|
+
on_mouse_dragged do |area_mouse_event|
|
132
|
+
puts 'dragged'
|
133
|
+
end
|
134
|
+
|
135
|
+
on_mouse_dropped do |area_mouse_event|
|
136
|
+
puts 'dropped'
|
137
|
+
end
|
138
|
+
|
139
|
+
on_mouse_entered do
|
140
|
+
puts 'entered'
|
141
|
+
end
|
142
|
+
|
143
|
+
on_mouse_exited do
|
144
|
+
puts 'exited'
|
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
|
110
158
|
}
|
111
159
|
}.show
|
data/examples/area_gallery3.rb
CHANGED
@@ -39,14 +39,62 @@ window('Area Gallery', 400, 400) {
|
|
39
39
|
}
|
40
40
|
|
41
41
|
fill r: 202, g: 102, b: 204, a: 0.5
|
42
|
-
stroke
|
42
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
43
43
|
}
|
44
44
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
45
45
|
arc(200, 200, 90, 0, 360, false)
|
46
46
|
|
47
47
|
fill r: 202, g: 102, b: 204, a: 0.5
|
48
|
-
stroke
|
48
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
49
49
|
}
|
50
50
|
end
|
51
|
+
|
52
|
+
on_mouse_event do |area_mouse_event|
|
53
|
+
p area_mouse_event
|
54
|
+
end
|
55
|
+
|
56
|
+
on_mouse_moved do |area_mouse_event|
|
57
|
+
puts 'moved'
|
58
|
+
end
|
59
|
+
|
60
|
+
on_mouse_down do |area_mouse_event|
|
61
|
+
puts 'mouse down'
|
62
|
+
end
|
63
|
+
|
64
|
+
on_mouse_up do |area_mouse_event|
|
65
|
+
puts 'mouse up'
|
66
|
+
end
|
67
|
+
|
68
|
+
on_mouse_drag_started do |area_mouse_event|
|
69
|
+
puts 'drag started'
|
70
|
+
end
|
71
|
+
|
72
|
+
on_mouse_dragged do |area_mouse_event|
|
73
|
+
puts 'dragged'
|
74
|
+
end
|
75
|
+
|
76
|
+
on_mouse_dropped do |area_mouse_event|
|
77
|
+
puts 'dropped'
|
78
|
+
end
|
79
|
+
|
80
|
+
on_mouse_entered do
|
81
|
+
puts 'entered'
|
82
|
+
end
|
83
|
+
|
84
|
+
on_mouse_exited do
|
85
|
+
puts 'exited'
|
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
|
51
99
|
}
|
52
100
|
}.show
|
data/examples/area_gallery4.rb
CHANGED
@@ -93,7 +93,7 @@ window('Area Gallery', 400, 400) {
|
|
93
93
|
}
|
94
94
|
|
95
95
|
fill r: 202, g: 102, b: 204, a: 0.5
|
96
|
-
stroke
|
96
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
97
97
|
}
|
98
98
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
99
99
|
arc {
|
@@ -106,8 +106,56 @@ window('Area Gallery', 400, 400) {
|
|
106
106
|
}
|
107
107
|
|
108
108
|
fill r: 202, g: 102, b: 204, a: 0.5
|
109
|
-
stroke
|
109
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
110
110
|
}
|
111
111
|
end
|
112
|
+
|
113
|
+
on_mouse_event do |area_mouse_event|
|
114
|
+
p area_mouse_event
|
115
|
+
end
|
116
|
+
|
117
|
+
on_mouse_moved do |area_mouse_event|
|
118
|
+
puts 'moved'
|
119
|
+
end
|
120
|
+
|
121
|
+
on_mouse_down do |area_mouse_event|
|
122
|
+
puts 'mouse down'
|
123
|
+
end
|
124
|
+
|
125
|
+
on_mouse_up do |area_mouse_event|
|
126
|
+
puts 'mouse up'
|
127
|
+
end
|
128
|
+
|
129
|
+
on_mouse_drag_started do |area_mouse_event|
|
130
|
+
puts 'drag started'
|
131
|
+
end
|
132
|
+
|
133
|
+
on_mouse_dragged do |area_mouse_event|
|
134
|
+
puts 'dragged'
|
135
|
+
end
|
136
|
+
|
137
|
+
on_mouse_dropped do |area_mouse_event|
|
138
|
+
puts 'dropped'
|
139
|
+
end
|
140
|
+
|
141
|
+
on_mouse_entered do
|
142
|
+
puts 'entered'
|
143
|
+
end
|
144
|
+
|
145
|
+
on_mouse_exited do
|
146
|
+
puts 'exited'
|
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
|
112
160
|
}
|
113
161
|
}.show
|
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/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -36,6 +36,19 @@ 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', 'on_key_event', 'on_key_down', 'on_key_up']
|
40
|
+
LISTENER_ALIASES = {
|
41
|
+
on_drawn: 'on_draw',
|
42
|
+
on_mouse_moved: 'on_mouse_move',
|
43
|
+
on_mouse_drag_started: 'on_mouse_drag_start',
|
44
|
+
on_mouse_dragged: 'on_mouse_drag',
|
45
|
+
on_mouse_dropped: 'on_mouse_drop',
|
46
|
+
on_mouse_cross: 'on_mouse_crossed',
|
47
|
+
on_mouse_entered: 'on_mouse_enter',
|
48
|
+
on_mouse_exited: 'on_mouse_exit',
|
49
|
+
on_drag_break: 'on_drag_broken',
|
50
|
+
}
|
51
|
+
|
39
52
|
include Glimmer::FiddleConsumer
|
40
53
|
include Parent
|
41
54
|
prepend Transformable
|
@@ -47,29 +60,6 @@ module Glimmer
|
|
47
60
|
install_listeners
|
48
61
|
end
|
49
62
|
|
50
|
-
def on_draw(&block)
|
51
|
-
@on_draw_procs ||= []
|
52
|
-
if block.nil?
|
53
|
-
@on_draw_procs
|
54
|
-
else
|
55
|
-
@on_draw_procs << block
|
56
|
-
block
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def can_handle_listener?(listener_name)
|
61
|
-
listener_name == 'on_draw' || super
|
62
|
-
end
|
63
|
-
|
64
|
-
def handle_listener(listener_name, &listener)
|
65
|
-
case listener_name
|
66
|
-
when 'on_draw'
|
67
|
-
on_draw(&listener)
|
68
|
-
else
|
69
|
-
super
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
63
|
def draw(area_draw_params)
|
74
64
|
children.dup.each {|child| child.draw(area_draw_params)}
|
75
65
|
on_draw.each {|listener| listener.call(area_draw_params)}
|
@@ -94,10 +84,42 @@ module Glimmer
|
|
94
84
|
draw(area_draw_params)
|
95
85
|
AreaProxy.current_area_draw_params = nil
|
96
86
|
end
|
97
|
-
@area_handler.MouseEvent = fiddle_closure_block_caller(0, [
|
98
|
-
|
99
|
-
|
100
|
-
|
87
|
+
@area_handler.MouseEvent = fiddle_closure_block_caller(0, [1, 1, 1]) do |_, _, area_mouse_event|
|
88
|
+
area_mouse_event = ::LibUI::FFI::AreaMouseEvent.new(area_mouse_event)
|
89
|
+
area_mouse_event = area_mouse_event_hash(area_mouse_event)
|
90
|
+
on_mouse_event.each { |listener| listener.call(area_mouse_event)}
|
91
|
+
on_mouse_move.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:x].between?(0, area_mouse_event[:area_width]) && area_mouse_event[:y].between?(0, area_mouse_event[:area_height])
|
92
|
+
unless @last_area_mouse_event.nil?
|
93
|
+
on_mouse_down.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:down] > 0 && @last_area_mouse_event[:down] == 0
|
94
|
+
on_mouse_up.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:up] > 0 && @last_area_mouse_event[:up] == 0
|
95
|
+
on_mouse_drag_start.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:held] > 0 && @last_area_mouse_event[:held] == 0
|
96
|
+
on_mouse_drag.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:held] > 0
|
97
|
+
on_mouse_drop.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:held] == 0 && @last_area_mouse_event[:held] > 0
|
98
|
+
end
|
99
|
+
@last_area_mouse_event = area_mouse_event
|
100
|
+
end
|
101
|
+
@area_handler.MouseCrossed = fiddle_closure_block_caller(0, [1, 1, 4]) do |_, _, left|
|
102
|
+
left = Glimmer::LibUI.integer_to_boolean(left)
|
103
|
+
on_mouse_crossed.each { |listener| listener.call(left) }
|
104
|
+
if left
|
105
|
+
on_mouse_exit.each { |listener| listener.call(left) }
|
106
|
+
else
|
107
|
+
on_mouse_enter.each { |listener| listener.call(left) }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
@area_handler.DragBroken = fiddle_closure_block_caller(0, [1, 1]) do |_, _|
|
111
|
+
on_drag_broken.each { |listener| listener.call }
|
112
|
+
end
|
113
|
+
@area_handler.KeyEvent = fiddle_closure_block_caller(0, [1, 1, 1]) do |_, _, area_key_event|
|
114
|
+
area_key_event = ::LibUI::FFI::AreaKeyEvent.new(area_key_event)
|
115
|
+
area_key_event = area_key_event_hash(area_key_event)
|
116
|
+
on_key_event.each { |listener| listener.call(area_key_event) }
|
117
|
+
if area_key_event[:up]
|
118
|
+
on_key_up.each { |listener| listener.call(area_key_event) }
|
119
|
+
else
|
120
|
+
on_key_down.each { |listener| listener.call(area_key_event) }
|
121
|
+
end
|
122
|
+
end
|
101
123
|
end
|
102
124
|
|
103
125
|
def area_draw_params_hash(area_draw_params)
|
@@ -111,6 +133,62 @@ module Glimmer
|
|
111
133
|
clip_height: area_draw_params.ClipHeight,
|
112
134
|
}
|
113
135
|
end
|
136
|
+
|
137
|
+
def area_mouse_event_hash(area_mouse_event)
|
138
|
+
{
|
139
|
+
x: area_mouse_event.X,
|
140
|
+
y: area_mouse_event.Y,
|
141
|
+
area_width: area_mouse_event.AreaWidth,
|
142
|
+
area_height: area_mouse_event.AreaHeight,
|
143
|
+
down: area_mouse_event.Down,
|
144
|
+
up: area_mouse_event.Up,
|
145
|
+
count: area_mouse_event.Count,
|
146
|
+
modifers: modifiers_to_symbols(area_mouse_event.Modifiers),
|
147
|
+
held: area_mouse_event.Held1To64,
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def area_key_event_hash(area_key_event)
|
152
|
+
{
|
153
|
+
key: key_to_char(area_key_event.Key),
|
154
|
+
key_value: area_key_event.Key,
|
155
|
+
ext_key: ext_key_to_symbol(area_key_event.ExtKey),
|
156
|
+
ext_key_value: area_key_event.ExtKey,
|
157
|
+
modifier: modifiers_to_symbols(area_key_event.Modifier).first,
|
158
|
+
modifiers: modifiers_to_symbols(area_key_event.Modifiers),
|
159
|
+
up: Glimmer::LibUI.integer_to_boolean(area_key_event.Up),
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
def key_to_char(key)
|
164
|
+
key.chr if key > 0
|
165
|
+
end
|
166
|
+
|
167
|
+
def ext_key_to_symbol(ext_key_value)
|
168
|
+
Glimmer::LibUI.enum_symbols(:ext_key)[ext_key_value - 1].to_s.to_sym if ext_key_value > 0
|
169
|
+
end
|
170
|
+
|
171
|
+
def modifiers_to_symbols(modifiers_value)
|
172
|
+
symbols = []
|
173
|
+
modifiers_value = extract_symbol_from_modifiers_value(modifiers_value, symbols: symbols) while modifiers_value > 0
|
174
|
+
symbols
|
175
|
+
end
|
176
|
+
|
177
|
+
def extract_symbol_from_modifiers_value(modifiers_value, symbols: )
|
178
|
+
if modifiers_value >= 8
|
179
|
+
symbols << :command
|
180
|
+
modifiers_value -= 8
|
181
|
+
elsif modifiers_value >= 4
|
182
|
+
symbols << :shift
|
183
|
+
modifiers_value -= 4
|
184
|
+
elsif modifiers_value >= 2
|
185
|
+
symbols << :alt
|
186
|
+
modifiers_value -= 2
|
187
|
+
elsif modifiers_value >= 1
|
188
|
+
symbols << :control
|
189
|
+
modifiers_value -= 1
|
190
|
+
end
|
191
|
+
end
|
114
192
|
end
|
115
193
|
end
|
116
194
|
end
|
@@ -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
|
|
@@ -117,17 +117,24 @@ module Glimmer
|
|
117
117
|
|
118
118
|
def draw_stroke_params
|
119
119
|
@draw_stroke_params ||= ::LibUI::FFI::DrawStrokeParams.malloc
|
120
|
-
@draw_stroke_params.Cap =
|
121
|
-
@draw_stroke_params.Join =
|
120
|
+
@draw_stroke_params.Cap = draw_line_cap # flat
|
121
|
+
@draw_stroke_params.Join = draw_line_join # miter
|
122
122
|
@draw_stroke_params.Thickness = @stroke[:thickness] || 1
|
123
123
|
@draw_stroke_params.MiterLimit = @stroke[:miter_limit] || 10 # DEFAULT_MITER_LIMIT
|
124
|
-
@
|
125
|
-
@draw_stroke_params.
|
126
|
-
@draw_stroke_params.NumDashes = @stroke[:num_dashes] || 0 # TODO reimplement this line correctly (perhaps no need to pass num dashes, yet dashes themselves and use their count here)
|
124
|
+
@draw_stroke_params.Dashes = @stroke[:dashes].to_a.pack('d*')
|
125
|
+
@draw_stroke_params.NumDashes = @stroke[:dashes].to_a.count
|
127
126
|
@draw_stroke_params.DashPhase = @stroke[:dash_phase] || 0
|
128
127
|
@draw_stroke_params
|
129
128
|
end
|
130
129
|
|
130
|
+
def draw_line_cap
|
131
|
+
Glimmer::LibUI.enum_symbol_to_value(:draw_line_cap, @stroke && @stroke[:cap])
|
132
|
+
end
|
133
|
+
|
134
|
+
def draw_line_join
|
135
|
+
Glimmer::LibUI.enum_symbol_to_value(:draw_line_join, @stroke && @stroke[:join])
|
136
|
+
end
|
137
|
+
|
131
138
|
def destroy
|
132
139
|
@parent_proxy&.children&.delete(self)
|
133
140
|
ControlProxy.control_proxies.delete(self)
|
@@ -144,20 +151,7 @@ module Glimmer
|
|
144
151
|
end
|
145
152
|
|
146
153
|
def init_draw_brush(draw_brush, draw_brush_args)
|
147
|
-
|
148
|
-
when Integer
|
149
|
-
draw_brush.Type = draw_brush_args[:type]
|
150
|
-
when :solid, 'solid'
|
151
|
-
draw_brush.Type = 0
|
152
|
-
when :linear_gradient, 'linear_gradient'
|
153
|
-
draw_brush.Type = 1
|
154
|
-
when :radial_gradient, 'radial_gradient'
|
155
|
-
draw_brush.Type = 2
|
156
|
-
when :image, 'image'
|
157
|
-
draw_brush.Type = 3
|
158
|
-
else
|
159
|
-
draw_brush.Type = 0
|
160
|
-
end
|
154
|
+
draw_brush.Type = Glimmer::LibUI.enum_symbol_to_value(:draw_brush_type, draw_brush_args[:type])
|
161
155
|
draw_brush.R = (draw_brush_args[:r] || draw_brush_args[:red]).to_f / 255.0
|
162
156
|
draw_brush.G = (draw_brush_args[:g] || draw_brush_args[:green]).to_f / 255.0
|
163
157
|
draw_brush.B = (draw_brush_args[:b] || draw_brush_args[:blue]).to_f / 255.0
|
@@ -141,7 +141,8 @@ module Glimmer
|
|
141
141
|
|
142
142
|
def can_handle_listener?(listener_name)
|
143
143
|
::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
|
144
|
-
::LibUI.respond_to?("control_#{listener_name}")
|
144
|
+
::LibUI.respond_to?("control_#{listener_name}") ||
|
145
|
+
has_custom_listener?(listener_name)
|
145
146
|
end
|
146
147
|
|
147
148
|
def handle_listener(listener_name, &listener)
|
@@ -150,6 +151,34 @@ module Glimmer
|
|
150
151
|
::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &safe_listener)
|
151
152
|
elsif ::LibUI.respond_to?("control_#{listener_name}")
|
152
153
|
::LibUI.send("control_#{listener_name}", @libui, &safe_listener)
|
154
|
+
elsif has_custom_listener?(listener_name)
|
155
|
+
handle_custom_listener(listener_name, &listener)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def has_custom_listener?(listener_name)
|
160
|
+
listener_name = listener_name.to_s
|
161
|
+
custom_listeners.include?(listener_name) || custom_listener_aliases.stringify_keys.keys.include?(listener_name)
|
162
|
+
end
|
163
|
+
|
164
|
+
def custom_listeners
|
165
|
+
self.class.constants.include?(:LISTENERS) ? self.class::LISTENERS : []
|
166
|
+
end
|
167
|
+
|
168
|
+
def custom_listener_aliases
|
169
|
+
self.class.constants.include?(:LISTENER_ALIASES) ? self.class::LISTENER_ALIASES : {}
|
170
|
+
end
|
171
|
+
|
172
|
+
def handle_custom_listener(listener_name, &listener)
|
173
|
+
listener_name = listener_name.to_s
|
174
|
+
listener_name = custom_listener_aliases.stringify_keys[listener_name] || listener_name
|
175
|
+
instance_variable_name = "@#{listener_name}_procs"
|
176
|
+
instance_variable_set(instance_variable_name, []) if instance_variable_get(instance_variable_name).nil?
|
177
|
+
if listener.nil?
|
178
|
+
instance_variable_get(instance_variable_name)
|
179
|
+
else
|
180
|
+
instance_variable_get(instance_variable_name) << listener
|
181
|
+
listener
|
153
182
|
end
|
154
183
|
end
|
155
184
|
|
@@ -160,6 +189,7 @@ module Glimmer
|
|
160
189
|
(append_properties.include?(method_name.to_s.sub(/\?$/, '')) && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, ''))) ||
|
161
190
|
append_properties.include?(method_name.to_s.sub(/=$/, ''))
|
162
191
|
) ||
|
192
|
+
can_handle_listener?(method_name.to_s) ||
|
163
193
|
super(method_name, true)
|
164
194
|
end
|
165
195
|
|
@@ -178,6 +208,8 @@ module Glimmer
|
|
178
208
|
elsif append_properties.include?(method_name.to_s) ||
|
179
209
|
append_properties.include?(method_name.to_s.sub(/(=|\?)$/, ''))
|
180
210
|
append_property(method_name, *args)
|
211
|
+
elsif can_handle_listener?(method_name.to_s)
|
212
|
+
handle_listener(method_name.to_s, &block)
|
181
213
|
else
|
182
214
|
super
|
183
215
|
end
|
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
|
data/lib/glimmer-dsl-libui.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.10
|
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-03 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.1
|
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.1
|
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
|