glimmer-dsl-libui 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +81 -11
- 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/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +33 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6159cc2323ab4b53114187df37e888c3f070102ce1b8a98dbaad724912b999b9
|
4
|
+
data.tar.gz: b0368395d3175a5528732c665f43902f84187a4f62ab23e4f47ebb8d729ac304
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ede14899e28cc5030f2d49653c51b931e1438934b26f7486843ed518d74fbe33107fa6db7c53a46991895835d9989e275a41474fbf4d2d692ae33d0c6cbf2bfd
|
7
|
+
data.tar.gz: e0964cfde750af8ebe2f14ab326eb477ebf0ed7cea56b7145828af909615a534acd67ec0169ceb41ed3d876bb229fb552dd62cc79ed4f9a552d7e72750d8a108
|
data/CHANGELOG.md
CHANGED
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.9
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
@@ -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.9](#-glimmer-dsl-for-libui-019)
|
183
195
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
184
196
|
- [Usage](#usage)
|
185
197
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
@@ -309,7 +321,7 @@ gem install glimmer-dsl-libui
|
|
309
321
|
Or install via Bundler `Gemfile`:
|
310
322
|
|
311
323
|
```ruby
|
312
|
-
gem 'glimmer-dsl-libui', '~> 0.1.
|
324
|
+
gem 'glimmer-dsl-libui', '~> 0.1.9'
|
313
325
|
```
|
314
326
|
|
315
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.
|
@@ -383,7 +395,7 @@ w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0
|
|
383
395
|
Control(Args) | Properties | Listeners
|
384
396
|
------------- | ---------- | ---------
|
385
397
|
`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`
|
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)`
|
387
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
|
388
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
|
389
401
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
@@ -645,18 +657,21 @@ The `area_draw_params` argument for `on_draw` block is a hash consisting of the
|
|
645
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.
|
646
658
|
|
647
659
|
`area` supported mouse listeners are:
|
648
|
-
- `
|
649
|
-
- `
|
650
|
-
- `
|
651
|
-
- `
|
652
|
-
- `
|
653
|
-
- `
|
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| ...}`
|
654
669
|
- `on_mouse_entered {...}`
|
655
670
|
- `on_mouse_exited {...}`
|
656
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`)
|
657
672
|
- `on_drag_broken {...}` (NOT RECOMMENDED; varies per platforms; use `on_mouse_dropped` instead)
|
658
673
|
|
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:
|
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:
|
660
675
|
- `:x`: mouse x location in relation to area's top-left-corner
|
661
676
|
- `:y`: mouse y location in relation to area's top-left-corner
|
662
677
|
- `:area_width`: area current width
|
@@ -667,6 +682,13 @@ The `area_mouse_event` argument for mouse events that receive it (e.g. `on_mouse
|
|
667
682
|
- `:modifers`: `Array` of `Symbol`s from one of the following: `[:command, :shift, :alt, :control]`
|
668
683
|
- `:held`: mouse held button during dragging (e.g. `1` is left button, `4` is right button)
|
669
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
|
+
- `:ext_key`: non-character extra key (`Symbol`) such as `:left`, `:right`, `:escape`, `:insert`
|
688
|
+
- `:modifier`: modifier key pressed alone (e.g. `:shift` or `:control`)
|
689
|
+
- `:modifiers`: modifier keys pressed simultaneously with `:key`, `:ext_key`, or `:modifier`
|
690
|
+
- `:up`: indicates if key has been released or not (Boolean)
|
691
|
+
|
670
692
|
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
693
|
|
672
694
|
To redraw an `area`, you may call the `#queue_redraw_all` method, or simply `#redraw`.
|
@@ -3474,6 +3496,18 @@ window('Area Gallery', 400, 400) {
|
|
3474
3496
|
on_mouse_exited do
|
3475
3497
|
puts 'exited'
|
3476
3498
|
end
|
3499
|
+
|
3500
|
+
on_key_event do |area_key_event|
|
3501
|
+
p area_key_event
|
3502
|
+
end
|
3503
|
+
|
3504
|
+
on_key_up do |area_key_event|
|
3505
|
+
puts 'key up'
|
3506
|
+
end
|
3507
|
+
|
3508
|
+
on_key_down do |area_key_event|
|
3509
|
+
puts 'key down'
|
3510
|
+
end
|
3477
3511
|
}
|
3478
3512
|
}.show
|
3479
3513
|
```
|
@@ -3626,6 +3660,18 @@ window('Area Gallery', 400, 400) {
|
|
3626
3660
|
on_mouse_exited do
|
3627
3661
|
puts 'exited'
|
3628
3662
|
end
|
3663
|
+
|
3664
|
+
on_key_event do |area_key_event|
|
3665
|
+
p area_key_event
|
3666
|
+
end
|
3667
|
+
|
3668
|
+
on_key_up do |area_key_event|
|
3669
|
+
puts 'key up'
|
3670
|
+
end
|
3671
|
+
|
3672
|
+
on_key_down do |area_key_event|
|
3673
|
+
puts 'key down'
|
3674
|
+
end
|
3629
3675
|
}
|
3630
3676
|
}.show
|
3631
3677
|
```
|
@@ -3719,6 +3765,18 @@ window('Area Gallery', 400, 400) {
|
|
3719
3765
|
on_mouse_exited do
|
3720
3766
|
puts 'exited'
|
3721
3767
|
end
|
3768
|
+
|
3769
|
+
on_key_event do |area_key_event|
|
3770
|
+
p area_key_event
|
3771
|
+
end
|
3772
|
+
|
3773
|
+
on_key_up do |area_key_event|
|
3774
|
+
puts 'key up'
|
3775
|
+
end
|
3776
|
+
|
3777
|
+
on_key_down do |area_key_event|
|
3778
|
+
puts 'key down'
|
3779
|
+
end
|
3722
3780
|
}
|
3723
3781
|
}.show
|
3724
3782
|
```
|
@@ -3873,6 +3931,18 @@ window('Area Gallery', 400, 400) {
|
|
3873
3931
|
on_mouse_exited do
|
3874
3932
|
puts 'exited'
|
3875
3933
|
end
|
3934
|
+
|
3935
|
+
on_key_event do |area_key_event|
|
3936
|
+
p area_key_event
|
3937
|
+
end
|
3938
|
+
|
3939
|
+
on_key_up do |area_key_event|
|
3940
|
+
puts 'key up'
|
3941
|
+
end
|
3942
|
+
|
3943
|
+
on_key_down do |area_key_event|
|
3944
|
+
puts 'key down'
|
3945
|
+
end
|
3876
3946
|
}
|
3877
3947
|
}.show
|
3878
3948
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
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/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -34,9 +34,13 @@ module Glimmer
|
|
34
34
|
class << self
|
35
35
|
# this attribute is only populated during on_draw call
|
36
36
|
attr_accessor :current_area_draw_params
|
37
|
+
|
38
|
+
def ext_key_symbols
|
39
|
+
@ext_key_symbols ||= ::LibUI.constants.select { |c| c.to_s.start_with?('ExtKey') }.map { |c| c.to_s.underscore.sub('ext_key_', '') }
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
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']
|
43
|
+
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
44
|
LISTENER_ALIASES = {
|
41
45
|
on_drawn: 'on_draw',
|
42
46
|
on_mouse_moved: 'on_mouse_move',
|
@@ -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,24 @@ 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
|
+
ext_key: ext_key_to_symbol(area_key_event.ExtKey),
|
159
|
+
modifier: modifiers_to_symbols(area_key_event.Modifier).first,
|
160
|
+
modifiers: modifiers_to_symbols(area_key_event.Modifiers),
|
161
|
+
up: Glimmer::LibUI.integer_to_boolean(area_key_event.Up),
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
def key_to_char(key)
|
166
|
+
key.chr if key > 0
|
167
|
+
end
|
168
|
+
|
169
|
+
def ext_key_to_symbol(ext_key_value)
|
170
|
+
AreaProxy.ext_key_symbols[ext_key_value - 1].to_s.to_sym if ext_key_value > 0
|
171
|
+
end
|
172
|
+
|
142
173
|
def modifiers_to_symbols(modifiers_value)
|
143
174
|
symbols = []
|
144
175
|
modifiers_value = extract_symbol_from_modifiers_value(modifiers_value, symbols: symbols) while modifiers_value > 0
|
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.9
|
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
|
@@ -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
|