glimmer-dsl-libui 0.1.7 → 0.1.11
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 +35 -0
- data/README.md +430 -13
- data/VERSION +1 -1
- data/examples/area_gallery.rb +48 -0
- data/examples/area_gallery2.rb +48 -0
- data/examples/area_gallery3.rb +48 -0
- data/examples/area_gallery4.rb +48 -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 +111 -27
- 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 +34 -1
- data/lib/glimmer/libui.rb +17 -0
- data/lib/glimmer-dsl-libui.rb +1 -0
- metadata +11 -6
data/examples/area_gallery.rb
CHANGED
@@ -46,5 +46,53 @@ window('Area Gallery', 400, 400) {
|
|
46
46
|
fill r: 202, g: 102, b: 204, a: 0.5
|
47
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
@@ -107,5 +107,53 @@ window('Area Gallery', 400, 400) {
|
|
107
107
|
fill r: 202, g: 102, b: 204, a: 0.5
|
108
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
@@ -48,5 +48,53 @@ window('Area Gallery', 400, 400) {
|
|
48
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
@@ -109,5 +109,53 @@ window('Area Gallery', 400, 400) {
|
|
109
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/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,40 +36,34 @@ 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
|
42
55
|
|
43
56
|
attr_reader :area_handler
|
44
57
|
|
58
|
+
def libui_api_keyword
|
59
|
+
'area'
|
60
|
+
end
|
61
|
+
|
45
62
|
def post_add_content
|
46
63
|
super
|
47
64
|
install_listeners
|
48
65
|
end
|
49
66
|
|
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
67
|
def draw(area_draw_params)
|
74
68
|
children.dup.each {|child| child.draw(area_draw_params)}
|
75
69
|
on_draw.each {|listener| listener.call(area_draw_params)}
|
@@ -94,10 +88,42 @@ module Glimmer
|
|
94
88
|
draw(area_draw_params)
|
95
89
|
AreaProxy.current_area_draw_params = nil
|
96
90
|
end
|
97
|
-
@area_handler.MouseEvent = fiddle_closure_block_caller(0, [
|
98
|
-
|
99
|
-
|
100
|
-
|
91
|
+
@area_handler.MouseEvent = fiddle_closure_block_caller(0, [1, 1, 1]) do |_, _, area_mouse_event|
|
92
|
+
area_mouse_event = ::LibUI::FFI::AreaMouseEvent.new(area_mouse_event)
|
93
|
+
area_mouse_event = area_mouse_event_hash(area_mouse_event)
|
94
|
+
on_mouse_event.each { |listener| listener.call(area_mouse_event)}
|
95
|
+
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])
|
96
|
+
unless @last_area_mouse_event.nil?
|
97
|
+
on_mouse_down.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:down] > 0 && @last_area_mouse_event[:down] == 0
|
98
|
+
on_mouse_up.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:up] > 0 && @last_area_mouse_event[:up] == 0
|
99
|
+
on_mouse_drag_start.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:held] > 0 && @last_area_mouse_event[:held] == 0
|
100
|
+
on_mouse_drag.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:held] > 0
|
101
|
+
on_mouse_drop.each { |listener| listener.call(area_mouse_event)} if area_mouse_event[:held] == 0 && @last_area_mouse_event[:held] > 0
|
102
|
+
end
|
103
|
+
@last_area_mouse_event = area_mouse_event
|
104
|
+
end
|
105
|
+
@area_handler.MouseCrossed = fiddle_closure_block_caller(0, [1, 1, 4]) do |_, _, left|
|
106
|
+
left = Glimmer::LibUI.integer_to_boolean(left)
|
107
|
+
on_mouse_crossed.each { |listener| listener.call(left) }
|
108
|
+
if left
|
109
|
+
on_mouse_exit.each { |listener| listener.call(left) }
|
110
|
+
else
|
111
|
+
on_mouse_enter.each { |listener| listener.call(left) }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
@area_handler.DragBroken = fiddle_closure_block_caller(0, [1, 1]) do |_, _|
|
115
|
+
on_drag_broken.each { |listener| listener.call }
|
116
|
+
end
|
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
|
101
127
|
end
|
102
128
|
|
103
129
|
def area_draw_params_hash(area_draw_params)
|
@@ -111,7 +137,65 @@ module Glimmer
|
|
111
137
|
clip_height: area_draw_params.ClipHeight,
|
112
138
|
}
|
113
139
|
end
|
140
|
+
|
141
|
+
def area_mouse_event_hash(area_mouse_event)
|
142
|
+
{
|
143
|
+
x: area_mouse_event.X,
|
144
|
+
y: area_mouse_event.Y,
|
145
|
+
area_width: area_mouse_event.AreaWidth,
|
146
|
+
area_height: area_mouse_event.AreaHeight,
|
147
|
+
down: area_mouse_event.Down,
|
148
|
+
up: area_mouse_event.Up,
|
149
|
+
count: area_mouse_event.Count,
|
150
|
+
modifers: modifiers_to_symbols(area_mouse_event.Modifiers),
|
151
|
+
held: area_mouse_event.Held1To64,
|
152
|
+
}
|
153
|
+
end
|
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
|
+
|
175
|
+
def modifiers_to_symbols(modifiers_value)
|
176
|
+
symbols = []
|
177
|
+
modifiers_value = extract_symbol_from_modifiers_value(modifiers_value, symbols: symbols) while modifiers_value > 0
|
178
|
+
symbols
|
179
|
+
end
|
180
|
+
|
181
|
+
def extract_symbol_from_modifiers_value(modifiers_value, symbols: )
|
182
|
+
if modifiers_value >= 8
|
183
|
+
symbols << :command
|
184
|
+
modifiers_value -= 8
|
185
|
+
elsif modifiers_value >= 4
|
186
|
+
symbols << :shift
|
187
|
+
modifiers_value -= 4
|
188
|
+
elsif modifiers_value >= 2
|
189
|
+
symbols << :alt
|
190
|
+
modifiers_value -= 2
|
191
|
+
elsif modifiers_value >= 1
|
192
|
+
symbols << :control
|
193
|
+
modifiers_value -= 1
|
194
|
+
end
|
195
|
+
end
|
114
196
|
end
|
115
197
|
end
|
116
198
|
end
|
117
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}
|