Skip to content

Commit d739fee

Browse files
committed
callback types
1 parent c4ee446 commit d739fee

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/main/kotlin/uno/glfw/GlfwWindow.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ import uno.buffer.destroyBuf
1212
import uno.buffer.doubleBufferBig
1313
import uno.buffer.intBufferBig
1414

15-
/**
16-
* Created by GBarbieri on 24.04.2017.
17-
*/
15+
/**
16+
* Created by GBarbieri on 24.04.2017.
17+
*/
18+
19+
typealias framebufferSizeCallbackT = (Vec2i) -> Unit
20+
typealias cursorPosCallbackT = (Vec2d) -> Unit
21+
typealias scrollCallbackT = (Vec2d) -> Unit
22+
typealias mouseButtonCallbackT = (Int, Int, Int) -> Unit
23+
typealias keyCallbackT = (Int, Int, Int, Int) -> Unit
24+
typealias charCallbackT = (Int) -> Unit
1825

1926
class GlfwWindow(val handle: Long) {
2027

@@ -134,7 +141,7 @@ class GlfwWindow(val handle: Long) {
134141
}
135142
*/
136143

137-
var framebufferSizeCallback: ((Vec2i) -> Unit)? = null
144+
var framebufferSizeCallback: framebufferSizeCallbackT? = null
138145
set(value) {
139146
glfwSetFramebufferSizeCallback(handle, value?.let { GLFWFramebufferSizeCallbackI { _, width, height -> it(Vec2i(width, height)) } })?.free()
140147
field = value
@@ -169,7 +176,7 @@ class GlfwWindow(val handle: Long) {
169176
glfwSetCursorPosCallback(handle, callback)?.free()
170177
}*/
171178

172-
var cursorPosCallback: ((Vec2d) -> Unit)? = null
179+
var cursorPosCallback: cursorPosCallbackT? = null
173180
set(value) {
174181
glfwSetCursorPosCallback(handle, value?.let { GLFWCursorPosCallbackI { _, xPos, yPos -> it(Vec2d(xPos, yPos)) } })?.free()
175182
field = value
@@ -196,7 +203,7 @@ class GlfwWindow(val handle: Long) {
196203
glfwSetScrollCallback(handle, callback)?.free()
197204
}*/
198205

199-
var scrollCallback: ((Vec2d) -> Unit)? = null
206+
var scrollCallback: scrollCallbackT? = null
200207
set(value) {
201208
glfwSetScrollCallback(handle, value?.let { GLFWScrollCallbackI { _, xOffset, yOffset -> it(Vec2d(xOffset, yOffset)) } })?.free()
202209
field = value
@@ -218,7 +225,7 @@ class GlfwWindow(val handle: Long) {
218225
glfwSetMouseButtonCallback(handle, callback)?.free()
219226
}*/
220227

221-
var mouseButtonCallback: ((Int, Int, Int) -> Unit)? = null
228+
var mouseButtonCallback: mouseButtonCallbackT? = null
222229
set(value) {
223230
glfwSetMouseButtonCallback(handle, value?.let { GLFWMouseButtonCallbackI { _, button, action, mods -> it(button, action, mods) } })?.free()
224231
field = value
@@ -240,7 +247,7 @@ class GlfwWindow(val handle: Long) {
240247
glfwSetKeyCallback(handle, callback)?.free()
241248
}*/
242249

243-
var keyCallback: ((Int, Int, Int, Int) -> Unit)? = null
250+
var keyCallback: keyCallbackT? = null
244251
set(value) {
245252
glfwSetKeyCallback(handle, value?.let { GLFWKeyCallbackI { _, key, scancode, action, mods -> it(key, scancode, action, mods) } })?.free()
246253
field = value
@@ -262,7 +269,7 @@ class GlfwWindow(val handle: Long) {
262269
glfwSetCharCallback(handle, callback)?.free()
263270
}*/
264271

265-
var charCallback: ((Int) -> Unit)? = null
272+
var charCallback: charCallbackT? = null
266273
set(value) {
267274
glfwSetCharCallback(handle, value?.let { GLFWCharCallbackI { _, codepoint -> it(codepoint) } })?.free()
268275
field = value

0 commit comments

Comments
 (0)