Skip to content

Commit 66ea84f

Browse files
authored
Added option to disable swipe on release only (#50)
1 parent 63ea943 commit 66ea84f

6 files changed

Lines changed: 137 additions & 191 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Thumbs.db
77
*.pyc
88
.project
99
.cproject
10-
builtins
10+
builtins
11+
/.editor_settings

examples/gesture/gesture.collection

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,10 @@ embedded_instances {
55
data: "components {\n"
66
" id: \"script\"\n"
77
" component: \"/examples/gesture/gesture.script\"\n"
8-
" position {\n"
9-
" x: 0.0\n"
10-
" y: 0.0\n"
11-
" z: 0.0\n"
12-
" }\n"
13-
" rotation {\n"
14-
" x: 0.0\n"
15-
" y: 0.0\n"
16-
" z: 0.0\n"
17-
" w: 1.0\n"
18-
" }\n"
198
"}\n"
209
"components {\n"
2110
" id: \"gesture\"\n"
2211
" component: \"/in/gesture.script\"\n"
23-
" position {\n"
24-
" x: 0.0\n"
25-
" y: 0.0\n"
26-
" z: 0.0\n"
27-
" }\n"
28-
" rotation {\n"
29-
" x: 0.0\n"
30-
" y: 0.0\n"
31-
" z: 0.0\n"
32-
" w: 1.0\n"
33-
" }\n"
3412
" properties {\n"
3513
" id: \"acquire_input_focus\"\n"
3614
" value: \"true\"\n"
@@ -43,70 +21,16 @@ embedded_instances {
4321
" data: \"size {\\n"
4422
" x: 400.0\\n"
4523
" y: 32.0\\n"
46-
" z: 0.0\\n"
47-
" w: 0.0\\n"
4824
"}\\n"
49-
"scale {\\n"
50-
" x: 1.0\\n"
51-
" y: 1.0\\n"
52-
" z: 1.0\\n"
53-
" w: 0.0\\n"
54-
"}\\n"
55-
"color {\\n"
56-
" x: 1.0\\n"
57-
" y: 1.0\\n"
58-
" z: 1.0\\n"
59-
" w: 1.0\\n"
60-
"}\\n"
61-
"outline {\\n"
62-
" x: 0.0\\n"
63-
" y: 0.0\\n"
64-
" z: 0.0\\n"
65-
" w: 1.0\\n"
66-
"}\\n"
67-
"shadow {\\n"
68-
" x: 0.0\\n"
69-
" y: 0.0\\n"
70-
" z: 0.0\\n"
71-
" w: 1.0\\n"
72-
"}\\n"
73-
"leading: 1.0\\n"
74-
"tracking: 0.0\\n"
7525
"pivot: PIVOT_NW\\n"
76-
"blend_mode: BLEND_MODE_ALPHA\\n"
77-
"line_break: false\\n"
78-
"text: \\\"\\\"\\n"
7926
"font: \\\"/examples/assets/fonts/kenpixel15.font\\\"\\n"
8027
"material: \\\"/builtins/fonts/label.material\\\"\\n"
8128
"\"\n"
82-
" position {\n"
83-
" x: 0.0\n"
84-
" y: 0.0\n"
85-
" z: 0.0\n"
86-
" }\n"
87-
" rotation {\n"
88-
" x: 0.0\n"
89-
" y: 0.0\n"
90-
" z: 0.0\n"
91-
" w: 1.0\n"
92-
" }\n"
9329
"}\n"
9430
""
9531
position {
9632
x: 30.0
9733
y: 650.0
98-
z: 0.0
99-
}
100-
rotation {
101-
x: 0.0
102-
y: 0.0
103-
z: 0.0
104-
w: 1.0
105-
}
106-
scale3 {
107-
x: 1.0
108-
y: 1.0
109-
z: 1.0
11034
}
11135
}
11236
embedded_instances {
@@ -117,37 +41,8 @@ embedded_instances {
11741
" data: \"size {\\n"
11842
" x: 600.0\\n"
11943
" y: 32.0\\n"
120-
" z: 0.0\\n"
121-
" w: 0.0\\n"
122-
"}\\n"
123-
"scale {\\n"
124-
" x: 1.0\\n"
125-
" y: 1.0\\n"
126-
" z: 1.0\\n"
127-
" w: 0.0\\n"
128-
"}\\n"
129-
"color {\\n"
130-
" x: 1.0\\n"
131-
" y: 1.0\\n"
132-
" z: 1.0\\n"
133-
" w: 1.0\\n"
134-
"}\\n"
135-
"outline {\\n"
136-
" x: 0.0\\n"
137-
" y: 0.0\\n"
138-
" z: 0.0\\n"
139-
" w: 1.0\\n"
14044
"}\\n"
141-
"shadow {\\n"
142-
" x: 0.0\\n"
143-
" y: 0.0\\n"
144-
" z: 0.0\\n"
145-
" w: 1.0\\n"
146-
"}\\n"
147-
"leading: 1.0\\n"
148-
"tracking: 0.0\\n"
14945
"pivot: PIVOT_SW\\n"
150-
"blend_mode: BLEND_MODE_ALPHA\\n"
15146
"line_break: true\\n"
15247
"text: \\\"Touch, long-press, swipe, double tap, pinch\\\"\\n"
15348
"font: \\\"/examples/assets/fonts/kenpixel15.font\\\"\\n"
@@ -156,30 +51,7 @@ embedded_instances {
15651
" position {\n"
15752
" x: 22.0\n"
15853
" y: 22.0\n"
159-
" z: 0.0\n"
160-
" }\n"
161-
" rotation {\n"
162-
" x: 0.0\n"
163-
" y: 0.0\n"
164-
" z: 0.0\n"
165-
" w: 1.0\n"
16654
" }\n"
16755
"}\n"
16856
""
169-
position {
170-
x: 0.0
171-
y: 0.0
172-
z: 0.0
173-
}
174-
rotation {
175-
x: 0.0
176-
y: 0.0
177-
z: 0.0
178-
w: 1.0
179-
}
180-
scale3 {
181-
x: 1.0
182-
y: 1.0
183-
z: 1.0
184-
}
18557
}

examples/gesture/gesture.script

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
local prettify = require "examples.prettify"
22

3+
local FMT = "repeated: %s\n"
4+
FMT = FMT .. "swipe_left: %s\n"
5+
FMT = FMT .. "swipe_right: %s\n"
6+
FMT = FMT .. "swipe_up: %s\n"
7+
FMT = FMT .. "swipe_down: %s\n"
8+
FMT = FMT .. "tap: %s\n"
9+
FMT = FMT .. "double_tap: %s\n"
10+
FMT = FMT .. "long_press: %s\n"
11+
FMT = FMT .. "two_finger: %s\n"
12+
313
function on_message(self, message_id, message, sender)
414
if message_id == hash("on_gesture") then
5-
label.set_text("#label", prettify(message))
15+
local s = FMT:format(
16+
tostring(message.repeated),
17+
tostring(message.swipe_left),
18+
tostring(message.swipe_right),
19+
tostring(message.swipe_up),
20+
tostring(message.swipe_down),
21+
prettify({message.tap or {}}, " "),
22+
prettify({message.double_tap or {}}, " "),
23+
prettify({message.long_press or {}}, " "),
24+
prettify({message.two_finger or {}}, " ")
25+
)
26+
label.set_text("#label", s)
27+
--label.set_text("#label", prettify(message))
628
end
729
end

examples/prettify.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ local M = {}
44
function M.prettify(t, indentation)
55
indentation = indentation or ""
66
local s = ""
7+
local keys = {}
78
for k,v in pairs(t) do
9+
keys[#keys + 1] = k
10+
end
11+
for i=1,#keys do
12+
local k = keys[i]
13+
local v = t[k]
14+
local last = (i == #keys) and "" or ",\n"
815
if type(v) == "table" then
9-
s = s .. ("%s%s = {\n%s},\n"):format(indentation, k, M.prettify(v, indentation .. " "))
16+
s = s .. ("%s%s = {\n%s\n}%s"):format(indentation, k, M.prettify(v, indentation .. " "), last)
1017
else
11-
s = s .. ("%s%s = %s,\n"):format(indentation, k, tostring(v))
18+
s = s .. ("%s%s = %s%s"):format(indentation, k, tostring(v), last)
1219
end
1320
end
1421
return s

0 commit comments

Comments
 (0)