glimmer-dsl-libui 0.7.6 → 0.7.7
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 +2 -2
- data/VERSION +1 -1
- data/examples/area_gallery.rb +36 -0
- data/examples/tetris.rb +6 -5
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +19 -6
- data/lib/glimmer/libui/control_proxy.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc2c8178ea922168b2df15740230c175155c96313d847dd117137ba18eba0991
|
4
|
+
data.tar.gz: 49cbaff89df8bb0d1099b6adf9f0dcdaefe05010c4ee7b295160b0f7fbe8bd66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30c0cbe41224d6c18e32c204a9f8fab80330ce27d8174f3293399ea9aeb73474f2083145d361d708f062d7035762a4417a135be886dacc09785034ed2b8f0887
|
7
|
+
data.tar.gz: 3f5adf2374b390a21f4e6e7c28003c0446d5fd2a1c810beaebedb820530f56f7415c4a44f91887056be8e7745bc6cc6cd9728c9833cbd7688886f1b3a293d355
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.7.7
|
4
|
+
|
5
|
+
- Support ability for `area` `on_key_event`/`on_key_down`/`on_key_up` listeners to return a boolean value indicating whether they handled a key event or not in case some key events need to be left to other operating system key handlers like COMMAND+Q for the Mac quit menu item
|
6
|
+
- Update `examples/tetris.rb` to return `false` in its `on_key_down` listener for unhandled events
|
7
|
+
- Update `examples/area_gallery.rb` to return `false` in its `on_key_event`/`on_key_down`/`on_key_up` listeners for unhandled events
|
8
|
+
|
3
9
|
## 0.7.6
|
4
10
|
|
5
11
|
- Fix issue with hearing "fonk" sound on every key press when handling `on_key_event`/`on_key_down`/`on_key_up` listeners (by returning expected `1` value if the listeners are handled properly or otherwise allowing the "fonk" sound to ring when the listeners are not handled)
|
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.7.
|
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.7.7
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
### The Quickest Way From Zero To GUI
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
@@ -544,7 +544,7 @@ gem install glimmer-dsl-libui
|
|
544
544
|
Or install via Bundler `Gemfile`:
|
545
545
|
|
546
546
|
```ruby
|
547
|
-
gem 'glimmer-dsl-libui', '~> 0.7.
|
547
|
+
gem 'glimmer-dsl-libui', '~> 0.7.7'
|
548
548
|
```
|
549
549
|
|
550
550
|
Test that installation worked by running the [Meta-Example](#examples):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.7
|
data/examples/area_gallery.rb
CHANGED
@@ -92,14 +92,50 @@ window('Area Gallery', 400, 400) {
|
|
92
92
|
|
93
93
|
on_key_event do |area_key_event|
|
94
94
|
p area_key_event
|
95
|
+
# As a smart default, key events are assumed to be handled if you add a key event listener,
|
96
|
+
# but you can return false to indicate a key event is not handled to allow it
|
97
|
+
# to propagate to other operating system key handlers, like the Mac quit menu item,
|
98
|
+
# which expects a COMMAND+Q shortcut usually.
|
99
|
+
# Otherwise, if you return false in all key event handlers for a specific key combo,
|
100
|
+
# the Mac beeps (makes a "fonk" sound), which is normal behavior on the Mac.
|
101
|
+
case area_key_event
|
102
|
+
in modifiers: [:command], key: 'q'
|
103
|
+
false if OS.mac? # allow to propagate to Mac quit menu item
|
104
|
+
else
|
105
|
+
# true # no return value (nil) or any return value other than false or 0 means true (event handled)
|
106
|
+
end
|
95
107
|
end
|
96
108
|
|
97
109
|
on_key_up do |area_key_event|
|
98
110
|
puts 'key up'
|
111
|
+
# As a smart default, key events are assumed to be handled if you add a key event listener,
|
112
|
+
# but you can return false to indicate a key event is not handled to allow it
|
113
|
+
# to propagate to other operating system key handlers, like the Mac quit menu item,
|
114
|
+
# which expects a COMMAND+Q shortcut usually.
|
115
|
+
# Otherwise, if you return false in all key event handlers for a specific key combo,
|
116
|
+
# the Mac beeps (makes a "fonk" sound), which is normal behavior on the Mac.
|
117
|
+
case area_key_event
|
118
|
+
in modifiers: [:command], key: 'q'
|
119
|
+
false if OS.mac? # allow to propagate to Mac quit menu item
|
120
|
+
else
|
121
|
+
# true # no return value (nil) or any return value other than false or 0 means true (event handled)
|
122
|
+
end
|
99
123
|
end
|
100
124
|
|
101
125
|
on_key_down do |area_key_event|
|
102
126
|
puts 'key down'
|
127
|
+
# As a smart default, key events are assumed to be handled if you add a key event listener,
|
128
|
+
# but you can return false to indicate a key event is not handled to allow it
|
129
|
+
# to propagate to other operating system key handlers, like the Mac quit menu item,
|
130
|
+
# which expects a COMMAND+Q shortcut usually.
|
131
|
+
# Otherwise, if you return false in all key event handlers for a specific key combo,
|
132
|
+
# the Mac beeps (makes a "fonk" sound), which is normal behavior on the Mac.
|
133
|
+
case area_key_event
|
134
|
+
in modifiers: [:command], key: 'q'
|
135
|
+
false if OS.mac? # allow to propagate to Mac quit menu item
|
136
|
+
else
|
137
|
+
# true # no return value (nil) or any return value other than false or 0 means true (event handled)
|
138
|
+
end
|
103
139
|
end
|
104
140
|
}
|
105
141
|
}.show
|
data/examples/tetris.rb
CHANGED
@@ -258,6 +258,7 @@ class Tetris
|
|
258
258
|
}
|
259
259
|
|
260
260
|
on_key_down do |key_event|
|
261
|
+
handled = true # assume it is handled for all cases except the else clause below
|
261
262
|
case key_event
|
262
263
|
in ext_key: :down
|
263
264
|
if OS.windows?
|
@@ -292,13 +293,13 @@ class Tetris
|
|
292
293
|
@game.rotate!(:right)
|
293
294
|
in modifier: :control
|
294
295
|
@game.rotate!(:left)
|
295
|
-
in modifiers: [:command], key: 'q'
|
296
|
-
exit(0) if OS.mac?
|
297
|
-
in modifiers: [:alt], ext_key: :f4
|
298
|
-
exit(0) unless OS.mac?
|
299
296
|
else
|
300
|
-
#
|
297
|
+
# returning false explicitly means the key event was not handled, which
|
298
|
+
# propagates the event to other handlers, like the quit menu item, which
|
299
|
+
# can handle COMMAND+Q on the Mac to quit an application
|
300
|
+
handled = false
|
301
301
|
end
|
302
|
+
handled
|
302
303
|
end
|
303
304
|
|
304
305
|
extra_content&.call
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -182,16 +182,29 @@ module Glimmer
|
|
182
182
|
@area_handler.KeyEvent = fiddle_closure_block_caller(1, [1, 1, 1]) do |_, _, area_key_event|
|
183
183
|
area_key_event = ::LibUI::FFI::AreaKeyEvent.new(area_key_event)
|
184
184
|
area_key_event = area_key_event_hash(area_key_event)
|
185
|
-
|
185
|
+
on_key_up_results = on_key_down_results = []
|
186
|
+
on_key_event_results = notify_custom_listeners('on_key_event', area_key_event)
|
186
187
|
if area_key_event[:up]
|
187
|
-
notify_custom_listeners('on_key_up', area_key_event)
|
188
|
+
on_key_up_results = notify_custom_listeners('on_key_up', area_key_event)
|
188
189
|
else
|
189
|
-
notify_custom_listeners('on_key_down', area_key_event)
|
190
|
+
on_key_down_results = notify_custom_listeners('on_key_down', area_key_event)
|
190
191
|
end
|
191
|
-
if
|
192
|
-
|
193
|
-
|
192
|
+
if ((
|
193
|
+
handle_custom_listener('on_key_event').empty? ||
|
194
|
+
(handle_custom_listener('on_key_event').any? && on_key_event_results.all? {|result| LibUI.boolean_to_integer(result) == 0})
|
195
|
+
) &&
|
196
|
+
(
|
197
|
+
handle_custom_listener('on_key_up').empty? ||
|
198
|
+
(handle_custom_listener('on_key_up').any? && on_key_up_results.all? {|result| LibUI.boolean_to_integer(result) == 0})
|
199
|
+
) &&
|
200
|
+
(
|
201
|
+
handle_custom_listener('on_key_down').empty? ||
|
202
|
+
(handle_custom_listener('on_key_down').any? && on_key_down_results.all? {|result| LibUI.boolean_to_integer(result) == 0})
|
203
|
+
)
|
204
|
+
)
|
194
205
|
0
|
206
|
+
else
|
207
|
+
1
|
195
208
|
end
|
196
209
|
end
|
197
210
|
@listeners_installed = true
|
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.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|