diff --git a/FontAtlasProsessor.go b/FontAtlasProsessor.go index c1291de1..4ed5670e 100644 --- a/FontAtlasProsessor.go +++ b/FontAtlasProsessor.go @@ -9,6 +9,7 @@ import ( "unsafe" "github.com/AllenDang/cimgui-go/imgui" + "github.com/AllenDang/cimgui-go/utils" "github.com/AllenDang/go-findfont" ) @@ -300,7 +301,7 @@ func (a *FontAtlas) rebuildFontAtlas() { } else { fontConfig.SetFontDataOwnedByAtlas(false) fonts.AddFontFromMemoryTTFV( - uintptr(unsafe.Pointer(imgui.SliceToPtr(fontInfo.fontByte))), + uintptr(unsafe.Pointer(utils.SliceToPtr(fontInfo.fontByte))), int32(len(fontInfo.fontByte)), fontInfo.size, fontConfig, @@ -338,7 +339,7 @@ func (a *FontAtlas) rebuildFontAtlas() { fontConfig := imgui.NewFontConfig() fontConfig.SetFontDataOwnedByAtlas(false) f = fonts.AddFontFromMemoryTTFV( - uintptr(unsafe.Pointer(imgui.SliceToPtr(fontInfo.fontByte))), + uintptr(unsafe.Pointer(utils.SliceToPtr(fontInfo.fontByte))), int32(len(fontInfo.fontByte)), fontInfo.size, fontConfig, diff --git a/Plot.go b/Plot.go index d13966da..8c98edfa 100644 --- a/Plot.go +++ b/Plot.go @@ -4,6 +4,7 @@ import ( "image" "github.com/AllenDang/cimgui-go/implot" + "github.com/AllenDang/cimgui-go/utils" ) type ( @@ -238,7 +239,7 @@ func (p *PlotCanvasWidget) Build() { if len(p.xTicksValue) > 0 { implot.PlotSetupAxisTicksdoublePtrV( implot.AxisX1, - &p.xTicksValue, + utils.SliceToPtr(p.xTicksValue), int32(len(p.xTicksValue)), p.xTicksLabel, p.xTicksShowDefault, @@ -248,7 +249,7 @@ func (p *PlotCanvasWidget) Build() { if len(p.yTicksValue) > 0 { implot.PlotSetupAxisTicksdoublePtrV( implot.AxisY1, - &p.yTicksValue, + utils.SliceToPtr(p.yTicksValue), int32(len(p.yTicksValue)), p.yTicksLabel, p.yTicksShowDefault, @@ -340,7 +341,7 @@ func (p *BarPlot) Offset(offset int) *BarPlot { func (p *BarPlot) Plot() { implot.PlotPlotBarsdoublePtrIntV( p.title, - &p.data, + utils.SliceToPtr(p.data), int32(len(p.data)), p.width, p.shift, @@ -392,7 +393,7 @@ func (p *BarHPlot) Offset(offset int) *BarHPlot { func (p *BarHPlot) Plot() { implot.PlotPlotBarsdoublePtrIntV( Context.FontAtlas.RegisterString(p.title), - &p.data, + utils.SliceToPtr(p.data), int32(len(p.data)), p.height, p.shift, @@ -454,7 +455,7 @@ func (p *LinePlot) Plot() { implot.PlotPlotLinedoublePtrIntV( Context.FontAtlas.RegisterString(p.title), - &p.values, + utils.SliceToPtr(p.values), int32(len(p.values)), p.xScale, p.x0, @@ -499,8 +500,8 @@ func (p *LineXYPlot) Plot() { implot.PlotSetAxis(implot.PlotAxisEnum(p.yAxis)) implot.PlotPlotLinedoublePtrdoublePtrV( Context.FontAtlas.RegisterString(p.title), - &p.xs, - &p.ys, + utils.SliceToPtr(p.xs), + utils.SliceToPtr(p.ys), int32(len(p.xs)), 0, // flags int32(p.offset), @@ -560,7 +561,7 @@ func (p *PieChartPlot) Plot() { implot.PlotPlotPieChartdoublePtrStrV( Context.FontAtlas.RegisterStringSlice(p.labels), - &p.values, + utils.SliceToPtr(p.values), int32(len(p.values)), p.x, p.y, @@ -612,7 +613,7 @@ func (p *ScatterPlot) Offset(offset int) *ScatterPlot { func (p *ScatterPlot) Plot() { implot.PlotPlotScatterdoublePtrIntV( Context.FontAtlas.RegisterString(p.label), - &p.values, + utils.SliceToPtr(p.values), int32(len(p.values)), p.xscale, p.x0, @@ -649,8 +650,8 @@ func (p *ScatterXYPlot) Offset(offset int) *ScatterXYPlot { func (p *ScatterXYPlot) Plot() { implot.PlotPlotScatterdoublePtrdoublePtrV( Context.FontAtlas.RegisterString(p.label), - &p.xs, - &p.ys, + utils.SliceToPtr(p.xs), + utils.SliceToPtr(p.ys), int32(len(p.xs)), 0, // TODO: implement int32(p.offset), diff --git a/examples/paint/toolbar.go b/examples/paint/toolbar.go index 01a808ff..726d654a 100644 --- a/examples/paint/toolbar.go +++ b/examples/paint/toolbar.go @@ -7,6 +7,7 @@ import ( "io/fs" "github.com/AllenDang/cimgui-go/imgui" + "github.com/AllenDang/cimgui-go/utils" g "github.com/AllenDang/giu" ) @@ -112,7 +113,7 @@ func colorPopup(ce *color.RGBA, fe g.ColorEditFlags) { g.Context.FontAtlas.RegisterString("##COLOR_POPUP##me"), &col, imgui.ColorEditFlags(fe), - refCol, + utils.SliceToPtr(refCol), ) { *ce = g.Vec4ToRGBA(imgui.Vec4{ X: col[0], diff --git a/go.mod b/go.mod index a76ee12d..8818ab7f 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 toolchain go1.23.1 require ( - github.com/AllenDang/cimgui-go v1.0.4-0.20241026200445-990a0e771992 + github.com/AllenDang/cimgui-go v1.1.0 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.5 diff --git a/go.sum b/go.sum index 911d23b0..aae7f016 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/AllenDang/cimgui-go v1.0.4-0.20241026200445-990a0e771992 h1:gLSKrpQ89PEJQ9t2EzTcblz7qsAQvLoCjDLdt5s7RFI= -github.com/AllenDang/cimgui-go v1.0.4-0.20241026200445-990a0e771992/go.mod h1:aY20nGDN5w+zaGAmRV24bKI/OYVmEptB0qlr5z/0OoI= +github.com/AllenDang/cimgui-go v1.1.0 h1:hltblxjy6Q+/TxOQLjI45yVlCn/DQSC9DLTtKc8PhfQ= +github.com/AllenDang/cimgui-go v1.1.0/go.mod h1:v5iftKz+rJRG6TArxibxqqOhVqUyzMkqbX90iC2Mqe0= 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=