fix mouse wheel scroll, cleanup imgui
This commit is contained in:
parent
6faac2f08e
commit
fa830ec9c8
@ -152,16 +152,8 @@ func ProcessEvent(event sdl.Event) (bool, error) {
|
|||||||
switch event.GetType() {
|
switch event.GetType() {
|
||||||
case sdl.MOUSEWHEEL:
|
case sdl.MOUSEWHEEL:
|
||||||
wheelEvent := event.(*sdl.MouseWheelEvent)
|
wheelEvent := event.(*sdl.MouseWheelEvent)
|
||||||
if wheelEvent.X > 0 {
|
imguiState.imguiIo.MouseWheelH += C.float(wheelEvent.X)
|
||||||
imguiState.imguiIo.MouseDelta.x++
|
imguiState.imguiIo.MouseWheel += C.float(wheelEvent.Y)
|
||||||
} else if wheelEvent.X < 0 {
|
|
||||||
imguiState.imguiIo.MouseDelta.x--
|
|
||||||
}
|
|
||||||
if wheelEvent.Y > 0 {
|
|
||||||
imguiState.imguiIo.MouseDelta.y++
|
|
||||||
} else if wheelEvent.Y < 0 {
|
|
||||||
imguiState.imguiIo.MouseDelta.y--
|
|
||||||
}
|
|
||||||
return true, nil
|
return true, nil
|
||||||
case sdl.MOUSEBUTTONDOWN:
|
case sdl.MOUSEBUTTONDOWN:
|
||||||
buttonEvent := event.(*sdl.MouseButtonEvent)
|
buttonEvent := event.(*sdl.MouseButtonEvent)
|
||||||
|
@ -10,22 +10,22 @@ import (
|
|||||||
"github.com/FooSoft/lazarus/math"
|
"github.com/FooSoft/lazarus/math"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DialogBegin(label string) bool {
|
func Begin(label string) bool {
|
||||||
labelC := C.CString(label)
|
labelC := C.CString(label)
|
||||||
defer C.free(unsafe.Pointer(labelC))
|
defer C.free(unsafe.Pointer(labelC))
|
||||||
return bool(C.igBegin(labelC, nil, 0))
|
return bool(C.igBegin(labelC, nil, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
func DialogEnd() {
|
|
||||||
C.igEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
func Button(label string) bool {
|
func Button(label string) bool {
|
||||||
labelC := C.CString(label)
|
labelC := C.CString(label)
|
||||||
defer C.free(unsafe.Pointer(labelC))
|
defer C.free(unsafe.Pointer(labelC))
|
||||||
return bool(C.igButton(labelC, C.ImVec2{}))
|
return bool(C.igButton(labelC, C.ImVec2{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func End() {
|
||||||
|
C.igEnd()
|
||||||
|
}
|
||||||
|
|
||||||
func Image(texture graphics.Texture) {
|
func Image(texture graphics.Texture) {
|
||||||
ImageSized(texture, texture.Size())
|
ImageSized(texture, texture.Size())
|
||||||
}
|
}
|
||||||
@ -41,6 +41,10 @@ func ImageSized(texture graphics.Texture, size math.Vec2i) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SameLine() {
|
||||||
|
C.igSameLine(0, -1)
|
||||||
|
}
|
||||||
|
|
||||||
func SliderInt(label string, value *int, min, max int) bool {
|
func SliderInt(label string, value *int, min, max int) bool {
|
||||||
labelC := C.CString(label)
|
labelC := C.CString(label)
|
||||||
defer C.free(unsafe.Pointer(labelC))
|
defer C.free(unsafe.Pointer(labelC))
|
||||||
|
@ -66,7 +66,7 @@ func (s *scene) Advance() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imgui.DialogBegin("DC6 Viewer")
|
imgui.Begin("DC6 Viewer")
|
||||||
imgui.Image(s.texture)
|
imgui.Image(s.texture)
|
||||||
direction := s.animation.Directions[directionIndex]
|
direction := s.animation.Directions[directionIndex]
|
||||||
if imgui.SliderInt("Direction", &directionIndex, 0, len(s.animation.Directions)-1) {
|
if imgui.SliderInt("Direction", &directionIndex, 0, len(s.animation.Directions)-1) {
|
||||||
@ -79,7 +79,7 @@ func (s *scene) Advance() error {
|
|||||||
if imgui.Button("Exit") {
|
if imgui.Button("Exit") {
|
||||||
platform.WindowSetScene(nil)
|
platform.WindowSetScene(nil)
|
||||||
}
|
}
|
||||||
imgui.DialogEnd()
|
imgui.End()
|
||||||
|
|
||||||
if directionIndex != s.directionIndex || frameIndex != s.frameIndex {
|
if directionIndex != s.directionIndex || frameIndex != s.frameIndex {
|
||||||
s.directionIndex = directionIndex
|
s.directionIndex = directionIndex
|
||||||
|
Loading…
Reference in New Issue
Block a user