1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sokol: add mouse cursor support (#15111)

This commit is contained in:
Mehmet Ali
2022-07-18 09:44:48 +03:00
committed by GitHub
parent c1502b3c1f
commit 12d57e8e7b
6 changed files with 344 additions and 37 deletions

View File

@ -36,6 +36,20 @@ pub enum MouseButton {
middle = 2
}
pub enum MouseCursor {
default = C.SAPP_MOUSECURSOR_DEFAULT
arrow = C.SAPP_MOUSECURSOR_ARROW
ibeam = C.SAPP_MOUSECURSOR_IBEAM
crosshair = C.SAPP_MOUSECURSOR_CROSSHAIR
pointing_hand = C.SAPP_MOUSECURSOR_POINTING_HAND
resize_ew = C.SAPP_MOUSECURSOR_RESIZE_EW
resize_ns = C.SAPP_MOUSECURSOR_RESIZE_NS
resize_nwse = C.SAPP_MOUSECURSOR_RESIZE_NWSE
resize_nesw = C.SAPP_MOUSECURSOR_RESIZE_NESW
resize_all = C.SAPP_MOUSECURSOR_RESIZE_ALL
not_allowed = C.SAPP_MOUSECURSOR_NOT_ALLOWED
}
pub enum Modifier {
shift = 1 //(1<<0)
ctrl = 2 //(1<<1)

View File

@ -97,6 +97,12 @@ pub fn show_mouse(visible bool) {
C.sapp_show_mouse(visible)
}
// set mouse cursor
[inline]
pub fn set_mouse_cursor(cursor MouseCursor) {
C.sapp_set_mouse_cursor(cursor)
}
// show or hide the mouse cursor
[inline]
pub fn mouse_shown() bool {

View File

@ -44,6 +44,9 @@ fn C.sapp_show_mouse(visible bool)
// return true if the mouse cursor is shown
fn C.sapp_mouse_shown() bool
// set mouse cursor
fn C.sapp_set_mouse_cursor(cursor MouseCursor)
// lock or unlock the mouse cursor
fn C.sapp_lock_mouse(locked bool)

View File

@ -54,7 +54,6 @@ pub:
fullscreen bool // whether the window should be created in fullscreen mode
alpha bool // whether the framebuffer should have an alpha channel (ignored on some platforms)
window_title &char // the window title as UTF-8 encoded string
user_cursor bool // if true, user is expected to manage cursor image in SAPP_EVENTTYPE_UPDATE_CURSOR
enable_clipboard bool // enable clipboard access, default is false
clipboard_size int // max size of clipboard content in bytes
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false