diff --git a/.golangci.yml b/.golangci.yml index 443c5dc..dfca711 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,16 +5,20 @@ run: - sdl linters: + # Take an aggressive approach: enable everything and only disable if not useful. + # So far there are fewer to disable than to enable explicitly. enable-all: true # linters are disabled if their majority of issues is considered false-positive (intended code) # and the remaining issues (if existing) aren't worth it. disable: - gochecknoglobals + - gocognit # disabled because of the high complexity of demo files - goimports # disabled because of so many false-positives with "imgui-go" - gofumpt # disabled because no extra need - gosec - maligned + - nestif # disabled because of the high complexity of demo files - gomnd # disabled as most OpenGL stuff are direct constants. - funlen # disabled because of example code. While people will probably tend to duplicate this, they'll handle it on their own. - wsl # this one became too pedantic and with a different style than I would. diff --git a/assets/screenshot.png b/assets/screenshot.png index c7a3e71..56041d4 100644 Binary files a/assets/screenshot.png and b/assets/screenshot.png differ diff --git a/cmd/example_glfw_opengl2/main.go b/cmd/example_glfw_opengl2/main.go index a9f1b3c..e236ce3 100644 --- a/cmd/example_glfw_opengl2/main.go +++ b/cmd/example_glfw_opengl2/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" "github.com/inkyblackness/imgui-go-examples/internal/example" "github.com/inkyblackness/imgui-go-examples/internal/platforms" diff --git a/cmd/example_glfw_opengl3/main.go b/cmd/example_glfw_opengl3/main.go index a4e08ab..6eed56a 100644 --- a/cmd/example_glfw_opengl3/main.go +++ b/cmd/example_glfw_opengl3/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" "github.com/inkyblackness/imgui-go-examples/internal/example" "github.com/inkyblackness/imgui-go-examples/internal/platforms" diff --git a/cmd/example_sdl_opengl2/main.go b/cmd/example_sdl_opengl2/main.go index 9c5ebac..4818a7f 100644 --- a/cmd/example_sdl_opengl2/main.go +++ b/cmd/example_sdl_opengl2/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" "github.com/inkyblackness/imgui-go-examples/internal/example" "github.com/inkyblackness/imgui-go-examples/internal/platforms" diff --git a/cmd/example_sdl_opengl3/main.go b/cmd/example_sdl_opengl3/main.go index a87d223..0d124d4 100644 --- a/cmd/example_sdl_opengl3/main.go +++ b/cmd/example_sdl_opengl3/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" "github.com/inkyblackness/imgui-go-examples/internal/example" "github.com/inkyblackness/imgui-go-examples/internal/platforms" diff --git a/go.mod b/go.mod index b0b1b23..4e6f644 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72 - github.com/inkyblackness/imgui-go/v3 v3.0.0 + github.com/inkyblackness/imgui-go/v4 v4.0.1 github.com/veandco/go-sdl2 v0.4.0 ) diff --git a/go.sum b/go.sum index d22c7a5..4ab86ac 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluN github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72 h1:LgLYrxDRSVv3kStk6louYTP1ekZ6t7HZY/X05KUyaeM= github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/inkyblackness/imgui-go/v3 v3.0.0 h1:+gOBA/xlr528SOGDteKQS+q7QkyBcOi+znhn18BMs/8= -github.com/inkyblackness/imgui-go/v3 v3.0.0/go.mod h1:WdM5LZHuTrjd1d+yd2fA19t3mG538kJ6zOLB2sAXF6U= +github.com/inkyblackness/imgui-go/v4 v4.0.1 h1:TzbdvkDsmuPQ6pEsDkOqFxhOyA0RLbP7r34yRnCUz6Q= +github.com/inkyblackness/imgui-go/v4 v4.0.1/go.mod h1:g8SAGtOYUP7rYaOB2AsVKCEHmPMDmJKgt4z6d+flhb0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/internal/demo/Window.go b/internal/demo/Window.go index 55216f3..2a31362 100644 --- a/internal/demo/Window.go +++ b/internal/demo/Window.go @@ -3,7 +3,7 @@ package demo import ( "fmt" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" ) type windowFlags struct { @@ -18,8 +18,8 @@ type windowFlags struct { noBringToFront bool } -func (f windowFlags) combined() int { - flags := 0 +func (f windowFlags) combined() imgui.WindowFlags { + flags := imgui.WindowFlagsNone if f.noTitlebar { flags |= imgui.WindowFlagsNoTitleBar } @@ -58,6 +58,7 @@ var window = struct { layout layout popups popups columns columns + tables tables misc misc }{} @@ -153,6 +154,7 @@ func Show(keepOpen *bool) { window.layout.show() window.popups.show() window.columns.show() + window.tables.show() window.misc.show() // End of ShowDemoWindow() @@ -226,6 +228,102 @@ func (widgets *widgets) show() { } } +type tables struct { + background bool + borders bool + noInnerBorders bool + header bool +} + +var demoTableHeader = []string{ + "Name", "Favourite Food", "Favourite Colour", +} + +var demoTable = [][]string{ + {"Eric", "Bannana", "Yellow"}, + {"Peter", "Apple", "Red"}, + {"Bruce", "Liquorice", "Black"}, + {"Aaron", "Chocolates", "Blue"}, +} + +func (tables *tables) show() { + if !imgui.CollapsingHeader("Tables") { + return + } + + if imgui.TreeNode("Rows & Columns") { + if imgui.BeginTable("tableRowsAndColumns", 3) { + for row := 0; row < 4; row++ { + imgui.TableNextRow() + for column := 0; column < 3; column++ { + imgui.TableSetColumnIndex(column) + imgui.Text(fmt.Sprintf("Row %d Column %d", row, column)) + } + } + imgui.EndTable() + } + imgui.TreePop() + } + + if imgui.TreeNode("Options") { + // tables are useful for more than tabulated data. we use tables here + // to facilitate layout of the option checkboxes + if imgui.BeginTable("tableOptions", 2) { + imgui.TableNextRow() + if imgui.TableNextColumn() { + imgui.Checkbox("Background", &tables.background) + } + if imgui.TableNextColumn() { + imgui.Checkbox("Header Row", &tables.header) + } + + imgui.TableNextRow() + if imgui.TableNextColumn() { + imgui.Checkbox("Borders", &tables.borders) + } + if tables.borders { + if imgui.TableNextColumn() { + imgui.Checkbox("No Inner Borders", &tables.noInnerBorders) + } + } + + imgui.EndTable() + } + + // set flags according to the options that have been selected + flgs := imgui.TableFlagsNone + if tables.background { + flgs |= imgui.TableFlagsRowBg + } + if tables.borders { + flgs |= imgui.TableFlagsBorders + if tables.noInnerBorders { + flgs |= imgui.TableFlagsNoBordersInBody + } + } + + if imgui.BeginTableV("tableRowsAndColumns", len(demoTableHeader), flgs, imgui.Vec2{}, 0.0) { + if tables.header { + imgui.TableHeadersRow() + for column := 0; column < len(demoTableHeader); column++ { + imgui.TableSetColumnIndex(column) + imgui.Text(demoTableHeader[column]) + } + } + + for row := 0; row < len(demoTable); row++ { + imgui.TableNextRow() + for column := 0; column < len(demoTableHeader); column++ { + imgui.TableSetColumnIndex(column) + imgui.Text(demoTable[row][column]) + } + } + imgui.EndTable() + } + imgui.TreePop() + } +} + type layout struct { } diff --git a/internal/example/Run.go b/internal/example/Run.go index 966ad51..57575f4 100644 --- a/internal/example/Run.go +++ b/internal/example/Run.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" "github.com/inkyblackness/imgui-go-examples/internal/demo" ) diff --git a/internal/platforms/glfw.go b/internal/platforms/glfw.go index cd9a508..d8a0d2c 100644 --- a/internal/platforms/glfw.go +++ b/internal/platforms/glfw.go @@ -8,7 +8,7 @@ import ( "runtime" "github.com/go-gl/glfw/v3.2/glfw" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" ) // GLFWClientAPI identifies the render system that shall be initialized. diff --git a/internal/platforms/sdl.go b/internal/platforms/sdl.go index 8df380e..a27960e 100644 --- a/internal/platforms/sdl.go +++ b/internal/platforms/sdl.go @@ -6,7 +6,7 @@ import ( "fmt" "runtime" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" "github.com/veandco/go-sdl2/sdl" ) diff --git a/internal/renderers/OpenGL2.go b/internal/renderers/OpenGL2.go index 77c9939..7a85b72 100644 --- a/internal/renderers/OpenGL2.go +++ b/internal/renderers/OpenGL2.go @@ -5,7 +5,7 @@ import ( "unsafe" "github.com/go-gl/gl/v2.1/gl" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" ) // OpenGL2 implements a renderer based on github.com/go-gl/gl (v2.1). diff --git a/internal/renderers/OpenGL3.go b/internal/renderers/OpenGL3.go index 1f41265..312bfff 100644 --- a/internal/renderers/OpenGL3.go +++ b/internal/renderers/OpenGL3.go @@ -5,7 +5,7 @@ import ( "unsafe" "github.com/go-gl/gl/v3.2-core/gl" - "github.com/inkyblackness/imgui-go/v3" + "github.com/inkyblackness/imgui-go/v4" ) // OpenGL3 implements a renderer based on github.com/go-gl/gl (v3.2-core).