v2 / vlib / gg / gg.v
51 lines · 37 sloc · 1.88 KB · bbb174e3c49bca80515174e591f38af3ae1d9993
Raw
1// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
2// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
3
4module gg
5
6pub type FNCb = fn (data voidptr)
7
8// FNEvent defines the type of a function that will be called for every event
9pub type FNEvent = fn (e &Event, data voidptr)
10
11// FNEvent2 same as FNEvent with inverted arguments TODO: deprecate this, in favor of event_fn
12pub type FNEvent2 = fn (data voidptr, e &Event)
13
14// FNFail defines the type of a function that will be called when there is a fail
15pub type FNFail = fn (msg string, data voidptr)
16
17// FNKeyDown defines the type of a function that will be called for every key pressed down
18pub type FNKeyDown = fn (c KeyCode, m Modifier, data voidptr)
19
20// FNKeyUp defines the type of a function that will be called for every release of a pressed key
21pub type FNKeyUp = fn (c KeyCode, m Modifier, data voidptr)
22
23// FNMove defines the type of a function that will be called for every mouse move on the screen
24pub type FNMove = fn (x f32, y f32, data voidptr)
25
26// FNClick defines the type of a function that will be called for every mouse click
27pub type FNClick = fn (x f32, y f32, button MouseButton, data voidptr)
28
29// FNUnClick defines the type of a function that will be called every time a mouse button is released
30pub type FNUnClick = fn (x f32, y f32, button MouseButton, data voidptr)
31
32// FNChar defines the type of a function that will be called once per character
33pub type FNChar = fn (c u32, data voidptr)
34
35// FNUpdate defines the type of a function, that will be called at the start of each frame
36// with an argument `dt`, that has the passed time in seconds, since the previous update.
37pub type FNUpdate = fn (dt f32, data voidptr)
38
39pub struct PenConfig {
40pub:
41 color Color
42 line_type PenLineType = .solid
43 thickness f32 = 1
44}
45
46@[markused]
47pub struct Size {
48pub mut:
49 width int
50 height int
51}
52