gui: step
This commit is contained in:
parent
ce3c8e83dd
commit
806e6560f2
5 changed files with 4661 additions and 0 deletions
3
examples/gui/button/go.mod
Normal file
3
examples/gui/button/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module example
|
||||
|
||||
go 1.19
|
31
examples/gui/button/main.go
Normal file
31
examples/gui/button/main.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
rl "github.com/Konstantin8105/raylib"
|
||||
gui "github.com/Konstantin8105/raygui3.5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rl.InitWindow(800, 450, "raylib [physics] example - box2d")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
var button bool
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
rl.ClearBackground(rl.Black)
|
||||
|
||||
button = gui.Button(rl.NewRectangle(50, 150, 100, 40), "Click")
|
||||
if button {
|
||||
fmt.Println("Clicked on button")
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
3
raygui3.5/go.mod
Normal file
3
raygui3.5/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/gen2brain/raylib-go/raygui
|
||||
|
||||
go 1.19
|
43
raygui3.5/gui.go
Normal file
43
raygui3.5/gui.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package rl
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DRAYGUI_IMPLEMENTATION
|
||||
#include "raygui.h"
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// int GuiToggleGroup(Rectangle bounds, const char *text, int active)
|
||||
func ToggleGroup(bounds Rectangle, text string, active int) int {
|
||||
var cbounds C.struct_Rectangle
|
||||
cbounds.x = C.float(bounds.X)
|
||||
cbounds.y = C.float(bounds.Y)
|
||||
cbounds.width = C.float(bounds.Width)
|
||||
cbounds.height = C.float(bounds.Height)
|
||||
ctext := C.CString(text)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
cactive := C.int(active)
|
||||
res := C.GuiToggleGroup(cbounds, ctext, cactive)
|
||||
fmt.Printf(">%v %v<", active, res)
|
||||
return int(res)
|
||||
}
|
||||
|
||||
|
||||
// bool GuiButton(Rectangle bounds, const char *text)
|
||||
func Button(bounds Rectangle, text string) bool {
|
||||
var cbounds C.struct_Rectangle
|
||||
cbounds.x = C.float(bounds.X)
|
||||
cbounds.y = C.float(bounds.Y)
|
||||
cbounds.width = C.float(bounds.Width)
|
||||
cbounds.height = C.float(bounds.Height)
|
||||
ctext := C.CString(text)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
res := C.GuiButton(cbounds, ctext)
|
||||
fmt.Printf(">%v<", res)
|
||||
return bool(res)
|
||||
}
|
4581
raygui3.5/raygui.h
Normal file
4581
raygui3.5/raygui.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue