2019-01-01 01:30:59 +00:00
|
|
|
package imgui
|
|
|
|
|
2019-01-07 01:00:19 +00:00
|
|
|
// #cgo linux LDFLAGS: -L./cimgui -l:cimgui.a -lstdc++ -lm
|
2019-01-04 03:05:19 +00:00
|
|
|
// #include "native.h"
|
|
|
|
import "C"
|
2019-01-01 01:30:59 +00:00
|
|
|
import (
|
2019-01-08 03:25:48 +00:00
|
|
|
"fmt"
|
2019-01-04 03:05:19 +00:00
|
|
|
"unsafe"
|
|
|
|
|
2019-01-01 01:30:59 +00:00
|
|
|
"github.com/FooSoft/lazarus/graphics"
|
|
|
|
"github.com/FooSoft/lazarus/math"
|
|
|
|
)
|
|
|
|
|
2019-01-07 01:11:22 +00:00
|
|
|
func Begin(label string) bool {
|
2019-01-04 03:05:19 +00:00
|
|
|
labelC := C.CString(label)
|
|
|
|
defer C.free(unsafe.Pointer(labelC))
|
|
|
|
return bool(C.igBegin(labelC, nil, 0))
|
2019-01-01 01:30:59 +00:00
|
|
|
}
|
|
|
|
|
2019-01-08 03:20:11 +00:00
|
|
|
func End() {
|
|
|
|
C.igEnd()
|
|
|
|
}
|
|
|
|
|
2019-01-07 01:00:19 +00:00
|
|
|
func Button(label string) bool {
|
2019-01-04 03:05:19 +00:00
|
|
|
labelC := C.CString(label)
|
|
|
|
defer C.free(unsafe.Pointer(labelC))
|
|
|
|
return bool(C.igButton(labelC, C.ImVec2{}))
|
2019-01-01 01:30:59 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 01:00:19 +00:00
|
|
|
func Image(texture graphics.Texture) {
|
|
|
|
ImageSized(texture, texture.Size())
|
2019-01-01 01:42:00 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 01:00:19 +00:00
|
|
|
func ImageSized(texture graphics.Texture, size math.Vec2i) {
|
2019-01-04 03:05:19 +00:00
|
|
|
C.igImage(
|
|
|
|
C.nativeHandleCast(C.uintptr_t(texture.Id())),
|
|
|
|
C.ImVec2{x: C.float(size.X), y: C.float(size.Y)},
|
|
|
|
C.ImVec2{0, 0},
|
|
|
|
C.ImVec2{1, 1},
|
|
|
|
C.ImVec4{1, 1, 1, 1},
|
|
|
|
C.ImVec4{0, 0, 0, 0},
|
|
|
|
)
|
2019-01-01 01:30:59 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 01:11:22 +00:00
|
|
|
func SameLine() {
|
|
|
|
C.igSameLine(0, -1)
|
|
|
|
}
|
|
|
|
|
2019-01-07 01:00:19 +00:00
|
|
|
func SliderInt(label string, value *int, min, max int) bool {
|
2019-01-04 03:05:19 +00:00
|
|
|
labelC := C.CString(label)
|
|
|
|
defer C.free(unsafe.Pointer(labelC))
|
|
|
|
valueC := C.int(*value)
|
|
|
|
result := bool(C.igSliderInt(labelC, &valueC, (C.int)(min), (C.int)(max), nil))
|
|
|
|
*value = int(valueC)
|
2019-01-01 01:30:59 +00:00
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2019-01-08 03:25:48 +00:00
|
|
|
func Text(format string, args ...interface{}) {
|
|
|
|
label := fmt.Sprintf(format, args...)
|
2019-01-04 03:05:19 +00:00
|
|
|
labelStartC := C.CString(label)
|
|
|
|
labelEndC := (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(labelStartC)) + uintptr(len(label))))
|
|
|
|
defer C.free(unsafe.Pointer(labelStartC))
|
|
|
|
C.igTextUnformatted(labelStartC, labelEndC)
|
2019-01-01 01:30:59 +00:00
|
|
|
}
|
2019-01-08 03:20:11 +00:00
|
|
|
|
|
|
|
func Columns(count int) {
|
|
|
|
C.igColumns(C.int(count), nil, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NextColumn() {
|
|
|
|
C.igNextColumn()
|
|
|
|
}
|