Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit a8e1038

Browse files
authored
Merge pull request #11 from inkyblackness/prepare-for-v4
Prepare for v4
2 parents b01e28d + c87a270 commit a8e1038

File tree

14 files changed

+117
-15
lines changed

14 files changed

+117
-15
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ run:
55
- sdl
66

77
linters:
8+
# Take an aggressive approach: enable everything and only disable if not useful.
9+
# So far there are fewer to disable than to enable explicitly.
810
enable-all: true
911

1012
# linters are disabled if their majority of issues is considered false-positive (intended code)
1113
# and the remaining issues (if existing) aren't worth it.
1214
disable:
1315
- gochecknoglobals
16+
- gocognit # disabled because of the high complexity of demo files
1417
- goimports # disabled because of so many false-positives with "imgui-go"
1518
- gofumpt # disabled because no extra need
1619
- gosec
1720
- maligned
21+
- nestif # disabled because of the high complexity of demo files
1822
- gomnd # disabled as most OpenGL stuff are direct constants.
1923
- funlen # disabled because of example code. While people will probably tend to duplicate this, they'll handle it on their own.
2024
- wsl # this one became too pedantic and with a different style than I would.

assets/screenshot.png

-7.79 KB
Loading

cmd/example_glfw_opengl2/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"os"
88

9-
"github.com/inkyblackness/imgui-go/v3"
9+
"github.com/inkyblackness/imgui-go/v4"
1010

1111
"github.com/inkyblackness/imgui-go-examples/internal/example"
1212
"github.com/inkyblackness/imgui-go-examples/internal/platforms"

cmd/example_glfw_opengl3/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"os"
88

9-
"github.com/inkyblackness/imgui-go/v3"
9+
"github.com/inkyblackness/imgui-go/v4"
1010

1111
"github.com/inkyblackness/imgui-go-examples/internal/example"
1212
"github.com/inkyblackness/imgui-go-examples/internal/platforms"

cmd/example_sdl_opengl2/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"os"
88

9-
"github.com/inkyblackness/imgui-go/v3"
9+
"github.com/inkyblackness/imgui-go/v4"
1010

1111
"github.com/inkyblackness/imgui-go-examples/internal/example"
1212
"github.com/inkyblackness/imgui-go-examples/internal/platforms"

cmd/example_sdl_opengl3/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"os"
88

9-
"github.com/inkyblackness/imgui-go/v3"
9+
"github.com/inkyblackness/imgui-go/v4"
1010

1111
"github.com/inkyblackness/imgui-go-examples/internal/example"
1212
"github.com/inkyblackness/imgui-go-examples/internal/platforms"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require (
44
github.com/davecgh/go-spew v1.1.1 // indirect
55
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
66
github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72
7-
github.com/inkyblackness/imgui-go/v3 v3.0.0
7+
github.com/inkyblackness/imgui-go/v4 v4.0.1
88
github.com/veandco/go-sdl2 v0.4.0
99
)
1010

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluN
55
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
66
github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72 h1:LgLYrxDRSVv3kStk6louYTP1ekZ6t7HZY/X05KUyaeM=
77
github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
8-
github.com/inkyblackness/imgui-go/v3 v3.0.0 h1:+gOBA/xlr528SOGDteKQS+q7QkyBcOi+znhn18BMs/8=
9-
github.com/inkyblackness/imgui-go/v3 v3.0.0/go.mod h1:WdM5LZHuTrjd1d+yd2fA19t3mG538kJ6zOLB2sAXF6U=
8+
github.com/inkyblackness/imgui-go/v4 v4.0.1 h1:TzbdvkDsmuPQ6pEsDkOqFxhOyA0RLbP7r34yRnCUz6Q=
9+
github.com/inkyblackness/imgui-go/v4 v4.0.1/go.mod h1:g8SAGtOYUP7rYaOB2AsVKCEHmPMDmJKgt4z6d+flhb0=
1010
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1111
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1212
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

internal/demo/Window.go

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package demo
33
import (
44
"fmt"
55

6-
"github.com/inkyblackness/imgui-go/v3"
6+
"github.com/inkyblackness/imgui-go/v4"
77
)
88

99
type windowFlags struct {
@@ -18,8 +18,8 @@ type windowFlags struct {
1818
noBringToFront bool
1919
}
2020

21-
func (f windowFlags) combined() int {
22-
flags := 0
21+
func (f windowFlags) combined() imgui.WindowFlags {
22+
flags := imgui.WindowFlagsNone
2323
if f.noTitlebar {
2424
flags |= imgui.WindowFlagsNoTitleBar
2525
}
@@ -58,6 +58,7 @@ var window = struct {
5858
layout layout
5959
popups popups
6060
columns columns
61+
tables tables
6162
misc misc
6263
}{}
6364

@@ -153,6 +154,7 @@ func Show(keepOpen *bool) {
153154
window.layout.show()
154155
window.popups.show()
155156
window.columns.show()
157+
window.tables.show()
156158
window.misc.show()
157159

158160
// End of ShowDemoWindow()
@@ -226,6 +228,102 @@ func (widgets *widgets) show() {
226228
}
227229
}
228230

231+
type tables struct {
232+
background bool
233+
borders bool
234+
noInnerBorders bool
235+
header bool
236+
}
237+
238+
var demoTableHeader = []string{
239+
"Name", "Favourite Food", "Favourite Colour",
240+
}
241+
242+
var demoTable = [][]string{
243+
{"Eric", "Bannana", "Yellow"},
244+
{"Peter", "Apple", "Red"},
245+
{"Bruce", "Liquorice", "Black"},
246+
{"Aaron", "Chocolates", "Blue"},
247+
}
248+
249+
func (tables *tables) show() {
250+
if !imgui.CollapsingHeader("Tables") {
251+
return
252+
}
253+
254+
if imgui.TreeNode("Rows & Columns") {
255+
if imgui.BeginTable("tableRowsAndColumns", 3) {
256+
for row := 0; row < 4; row++ {
257+
imgui.TableNextRow()
258+
for column := 0; column < 3; column++ {
259+
imgui.TableSetColumnIndex(column)
260+
imgui.Text(fmt.Sprintf("Row %d Column %d", row, column))
261+
}
262+
}
263+
imgui.EndTable()
264+
}
265+
imgui.TreePop()
266+
}
267+
268+
if imgui.TreeNode("Options") {
269+
// tables are useful for more than tabulated data. we use tables here
270+
// to facilitate layout of the option checkboxes
271+
if imgui.BeginTable("tableOptions", 2) {
272+
imgui.TableNextRow()
273+
if imgui.TableNextColumn() {
274+
imgui.Checkbox("Background", &tables.background)
275+
}
276+
if imgui.TableNextColumn() {
277+
imgui.Checkbox("Header Row", &tables.header)
278+
}
279+
280+
imgui.TableNextRow()
281+
if imgui.TableNextColumn() {
282+
imgui.Checkbox("Borders", &tables.borders)
283+
}
284+
if tables.borders {
285+
if imgui.TableNextColumn() {
286+
imgui.Checkbox("No Inner Borders", &tables.noInnerBorders)
287+
}
288+
}
289+
290+
imgui.EndTable()
291+
}
292+
293+
// set flags according to the options that have been selected
294+
flgs := imgui.TableFlagsNone
295+
if tables.background {
296+
flgs |= imgui.TableFlagsRowBg
297+
}
298+
if tables.borders {
299+
flgs |= imgui.TableFlagsBorders
300+
if tables.noInnerBorders {
301+
flgs |= imgui.TableFlagsNoBordersInBody
302+
}
303+
}
304+
305+
if imgui.BeginTableV("tableRowsAndColumns", len(demoTableHeader), flgs, imgui.Vec2{}, 0.0) {
306+
if tables.header {
307+
imgui.TableHeadersRow()
308+
for column := 0; column < len(demoTableHeader); column++ {
309+
imgui.TableSetColumnIndex(column)
310+
imgui.Text(demoTableHeader[column])
311+
}
312+
}
313+
314+
for row := 0; row < len(demoTable); row++ {
315+
imgui.TableNextRow()
316+
for column := 0; column < len(demoTableHeader); column++ {
317+
imgui.TableSetColumnIndex(column)
318+
imgui.Text(demoTable[row][column])
319+
}
320+
}
321+
imgui.EndTable()
322+
}
323+
imgui.TreePop()
324+
}
325+
}
326+
229327
type layout struct {
230328
}
231329

internal/example/Run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"time"
66

7-
"github.com/inkyblackness/imgui-go/v3"
7+
"github.com/inkyblackness/imgui-go/v4"
88

99
"github.com/inkyblackness/imgui-go-examples/internal/demo"
1010
)

0 commit comments

Comments
 (0)