2021-01-18 13:20:06 +01:00
|
|
|
// Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved.
|
2020-07-06 20:29:05 +02:00
|
|
|
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
|
2021-06-24 10:02:04 +02:00
|
|
|
|
2019-06-22 20:20:28 +02:00
|
|
|
module gg
|
|
|
|
|
2020-04-26 11:42:44 +02:00
|
|
|
import gx
|
2019-06-22 20:20:28 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNCb = fn (data voidptr)
|
|
|
|
|
|
|
|
pub type FNEvent = fn (e &Event, data voidptr)
|
|
|
|
|
|
|
|
pub type FNFail = fn (msg string, data voidptr)
|
2020-08-01 23:40:25 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNKeyDown = fn (c KeyCode, m Modifier, data voidptr)
|
2020-08-01 23:40:25 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNKeyUp = fn (c KeyCode, m Modifier, data voidptr)
|
2020-08-01 23:40:25 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNMove = fn (x f32, y f32, data voidptr)
|
2020-08-01 23:40:25 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNClick = fn (x f32, y f32, button MouseButton, data voidptr)
|
2020-09-21 02:42:28 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNUnClick = fn (x f32, y f32, button MouseButton, data voidptr)
|
2021-05-28 11:46:23 +02:00
|
|
|
|
2021-06-24 10:02:04 +02:00
|
|
|
pub type FNChar = fn (c u32, data voidptr)
|
2019-06-22 20:20:28 +02:00
|
|
|
|
2020-06-04 16:05:12 +02:00
|
|
|
pub struct Config {
|
2019-08-22 23:00:31 +02:00
|
|
|
pub:
|
2021-01-12 04:38:43 +01:00
|
|
|
width int
|
|
|
|
height int
|
2021-06-24 10:02:04 +02:00
|
|
|
use_ortho bool // unused, still here just for backwards compatibility
|
2021-01-12 04:38:43 +01:00
|
|
|
retina bool
|
|
|
|
resizable bool
|
|
|
|
user_data voidptr
|
|
|
|
font_size int
|
|
|
|
create_window bool
|
2020-06-04 16:05:12 +02:00
|
|
|
// window_user_ptr voidptr
|
2021-01-12 04:38:43 +01:00
|
|
|
window_title string
|
|
|
|
borderless_window bool
|
|
|
|
always_on_top bool
|
|
|
|
bg_color gx.Color
|
2021-06-24 10:02:04 +02:00
|
|
|
init_fn FNCb = voidptr(0)
|
|
|
|
frame_fn FNCb = voidptr(0)
|
|
|
|
native_frame_fn FNCb = voidptr(0)
|
|
|
|
cleanup_fn FNCb = voidptr(0)
|
|
|
|
fail_fn FNFail = voidptr(0)
|
|
|
|
//
|
|
|
|
event_fn FNEvent = voidptr(0)
|
|
|
|
quit_fn FNEvent = voidptr(0)
|
|
|
|
//
|
|
|
|
keydown_fn FNKeyDown = voidptr(0)
|
|
|
|
keyup_fn FNKeyUp = voidptr(0)
|
|
|
|
char_fn FNChar = voidptr(0)
|
|
|
|
//
|
|
|
|
move_fn FNMove = voidptr(0)
|
|
|
|
click_fn FNClick = voidptr(0)
|
|
|
|
unclick_fn FNUnClick = voidptr(0)
|
|
|
|
leave_fn FNEvent = voidptr(0)
|
|
|
|
enter_fn FNEvent = voidptr(0)
|
|
|
|
resized_fn FNEvent = voidptr(0)
|
|
|
|
scroll_fn FNEvent = voidptr(0)
|
2020-11-21 00:04:29 +01:00
|
|
|
// wait_events bool // set this to true for UIs, to save power
|
2021-09-25 14:06:56 +02:00
|
|
|
fullscreen bool
|
|
|
|
scale f32 = 1.0
|
|
|
|
sample_count int
|
|
|
|
swap_interval int = 1 // 1 = 60fps, 2 = 30fps etc. The preferred swap interval (ignored on some platforms)
|
2021-05-27 19:14:36 +02:00
|
|
|
// ved needs this
|
2020-08-01 23:40:25 +02:00
|
|
|
// init_text bool
|
2020-12-01 16:30:22 +01:00
|
|
|
font_path string
|
|
|
|
custom_bold_font_path string
|
|
|
|
ui_mode bool // refreshes only on events to save CPU usage
|
2021-01-21 22:07:47 +01:00
|
|
|
// font bytes for embedding
|
|
|
|
font_bytes_normal []byte
|
|
|
|
font_bytes_bold []byte
|
|
|
|
font_bytes_mono []byte
|
|
|
|
font_bytes_italic []byte
|
2021-01-23 10:25:40 +01:00
|
|
|
native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows
|
2021-09-01 08:21:27 +02:00
|
|
|
// drag&drop
|
|
|
|
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
|
|
|
|
max_dropped_files int = 1 // max number of dropped files to process (default: 1)
|
|
|
|
max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)
|
2019-06-22 20:20:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-19 20:32:08 +02:00
|
|
|
pub struct PenConfig {
|
|
|
|
color gx.Color
|
|
|
|
line_type PenLineType = .solid
|
|
|
|
thickness int = 1
|
|
|
|
}
|
|
|
|
|
2020-08-01 23:40:25 +02:00
|
|
|
pub struct Size {
|
|
|
|
pub:
|
|
|
|
width int
|
|
|
|
height int
|
|
|
|
}
|