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

cimgui-go Migration #628

Merged
merged 121 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
8703a3e
add migration.sh: WIP
gucio321 Dec 4, 2022
2998ebd
migration: add go module updating step
gucio321 Dec 4, 2022
9499697
migration.sh: rename style vars
gucio321 Dec 4, 2022
de934f2
migration: further work
gucio321 Dec 4, 2022
45d9466
migration: exclude markdown.go
gucio321 Dec 4, 2022
4675397
migration: exclude CodeEditor
gucio321 Dec 4, 2022
b4a24a4
add migration.txt with api changes
gucio321 Dec 4, 2022
9e034ba
migration: update
gucio321 Dec 4, 2022
7afd070
migration: update
gucio321 Dec 4, 2022
89145c7
migration: update ImGuiWindowFlags
gucio321 Dec 4, 2022
8ce0bb0
migration: fix conflicts
gucio321 Dec 4, 2022
747abcc
migration: further progress
gucio321 Dec 4, 2022
3365c50
migration: add colorToUint
gucio321 Dec 4, 2022
a336d8b
migration: work on canvas.go
gucio321 Dec 10, 2022
dea7bc9
migration: work on styles
gucio321 Dec 10, 2022
555b5cd
migration: work on style.go
gucio321 Dec 10, 2022
86eae03
migration: fix single bug in splitLayout.go
gucio321 Dec 10, 2022
955214f
migration: direction.go
gucio321 Dec 10, 2022
81020b8
migration: clickablewidgets.go
gucio321 Dec 10, 2022
13a6a15
migration: events.go
gucio321 Dec 10, 2022
991431d
migration: listclipper.go
gucio321 Dec 10, 2022
174e9e3
migration: ProgressIndicator.go
gucio321 Dec 10, 2022
0092c10
migration: popups.go
gucio321 Dec 10, 2022
3ba52d6
migration: window.go
gucio321 Dec 10, 2022
3785b32
migration: further work on window.go
gucio321 Dec 10, 2022
c2ebb7c
migration: font atlas processor
gucio321 Dec 10, 2022
49f787f
migration: work on extrtaWidgets.go
gucio321 Dec 10, 2022
51ce92f
migration: SliderWidgets.go
gucio321 Dec 11, 2022
a8895ff
migration.sh: work on TableWidgets.go
gucio321 Dec 11, 2022
7cfcbd2
migration: work on Widgets.go
gucio321 Dec 11, 2022
9d7a617
format files
gucio321 Dec 11, 2022
d0a819e
migration: upgrade cimgui-go
gucio321 Dec 13, 2022
05e580a
migration: update to latest cimgui api
gucio321 Dec 13, 2022
d1d656c
fix some remaining api changes
gucio321 Dec 16, 2022
526514a
update cimgui
gucio321 Jan 1, 2023
f5acff9
migration: remove `_`
gucio321 Jan 10, 2023
f2d7443
migration: update to main of cimgui
gucio321 Apr 13, 2023
b42ec3d
context: remove imgui.platform and renderer
gucio321 Apr 13, 2023
1266588
migration: updates
gucio321 Apr 13, 2023
8425876
migration: migrate great amount of code
gucio321 Apr 26, 2023
9e5e595
code: further updates
gucio321 Apr 27, 2023
663f7ba
fix all build errors
gucio321 Apr 27, 2023
95b9ad4
masterwindow: rewrite to fit new cimgui strategy
gucio321 May 7, 2023
61b233d
deps: update cimgui-go
gucio321 May 7, 2023
90219fe
master window: clean up code
gucio321 May 7, 2023
881687b
fix: fix nil pointer in input handler
gucio321 May 7, 2023
796cf8a
master window: move texture loading to appropiate place
gucio321 May 8, 2023
4294fd7
example: add temporary debug example
gucio321 May 8, 2023
4070e04
master window: move some code to CreateCOntext
gucio321 May 10, 2023
225ccb3
Merge remote-tracking branch 'upstream/master' into migration
gucio321 May 10, 2023
1b28a3b
run go mod tidy
gucio321 May 13, 2023
ef3bb1d
font atlas: comment out failing line
gucio321 May 14, 2023
c57de25
add theme
gucio321 May 14, 2023
1031e2f
examples: fix each example to make them compilable
gucio321 May 14, 2023
ea6232d
texture: use textures impl from imgui
gucio321 May 14, 2023
bd6f97f
Merge branch 'master' into migration
gucio321 Jul 13, 2023
0c638f0
window: fix single window
gucio321 Jul 13, 2023
210958b
texture: remove GO call in NewTextureFromRGBA
gucio321 Jul 13, 2023
71f2dc2
image from URL bugfix: use right function to convert rgba to texture
gucio321 Jul 13, 2023
a5775be
remove debug example
gucio321 Jul 13, 2023
858f937
context test: fix build error
gucio321 Jul 14, 2023
ee41e61
commented-out code: fix some golangci lint errrors
gucio321 Jul 14, 2023
08bef62
get rid of migration.sh script
gucio321 Jul 14, 2023
79aad89
master window: add SetDropCallback
gucio321 Jul 14, 2023
0ef9b60
windows: fix SingleWindowWithMenubar
gucio321 Jul 14, 2023
bc99ea6
cimgui: update to latest commit
gucio321 Jul 21, 2023
90619b5
implement cimgui references
gucio321 Jul 21, 2023
f3fc166
deps: update to latest cimgui
gucio321 Jul 24, 2023
c144fc5
master window: enabe SetCloseCallback
gucio321 Jul 24, 2023
6dfe353
master window: enable SetShouldCLose
gucio321 Jul 24, 2023
23a15ce
some style fixes
gucio321 Jul 24, 2023
af431ae
set font size pixels to non-zero
gucio321 Jul 24, 2023
27f0dce
deps: switch to temporary upstream branch gucio321/cimgui-go@giu-dev
gucio321 Aug 8, 2023
47f90f8
implement cimgui changes
gucio321 Aug 8, 2023
e2e6fe0
master window: fix panic with style stuff
gucio321 Aug 8, 2023
772dd41
deps: update to latest cimgui-go
gucio321 Aug 9, 2023
593f6a0
font atlas: fix font textures
gucio321 Aug 9, 2023
b36b21d
master window: enable GetPos
gucio321 Aug 9, 2023
bece383
deps: update to latest cimgui-go
gucio321 Aug 19, 2023
9b82f39
font atlas: fix build error
gucio321 Aug 19, 2023
df9d1d7
font atlas: when adding font from memory, tell imgui not to free data
gucio321 Aug 19, 2023
2a99ea2
multiplefonts: fix example
gucio321 Aug 19, 2023
fa947a2
font atlas: set tex ready
gucio321 Aug 19, 2023
911915e
deps: update to latest cimgui-go
gucio321 Aug 30, 2023
0f313ab
deps: update to use latest cimgui-go
gucio321 Aug 30, 2023
b2bf8a8
code: update to fit fixed pointers strategy in cimgui-go
gucio321 Aug 30, 2023
9b57ac2
master window: reenable SetIcon
gucio321 Aug 31, 2023
26aee64
Merge branch 'master' into migration
gucio321 Aug 31, 2023
a241c1c
master window: support size change cb, attempt to reenable input-manager
gucio321 Aug 31, 2023
9ac244c
Merge branch 'migration' of github.com:gucio321/giu into migration
gucio321 Aug 31, 2023
4ecc361
examples: update
gucio321 Aug 31, 2023
c4e067e
deps: update (add imnodes)
gucio321 Sep 1, 2023
51a1aff
deps: update
gucio321 Sep 11, 2023
0759099
remove some flag
gucio321 Sep 11, 2023
25ef27f
update deps
gucio321 Sep 13, 2023
10b12f3
deps: update cimgui-go
gucio321 Sep 14, 2023
5627394
master window: remove DestroyContext TODO
gucio321 Sep 14, 2023
743478a
font atlas: use SliceToPtr imgui func
gucio321 Sep 14, 2023
c5e9cdb
mod: require go v1.21.X
gucio321 Sep 14, 2023
1a7e8c5
workflows: use go 1.21
gucio321 Sep 14, 2023
63cd282
plot: fix code (examples/plot works now
gucio321 Sep 14, 2023
44916ab
mod: remove replace directive
gucio321 Sep 14, 2023
bf491d9
Font atlas processor: figure out why it crashed
gucio321 Sep 14, 2023
87690a4
deps: update
gucio321 Sep 14, 2023
6caf7ca
examples/canvas: use right function to load texture; check if tex isn…
gucio321 Sep 14, 2023
d739b24
feat: set default pos of new window at 0x0 of viewport (not screen)
gucio321 Sep 14, 2023
8bf789a
customwidget: update
gucio321 Sep 14, 2023
083bbe1
discussion 652: minor update
gucio321 Sep 14, 2023
c3ab91a
update deps; fix bg color setting
gucio321 Sep 17, 2023
51b5435
fix some todos (context/flags)
gucio321 Sep 17, 2023
a0ec50d
plot: apply some updates
gucio321 Sep 17, 2023
c0d9861
master window: correct input handler so that it passes arguments corr…
gucio321 Sep 17, 2023
3328dc3
update keycodes so that input handler works now
gucio321 Sep 18, 2023
f1dfa87
reenable content scaling
gucio321 Sep 18, 2023
a727785
upgrade to latest golangci-lint
gucio321 Sep 18, 2023
669f55f
fix some lint errors
gucio321 Sep 18, 2023
1de7003
fix some more lin terrors
gucio321 Sep 18, 2023
bd9db0c
disable depguard
gucio321 Sep 18, 2023
e0e26bb
fix remaining (fixable) lints
gucio321 Sep 22, 2023
33ba5ad
widgets: reenable parts of markdown and codeditor code to avoid api c…
gucio321 Sep 22, 2023
903adab
run golangci with --fix
gucio321 Sep 22, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Go environment
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.21.x
id: go

- name: Cache Go modules
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
version: v1.54.2
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ linters:
enable:
- asciicheck
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
Expand Down
4 changes: 2 additions & 2 deletions Alignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"image"

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

// These constants holds information about where GetWidgetWidth should proceed their
Expand Down Expand Up @@ -177,7 +177,7 @@ func (a *AlignmentSetter) Build() {
// if you find anything else, please report it on
// https://github.com/AllenDang/giu Any contribution is appreciated!
func GetWidgetWidth(w Widget) (result float32) {
imgui.PushID(GenAutoID("GetWidgetWidthMeasurement"))
imgui.PushIDStr(GenAutoID("GetWidgetWidthMeasurement"))
defer imgui.PopID()

// save cursor position before doing anything
Expand Down
84 changes: 42 additions & 42 deletions Canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"image"
"image/color"

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

// Canvas represents imgui.DrawList
Expand All @@ -20,103 +20,103 @@ import (
//
// c := &Canvas{imgui.GetXXXDrawList()}
type Canvas struct {
DrawList imgui.DrawList
DrawList *imgui.DrawList
}

// GetCanvas returns current draw list (for current window).
// it will fail if called out of window's layout.
func GetCanvas() *Canvas {
return &Canvas{
DrawList: imgui.GetWindowDrawList(),
DrawList: imgui.WindowDrawList(),
}
}

// AddLine draws a line (from p1 to p2).
func (c *Canvas) AddLine(p1, p2 image.Point, col color.Color, thickness float32) {
c.DrawList.AddLine(ToVec2(p1), ToVec2(p2), ToVec4Color(col), thickness)
c.DrawList.AddLineV(ToVec2(p1), ToVec2(p2), ColorToUint(col), thickness)
}

// DrawFlags represents imgui.DrawFlags.
type DrawFlags int
type DrawFlags imgui.DrawFlags

// draw flags enum:.
const (
DrawFlagsNone DrawFlags = 0
DrawFlagsNone DrawFlags = DrawFlags(imgui.DrawFlagsNone)
// PathStroke(), AddPolyline(): specify that shape should be closed (note: this is always == 1 for legacy reasons).
DrawFlagsClosed DrawFlags = 1 << 0
DrawFlagsClosed DrawFlags = DrawFlags(imgui.DrawFlagsClosed)
// AddRect(), AddRectFilled(), PathRect(): enable rounding top-left corner only (when rounding > 0.0f, we default to all corners).
// Was 0x01.
DrawFlagsRoundCornersTopLeft DrawFlags = 1 << 4
DrawFlagsRoundCornersTopLeft DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersTopLeft)
// AddRect(), AddRectFilled(), PathRect(): enable rounding top-right corner only (when rounding > 0.0f, we default to all corners).
// Was 0x02.
DrawFlagsRoundCornersTopRight DrawFlags = 1 << 5
DrawFlagsRoundCornersTopRight DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersTopRight)
// AddRect(), AddRectFilled(), PathRect(): enable rounding bottom-left corner only (when rounding > 0.0f, we default to all corners).
// Was 0x04.
DrawFlagsRoundCornersBottomLeft DrawFlags = 1 << 6
DrawFlagsRoundCornersBottomLeft DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersBottomLeft)
// AddRect(), AddRectFilled(), PathRect(): enable rounding bottom-right corner only (when rounding > 0.0f,
// we default to all corners). Wax 0x08.
DrawFlagsRoundCornersBottomRight DrawFlags = 1 << 7
DrawFlagsRoundCornersBottomRight DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersBottomRight)
// AddRect(), AddRectFilled(), PathRect(): disable rounding on all corners (when rounding > 0.0f). This is NOT zero, NOT an implicit flag!
DrawFlagsRoundCornersNone DrawFlags = 1 << 8
DrawFlagsRoundCornersTop DrawFlags = DrawFlagsRoundCornersTopLeft | DrawFlagsRoundCornersTopRight
DrawFlagsRoundCornersBottom DrawFlags = DrawFlagsRoundCornersBottomLeft | DrawFlagsRoundCornersBottomRight
DrawFlagsRoundCornersLeft DrawFlags = DrawFlagsRoundCornersBottomLeft | DrawFlagsRoundCornersTopLeft
DrawFlagsRoundCornersRight DrawFlags = DrawFlagsRoundCornersBottomRight | DrawFlagsRoundCornersTopRight
DrawFlagsRoundCornersAll DrawFlags = DrawFlagsRoundCornersTopLeft | DrawFlagsRoundCornersTopRight |
DrawFlagsRoundCornersBottomLeft | DrawFlagsRoundCornersBottomRight
DrawFlagsRoundCornersNone DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersNone)
DrawFlagsRoundCornersTop DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersTop)
DrawFlagsRoundCornersBottom DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersBottom)
DrawFlagsRoundCornersLeft DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersLeft)
DrawFlagsRoundCornersRight DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersRight)
DrawFlagsRoundCornersAll DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersAll)

// Default to ALL corners if none of the RoundCornersXX flags are specified.
DrawFlagsRoundCornersDefault DrawFlags = DrawFlagsRoundCornersAll
DrawFlagsRoundCornersMask DrawFlags = DrawFlagsRoundCornersAll | DrawFlagsRoundCornersNone
DrawFlagsRoundCornersDefault DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersDefault)
DrawFlagsRoundCornersMask DrawFlags = DrawFlags(imgui.DrawFlagsRoundCornersMask)
)

// AddRect draws a rectangle.
func (c *Canvas) AddRect(pMin, pMax image.Point, col color.Color, rounding float32, roundingCorners DrawFlags, thickness float32) {
c.DrawList.AddRect(ToVec2(pMin), ToVec2(pMax), ToVec4Color(col), rounding, int(roundingCorners), thickness)
c.DrawList.AddRectV(ToVec2(pMin), ToVec2(pMax), ColorToUint(col), rounding, imgui.DrawFlags(roundingCorners), thickness)
}

// AddRectFilled draws a rectangle filled with `col`.
func (c *Canvas) AddRectFilled(pMin, pMax image.Point, col color.Color, rounding float32, roundingCorners DrawFlags) {
c.DrawList.AddRectFilled(ToVec2(pMin), ToVec2(pMax), ToVec4Color(col), rounding, int(roundingCorners))
c.DrawList.AddRectFilledV(ToVec2(pMin), ToVec2(pMax), ColorToUint(col), rounding, imgui.DrawFlags(roundingCorners))
}

// AddText draws text.
func (c *Canvas) AddText(pos image.Point, col color.Color, text string) {
c.DrawList.AddText(ToVec2(pos), ToVec4Color(col), Context.FontAtlas.RegisterString(text))
c.DrawList.AddTextVec2(ToVec2(pos), ColorToUint(col), Context.FontAtlas.RegisterString(text))
}

// AddBezierCubic draws bezier cubic.
func (c *Canvas) AddBezierCubic(pos0, cp0, cp1, pos1 image.Point, col color.Color, thickness float32, numSegments int) {
c.DrawList.AddBezierCubic(ToVec2(pos0), ToVec2(cp0), ToVec2(cp1), ToVec2(pos1), ToVec4Color(col), thickness, numSegments)
func (c *Canvas) AddBezierCubic(pos0, cp0, cp1, pos1 image.Point, col color.Color, thickness float32, numSegments int32) {
c.DrawList.AddBezierCubicV(ToVec2(pos0), ToVec2(cp0), ToVec2(cp1), ToVec2(pos1), ColorToUint(col), thickness, numSegments)
}

// AddTriangle draws a triangle.
func (c *Canvas) AddTriangle(p1, p2, p3 image.Point, col color.Color, thickness float32) {
c.DrawList.AddTriangle(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec4Color(col), thickness)
c.DrawList.AddTriangleV(ToVec2(p1), ToVec2(p2), ToVec2(p3), ColorToUint(col), thickness)
}

// AddTriangleFilled draws a filled triangle.
func (c *Canvas) AddTriangleFilled(p1, p2, p3 image.Point, col color.Color) {
c.DrawList.AddTriangleFilled(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec4Color(col))
c.DrawList.AddTriangleFilled(ToVec2(p1), ToVec2(p2), ToVec2(p3), ColorToUint(col))
}

// AddCircle draws a circle.
func (c *Canvas) AddCircle(center image.Point, radius float32, col color.Color, segments int, thickness float32) {
c.DrawList.AddCircle(ToVec2(center), radius, ToVec4Color(col), segments, thickness)
func (c *Canvas) AddCircle(center image.Point, radius float32, col color.Color, segments int32, thickness float32) {
c.DrawList.AddCircleV(ToVec2(center), radius, ColorToUint(col), segments, thickness)
}

// AddCircleFilled draws a filled circle.
func (c *Canvas) AddCircleFilled(center image.Point, radius float32, col color.Color) {
c.DrawList.AddCircleFilled(ToVec2(center), radius, ToVec4Color(col))
c.DrawList.AddCircleFilled(ToVec2(center), radius, ColorToUint(col))
}

// AddQuad draws a quad.
func (c *Canvas) AddQuad(p1, p2, p3, p4 image.Point, col color.Color, thickness float32) {
c.DrawList.AddQuad(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ToVec4Color(col), thickness)
c.DrawList.AddQuadV(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ColorToUint(col), thickness)
}

// AddQuadFilled draws a filled quad.
func (c *Canvas) AddQuadFilled(p1, p2, p3, p4 image.Point, col color.Color) {
c.DrawList.AddQuadFilled(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ToVec4Color(col))
c.DrawList.AddQuadFilled(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ColorToUint(col))
}

// Stateful path API, add points then finish with PathFillConvex() or PathStroke().
Expand All @@ -134,29 +134,29 @@ func (c *Canvas) PathLineToMergeDuplicate(pos image.Point) {
}

func (c *Canvas) PathFillConvex(col color.Color) {
c.DrawList.PathFillConvex(ToVec4Color(col))
c.DrawList.PathFillConvex(ColorToUint(col))
}

func (c *Canvas) PathStroke(col color.Color, closed bool, thickness float32) {
c.DrawList.PathStroke(ToVec4Color(col), closed, thickness)
func (c *Canvas) PathStroke(col color.Color, flags DrawFlags, thickness float32) {
c.DrawList.PathStrokeV(ColorToUint(col), imgui.DrawFlags(flags), thickness)
}

func (c *Canvas) PathArcTo(center image.Point, radius, min, max float32, numSegments int) {
c.DrawList.PathArcTo(ToVec2(center), radius, min, max, numSegments)
func (c *Canvas) PathArcTo(center image.Point, radius, min, max float32, numSegments int32) {
c.DrawList.PathArcToV(ToVec2(center), radius, min, max, numSegments)
}

func (c *Canvas) PathArcToFast(center image.Point, radius float32, min12, max12 int) {
func (c *Canvas) PathArcToFast(center image.Point, radius float32, min12, max12 int32) {
c.DrawList.PathArcToFast(ToVec2(center), radius, min12, max12)
}

func (c *Canvas) PathBezierCubicCurveTo(p1, p2, p3 image.Point, numSegments int) {
c.DrawList.PathBezierCubicCurveTo(ToVec2(p1), ToVec2(p2), ToVec2(p3), numSegments)
func (c *Canvas) PathBezierCubicCurveTo(p1, p2, p3 image.Point, numSegments int32) {
c.DrawList.PathBezierCubicCurveToV(ToVec2(p1), ToVec2(p2), ToVec2(p3), numSegments)
}

func (c *Canvas) AddImage(texture *Texture, pMin, pMax image.Point) {
c.DrawList.AddImage(texture.id, ToVec2(pMin), ToVec2(pMax))
c.DrawList.AddImage(texture.ID(), ToVec2(pMin), ToVec2(pMax))
}

func (c *Canvas) AddImageV(texture *Texture, pMin, pMax, uvMin, uvMax image.Point, col color.Color) {
c.DrawList.AddImageV(texture.id, ToVec2(pMin), ToVec2(pMax), ToVec2(uvMin), ToVec2(uvMax), ToVec4Color(col))
c.DrawList.AddImageV(texture.tex.ID(), ToVec2(pMin), ToVec2(pMax), ToVec2(uvMin), ToVec2(uvMax), ColorToUint(col))
}
19 changes: 10 additions & 9 deletions ClickableWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"image"
"image/color"

"github.com/AllenDang/imgui-go"
imgui "github.com/AllenDang/cimgui-go"
"golang.org/x/image/colornames"
)

Expand Down Expand Up @@ -64,7 +64,7 @@ func (b *ButtonWidget) ID(id string) *ButtonWidget {
// Build implements Widget interface.
func (b *ButtonWidget) Build() {
if b.disabled {
imgui.BeginDisabled(true)
imgui.BeginDisabled()
defer imgui.EndDisabled()
}

Expand Down Expand Up @@ -105,7 +105,7 @@ func (b *ArrowButtonWidget) ID(id string) *ArrowButtonWidget {

// Build implements Widget interface.
func (b *ArrowButtonWidget) Build() {
if imgui.ArrowButton(b.id, uint8(b.dir)) && b.onClick != nil {
if imgui.ArrowButton(b.id, imgui.Dir(b.dir)) && b.onClick != nil {
b.onClick()
}
}
Expand Down Expand Up @@ -224,15 +224,16 @@ func ImageButton(texture *Texture) *ImageButtonWidget {

// Build implements Widget interface.
func (b *ImageButtonWidget) Build() {
if b.texture == nil || b.texture.id == 0 {
if b.texture == nil || b.texture.tex == nil {
return
}

if imgui.ImageButtonV(
b.texture.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),
b.framePadding, ToVec4Color(b.bgColor),
ToVec4Color(b.bgColor),
ToVec4Color(b.tintColor),
) && b.onClick != nil {
b.onClick()
Expand Down Expand Up @@ -406,7 +407,7 @@ func (r *RadioButtonWidget) OnChange(onChange func()) *RadioButtonWidget {

// Build implements Widget interface.
func (r *RadioButtonWidget) Build() {
if imgui.RadioButton(Context.FontAtlas.RegisterString(r.text), r.active) && r.onChange != nil {
if imgui.RadioButtonBool(Context.FontAtlas.RegisterString(r.text), r.active) && r.onChange != nil {
r.onChange()
}
}
Expand Down Expand Up @@ -481,7 +482,7 @@ func (s *SelectableWidget) Build() {
s.flags |= SelectableFlagsAllowDoubleClick
}

if imgui.SelectableV(Context.FontAtlas.RegisterString(s.label), s.selected, int(s.flags), imgui.Vec2{X: s.width, Y: s.height}) && s.onClick != nil {
if imgui.SelectableBoolV(Context.FontAtlas.RegisterString(s.label), s.selected, imgui.SelectableFlags(s.flags), imgui.Vec2{X: s.width, Y: s.height}) && s.onClick != nil {
s.onClick()
}

Expand Down Expand Up @@ -539,7 +540,7 @@ func (t *TreeNodeWidget) Layout(widgets ...Widget) *TreeNodeWidget {

// Build implements Widget interface.
func (t *TreeNodeWidget) Build() {
open := imgui.TreeNodeV(t.label, int(t.flags))
open := imgui.TreeNodeExStrV(t.label, imgui.TreeNodeFlags(t.flags))

if t.eventHandler != nil {
t.eventHandler()
Expand Down
Loading
Loading