Add Window-related functions
This commit is contained in:
parent
e4af280033
commit
f548130d14
2 changed files with 117 additions and 75 deletions
153
raylib/core.go
153
raylib/core.go
|
@ -50,6 +50,13 @@ func (b *BoundingBox) cptr() *C.BoundingBox {
|
||||||
return (*C.BoundingBox)(unsafe.Pointer(b))
|
return (*C.BoundingBox)(unsafe.Pointer(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WindowShouldClose - Check if KEY_ESCAPE pressed or Close icon pressed
|
||||||
|
func WindowShouldClose() bool {
|
||||||
|
ret := C.WindowShouldClose()
|
||||||
|
v := bool(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// CloseWindow - Close Window and Terminate Context
|
// CloseWindow - Close Window and Terminate Context
|
||||||
func CloseWindow() {
|
func CloseWindow() {
|
||||||
C.CloseWindow()
|
C.CloseWindow()
|
||||||
|
@ -62,23 +69,9 @@ func IsWindowReady() bool {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// WindowShouldClose - Detect if KEY_ESCAPE pressed or Close icon pressed
|
// IsWindowFullscreen - Check if window is currently fullscreen
|
||||||
func WindowShouldClose() bool {
|
func IsWindowFullscreen() bool {
|
||||||
ret := C.WindowShouldClose()
|
ret := C.IsWindowFullscreen()
|
||||||
v := bool(ret)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsWindowMinimized - Detect if window has been minimized (or lost focus)
|
|
||||||
func IsWindowMinimized() bool {
|
|
||||||
ret := C.IsWindowMinimized()
|
|
||||||
v := bool(ret)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsWindowResized - Check if window has been resized
|
|
||||||
func IsWindowResized() bool {
|
|
||||||
ret := C.IsWindowResized()
|
|
||||||
v := bool(ret)
|
v := bool(ret)
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
@ -90,11 +83,74 @@ func IsWindowHidden() bool {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsWindowMinimized - Check if window is currently minimized
|
||||||
|
func IsWindowMinimized() bool {
|
||||||
|
ret := C.IsWindowMinimized()
|
||||||
|
v := bool(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsWindowMaximized - Check if window is currently maximized
|
||||||
|
func IsWindowMaximized() bool {
|
||||||
|
ret := C.IsWindowMaximized()
|
||||||
|
v := bool(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsWindowFocused - Check if window is currently focused
|
||||||
|
func IsWindowFocused() bool {
|
||||||
|
ret := C.IsWindowFocused()
|
||||||
|
v := bool(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsWindowResized - Check if window has been resized
|
||||||
|
func IsWindowResized() bool {
|
||||||
|
ret := C.IsWindowResized()
|
||||||
|
v := bool(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsWindowState - Check if one specific window flag is enabled
|
||||||
|
func IsWindowState(flag byte) bool {
|
||||||
|
cflag := (C.uint)(flag)
|
||||||
|
ret := C.IsWindowState(cflag)
|
||||||
|
v := bool(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetWindowState - Set window configuration state using flags
|
||||||
|
func SetWindowState(flags byte) {
|
||||||
|
cflags := (C.uint)(flags)
|
||||||
|
C.SetWindowState(cflags)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearWindowState - Clear window configuration state flags
|
||||||
|
func ClearWindowState(flags byte) {
|
||||||
|
cflags := (C.uint)(flags)
|
||||||
|
C.ClearWindowState(cflags)
|
||||||
|
}
|
||||||
|
|
||||||
// ToggleFullscreen - Fullscreen toggle (only PLATFORM_DESKTOP)
|
// ToggleFullscreen - Fullscreen toggle (only PLATFORM_DESKTOP)
|
||||||
func ToggleFullscreen() {
|
func ToggleFullscreen() {
|
||||||
C.ToggleFullscreen()
|
C.ToggleFullscreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaximizeWindow - Set window state: maximized, if resizable
|
||||||
|
func MaximizeWindow() {
|
||||||
|
C.MaximizeWindow()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinimizeWindow - Set window state: minimized, if resizable
|
||||||
|
func MinimizeWindow() {
|
||||||
|
C.MinimizeWindow()
|
||||||
|
}
|
||||||
|
|
||||||
|
// RestoreWindow - Set window state: not minimized/maximized
|
||||||
|
func RestoreWindow() {
|
||||||
|
C.RestoreWindow()
|
||||||
|
}
|
||||||
|
|
||||||
// SetWindowIcon - Set icon for window (only PLATFORM_DESKTOP)
|
// SetWindowIcon - Set icon for window (only PLATFORM_DESKTOP)
|
||||||
func SetWindowIcon(image Image) {
|
func SetWindowIcon(image Image) {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
|
@ -135,18 +191,6 @@ func SetWindowSize(w, h int) {
|
||||||
C.SetWindowSize(cw, ch)
|
C.SetWindowSize(cw, ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowState - Set window configuration state using flags
|
|
||||||
func SetWindowState(flags byte) {
|
|
||||||
cflags := (C.uint)(flags)
|
|
||||||
C.SetWindowState(cflags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearWindowState - Clear window configuration state flags
|
|
||||||
func ClearWindowState(flags byte) {
|
|
||||||
cflags := (C.uint)(flags)
|
|
||||||
C.ClearWindowState(cflags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetScreenWidth - Get current screen width
|
// GetScreenWidth - Get current screen width
|
||||||
func GetScreenWidth() int {
|
func GetScreenWidth() int {
|
||||||
ret := C.GetScreenWidth()
|
ret := C.GetScreenWidth()
|
||||||
|
@ -168,6 +212,21 @@ func GetMonitorCount() int {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCurrentMonitor - Get current connected monitor
|
||||||
|
func GetCurrentMonitor() int {
|
||||||
|
ret := C.GetCurrentMonitor()
|
||||||
|
v := (int)(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMonitorPosition - Get specified monitor position
|
||||||
|
func GetMonitorPosition(monitor int) Vector2 {
|
||||||
|
cmonitor := (C.int)(monitor)
|
||||||
|
ret := C.GetMonitorPosition(cmonitor)
|
||||||
|
v := newVector2FromPointer(unsafe.Pointer(&ret))
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// GetMonitorWidth - Get primary monitor width
|
// GetMonitorWidth - Get primary monitor width
|
||||||
func GetMonitorWidth(monitor int) int {
|
func GetMonitorWidth(monitor int) int {
|
||||||
cmonitor := (C.int)(monitor)
|
cmonitor := (C.int)(monitor)
|
||||||
|
@ -200,6 +259,28 @@ func GetMonitorPhysicalHeight(monitor int) int {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMonitorRefreshRate - Get specified monitor refresh rate
|
||||||
|
func GetMonitorRefreshRate(monitor int) int {
|
||||||
|
cmonitor := (C.int)(monitor)
|
||||||
|
ret := C.GetMonitorRefreshRate(cmonitor)
|
||||||
|
v := (int)(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWindowPosition - Get window position XY on monitor
|
||||||
|
func GetWindowPosition() Vector2 {
|
||||||
|
ret := C.GetWindowPosition()
|
||||||
|
v := newVector2FromPointer(unsafe.Pointer(&ret))
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWindowScaleDPI - Get window scale DPI factor
|
||||||
|
func GetWindowScaleDPI() Vector2 {
|
||||||
|
ret := C.GetWindowScaleDPI()
|
||||||
|
v := newVector2FromPointer(unsafe.Pointer(&ret))
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// GetMonitorName - Get the human-readable, UTF-8 encoded name of the primary monitor
|
// GetMonitorName - Get the human-readable, UTF-8 encoded name of the primary monitor
|
||||||
func GetMonitorName(monitor int) string {
|
func GetMonitorName(monitor int) string {
|
||||||
cmonitor := (C.int)(monitor)
|
cmonitor := (C.int)(monitor)
|
||||||
|
@ -208,13 +289,6 @@ func GetMonitorName(monitor int) string {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetClipboardText - Get clipboard text content
|
|
||||||
func GetClipboardText() string {
|
|
||||||
ret := C.GetClipboardText()
|
|
||||||
v := C.GoString(ret)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetClipboardText - Set clipboard text content
|
// SetClipboardText - Set clipboard text content
|
||||||
func SetClipboardText(data string) {
|
func SetClipboardText(data string) {
|
||||||
cdata := C.CString(data)
|
cdata := C.CString(data)
|
||||||
|
@ -222,6 +296,13 @@ func SetClipboardText(data string) {
|
||||||
C.SetClipboardText(cdata)
|
C.SetClipboardText(cdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetClipboardText - Get clipboard text content
|
||||||
|
func GetClipboardText() string {
|
||||||
|
ret := C.GetClipboardText()
|
||||||
|
v := C.GoString(ret)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// ClearBackground - Sets Background Color
|
// ClearBackground - Sets Background Color
|
||||||
func ClearBackground(color Color) {
|
func ClearBackground(color Color) {
|
||||||
ccolor := color.cptr()
|
ccolor := color.cptr()
|
||||||
|
|
|
@ -91,45 +91,6 @@ func OpenAsset(name string) (Asset, error) {
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowMaximized - Check if window has been maximized (only PLATFORM_DESKTOP)
|
|
||||||
func IsWindowMaximized() bool {
|
|
||||||
ret := C.IsWindowMaximized()
|
|
||||||
v := bool(ret)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsWindowFocused - Check if window has been focused
|
|
||||||
func IsWindowFocused() bool {
|
|
||||||
ret := C.IsWindowFocused()
|
|
||||||
v := bool(ret)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// MaximizeWindow - Maximize the window, if resizable (only PLATFORM_DESKTOP)
|
|
||||||
func MaximizeWindow() {
|
|
||||||
C.MaximizeWindow()
|
|
||||||
}
|
|
||||||
|
|
||||||
// RestoreWindow - Restore the window, if resizable (only PLATFORM_DESKTOP)
|
|
||||||
func RestoreWindow() {
|
|
||||||
C.RestoreWindow()
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMonitorRefreshRate - Get primary monitor refresh rate
|
|
||||||
func GetMonitorRefreshRate(monitor int) int {
|
|
||||||
cmonitor := (C.int)(monitor)
|
|
||||||
ret := C.GetMonitorRefreshRate(cmonitor)
|
|
||||||
v := (int)(ret)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetWindowScaleDPI - Get window scale DPI factor
|
|
||||||
func GetWindowScaleDPI() Vector2 {
|
|
||||||
ret := C.GetWindowScaleDPI()
|
|
||||||
v := newVector2FromPointer(unsafe.Pointer(&ret))
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsCursorOnScreen - Check if cursor is on the current screen.
|
// IsCursorOnScreen - Check if cursor is on the current screen.
|
||||||
func IsCursorOnScreen() bool {
|
func IsCursorOnScreen() bool {
|
||||||
ret := C.IsCursorOnScreen()
|
ret := C.IsCursorOnScreen()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue