Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cimgui-go version #783

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ func (c *Canvas) AddImage(texture *Texture, pMin, pMax image.Point) {
}

func (c *Canvas) AddImageQuad(texture *Texture, p1, p2, p3, p4, uv1, uv2, uv3, uv4 image.Point, col color.Color) {
c.DrawList.AddImageQuadV(texture.tex.ID(), ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ToVec2(uv1), ToVec2(uv2), ToVec2(uv3), ToVec2(uv4), ColorToUint(col))
c.DrawList.AddImageQuadV(texture.tex.ID, ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ToVec2(uv1), ToVec2(uv2), ToVec2(uv3), ToVec2(uv4), ColorToUint(col))
}

func (c *Canvas) AddImageV(texture *Texture, pMin, pMax, uvMin, uvMax image.Point, col color.Color) {
c.DrawList.AddImageV(texture.tex.ID(), ToVec2(pMin), ToVec2(pMax), ToVec2(uvMin), ToVec2(uvMax), ColorToUint(col))
c.DrawList.AddImageV(texture.tex.ID, ToVec2(pMin), ToVec2(pMax), ToVec2(uvMin), ToVec2(uvMax), ColorToUint(col))
}
4 changes: 2 additions & 2 deletions ClickableWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func (b *ImageButtonWidget) Build() {
}

if imgui.ImageButtonV(
fmt.Sprintf("%v", b.texture.tex.ID()),
b.texture.tex.ID(),
fmt.Sprintf("%v", b.texture.tex.ID),
b.texture.tex.ID,
imgui.Vec2{X: b.width, Y: b.height},
ToVec2(b.uv0), ToVec2(b.uv1),
ToVec4Color(b.bgColor),
Expand Down
8 changes: 4 additions & 4 deletions Events.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func IsItemActive() bool {

// IsKeyDown returns true if key `key` is down.
func IsKeyDown(key Key) bool {
return imgui.IsKeyDownNil(imgui.Key(key))
return imgui.IsKeyDown(imgui.Key(key))
}

// IsKeyPressed returns true if key `key` is pressed.
Expand All @@ -40,12 +40,12 @@ func IsKeyPressed(key Key) bool {

// IsKeyReleased returns true if key `key` is released.
func IsKeyReleased(key Key) bool {
return imgui.IsKeyReleasedNil(imgui.Key(key))
return imgui.IsKeyReleased(imgui.Key(key))
}

// IsMouseDown returns true if mouse button `button` is down.
func IsMouseDown(button MouseButton) bool {
return imgui.IsMouseDownNil(imgui.MouseButton(button))
return imgui.IsMouseDown(imgui.MouseButton(button))
}

// IsMouseClicked returns true if mouse button `button` is clicked
Expand All @@ -56,7 +56,7 @@ func IsMouseClicked(button MouseButton) bool {

// IsMouseReleased returns true if mouse button `button` is released.
func IsMouseReleased(button MouseButton) bool {
return imgui.IsMouseReleasedNil(imgui.MouseButton(button))
return imgui.IsMouseReleased(imgui.MouseButton(button))
}

// IsMouseDoubleClicked returns true if mouse button `button` is double clicked.
Expand Down
3 changes: 0 additions & 3 deletions Flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ const (
WindowFlagsAlwaysVerticalScrollbar WindowFlags = WindowFlags(imgui.WindowFlagsAlwaysVerticalScrollbar)
// WindowFlagsAlwaysHorizontalScrollbar always shows horizontal scrollbar, even if ContentSize.x < Size.x .
WindowFlagsAlwaysHorizontalScrollbar WindowFlags = WindowFlags(imgui.WindowFlagsAlwaysHorizontalScrollbar)
// WindowFlagsAlwaysUseWindowPadding ensures child windows without border uses style.WindowPadding (ignored by
// default for non-bordered child windows, because more convenient).
WindowFlagsAlwaysUseWindowPadding WindowFlags = WindowFlags(imgui.WindowFlagsAlwaysUseWindowPadding)
// WindowFlagsNoNavInputs has no gamepad/keyboard navigation within the window.
WindowFlagsNoNavInputs WindowFlags = WindowFlags(imgui.WindowFlagsNoNavInputs)
// WindowFlagsNoNavFocus has no focusing toward this window with gamepad/keyboard navigation
Expand Down
2 changes: 1 addition & 1 deletion ImageWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (i *ImageWidget) Build() {
}
}

imgui.ImageV(i.texture.tex.ID(), size, i.uv0, i.uv1, ToVec4Color(i.tintColor), ToVec4Color(i.borderColor))
imgui.ImageV(i.texture.tex.ID, size, i.uv0, i.uv1, ToVec4Color(i.tintColor), ToVec4Color(i.borderColor))
}

type imageState struct {
Expand Down
6 changes: 5 additions & 1 deletion MasterWindow.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package giu

import (
"errors"
"image"
"image/color"
"runtime"
Expand Down Expand Up @@ -85,7 +86,10 @@ func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) *
// Disable imgui.ini
io.SetIniFilename("")

backend := imgui.CreateBackend(imgui.NewGLFWBackend())
backend, err := imgui.CreateBackend(imgui.NewGLFWBackend())
if err != nil && !errors.Is(err, imgui.CExposerError) {
panic(err)
}

// Create GIU context
Context = CreateContext(backend)
Expand Down
5 changes: 3 additions & 2 deletions Plot.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package giu

import (
imgui "github.com/AllenDang/cimgui-go"
"image"

imgui "github.com/AllenDang/cimgui-go"
)

// PlotWidget is implemented by all the particular plots, which can be used
Expand Down Expand Up @@ -493,7 +494,7 @@ func (p *PieChartPlot) Angle0(a float64) *PieChartPlot {

func (p *PieChartPlot) Plot() {
// TODO: p.normalized not used anymore - replace with flags
imgui.PlotPlotPieChartdoublePtrV(
imgui.PlotPlotPieChartdoublePtrStrV(
Context.FontAtlas.RegisterStringSlice(p.labels),
&p.values,
int32(len(p.values)),
Expand Down
2 changes: 1 addition & 1 deletion Texture.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ToTexture(texture *imgui.Texture) *Texture {

func (t *Texture) ID() imgui.TextureID {
if t.tex != nil {
return t.tex.ID()
return t.tex.ID
}

return imgui.TextureID{}
Expand Down
8 changes: 7 additions & 1 deletion Widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ type ChildWidget struct {

// Build implements Widget interface.
func (c *ChildWidget) Build() {
if imgui.BeginChildStrV(c.id, imgui.Vec2{X: c.width, Y: c.height}, c.border, imgui.WindowFlags(c.flags)) {
if imgui.BeginChildStrV(c.id, imgui.Vec2{X: c.width, Y: c.height}, func() imgui.ChildFlags {
if c.border {
return imgui.ChildFlagsBorder
}

return 0
}(), imgui.WindowFlags(c.flags)) {
c.layout.Build()
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/AllenDang/giu
go 1.21

require (
github.com/AllenDang/cimgui-go v0.0.0-20240217115856-389161c9afbe
github.com/AllenDang/cimgui-go v0.0.0-20240321080015-b8f29f999b6d
github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3
github.com/mazznoer/csscolorparser v0.1.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/AllenDang/cimgui-go v0.0.0-20240217115856-389161c9afbe h1:hCgPHyxsipQgkSIDoDkFS6/axFK2tDqXgRySwqdYvZc=
github.com/AllenDang/cimgui-go v0.0.0-20240217115856-389161c9afbe/go.mod h1:e6feXR4FrATVY/UrWS3si3KCJOm0wruwbxVI/B85fUM=
github.com/AllenDang/cimgui-go v0.0.0-20240321080015-b8f29f999b6d h1:AUfBQnUrFx3HutYvsJq/NPYjz7wnoY91zRO/AOW8/m8=
github.com/AllenDang/cimgui-go v0.0.0-20240321080015-b8f29f999b6d/go.mod h1:e6feXR4FrATVY/UrWS3si3KCJOm0wruwbxVI/B85fUM=
github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8 h1:dKZMqib/yUDoCFigmz2agG8geZ/e3iRq304/KJXqKyw=
github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8/go.mod h1:b4uuDd0s6KRIPa84cEEchdQ9ICh7K0OryZHbSzMca9k=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
Loading