2021-01-18 15:20:06 +03:00
|
|
|
// Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved.
|
2020-07-06 21:29:05 +03:00
|
|
|
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
|
2021-06-24 11:02:04 +03:00
|
|
|
|
2019-06-22 21:20:28 +03:00
|
|
|
module gg
|
|
|
|
|
2020-04-26 12:42:44 +03:00
|
|
|
import gx
|
2019-06-22 21:20:28 +03:00
|
|
|
|
2021-06-24 11:02:04 +03: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-02 00:40:25 +03:00
|
|
|
|
2021-06-24 11:02:04 +03:00
|
|
|
pub type FNKeyDown = fn (c KeyCode, m Modifier, data voidptr)
|
2020-08-02 00:40:25 +03:00
|
|
|
|
2021-06-24 11:02:04 +03:00
|
|
|
pub type FNKeyUp = fn (c KeyCode, m Modifier, data voidptr)
|
2020-08-02 00:40:25 +03:00
|
|
|
|
2021-06-24 11:02:04 +03:00
|
|
|
pub type FNMove = fn (x f32, y f32, data voidptr)
|
2020-08-02 00:40:25 +03:00
|
|
|
|
2021-06-24 11:02:04 +03:00
|
|
|
pub type FNClick = fn (x f32, y f32, button MouseButton, data voidptr)
|
2020-09-21 03:42:28 +03:00
|
|
|
|
2021-06-24 11:02:04 +03:00
|
|
|
pub type FNUnClick = fn (x f32, y f32, button MouseButton, data voidptr)
|
2021-05-28 12:46:23 +03:00
|
|
|
|
2021-06-24 11:02:04 +03:00
|
|
|
pub type FNChar = fn (c u32, data voidptr)
|
2019-06-22 21:20:28 +03:00
|
|
|
|
2020-06-04 17:05:12 +03:00
|
|
|
pub struct Config {
|
2019-08-23 00:00:31 +03:00
|
|
|
pub:
|
2021-01-12 06:38:43 +03:00
|
|
|
width int
|
|
|
|
height int
|
2021-06-24 11:02:04 +03:00
|
|
|
use_ortho bool // unused, still here just for backwards compatibility
|
2021-01-12 06:38:43 +03:00
|
|
|
retina bool
|
|
|
|
resizable bool
|
|
|
|
user_data voidptr
|
|
|
|
font_size int
|
|
|
|
create_window bool
|
2020-06-04 17:05:12 +03:00
|
|
|
// window_user_ptr voidptr
|
2021-01-12 06:38:43 +03:00
|
|
|
window_title string
|
|
|
|
borderless_window bool
|
|
|
|
always_on_top bool
|
|
|
|
bg_color gx.Color
|
2021-06-24 11:02:04 +03: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 02:04:29 +03:00
|
|
|
// wait_events bool // set this to true for UIs, to save power
|
2021-09-25 15:06:56 +03: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 20:14:36 +03:00
|
|
|
// ved needs this
|
2020-08-02 00:40:25 +03:00
|
|
|
// init_text bool
|
2020-12-01 18:30:22 +03:00
|
|
|
font_path string
|
|
|
|
custom_bold_font_path string
|
|
|
|
ui_mode bool // refreshes only on events to save CPU usage
|
2021-01-22 00:07:47 +03:00
|
|
|
// font bytes for embedding
|
|
|
|
font_bytes_normal []byte
|
|
|
|
font_bytes_bold []byte
|
|
|
|
font_bytes_mono []byte
|
|
|
|
font_bytes_italic []byte
|
2021-01-23 12:25:40 +03:00
|
|
|
native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows
|
2021-09-01 09:21:27 +03: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 21:20:28 +03:00
|
|
|
}
|
|
|
|
|
2021-06-19 21:32:08 +03:00
|
|
|
pub struct PenConfig {
|
|
|
|
color gx.Color
|
|
|
|
line_type PenLineType = .solid
|
|
|
|
thickness int = 1
|
|
|
|
}
|
|
|
|
|
2020-08-02 00:40:25 +03:00
|
|
|
pub struct Size {
|
|
|
|
pub:
|
|
|
|
width int
|
|
|
|
height int
|
|
|
|
}
|