diff --git a/Alignment.go b/Alignment.go index e9c0610a..27f552c5 100644 --- a/Alignment.go +++ b/Alignment.go @@ -4,7 +4,7 @@ import ( "fmt" "image" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // These constants holds information about where GetWidgetWidth should proceed their @@ -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 diff --git a/Canvas.go b/Canvas.go index 9873cfc3..b9584890 100644 --- a/Canvas.go +++ b/Canvas.go @@ -4,7 +4,7 @@ import ( "image" "image/color" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // Canvas represents imgui.DrawList @@ -27,96 +27,96 @@ type Canvas struct { // 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(). @@ -134,23 +134,23 @@ 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) { @@ -158,5 +158,5 @@ func (c *Canvas) AddImage(texture *Texture, pMin, pMax image.Point) { } 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.id, ToVec2(pMin), ToVec2(pMax), ToVec2(uvMin), ToVec2(uvMax), ColorToUint(col)) } diff --git a/ClickableWidgets.go b/ClickableWidgets.go index 56ddecab..86857a1c 100644 --- a/ClickableWidgets.go +++ b/ClickableWidgets.go @@ -5,7 +5,7 @@ import ( "image" "image/color" - "github.com/AllenDang/imgui-go" + imgui "github.com/AllenDang/cimgui-go" "golang.org/x/image/colornames" ) @@ -59,7 +59,7 @@ func (b *ButtonWidget) Size(width, height float32) *ButtonWidget { // Build implements Widget interface. func (b *ButtonWidget) Build() { if b.disabled { - imgui.BeginDisabled(true) + imgui.BeginDisabled() defer imgui.EndDisabled() } @@ -100,7 +100,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() } } @@ -224,10 +224,11 @@ func (b *ImageButtonWidget) Build() { } if imgui.ImageButtonV( + fmt.Sprintf("%v", b.texture.id), b.texture.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() @@ -401,7 +402,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() } } @@ -476,7 +477,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() } @@ -534,7 +535,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() diff --git a/CodeEditor.go b/CodeEditor.go index 34fc3ce3..8aa5d036 100644 --- a/CodeEditor.go +++ b/CodeEditor.go @@ -1,216 +1,249 @@ +// package giu +// +// import ( +// +// "fmt" +// +// "github.com/AllenDang/cimgui-go" +// +// ) +// +// // LanguageDefinition represents code editor's language definition. +// type LanguageDefinition byte +// +// // language definitions:. +// const ( +// +// LanguageDefinitionSQL LanguageDefinition = iota +// LanguageDefinitionCPP +// LanguageDefinitionLua +// LanguageDefinitionC +// +// ) +// +// var _ Disposable = &codeEditorState{} +// +// type codeEditorState struct { +// editor imgui.TextEditor +// } +// +// // Dispose implements Disposable interface. +// +// func (s *codeEditorState) Dispose() { +// // noop +// } +// +// // static check if code editor implements Widget interface. +// var _ Widget = &CodeEditorWidget{} +// +// // CodeEditorWidget represents imgui.TextEditor. +// +// type CodeEditorWidget struct { +// title string +// width, +// height float32 +// border bool +// } +// +// // CodeEditor creates new code editor widget. +// +// func CodeEditor() *CodeEditorWidget { +// return &CodeEditorWidget{ +// title: GenAutoID("##CodeEditor"), +// } +// } +// +// // ID allows to manually set editor's ID. +// // It isn't necessary to use it in a normal conditions. +// +// func (ce *CodeEditorWidget) ID(id string) *CodeEditorWidget { +// ce.title = id +// return ce +// } +// +// // ShowWhitespaces sets if whitespace is shown in code editor. +// +// func (ce *CodeEditorWidget) ShowWhitespaces(s bool) *CodeEditorWidget { +// ce.getState().editor.SetShowWhitespaces(s) +// return ce +// } +// +// // TabSize sets editor's tab size. +// +// func (ce *CodeEditorWidget) TabSize(size int) *CodeEditorWidget { +// ce.getState().editor.SetTabSize(size) +// return ce +// } +// +// // LanguageDefinition sets code editor language definition. +// +// func (ce *CodeEditorWidget) LanguageDefinition(definition LanguageDefinition) *CodeEditorWidget { +// s := ce.getState() +// lookup := map[LanguageDefinition]func(){ +// LanguageDefinitionSQL: s.editor.SetLanguageDefinitionSQL, +// LanguageDefinitionCPP: s.editor.SetLanguageDefinitionCPP, +// LanguageDefinitionLua: s.editor.SetLanguageDefinitionLua, +// LanguageDefinitionC: s.editor.SetLanguageDefinitionC, +// } +// +// setter, correctDefinition := lookup[definition] +// if !correctDefinition { +// panic(fmt.Sprintf("giu/CodeEditor.go: unknown language definition %d", definition)) +// } +// +// setter() +// +// return ce +// } +// +// // Text sets editor's text. +// +// func (ce *CodeEditorWidget) Text(str string) *CodeEditorWidget { +// ce.getState().editor.SetText(str) +// return ce +// } +// +// // ErrorMarkers sets error markers. +// +// func (ce *CodeEditorWidget) ErrorMarkers(markers imgui.ErrorMarkers) *CodeEditorWidget { +// ce.getState().editor.SetErrorMarkers(markers) +// return ce +// } +// +// // HandleKeyboardInputs sets if editor should handle keyboard input. +// +// func (ce *CodeEditorWidget) HandleKeyboardInputs(b bool) *CodeEditorWidget { +// ce.getState().editor.SetHandleKeyboardInputs(b) +// return ce +// } +// +// // Size sets editor's size. +// +// func (ce *CodeEditorWidget) Size(w, h float32) *CodeEditorWidget { +// ce.width, ce.height = w, h +// return ce +// } +// +// // Border sets editors borders. +// +// func (ce *CodeEditorWidget) Border(border bool) *CodeEditorWidget { +// ce.border = border +// return ce +// } +// +// // HasSelection returns true if some text is selected. +// +// func (ce *CodeEditorWidget) HasSelection() bool { +// return ce.getState().editor.HasSelection() +// } +// +// // GetSelectedText returns selected text. +// +// func (ce *CodeEditorWidget) GetSelectedText() string { +// return ce.getState().editor.GetSelectedText() +// } +// +// // GetText returns whole text from editor. +// +// func (ce *CodeEditorWidget) GetText() string { +// return ce.getState().editor.GetText() +// } +// +// // GetCurrentLineText returns current line. +// +// func (ce *CodeEditorWidget) GetCurrentLineText() string { +// return ce.getState().editor.GetCurrentLineText() +// } +// +// // GetCursorPos returns cursor position. +// // (in characters). +// +// func (ce *CodeEditorWidget) GetCursorPos() (x, y int) { +// return ce.getState().editor.GetCursorPos() +// } +// +// // GetSelectionStart returns star pos of selection. +// +// func (ce *CodeEditorWidget) GetSelectionStart() (x, y int) { +// return ce.getState().editor.GetSelectionStart() +// } +// +// // InsertText inserts the `text`. +// +// func (ce *CodeEditorWidget) InsertText(text string) { +// ce.getState().editor.InsertText(text) +// } +// +// // GetWordUnderCursor returns the word under the cursor. +// +// func (ce *CodeEditorWidget) GetWordUnderCursor() string { +// return ce.getState().editor.GetWordUnderCursor() +// } +// +// // SelectWordUnderCursor selects the word under cursor. +// +// func (ce *CodeEditorWidget) SelectWordUnderCursor() { +// ce.getState().editor.SelectWordUnderCursor() +// } +// +// // IsTextChanged returns true if the editable text was changed in the frame. +// +// func (ce *CodeEditorWidget) IsTextChanged() bool { +// return ce.getState().editor.IsTextChanged() +// } +// +// // GetScreenCursorPos returns cursor position on the screen. +// // (in pixels). +// +// func (ce *CodeEditorWidget) GetScreenCursorPos() (x, y int) { +// return ce.getState().editor.GetScreenCursorPos() +// } +// +// // Copy copies selection. +// +// func (ce *CodeEditorWidget) Copy() { +// ce.getState().editor.Copy() +// } +// +// // Cut cuts selection. +// +// func (ce *CodeEditorWidget) Cut() { +// ce.getState().editor.Cut() +// } +// +// // Paste does the same as Ctrl+V. +// +// func (ce *CodeEditorWidget) Paste() { +// ce.getState().editor.Paste() +// } +// +// // Delete deletes the selection. +// +// func (ce *CodeEditorWidget) Delete() { +// ce.getState().editor.Delete() +// } +// +// // Build implements Widget interface. +// +// func (ce *CodeEditorWidget) Build() { +// s := ce.getState() +// +// // register text in font atlas +// Context.FontAtlas.RegisterString(s.editor.GetText()) +// +// // build editor +// s.editor.Render(ce.title, imgui.Vec2{X: ce.width, Y: ce.height}, ce.border) +// } +// +// func (ce *CodeEditorWidget) getState() (state *codeEditorState) { +// if state = GetState[codeEditorState](Context, ce.title); state == nil { +// state = &codeEditorState{ +// editor: imgui.NewTextEditor(), +// } +// +// SetState(Context, ce.title, state) +// } +// +// return state +// } package giu - -import ( - "fmt" - - "github.com/AllenDang/imgui-go" -) - -// LanguageDefinition represents code editor's language definition. -type LanguageDefinition byte - -// language definitions:. -const ( - LanguageDefinitionSQL LanguageDefinition = iota - LanguageDefinitionCPP - LanguageDefinitionLua - LanguageDefinitionC -) - -var _ Disposable = &codeEditorState{} - -type codeEditorState struct { - editor imgui.TextEditor -} - -// Dispose implements Disposable interface. -func (s *codeEditorState) Dispose() { - // noop -} - -// static check if code editor implements Widget interface. -var _ Widget = &CodeEditorWidget{} - -// CodeEditorWidget represents imgui.TextEditor. -type CodeEditorWidget struct { - title string - width, - height float32 - border bool -} - -// CodeEditor creates new code editor widget. -func CodeEditor() *CodeEditorWidget { - return &CodeEditorWidget{ - title: GenAutoID("##CodeEditor"), - } -} - -// ID allows to manually set editor's ID. -// It isn't necessary to use it in a normal conditions. -func (ce *CodeEditorWidget) ID(id string) *CodeEditorWidget { - ce.title = id - return ce -} - -// ShowWhitespaces sets if whitespace is shown in code editor. -func (ce *CodeEditorWidget) ShowWhitespaces(s bool) *CodeEditorWidget { - ce.getState().editor.SetShowWhitespaces(s) - return ce -} - -// TabSize sets editor's tab size. -func (ce *CodeEditorWidget) TabSize(size int) *CodeEditorWidget { - ce.getState().editor.SetTabSize(size) - return ce -} - -// LanguageDefinition sets code editor language definition. -func (ce *CodeEditorWidget) LanguageDefinition(definition LanguageDefinition) *CodeEditorWidget { - s := ce.getState() - lookup := map[LanguageDefinition]func(){ - LanguageDefinitionSQL: s.editor.SetLanguageDefinitionSQL, - LanguageDefinitionCPP: s.editor.SetLanguageDefinitionCPP, - LanguageDefinitionLua: s.editor.SetLanguageDefinitionLua, - LanguageDefinitionC: s.editor.SetLanguageDefinitionC, - } - - setter, correctDefinition := lookup[definition] - if !correctDefinition { - panic(fmt.Sprintf("giu/CodeEditor.go: unknown language definition %d", definition)) - } - - setter() - - return ce -} - -// Text sets editor's text. -func (ce *CodeEditorWidget) Text(str string) *CodeEditorWidget { - ce.getState().editor.SetText(str) - return ce -} - -// ErrorMarkers sets error markers. -func (ce *CodeEditorWidget) ErrorMarkers(markers imgui.ErrorMarkers) *CodeEditorWidget { - ce.getState().editor.SetErrorMarkers(markers) - return ce -} - -// HandleKeyboardInputs sets if editor should handle keyboard input. -func (ce *CodeEditorWidget) HandleKeyboardInputs(b bool) *CodeEditorWidget { - ce.getState().editor.SetHandleKeyboardInputs(b) - return ce -} - -// Size sets editor's size. -func (ce *CodeEditorWidget) Size(w, h float32) *CodeEditorWidget { - ce.width, ce.height = w, h - return ce -} - -// Border sets editors borders. -func (ce *CodeEditorWidget) Border(border bool) *CodeEditorWidget { - ce.border = border - return ce -} - -// HasSelection returns true if some text is selected. -func (ce *CodeEditorWidget) HasSelection() bool { - return ce.getState().editor.HasSelection() -} - -// GetSelectedText returns selected text. -func (ce *CodeEditorWidget) GetSelectedText() string { - return ce.getState().editor.GetSelectedText() -} - -// GetText returns whole text from editor. -func (ce *CodeEditorWidget) GetText() string { - return ce.getState().editor.GetText() -} - -// GetCurrentLineText returns current line. -func (ce *CodeEditorWidget) GetCurrentLineText() string { - return ce.getState().editor.GetCurrentLineText() -} - -// GetCursorPos returns cursor position. -// (in characters). -func (ce *CodeEditorWidget) GetCursorPos() (x, y int) { - return ce.getState().editor.GetCursorPos() -} - -// GetSelectionStart returns star pos of selection. -func (ce *CodeEditorWidget) GetSelectionStart() (x, y int) { - return ce.getState().editor.GetSelectionStart() -} - -// InsertText inserts the `text`. -func (ce *CodeEditorWidget) InsertText(text string) { - ce.getState().editor.InsertText(text) -} - -// GetWordUnderCursor returns the word under the cursor. -func (ce *CodeEditorWidget) GetWordUnderCursor() string { - return ce.getState().editor.GetWordUnderCursor() -} - -// SelectWordUnderCursor selects the word under cursor. -func (ce *CodeEditorWidget) SelectWordUnderCursor() { - ce.getState().editor.SelectWordUnderCursor() -} - -// IsTextChanged returns true if the editable text was changed in the frame. -func (ce *CodeEditorWidget) IsTextChanged() bool { - return ce.getState().editor.IsTextChanged() -} - -// GetScreenCursorPos returns cursor position on the screen. -// (in pixels). -func (ce *CodeEditorWidget) GetScreenCursorPos() (x, y int) { - return ce.getState().editor.GetScreenCursorPos() -} - -// Copy copies selection. -func (ce *CodeEditorWidget) Copy() { - ce.getState().editor.Copy() -} - -// Cut cuts selection. -func (ce *CodeEditorWidget) Cut() { - ce.getState().editor.Cut() -} - -// Paste does the same as Ctrl+V. -func (ce *CodeEditorWidget) Paste() { - ce.getState().editor.Paste() -} - -// Delete deletes the selection. -func (ce *CodeEditorWidget) Delete() { - ce.getState().editor.Delete() -} - -// Build implements Widget interface. -func (ce *CodeEditorWidget) Build() { - s := ce.getState() - - // register text in font atlas - Context.FontAtlas.RegisterString(s.editor.GetText()) - - // build editor - s.editor.Render(ce.title, imgui.Vec2{X: ce.width, Y: ce.height}, ce.border) -} - -func (ce *CodeEditorWidget) getState() (state *codeEditorState) { - if state = GetState[codeEditorState](Context, ce.title); state == nil { - state = &codeEditorState{ - editor: imgui.NewTextEditor(), - } - - SetState(Context, ce.title, state) - } - - return state -} diff --git a/Context.go b/Context.go index 4d910b17..d4ea3c63 100644 --- a/Context.go +++ b/Context.go @@ -4,7 +4,7 @@ import ( "fmt" "sync" - "github.com/AllenDang/imgui-go" + imgui "github.com/AllenDang/cimgui-go" "gopkg.in/eapache/queue.v1" ) @@ -28,6 +28,8 @@ type state struct { } type context struct { + backend imgui.Backend + // TODO: should be handled by mainthread tbh // see https://github.com/faiface/mainthread/pull/4 isRunning bool @@ -48,9 +50,10 @@ type context struct { cssStylesheet cssStylesheet } -func CreateContext() *context { +func CreateContext(b imgui.Backend) *context { result := context{ cssStylesheet: make(cssStylesheet), + backend: b, } result.FontAtlas = newFontAtlas() @@ -59,8 +62,9 @@ func CreateContext() *context { if len(result.FontAtlas.defaultFonts) == 0 { io := result.IO() io.Fonts().AddFontDefault() - fontAtlas := io.Fonts().TextureDataRGBA32() - r.SetFontTexture(fontAtlas) + // TODO + //fontAtlas, _, _, _ := io.Fonts().GetTextureDataAsRGBA32() + // r.SetFontTexture(fontAtlas) } else { result.FontAtlas.shouldRebuildFontAtlas = true } diff --git a/Direction.go b/Direction.go index d8876771..24b68600 100644 --- a/Direction.go +++ b/Direction.go @@ -1,12 +1,14 @@ package giu +import imgui "github.com/AllenDang/cimgui-go" + // Direction represents a ArrowButton direction. -type Direction uint8 +type Direction imgui.Dir // directions. const ( - DirectionLeft Direction = iota - DirectionRight - DirectionUp - DirectionDown + DirectionLeft Direction = imgui.DirLeft + DirectionRight Direction = imgui.DirRight + DirectionUp Direction = imgui.DirUp + DirectionDown Direction = imgui.DirDown ) diff --git a/Events.go b/Events.go index 93f37760..14afe252 100644 --- a/Events.go +++ b/Events.go @@ -1,15 +1,15 @@ package giu -import "github.com/AllenDang/imgui-go" +import "github.com/AllenDang/cimgui-go" // MouseButton represents imgui.MouseButton. -type MouseButton int +type MouseButton imgui.MouseButton // mouse buttons. const ( - MouseButtonLeft MouseButton = 0 - MouseButtonRight MouseButton = 1 - MouseButtonMiddle MouseButton = 2 + MouseButtonLeft MouseButton = MouseButton(imgui.MouseButtonLeft) + MouseButtonRight MouseButton = MouseButton(imgui.MouseButtonRight) + MouseButtonMiddle MouseButton = MouseButton(imgui.MouseButtonMiddle) ) // IsItemHovered returns true if mouse is over the item. @@ -20,7 +20,7 @@ func IsItemHovered() bool { // IsItemClicked returns true if mouse is clicked // NOTE: if you're looking for clicking detection, see EventHandler.go. func IsItemClicked(mouseButton MouseButton) bool { - return imgui.IsItemClicked(int(mouseButton)) + return imgui.IsItemClickedV(imgui.MouseButton(mouseButton)) } // IsItemActive returns true if item is active. @@ -30,38 +30,38 @@ func IsItemActive() bool { // IsKeyDown returns true if key `key` is down. func IsKeyDown(key Key) bool { - return imgui.IsKeyDown(int(key)) + return imgui.IsKeyDownNil(imgui.Key(key)) } // IsKeyPressed returns true if key `key` is pressed. func IsKeyPressed(key Key) bool { - return imgui.IsKeyPressed(int(key)) + return imgui.IsKeyPressedBool(imgui.Key(key)) } // IsKeyReleased returns true if key `key` is released. func IsKeyReleased(key Key) bool { - return imgui.IsKeyReleased(int(key)) + return imgui.IsKeyReleasedNil(imgui.Key(key)) } // IsMouseDown returns true if mouse button `button` is down. func IsMouseDown(button MouseButton) bool { - return imgui.IsMouseDown(int(button)) + return imgui.IsMouseDownNil(imgui.MouseButton(button)) } // IsMouseClicked returns true if mouse button `button` is clicked // NOTE: if you're looking for clicking detection, see EventHandler.go. func IsMouseClicked(button MouseButton) bool { - return imgui.IsMouseClicked(int(button)) + return imgui.IsMouseClickedBool(imgui.MouseButton(button)) } // IsMouseReleased returns true if mouse button `button` is released. func IsMouseReleased(button MouseButton) bool { - return imgui.IsMouseReleased(int(button)) + return imgui.IsMouseReleasedNil(imgui.MouseButton(button)) } // IsMouseDoubleClicked returns true if mouse button `button` is double clicked. func IsMouseDoubleClicked(button MouseButton) bool { - return imgui.IsMouseDoubleClicked(int(button)) + return imgui.IsMouseDoubleClicked(imgui.MouseButton(button)) } // IsWindowAppearing returns true if window is appearing. @@ -77,10 +77,10 @@ func IsWindowCollapsed() bool { // IsWindowFocused returns true if window is focused // NOTE: see also (*Window).HasFocus and (*Window).BringToFront. func IsWindowFocused(flags FocusedFlags) bool { - return imgui.IsWindowFocused(int(flags)) + return imgui.IsWindowFocusedV(imgui.FocusedFlags(flags)) } // IsWindowHovered returns true if the window is hovered. func IsWindowHovered(flags HoveredFlags) bool { - return imgui.IsWindowHovered(int(flags)) + return imgui.IsWindowHoveredV(imgui.HoveredFlags(flags)) } diff --git a/ExtraWidgets.go b/ExtraWidgets.go index 44d06346..1c8fbdb1 100644 --- a/ExtraWidgets.go +++ b/ExtraWidgets.go @@ -5,7 +5,7 @@ import ( "image" "time" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) var _ Widget = &HSplitterWidget{} @@ -65,21 +65,20 @@ func (h *HSplitterWidget) Build() { ptMin := image.Pt(centerX-width/2, centerY-height/2) ptMax := image.Pt(centerX+width/2, centerY+height/2) - style := imgui.CurrentStyle() - c := Vec4ToRGBA(style.GetColor(imgui.StyleColorScrollbarGrab)) + c := Vec4ToRGBA(*imgui.StyleColorVec4(imgui.ColScrollbarGrab)) // Place a invisible button to capture event. imgui.InvisibleButton(h.id, imgui.Vec2{X: h.width, Y: h.height}) if imgui.IsItemActive() { - *(h.delta) = imgui.CurrentIO().GetMouseDelta().Y + *(h.delta) = imgui.CurrentIO().MouseDelta().Y } else { *(h.delta) = 0 } if imgui.IsItemHovered() { imgui.SetMouseCursor(imgui.MouseCursorResizeNS) - c = Vec4ToRGBA(style.GetColor(imgui.StyleColorScrollbarGrabActive)) + c = Vec4ToRGBA(*imgui.StyleColorVec4(imgui.ColScrollbarGrabActive)) } // Draw a line in the very center @@ -144,21 +143,20 @@ func (v *VSplitterWidget) Build() { ptMin := image.Pt(centerX-width/2, centerY-height/2) ptMax := image.Pt(centerX+width/2, centerY+height/2) - style := imgui.CurrentStyle() - c := Vec4ToRGBA(style.GetColor(imgui.StyleColorScrollbarGrab)) + c := Vec4ToRGBA(*imgui.StyleColorVec4(imgui.ColScrollbarGrab)) // Place a invisible button to capture event. imgui.InvisibleButton(v.id, imgui.Vec2{X: v.width, Y: v.height}) if imgui.IsItemActive() { - *(v.delta) = imgui.CurrentIO().GetMouseDelta().X + *(v.delta) = imgui.CurrentIO().MouseDelta().X } else { *(v.delta) = 0 } if imgui.IsItemHovered() { imgui.SetMouseCursor(imgui.MouseCursorResizeEW) - c = Vec4ToRGBA(style.GetColor(imgui.StyleColorScrollbarGrabActive)) + c = Vec4ToRGBA(*imgui.StyleColorVec4(imgui.ColScrollbarGrabActive)) } // Draw a line in the very center @@ -192,15 +190,15 @@ func (ttr *TreeTableRowWidget) Flags(flags TreeNodeFlags) *TreeTableRowWidget { // BuildTreeTableRow executes table row building steps. func (ttr *TreeTableRowWidget) BuildTreeTableRow() { - imgui.TableNextRow(0, 0) + imgui.TableNextRowV(0, 0) imgui.TableNextColumn() open := false if len(ttr.children) > 0 { - open = imgui.TreeNodeV(Context.FontAtlas.RegisterString(ttr.label), int(ttr.flags)) + open = imgui.TreeNodeExStrV(Context.FontAtlas.RegisterString(ttr.label), imgui.TreeNodeFlags(ttr.flags)) } else { ttr.flags |= TreeNodeFlagsLeaf | TreeNodeFlagsNoTreePushOnOpen - imgui.TreeNodeV(Context.FontAtlas.RegisterString(ttr.label), int(ttr.flags)) + imgui.TreeNodeExStrV(Context.FontAtlas.RegisterString(ttr.label), imgui.TreeNodeFlags(ttr.flags)) } for _, w := range ttr.layout { @@ -284,9 +282,9 @@ func (tt *TreeTableWidget) Build() { colCount = len(tt.rows[0].layout) + 1 } - if imgui.BeginTable(tt.id, colCount, imgui.TableFlags(tt.flags), tt.size, 0) { + if imgui.BeginTableV(tt.id, int32(colCount), imgui.TableFlags(tt.flags), tt.size, 0) { if tt.freezeColumn >= 0 && tt.freezeRow >= 0 { - imgui.TableSetupScrollFreeze(tt.freezeColumn, tt.freezeRow) + imgui.TableSetupScrollFreeze(int32(tt.freezeColumn), int32(tt.freezeRow)) } if len(tt.columns) > 0 { @@ -376,7 +374,7 @@ func (c *ConditionWidget) Build() { func RangeBuilder(id string, values []any, builder func(int, any) Widget) Layout { var layout Layout - layout = append(layout, Custom(func() { imgui.PushID(id) })) + layout = append(layout, Custom(func() { imgui.PushIDStr(id) })) if len(values) > 0 && builder != nil { for i, v := range values { @@ -470,9 +468,9 @@ func (l *ListBoxWidget) Build() { child := Child().Border(l.border).Size(l.width, l.height).Layout(Layout{ Custom(func() { clipper := imgui.NewListClipper() - defer clipper.Delete() + defer clipper.Destroy() - clipper.Begin(len(l.items)) + clipper.Begin(int32(len(l.items))) for clipper.Step() { for i := clipper.DisplayStart(); i < clipper.DisplayEnd(); i++ { @@ -582,7 +580,7 @@ func (d *DatePickerWidget) Build() { return } - imgui.PushID(d.id) + imgui.PushIDStr(d.id) defer imgui.PopID() if d.width > 0 { @@ -698,12 +696,12 @@ func (d *DatePickerWidget) getDaysGroups() (days [][]int) { func (d *DatePickerWidget) calendarField(day int) Widget { today := time.Now() - highlightColor := imgui.CurrentStyle().GetColor(imgui.StyleColorPlotHistogram) + highlightColor := imgui.StyleColorVec4(imgui.ColPlotHistogram) return Custom(func() { isToday := d.date.Year() == today.Year() && d.date.Month() == today.Month() && day == today.Day() if isToday { - imgui.PushStyleColor(imgui.StyleColorText, highlightColor) + imgui.PushStyleColorVec4(imgui.ColText, *highlightColor) } Selectable(fmt.Sprintf("%02d", day)).Selected(isToday).OnClick(func() { diff --git a/Flags.go b/Flags.go index eca9dfcc..62c8b49b 100644 --- a/Flags.go +++ b/Flags.go @@ -1,9 +1,9 @@ package giu -import "github.com/AllenDang/imgui-go" +import imgui "github.com/AllenDang/cimgui-go" // InputTextFlags represents input text flags. -type InputTextFlags int +type InputTextFlags imgui.InputTextFlags // input text flags. const ( @@ -38,7 +38,7 @@ const ( // InputTextFlagsNoHorizontalScroll disables following the cursor horizontally. InputTextFlagsNoHorizontalScroll InputTextFlags = imgui.InputTextFlagsNoHorizontalScroll // InputTextFlagsAlwaysInsertMode sets insert mode. - InputTextFlagsAlwaysInsertMode InputTextFlags = imgui.InputTextFlagsAlwaysInsertMode + // InputTextFlagsReadOnly sets read-only mode. InputTextFlagsReadOnly InputTextFlags = imgui.InputTextFlagsReadOnly // InputTextFlagsPassword sets password mode, display all characters as '*'. @@ -51,73 +51,73 @@ const ( ) // WindowFlags represents a window flags (see (*WindowWidget).Flags. -type WindowFlags int +type WindowFlags imgui.GLFWWindowFlags // window flags. const ( // WindowFlagsNone default = 0. - WindowFlagsNone WindowFlags = imgui.WindowFlagsNone + WindowFlagsNone WindowFlags = WindowFlags(imgui.WindowFlagsNone) // WindowFlagsNoTitleBar disables title-bar. - WindowFlagsNoTitleBar WindowFlags = imgui.WindowFlagsNoTitleBar + WindowFlagsNoTitleBar WindowFlags = WindowFlags(imgui.WindowFlagsNoTitleBar) // WindowFlagsNoResize disables user resizing with the lower-right grip. - WindowFlagsNoResize WindowFlags = imgui.WindowFlagsNoResize + WindowFlagsNoResize WindowFlags = WindowFlags(imgui.WindowFlagsNoResize) // WindowFlagsNoMove disables user moving the window. - WindowFlagsNoMove WindowFlags = imgui.WindowFlagsNoMove + WindowFlagsNoMove WindowFlags = WindowFlags(imgui.WindowFlagsNoMove) // WindowFlagsNoScrollbar disables scrollbars. Window can still scroll with mouse or programmatically. - WindowFlagsNoScrollbar WindowFlags = imgui.WindowFlagsNoScrollbar + WindowFlagsNoScrollbar WindowFlags = WindowFlags(imgui.WindowFlagsNoScrollbar) // WindowFlagsNoScrollWithMouse disables user vertically scrolling with mouse wheel. On child window, mouse wheel // will be forwarded to the parent unless NoScrollbar is also set. - WindowFlagsNoScrollWithMouse WindowFlags = imgui.WindowFlagsNoScrollWithMouse + WindowFlagsNoScrollWithMouse WindowFlags = WindowFlags(imgui.WindowFlagsNoScrollWithMouse) // WindowFlagsNoCollapse disables user collapsing window by double-clicking on it. - WindowFlagsNoCollapse WindowFlags = imgui.WindowFlagsNoCollapse + WindowFlagsNoCollapse WindowFlags = WindowFlags(imgui.WindowFlagsNoCollapse) // WindowFlagsAlwaysAutoResize resizes every window to its content every frame. - WindowFlagsAlwaysAutoResize WindowFlags = imgui.WindowFlagsAlwaysAutoResize + WindowFlagsAlwaysAutoResize WindowFlags = WindowFlags(imgui.WindowFlagsAlwaysAutoResize) // WindowFlagsNoBackground disables drawing background color (WindowBg, etc.) and outside border. Similar as using // SetNextWindowBgAlpha(0.0f). - WindowFlagsNoBackground WindowFlags = imgui.WindowFlagsNoBackground + WindowFlagsNoBackground WindowFlags = WindowFlags(imgui.WindowFlagsNoBackground) // WindowFlagsNoSavedSettings will never load/save settings in .ini file. - WindowFlagsNoSavedSettings WindowFlags = imgui.WindowFlagsNoSavedSettings + WindowFlagsNoSavedSettings WindowFlags = WindowFlags(imgui.WindowFlagsNoSavedSettings) // WindowFlagsNoMouseInputs disables catching mouse, hovering test with pass through. - WindowFlagsNoMouseInputs WindowFlags = imgui.WindowFlagsNoMouseInputs + WindowFlagsNoMouseInputs WindowFlags = WindowFlags(imgui.WindowFlagsNoMouseInputs) // WindowFlagsMenuBar has a menu-bar. - WindowFlagsMenuBar WindowFlags = imgui.WindowFlagsMenuBar + WindowFlagsMenuBar WindowFlags = WindowFlags(imgui.WindowFlagsMenuBar) // WindowFlagsHorizontalScrollbar allows horizontal scrollbar to appear (off by default). You may use // SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo // in the "Horizontal Scrolling" section. - WindowFlagsHorizontalScrollbar WindowFlags = imgui.WindowFlagsHorizontalScrollbar + WindowFlagsHorizontalScrollbar WindowFlags = WindowFlags(imgui.WindowFlagsHorizontalScrollbar) // WindowFlagsNoFocusOnAppearing disables taking focus when transitioning from hidden to visible state. - WindowFlagsNoFocusOnAppearing WindowFlags = imgui.WindowFlagsNoFocusOnAppearing + WindowFlagsNoFocusOnAppearing WindowFlags = WindowFlags(imgui.WindowFlagsNoFocusOnAppearing) // WindowFlagsNoBringToFrontOnFocus disables bringing window to front when taking focus. e.g. clicking on it or // programmatically giving it focus. - WindowFlagsNoBringToFrontOnFocus WindowFlags = imgui.WindowFlagsNoBringToFrontOnFocus + WindowFlagsNoBringToFrontOnFocus WindowFlags = WindowFlags(imgui.WindowFlagsNoBringToFrontOnFocus) // WindowFlagsAlwaysVerticalScrollbar always shows vertical scrollbar, even if ContentSize.y < Size.y . - WindowFlagsAlwaysVerticalScrollbar WindowFlags = imgui.WindowFlagsAlwaysVerticalScrollbar + WindowFlagsAlwaysVerticalScrollbar WindowFlags = WindowFlags(imgui.WindowFlagsAlwaysVerticalScrollbar) // WindowFlagsAlwaysHorizontalScrollbar always shows horizontal scrollbar, even if ContentSize.x < Size.x . - WindowFlagsAlwaysHorizontalScrollbar WindowFlags = imgui.WindowFlagsAlwaysHorizontalScrollbar + 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 = imgui.WindowFlagsAlwaysUseWindowPadding + WindowFlagsAlwaysUseWindowPadding WindowFlags = WindowFlags(imgui.WindowFlagsAlwaysUseWindowPadding) // WindowFlagsNoNavInputs has no gamepad/keyboard navigation within the window. - WindowFlagsNoNavInputs WindowFlags = imgui.WindowFlagsNoNavInputs + WindowFlagsNoNavInputs WindowFlags = WindowFlags(imgui.WindowFlagsNoNavInputs) // WindowFlagsNoNavFocus has no focusing toward this window with gamepad/keyboard navigation // (e.g. skipped by CTRL+TAB). - WindowFlagsNoNavFocus WindowFlags = imgui.WindowFlagsNoNavFocus + WindowFlagsNoNavFocus WindowFlags = WindowFlags(imgui.WindowFlagsNoNavFocus) // WindowFlagsUnsavedDocument appends '*' to title without affecting the ID, as a convenience to avoid using the // ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one // frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker. - WindowFlagsUnsavedDocument WindowFlags = imgui.WindowFlagsUnsavedDocument + WindowFlagsUnsavedDocument WindowFlags = WindowFlags(imgui.WindowFlagsUnsavedDocument) // WindowFlagsNoNav combines WindowFlagsNoNavInputs and WindowFlagsNoNavFocus. - WindowFlagsNoNav WindowFlags = imgui.WindowFlagsNoNav + WindowFlagsNoNav WindowFlags = WindowFlags(imgui.WindowFlagsNoNav) // WindowFlagsNoDecoration combines WindowFlagsNoTitleBar, WindowFlagsNoResize, WindowFlagsNoScrollbar and // WindowFlagsNoCollapse. - WindowFlagsNoDecoration WindowFlags = imgui.WindowFlagsNoDecoration + WindowFlagsNoDecoration WindowFlags = WindowFlags(imgui.WindowFlagsNoDecoration) // WindowFlagsNoInputs combines WindowFlagsNoMouseInputs, WindowFlagsNoNavInputs and WindowFlagsNoNavFocus. - WindowFlagsNoInputs WindowFlags = imgui.WindowFlagsNoInputs + WindowFlagsNoInputs WindowFlags = WindowFlags(imgui.WindowFlagsNoInputs) ) // ComboFlags represents imgui.ComboFlags. -type ComboFlags int +type ComboFlags imgui.ComboFlags // combo flags list. const ( @@ -141,7 +141,7 @@ const ( ) // SelectableFlags represents imgui.SelectableFlags. -type SelectableFlags int +type SelectableFlags imgui.SelectableFlags // selectable flags list. const ( @@ -158,7 +158,7 @@ const ( ) // TabItemFlags represents tab item flags. -type TabItemFlags int +type TabItemFlags imgui.TabItemFlags // tab item flags list. const ( @@ -175,11 +175,11 @@ const ( // (IsItemHovered() && IsMouseClicked(2)) *p_open = false. TabItemFlagsNoCloseWithMiddleMouseButton TabItemFlags = imgui.TabItemFlagsNoCloseWithMiddleMouseButton // TabItemFlagsNoPushID Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem(). - TabItemFlagsNoPushID TabItemFlags = imgui.TabItemFlagsNoPushID + ) // TabBarFlags represents imgui.TabBarFlags. -type TabBarFlags int +type TabBarFlags imgui.TabBarFlags // tab bar flags list. const ( @@ -212,7 +212,7 @@ const ( ) // TreeNodeFlags represents tree node widget flags. -type TreeNodeFlags int +type TreeNodeFlags imgui.TreeNodeFlags // tree node flags list. const ( @@ -259,7 +259,7 @@ const ( ) // FocusedFlags represents imgui.FocusedFlags. -type FocusedFlags int +type FocusedFlags imgui.FocusedFlags // focused flags list. const ( @@ -273,7 +273,7 @@ const ( ) // HoveredFlags represents a hovered flags. -type HoveredFlags int +type HoveredFlags imgui.HoveredFlags // hovered flags list. const ( @@ -302,202 +302,219 @@ type ColorEditFlags int // list of color edit flags. const ( - // ColorEditFlagsNone default = 0. - ColorEditFlagsNone ColorEditFlags = imgui.ColorEditFlagsNone - // ColorEditFlagsNoAlpha ignores Alpha component (read 3 components from the input pointer). - ColorEditFlagsNoAlpha ColorEditFlags = imgui.ColorEditFlagsNoAlpha - // ColorEditFlagsNoPicker disables picker when clicking on colored square. - ColorEditFlagsNoPicker ColorEditFlags = imgui.ColorEditFlagsNoPicker - // ColorEditFlagsNoOptions disables toggling options menu when right-clicking on inputs/small preview. - ColorEditFlagsNoOptions ColorEditFlags = imgui.ColorEditFlagsNoOptions - // ColorEditFlagsNoSmallPreview disables colored square preview next to the inputs. (e.g. to show only the inputs). - ColorEditFlagsNoSmallPreview ColorEditFlags = imgui.ColorEditFlagsNoSmallPreview - // ColorEditFlagsNoInputs disables inputs sliders/text widgets (e.g. to show only the small preview colored square). - ColorEditFlagsNoInputs ColorEditFlags = imgui.ColorEditFlagsNoInputs - // ColorEditFlagsNoTooltip disables tooltip when hovering the preview. - ColorEditFlagsNoTooltip ColorEditFlags = imgui.ColorEditFlagsNoTooltip - // ColorEditFlagsNoLabel disables display of inline text label (the label is still forwarded to the tooltip and picker). - ColorEditFlagsNoLabel ColorEditFlags = imgui.ColorEditFlagsNoLabel - // ColorEditFlagsNoDragDrop disables drag and drop target. ColorButton: disable drag and drop source. - ColorEditFlagsNoDragDrop ColorEditFlags = imgui.ColorEditFlagsNoDragDrop - - // User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). - // The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() - // during startup. - - // ColorEditFlagsAlphaBar shows vertical alpha bar/gradient in picker. - ColorEditFlagsAlphaBar ColorEditFlags = imgui.ColorEditFlagsAlphaBar - // ColorEditFlagsAlphaPreview displays preview as a transparent color over a checkerboard, instead of opaque. - ColorEditFlagsAlphaPreview ColorEditFlags = imgui.ColorEditFlagsAlphaPreview - // ColorEditFlagsAlphaPreviewHalf displays half opaque / half checkerboard, instead of opaque. - ColorEditFlagsAlphaPreviewHalf ColorEditFlags = imgui.ColorEditFlagsAlphaPreviewHalf - // ColorEditFlagsHDR = (WIP) currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use - // ImGuiColorEditFlags_Float flag as well). - ColorEditFlagsHDR ColorEditFlags = imgui.ColorEditFlagsHDR - // ColorEditFlagsRGB sets the format as RGB. - ColorEditFlagsRGB ColorEditFlags = imgui.ColorEditFlagsRGB - // ColorEditFlagsHSV sets the format as HSV. - ColorEditFlagsHSV ColorEditFlags = imgui.ColorEditFlagsHSV - // ColorEditFlagsHEX sets the format as HEX. - ColorEditFlagsHEX ColorEditFlags = imgui.ColorEditFlagsHEX - // ColorEditFlagsUint8 _display_ values formatted as 0..255. - ColorEditFlagsUint8 ColorEditFlags = imgui.ColorEditFlagsUint8 - // ColorEditFlagsFloat _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers. - ColorEditFlagsFloat ColorEditFlags = imgui.ColorEditFlagsFloat +// // ColorEditFlagsNone default = 0. +// ColorEditFlagsNone ColorEditFlags = imgui.ColorEditFlagsNone +// ColorEditFlagsNoAlpha ignores Alpha component (read 3 components from the input pointer). +// ColorEditFlagsNoAlpha ColorEditFlags = imgui.ColorEditFlagsNoAlpha +// ColorEditFlagsNoPicker disables picker when clicking on colored square. +// ColorEditFlagsNoPicker ColorEditFlags = imgui.ColorEditFlagsNoPicker +// ColorEditFlagsNoOptions disables toggling options menu when right-clicking on inputs/small preview. +// ColorEditFlagsNoOptions ColorEditFlags = imgui.ColorEditFlagsNoOptions +// ColorEditFlagsNoSmallPreview disables colored square preview next to the inputs. (e.g. to show only the inputs). +// ColorEditFlagsNoSmallPreview ColorEditFlags = imgui.ColorEditFlagsNoSmallPreview +// ColorEditFlagsNoInputs disables inputs sliders/text widgets (e.g. to show only the small preview colored square). +// ColorEditFlagsNoInputs ColorEditFlags = imgui.ColorEditFlagsNoInputs +// ColorEditFlagsNoTooltip disables tooltip when hovering the preview. +// ColorEditFlagsNoTooltip ColorEditFlags = imgui.ColorEditFlagsNoTooltip +// ColorEditFlagsNoLabel disables display of inline text label (the label is still forwarded to the tooltip and picker). +// ColorEditFlagsNoLabel ColorEditFlags = imgui.ColorEditFlagsNoLabel +// ColorEditFlagsNoDragDrop disables drag and drop target. ColorButton: disable drag and drop source. +// ColorEditFlagsNoDragDrop ColorEditFlags = imgui.ColorEditFlagsNoDragDrop + +// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). +// The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() +// during startup. + +// ColorEditFlagsAlphaBar shows vertical alpha bar/gradient in picker. +// +// ColorEditFlagsAlphaBar ColorEditFlags = imgui.ColorEditFlagsAlphaBar +// +// ColorEditFlagsAlphaPreview displays preview as a transparent color over a checkerboard, instead of opaque. +// +// ColorEditFlagsAlphaPreview ColorEditFlags = imgui.ColorEditFlagsAlphaPreview +// +// ColorEditFlagsAlphaPreviewHalf displays half opaque / half checkerboard, instead of opaque. +// +// ColorEditFlagsAlphaPreviewHalf ColorEditFlags = imgui.ColorEditFlagsAlphaPreviewHalf +// // ColorEditFlagsHDR = (WIP) currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use +// +// ImGuiColorEditFlags_Float flag as well). +// +// ColorEditFlagsHDR ColorEditFlags = imgui.ColorEditFlagsHDR +// +// ColorEditFlagsRGB sets the format as RGB. +// +// ColorEditFlagsRGB ColorEditFlags = imgui.ColorEditFlagsRGB +// +// ColorEditFlagsHSV sets the format as HSV. +// +// ColorEditFlagsHSV ColorEditFlags = imgui.ColorEditFlagsHSV +// +// ColorEditFlagsHEX sets the format as HEX. +// +// ColorEditFlagsHEX ColorEditFlags = imgui.ColorEditFlagsHEX +// +// ColorEditFlagsUint8 _display_ values formatted as 0..255. +// +// ColorEditFlagsUint8 ColorEditFlags = imgui.ColorEditFlagsUint8 +// +// ColorEditFlagsFloat _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers. +// +// ColorEditFlagsFloat ColorEditFlags = imgui.ColorEditFlagsFloat ) // TableFlags represents table flags. -type TableFlags int +type TableFlags imgui.TableFlags // Table flags enum:. const ( - TableFlagsNone TableFlags = TableFlags(imgui.TableFlags_None) - TableFlagsResizable TableFlags = TableFlags(imgui.TableFlags_Resizable) - TableFlagsReorderable TableFlags = TableFlags(imgui.TableFlags_Reorderable) - TableFlagsHideable TableFlags = TableFlags(imgui.TableFlags_Hideable) - TableFlagsSortable TableFlags = TableFlags(imgui.TableFlags_Sortable) - TableFlagsNoSavedSettings TableFlags = TableFlags(imgui.TableFlags_NoSavedSettings) - TableFlagsContextMenuInBody TableFlags = TableFlags(imgui.TableFlags_ContextMenuInBody) - TableFlagsRowBg TableFlags = TableFlags(imgui.TableFlags_RowBg) - TableFlagsBordersInnerH TableFlags = TableFlags(imgui.TableFlags_BordersInnerH) - TableFlagsBordersOuterH TableFlags = TableFlags(imgui.TableFlags_BordersOuterH) - TableFlagsBordersInnerV TableFlags = TableFlags(imgui.TableFlags_BordersInnerV) - TableFlagsBordersOuterV TableFlags = TableFlags(imgui.TableFlags_BordersOuterV) - TableFlagsBordersH TableFlags = TableFlags(imgui.TableFlags_BordersH) - TableFlagsBordersV TableFlags = TableFlags(imgui.TableFlags_BordersV) - TableFlagsBordersInner TableFlags = TableFlags(imgui.TableFlags_BordersInner) - TableFlagsBordersOuter TableFlags = TableFlags(imgui.TableFlags_BordersOuter) - TableFlagsBorders TableFlags = TableFlags(imgui.TableFlags_Borders) - TableFlagsNoBordersInBody TableFlags = TableFlags(imgui.TableFlags_NoBordersInBody) - TableFlagsNoBordersInBodyUntilResize TableFlags = TableFlags(imgui.TableFlags_NoBordersInBodyUntilResizeTableFlags) - TableFlagsSizingFixedFit TableFlags = TableFlags(imgui.TableFlags_SizingFixedFit) - TableFlagsSizingFixedSame TableFlags = TableFlags(imgui.TableFlags_SizingFixedSame) - TableFlagsSizingStretchProp TableFlags = TableFlags(imgui.TableFlags_SizingStretchProp) - TableFlagsSizingStretchSame TableFlags = TableFlags(imgui.TableFlags_SizingStretchSame) - TableFlagsNoHostExtendX TableFlags = TableFlags(imgui.TableFlags_NoHostExtendX) - TableFlagsNoHostExtendY TableFlags = TableFlags(imgui.TableFlags_NoHostExtendY) - TableFlagsNoKeepColumnsVisible TableFlags = TableFlags(imgui.TableFlags_NoKeepColumnsVisible) - TableFlagsPreciseWidths TableFlags = TableFlags(imgui.TableFlags_PreciseWidths) - TableFlagsNoClip TableFlags = TableFlags(imgui.TableFlags_NoClip) - TableFlagsPadOuterX TableFlags = TableFlags(imgui.TableFlags_PadOuterX) - TableFlagsNoPadOuterX TableFlags = TableFlags(imgui.TableFlags_NoPadOuterX) - TableFlagsNoPadInnerX TableFlags = TableFlags(imgui.TableFlags_NoPadInnerX) - TableFlagsScrollX TableFlags = TableFlags(imgui.TableFlags_ScrollX) - TableFlagsScrollY TableFlags = TableFlags(imgui.TableFlags_ScrollY) - TableFlagsSortMulti TableFlags = TableFlags(imgui.TableFlags_SortMulti) - TableFlagsSortTristate TableFlags = TableFlags(imgui.TableFlags_SortTristate) - TableFlagsSizingMask TableFlags = TableFlags(imgui.TableFlags_SizingMask_) + TableFlagsNone TableFlags = TableFlags(imgui.TableFlagsNone) + TableFlagsResizable TableFlags = TableFlags(imgui.TableFlagsResizable) + TableFlagsReorderable TableFlags = TableFlags(imgui.TableFlagsReorderable) + TableFlagsHideable TableFlags = TableFlags(imgui.TableFlagsHideable) + TableFlagsSortable TableFlags = TableFlags(imgui.TableFlagsSortable) + TableFlagsNoSavedSettings TableFlags = TableFlags(imgui.TableFlagsNoSavedSettings) + TableFlagsContextMenuInBody TableFlags = TableFlags(imgui.TableFlagsContextMenuInBody) + TableFlagsRowBg TableFlags = TableFlags(imgui.TableFlagsRowBg) + TableFlagsBordersInnerH TableFlags = TableFlags(imgui.TableFlagsBordersInnerH) + TableFlagsBordersOuterH TableFlags = TableFlags(imgui.TableFlagsBordersOuterH) + TableFlagsBordersInnerV TableFlags = TableFlags(imgui.TableFlagsBordersInnerV) + TableFlagsBordersOuterV TableFlags = TableFlags(imgui.TableFlagsBordersOuterV) + TableFlagsBordersH TableFlags = TableFlags(imgui.TableFlagsBordersH) + TableFlagsBordersV TableFlags = TableFlags(imgui.TableFlagsBordersV) + TableFlagsBordersInner TableFlags = TableFlags(imgui.TableFlagsBordersInner) + TableFlagsBordersOuter TableFlags = TableFlags(imgui.TableFlagsBordersOuter) + TableFlagsBorders TableFlags = TableFlags(imgui.TableFlagsBorders) + TableFlagsNoBordersInBody TableFlags = TableFlags(imgui.TableFlagsNoBordersInBody) + TableFlagsNoBordersInBodyUntilResize TableFlags = TableFlags(imgui.TableFlagsNoBordersInBodyUntilResize) + TableFlagsSizingFixedFit TableFlags = TableFlags(imgui.TableFlagsSizingFixedFit) + TableFlagsSizingFixedSame TableFlags = TableFlags(imgui.TableFlagsSizingFixedSame) + TableFlagsSizingStretchProp TableFlags = TableFlags(imgui.TableFlagsSizingStretchProp) + TableFlagsSizingStretchSame TableFlags = TableFlags(imgui.TableFlagsSizingStretchSame) + TableFlagsNoHostExtendX TableFlags = TableFlags(imgui.TableFlagsNoHostExtendX) + TableFlagsNoHostExtendY TableFlags = TableFlags(imgui.TableFlagsNoHostExtendY) + TableFlagsNoKeepColumnsVisible TableFlags = TableFlags(imgui.TableFlagsNoKeepColumnsVisible) + TableFlagsPreciseWidths TableFlags = TableFlags(imgui.TableFlagsPreciseWidths) + TableFlagsNoClip TableFlags = TableFlags(imgui.TableFlagsNoClip) + TableFlagsPadOuterX TableFlags = TableFlags(imgui.TableFlagsPadOuterX) + TableFlagsNoPadOuterX TableFlags = TableFlags(imgui.TableFlagsNoPadOuterX) + TableFlagsNoPadInnerX TableFlags = TableFlags(imgui.TableFlagsNoPadInnerX) + TableFlagsScrollX TableFlags = TableFlags(imgui.TableFlagsScrollX) + TableFlagsScrollY TableFlags = TableFlags(imgui.TableFlagsScrollY) + TableFlagsSortMulti TableFlags = TableFlags(imgui.TableFlagsSortMulti) + TableFlagsSortTristate TableFlags = TableFlags(imgui.TableFlagsSortTristate) + TableFlagsSizingMask TableFlags = TableFlags(imgui.TableFlagsSizingMask) ) // TableRowFlags represents table row flags. -type TableRowFlags int +type TableRowFlags imgui.TableRowFlags // table row flags:. const ( - TableRowFlagsNone TableRowFlags = TableRowFlags(imgui.TableRowFlags_None) + TableRowFlagsNone TableRowFlags = TableRowFlags(imgui.TableRowFlagsNone) // Identify header row (set default background color + width of its contents accounted different for auto column width). - TableRowFlagsHeaders TableRowFlags = TableRowFlags(imgui.TableRowFlags_Headers) + TableRowFlagsHeaders TableRowFlags = TableRowFlags(imgui.TableRowFlagsHeaders) ) // TableColumnFlags represents a flags for table column (see (*TableColumnWidget).Flags()). -type TableColumnFlags int +type TableColumnFlags imgui.TableColumnFlags // table column flags list. const ( // Input configuration flags. - TableColumnFlagsNone TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_None) - TableColumnFlagsDefaultHide TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_DefaultHide) - TableColumnFlagsDefaultSort TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_DefaultSort) - TableColumnFlagsWidthStretch TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_WidthStretch) - TableColumnFlagsWidthFixed TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_WidthFixed) - TableColumnFlagsNoResize TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoResize) - TableColumnFlagsNoReorder TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoReorder) - TableColumnFlagsNoHide TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoHide) - TableColumnFlagsNoClip TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoClip) - TableColumnFlagsNoSort TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoSort) - TableColumnFlagsNoSortAscending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoSortAscending) - TableColumnFlagsNoSortDescending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoSortDescending) - TableColumnFlagsNoHeaderWidth TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoHeaderWidth) - TableColumnFlagsPreferSortAscending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_PreferSortAscending) - TableColumnFlagsPreferSortDescending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_PreferSortDescending) - TableColumnFlagsIndentEnable TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IndentEnable) - TableColumnFlagsIndentDisable TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IndentDisable) + TableColumnFlagsNone TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNone) + TableColumnFlagsDefaultHide TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsDefaultHide) + TableColumnFlagsDefaultSort TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsDefaultSort) + TableColumnFlagsWidthStretch TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsWidthStretch) + TableColumnFlagsWidthFixed TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsWidthFixed) + TableColumnFlagsNoResize TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoResize) + TableColumnFlagsNoReorder TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoReorder) + TableColumnFlagsNoHide TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoHide) + TableColumnFlagsNoClip TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoClip) + TableColumnFlagsNoSort TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoSort) + TableColumnFlagsNoSortAscending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoSortAscending) + TableColumnFlagsNoSortDescending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoSortDescending) + TableColumnFlagsNoHeaderWidth TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoHeaderWidth) + TableColumnFlagsPreferSortAscending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsPreferSortAscending) + TableColumnFlagsPreferSortDescending TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsPreferSortDescending) + TableColumnFlagsIndentEnable TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIndentEnable) + TableColumnFlagsIndentDisable TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIndentDisable) // Output status flags read-only via TableGetColumnFlags(). - TableColumnFlagsIsEnabled TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsEnabled) - TableColumnFlagsIsVisible TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsVisible) - TableColumnFlagsIsSorted TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsSorted) - TableColumnFlagsIsHovered TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsHovered) + TableColumnFlagsIsEnabled TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIsEnabled) + TableColumnFlagsIsVisible TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIsVisible) + TableColumnFlagsIsSorted TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIsSorted) + TableColumnFlagsIsHovered TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIsHovered) // [Internal] Combinations and masks. - TableColumnFlagsWidthMask TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_WidthMask_) - TableColumnFlagsIndentMask TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IndentMask_) - TableColumnFlagsStatusMask TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_StatusMask_) - TableColumnFlagsNoDirectResize TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_NoDirectResize_) + TableColumnFlagsWidthMask TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsWidthMask) + TableColumnFlagsIndentMask TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsIndentMask) + TableColumnFlagsStatusMask TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsStatusMask) + TableColumnFlagsNoDirectResize TableColumnFlags = TableColumnFlags(imgui.TableColumnFlagsNoDirectResize) ) // SliderFlags represents imgui.SliderFlags // TODO: Hard-reffer to these constants. -type SliderFlags int +type SliderFlags imgui.SliderFlags // slider flags. const ( - SliderFlagsNone SliderFlags = 0 + SliderFlagsNone SliderFlags = imgui.SliderFlagsNone // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. - SliderFlagsAlwaysClamp SliderFlags = 1 << 4 - // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlagsNoRoundToFormat with this if using + SliderFlagsAlwaysClamp SliderFlags = imgui.SliderFlagsAlwaysClamp + // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlagsNoRoundToFormat SliderFlags = imgui.SliderFlagsNoRoundToFormat // a format-string with small amount of digits. - SliderFlagsLogarithmic SliderFlags = 1 << 5 + SliderFlagsLogarithmic SliderFlags = imgui.SliderFlagsLogarithmic // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits). - SliderFlagsNoRoundToFormat SliderFlags = 1 << 6 + SliderFlagsNoRoundToFormat SliderFlags = imgui.SliderFlagsNoRoundToFormat // Disable CTRL+Click or Enter key allowing to input text directly into the widget. - SliderFlagsNoInput SliderFlags = 1 << 7 + SliderFlagsNoInput SliderFlags = imgui.SliderFlagsNoInput // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast // to this enum, and will trigger an assert if needed. - SliderFlagsInvalidMask SliderFlags = 0x7000000F + SliderFlagsInvalidMask SliderFlags = imgui.SliderFlagsInvalidMask ) -// PlotFlags represents imgui.ImPlotFlags. -type PlotFlags int +// PlotFlags represents imgui.PlotFlags. +type PlotFlags imgui.PlotFlags // plot flags. const ( - PlotFlagsNone = PlotFlags(imgui.ImPlotFlags_None) - PlotFlagsNoTitle = PlotFlags(imgui.ImPlotFlags_NoTitle) - PlotFlagsNoLegend = PlotFlags(imgui.ImPlotFlags_NoLegend) - PlotFlagsNoMenus = PlotFlags(imgui.ImPlotFlags_NoMenus) - PlotFlagsNoBoxSelect = PlotFlags(imgui.ImPlotFlags_NoBoxSelect) - PlotFlagsNoMousePos = PlotFlags(imgui.ImPlotFlags_NoMousePos) - PlotFlagsNoHighlight = PlotFlags(imgui.ImPlotFlags_NoHighlight) - PlotFlagsNoChild = PlotFlags(imgui.ImPlotFlags_NoChild) - PlotFlagsEqual = PlotFlags(imgui.ImPlotFlags_Equal) - PlotFlagsYAxis2 = PlotFlags(imgui.ImPlotFlags_YAxis2) - PlotFlagsYAxis3 = PlotFlags(imgui.ImPlotFlags_YAxis3) - PlotFlagsQuery = PlotFlags(imgui.ImPlotFlags_Query) - PlotFlagsCrosshairs = PlotFlags(imgui.ImPlotFlags_Crosshairs) - PlotFlagsAntiAliased = PlotFlags(imgui.ImPlotFlags_AntiAliased) - PlotFlagsCanvasOnly = PlotFlags(imgui.ImPlotFlags_CanvasOnly) + PlotFlagsNone = PlotFlags(imgui.PlotFlagsNone) + PlotFlagsNoTitle = PlotFlags(imgui.PlotFlagsNoTitle) + PlotFlagsNoLegend = PlotFlags(imgui.PlotFlagsNoLegend) + PlotFlagsNoMenus = PlotFlags(imgui.PlotFlagsNoMenus) + PlotFlagsNoBoxSelect = PlotFlags(imgui.PlotFlagsNoBoxSelect) + // PlotFlagsNoMousePos = PlotFlags(imgui.PlotFlagsNoMousePos) + // PlotFlagsNoHighlight = PlotFlags(imgui.PlotFlagsNoHighlight) + PlotFlagsNoChild = PlotFlags(imgui.PlotFlagsNoChild) + PlotFlagsEqual = PlotFlags(imgui.PlotFlagsEqual) + // PlotFlagsYAxis2 = PlotFlags(imgui.PlotFlagsYAxis2) + // PlotFlagsYAxis3 = PlotFlags(imgui.PlotFlagsYAxis3) + // PlotFlagsQuery = PlotFlags(imgui.PlotFlagsQuery) + PlotFlagsCrosshairs = PlotFlags(imgui.PlotFlagsCrosshairs) + // PlotFlagsAntiAliased = PlotFlags(imgui.PlotFlagsAntiAliased) + PlotFlagsCanvasOnly = PlotFlags(imgui.PlotFlagsCanvasOnly) ) -// PlotAxisFlags represents imgui.ImPlotAxisFlags. -type PlotAxisFlags int +// PlotAxisFlags represents imgui.PlotAxisFlags. +type PlotAxisFlags imgui.PlotAxisFlags // plot axis flags. const ( - PlotAxisFlagsNone PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_None) - PlotAxisFlagsNoLabel PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_NoLabel) - PlotAxisFlagsNoGridLines PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_NoGridLines) - PlotAxisFlagsNoTickMarks PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_NoTickMarks) - PlotAxisFlagsNoTickLabels PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_NoTickLabels) - PlotAxisFlagsForeground PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_Foreground) - PlotAxisFlagsLogScale PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_LogScale) - PlotAxisFlagsTime PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_Time) - PlotAxisFlagsInvert PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_Invert) - PlotAxisFlagsNoInitialFit PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_NoInitialFit) - PlotAxisFlagsAutoFit PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_AutoFit) - PlotAxisFlagsRangeFit PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_RangeFit) - PlotAxisFlagsLockMin PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_LockMin) - PlotAxisFlagsLockMax PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_LockMax) - PlotAxisFlagsLock PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_Lock) - PlotAxisFlagsNoDecorations PlotAxisFlags = PlotAxisFlags(imgui.ImPlotAxisFlags_NoDecorations) + PlotAxisFlagsNone PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNone) + PlotAxisFlagsNoLabel PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoLabel) + PlotAxisFlagsNoGridLines PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoGridLines) + PlotAxisFlagsNoTickMarks PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoTickMarks) + PlotAxisFlagsNoTickLabels PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoTickLabels) + PlotAxisFlagsForeground PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsForeground) + // PlotAxisFlagsLogScale PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLogScale) + // PlotAxisFlagsTime PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsTime) + PlotAxisFlagsInvert PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsInvert) + PlotAxisFlagsNoInitialFit PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoInitialFit) + PlotAxisFlagsAutoFit PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsAutoFit) + PlotAxisFlagsRangeFit PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsRangeFit) + PlotAxisFlagsLockMin PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLockMin) + PlotAxisFlagsLockMax PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLockMax) + PlotAxisFlagsLock PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLock) + PlotAxisFlagsNoDecorations PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoDecorations) ) diff --git a/FontAtlasProsessor.go b/FontAtlasProsessor.go index a485bde6..a481d1b6 100644 --- a/FontAtlasProsessor.go +++ b/FontAtlasProsessor.go @@ -6,9 +6,10 @@ import ( "runtime" "strings" "sync" + "unsafe" + "github.com/AllenDang/cimgui-go" "github.com/AllenDang/go-findfont" - "github.com/AllenDang/imgui-go" ) const ( @@ -254,7 +255,7 @@ func (a *FontAtlas) rebuildFontAtlas() { return true }) - ranges := imgui.NewGlyphRanges() + ranges := imgui.NewGlyphRange() builder := imgui.NewFontGlyphRangesBuilder() // Because we pre-registered numbers, so default string map's length should greater then 11. @@ -278,14 +279,21 @@ func (a *FontAtlas) rebuildFontAtlas() { } // Scale font size with DPI scale factor - if runtime.GOOS == windows { - fontInfo.size *= Context.GetPlatform().GetContentScale() - } + // TODO + //if runtime.GOOS == windows { + // fontInfo.size *= Context.GetPlatform().GetContentScale() + //} if len(fontInfo.fontByte) == 0 { fonts.AddFontFromFileTTFV(fontInfo.fontPath, fontInfo.size, fontConfig, ranges.Data()) } else { - fonts.AddFontFromMemoryTTFV(fontInfo.fontByte, fontInfo.size, fontConfig, ranges.Data()) + fonts.AddFontFromMemoryTTFV( + unsafe.Pointer(&fontInfo.fontByte[0]), + int32(fontInfo.size), + 0, // TODO: validate + fontConfig, + ranges.Data(), + ) } } @@ -300,23 +308,36 @@ func (a *FontAtlas) rebuildFontAtlas() { // Add extra fonts for _, fontInfo := range a.extraFonts { // Scale font size with DPI scale factor - if runtime.GOOS == windows { - fontInfo.size *= Context.GetPlatform().GetContentScale() - } + // TODO + //if runtime.GOOS == windows { + // fontInfo.size *= Context.GetPlatform().GetContentScale() + //} // Store imgui.Font for PushFont var f imgui.Font if len(fontInfo.fontByte) == 0 { - f = fonts.AddFontFromFileTTFV(fontInfo.fontPath, fontInfo.size, imgui.DefaultFontConfig, ranges.Data()) + f = fonts.AddFontFromFileTTFV( + fontInfo.fontPath, + fontInfo.size, + 0, + ranges.Data(), + ) } else { - f = fonts.AddFontFromMemoryTTFV(fontInfo.fontByte, fontInfo.size, imgui.DefaultFontConfig, ranges.Data()) + f = fonts.AddFontFromMemoryTTFV( + unsafe.Pointer(&fontInfo.fontByte[0]), + int32(fontInfo.size), + 0, + 0, // TODO: in ref to imgui-go: `const DefaultFontConfig FontConfig = 0` + ranges.Data(), + ) } a.extraFontMap[fontInfo.String()] = &f } - fontTextureImg := fonts.TextureDataRGBA32() - Context.renderer.SetFontTexture(fontTextureImg) + // TODO + //fontTextureImg, _, _, _ := fonts.GetTextureDataAsRGBA32() + //Context.renderer.SetFontTexture(fontTextureImg) a.shouldRebuildFontAtlas = false } diff --git a/ImageWidgets.go b/ImageWidgets.go index b44df26f..bc5b495a 100644 --- a/ImageWidgets.go +++ b/ImageWidgets.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) var _ Widget = &ImageWidget{} @@ -66,8 +66,7 @@ func (i *ImageWidget) OnClick(cb func()) *ImageWidget { // Size sets image size. func (i *ImageWidget) Size(width, height float32) *ImageWidget { // Size image with DPI scaling - factor := Context.GetPlatform().GetContentScale() - i.width, i.height = width*factor, height*factor + i.width, i.height = width, height return i } @@ -298,13 +297,13 @@ func (i *ImageWithURLWidget) Size(width, height float32) *ImageWithURLWidget { // LayoutForLoading allows to set layout rendered while loading an image. func (i *ImageWithURLWidget) LayoutForLoading(widgets ...Widget) *ImageWithURLWidget { - i.whenLoading = Layout(widgets) + i.whenLoading = widgets return i } // LayoutForFailure allows to specify layout when image failed to download. func (i *ImageWithURLWidget) LayoutForFailure(widgets ...Widget) *ImageWithURLWidget { - i.whenFailure = Layout(widgets) + i.whenFailure = widgets return i } diff --git a/Keycode.go b/Keycode.go index a861814f..04c6ccc2 100644 --- a/Keycode.go +++ b/Keycode.go @@ -1,156 +1,161 @@ package giu -import "github.com/go-gl/glfw/v3.3/glfw" +import ( + imgui "github.com/AllenDang/cimgui-go" +) -// Key represents a glfw key. -type Key glfw.Key +// Key represents a imgui key. +type Key imgui.Key // These key codes are inspired by the USB HID Usage Tables v1.12 (p. 53-60), // but re-arranged to map to 7-bit ASCII for printable keys (function keys are // put in the 256+ range). const ( - KeyUnknown Key = Key(glfw.KeyUnknown) - KeySpace Key = Key(glfw.KeySpace) - KeyApostrophe Key = Key(glfw.KeyApostrophe) - KeyComma Key = Key(glfw.KeyComma) - KeyMinus Key = Key(glfw.KeyMinus) - KeyPeriod Key = Key(glfw.KeyPeriod) - KeySlash Key = Key(glfw.KeySlash) - Key0 Key = Key(glfw.Key0) - Key1 Key = Key(glfw.Key1) - Key2 Key = Key(glfw.Key2) - Key3 Key = Key(glfw.Key3) - Key4 Key = Key(glfw.Key4) - Key5 Key = Key(glfw.Key5) - Key6 Key = Key(glfw.Key6) - Key7 Key = Key(glfw.Key7) - Key8 Key = Key(glfw.Key8) - Key9 Key = Key(glfw.Key9) - KeySemicolon Key = Key(glfw.KeySemicolon) - KeyEqual Key = Key(glfw.KeyEqual) - KeyA Key = Key(glfw.KeyA) - KeyB Key = Key(glfw.KeyB) - KeyC Key = Key(glfw.KeyC) - KeyD Key = Key(glfw.KeyD) - KeyE Key = Key(glfw.KeyE) - KeyF Key = Key(glfw.KeyF) - KeyG Key = Key(glfw.KeyG) - KeyH Key = Key(glfw.KeyH) - KeyI Key = Key(glfw.KeyI) - KeyJ Key = Key(glfw.KeyJ) - KeyK Key = Key(glfw.KeyK) - KeyL Key = Key(glfw.KeyL) - KeyM Key = Key(glfw.KeyM) - KeyN Key = Key(glfw.KeyN) - KeyO Key = Key(glfw.KeyO) - KeyP Key = Key(glfw.KeyP) - KeyQ Key = Key(glfw.KeyQ) - KeyR Key = Key(glfw.KeyR) - KeyS Key = Key(glfw.KeyS) - KeyT Key = Key(glfw.KeyT) - KeyU Key = Key(glfw.KeyU) - KeyV Key = Key(glfw.KeyV) - KeyW Key = Key(glfw.KeyW) - KeyX Key = Key(glfw.KeyX) - KeyY Key = Key(glfw.KeyY) - KeyZ Key = Key(glfw.KeyZ) - KeyLeftBracket Key = Key(glfw.KeyLeftBracket) - KeyBackslash Key = Key(glfw.KeyBackslash) - KeyRightBracket Key = Key(glfw.KeyRightBracket) - KeyGraveAccent Key = Key(glfw.KeyGraveAccent) - KeyWorld1 Key = Key(glfw.KeyWorld1) - KeyWorld2 Key = Key(glfw.KeyWorld2) - KeyEscape Key = Key(glfw.KeyEscape) - KeyEnter Key = Key(glfw.KeyEnter) - KeyTab Key = Key(glfw.KeyTab) - KeyBackspace Key = Key(glfw.KeyBackspace) - KeyInsert Key = Key(glfw.KeyInsert) - KeyDelete Key = Key(glfw.KeyDelete) - KeyRight Key = Key(glfw.KeyRight) - KeyLeft Key = Key(glfw.KeyLeft) - KeyDown Key = Key(glfw.KeyDown) - KeyUp Key = Key(glfw.KeyUp) - KeyPageUp Key = Key(glfw.KeyPageUp) - KeyPageDown Key = Key(glfw.KeyPageDown) - KeyHome Key = Key(glfw.KeyHome) - KeyEnd Key = Key(glfw.KeyEnd) - KeyCapsLock Key = Key(glfw.KeyCapsLock) - KeyScrollLock Key = Key(glfw.KeyScrollLock) - KeyNumLock Key = Key(glfw.KeyNumLock) - KeyPrintScreen Key = Key(glfw.KeyPrintScreen) - KeyPause Key = Key(glfw.KeyPause) - KeyF1 Key = Key(glfw.KeyF1) - KeyF2 Key = Key(glfw.KeyF2) - KeyF3 Key = Key(glfw.KeyF3) - KeyF4 Key = Key(glfw.KeyF4) - KeyF5 Key = Key(glfw.KeyF5) - KeyF6 Key = Key(glfw.KeyF6) - KeyF7 Key = Key(glfw.KeyF7) - KeyF8 Key = Key(glfw.KeyF8) - KeyF9 Key = Key(glfw.KeyF9) - KeyF10 Key = Key(glfw.KeyF10) - KeyF11 Key = Key(glfw.KeyF11) - KeyF12 Key = Key(glfw.KeyF12) - KeyF13 Key = Key(glfw.KeyF13) - KeyF14 Key = Key(glfw.KeyF14) - KeyF15 Key = Key(glfw.KeyF15) - KeyF16 Key = Key(glfw.KeyF16) - KeyF17 Key = Key(glfw.KeyF17) - KeyF18 Key = Key(glfw.KeyF18) - KeyF19 Key = Key(glfw.KeyF19) - KeyF20 Key = Key(glfw.KeyF20) - KeyF21 Key = Key(glfw.KeyF21) - KeyF22 Key = Key(glfw.KeyF22) - KeyF23 Key = Key(glfw.KeyF23) - KeyF24 Key = Key(glfw.KeyF24) - KeyF25 Key = Key(glfw.KeyF25) - KeyKP0 Key = Key(glfw.KeyKP0) - KeyKP1 Key = Key(glfw.KeyKP1) - KeyKP2 Key = Key(glfw.KeyKP2) - KeyKP3 Key = Key(glfw.KeyKP3) - KeyKP4 Key = Key(glfw.KeyKP4) - KeyKP5 Key = Key(glfw.KeyKP5) - KeyKP6 Key = Key(glfw.KeyKP6) - KeyKP7 Key = Key(glfw.KeyKP7) - KeyKP8 Key = Key(glfw.KeyKP8) - KeyKP9 Key = Key(glfw.KeyKP9) - KeyKPDecimal Key = Key(glfw.KeyKPDecimal) - KeyKPDivide Key = Key(glfw.KeyKPDivide) - KeyKPMultiply Key = Key(glfw.KeyKPMultiply) - KeyKPSubtract Key = Key(glfw.KeyKPSubtract) - KeyKPAdd Key = Key(glfw.KeyKPAdd) - KeyKPEnter Key = Key(glfw.KeyKPEnter) - KeyKPEqual Key = Key(glfw.KeyKPEqual) - KeyLeftShift Key = Key(glfw.KeyLeftShift) - KeyLeftControl Key = Key(glfw.KeyLeftControl) - KeyLeftAlt Key = Key(glfw.KeyLeftAlt) - KeyLeftSuper Key = Key(glfw.KeyLeftSuper) - KeyRightShift Key = Key(glfw.KeyRightShift) - KeyRightControl Key = Key(glfw.KeyRightControl) - KeyRightAlt Key = Key(glfw.KeyRightAlt) - KeyRightSuper Key = Key(glfw.KeyRightSuper) - KeyMenu Key = Key(glfw.KeyMenu) - KeyLast Key = Key(glfw.KeyLast) + KeyNone Key = Key(imgui.KeyNone) + KeyUnknown = KeyNone // DEPRECATED: since cimgui-go migration use KeyNone + KeySpace Key = Key(imgui.KeySpace) + KeyApostrophe Key = Key(imgui.KeyApostrophe) + KeyComma Key = Key(imgui.KeyComma) + KeyMinus Key = Key(imgui.KeyMinus) + KeyPeriod Key = Key(imgui.KeyPeriod) + KeySlash Key = Key(imgui.KeySlash) + Key0 Key = Key(imgui.Key0) + Key1 Key = Key(imgui.Key1) + Key2 Key = Key(imgui.Key2) + Key3 Key = Key(imgui.Key3) + Key4 Key = Key(imgui.Key4) + Key5 Key = Key(imgui.Key5) + Key6 Key = Key(imgui.Key6) + Key7 Key = Key(imgui.Key7) + Key8 Key = Key(imgui.Key8) + Key9 Key = Key(imgui.Key9) + KeySemicolon Key = Key(imgui.KeySemicolon) + KeyEqual Key = Key(imgui.KeyEqual) + KeyA Key = Key(imgui.KeyA) + KeyB Key = Key(imgui.KeyB) + KeyC Key = Key(imgui.KeyC) + KeyD Key = Key(imgui.KeyD) + KeyE Key = Key(imgui.KeyE) + KeyF Key = Key(imgui.KeyF) + KeyG Key = Key(imgui.KeyG) + KeyH Key = Key(imgui.KeyH) + KeyI Key = Key(imgui.KeyI) + KeyJ Key = Key(imgui.KeyJ) + KeyK Key = Key(imgui.KeyK) + KeyL Key = Key(imgui.KeyL) + KeyM Key = Key(imgui.KeyM) + KeyN Key = Key(imgui.KeyN) + KeyO Key = Key(imgui.KeyO) + KeyP Key = Key(imgui.KeyP) + KeyQ Key = Key(imgui.KeyQ) + KeyR Key = Key(imgui.KeyR) + KeyS Key = Key(imgui.KeyS) + KeyT Key = Key(imgui.KeyT) + KeyU Key = Key(imgui.KeyU) + KeyV Key = Key(imgui.KeyV) + KeyW Key = Key(imgui.KeyW) + KeyX Key = Key(imgui.KeyX) + KeyY Key = Key(imgui.KeyY) + KeyZ Key = Key(imgui.KeyZ) + KeyLeftBracket Key = Key(imgui.KeyLeftBracket) + KeyBackslash Key = Key(imgui.KeyBackslash) + KeyRightBracket Key = Key(imgui.KeyRightBracket) + KeyGraveAccent Key = Key(imgui.KeyGraveAccent) + //KeyWorld1 Key = Key(imgui.KeyWorld1) + //KeyWorld2 Key = Key(imgui.KeyWorld2) + KeyEscape Key = Key(imgui.KeyEscape) + KeyEnter Key = Key(imgui.KeyEnter) + KeyTab Key = Key(imgui.KeyTab) + KeyBackspace Key = Key(imgui.KeyBackspace) + KeyInsert Key = Key(imgui.KeyInsert) + KeyDelete Key = Key(imgui.KeyDelete) + KeyRight Key = Key(imgui.KeyRightArrow) + KeyLeft Key = Key(imgui.KeyLeftArrow) + KeyDown Key = Key(imgui.KeyDownArrow) + KeyUp Key = Key(imgui.KeyUpArrow) + KeyPageUp Key = Key(imgui.KeyPageUp) + KeyPageDown Key = Key(imgui.KeyPageDown) + KeyHome Key = Key(imgui.KeyHome) + KeyEnd Key = Key(imgui.KeyEnd) + KeyCapsLock Key = Key(imgui.KeyCapsLock) + KeyScrollLock Key = Key(imgui.KeyScrollLock) + KeyNumLock Key = Key(imgui.KeyNumLock) + KeyPrintScreen Key = Key(imgui.KeyPrintScreen) + KeyPause Key = Key(imgui.KeyPause) + KeyF1 Key = Key(imgui.KeyF1) + KeyF2 Key = Key(imgui.KeyF2) + KeyF3 Key = Key(imgui.KeyF3) + KeyF4 Key = Key(imgui.KeyF4) + KeyF5 Key = Key(imgui.KeyF5) + KeyF6 Key = Key(imgui.KeyF6) + KeyF7 Key = Key(imgui.KeyF7) + KeyF8 Key = Key(imgui.KeyF8) + KeyF9 Key = Key(imgui.KeyF9) + KeyF10 Key = Key(imgui.KeyF10) + KeyF11 Key = Key(imgui.KeyF11) + KeyF12 Key = Key(imgui.KeyF12) + //KeyF13 Key = Key(imgui.KeyF13) + //KeyF14 Key = Key(imgui.KeyF14) + //KeyF15 Key = Key(imgui.KeyF15) + //KeyF16 Key = Key(imgui.KeyF16) + //KeyF17 Key = Key(imgui.KeyF17) + //KeyF18 Key = Key(imgui.KeyF18) + //KeyF19 Key = Key(imgui.KeyF19) + //KeyF20 Key = Key(imgui.KeyF20) + //KeyF21 Key = Key(imgui.KeyF21) + //KeyF22 Key = Key(imgui.KeyF22) + //KeyF23 Key = Key(imgui.KeyF23) + //KeyF24 Key = Key(imgui.KeyF24) + //KeyF25 Key = Key(imgui.KeyF25) + //KeyKP0 Key = Key(imgui.KeyKP0) + //KeyKP1 Key = Key(imgui.KeyKP1) + //KeyKP2 Key = Key(imgui.KeyKP2) + //KeyKP3 Key = Key(imgui.KeyKP3) + //KeyKP4 Key = Key(imgui.KeyKP4) + //KeyKP5 Key = Key(imgui.KeyKP5) + //KeyKP6 Key = Key(imgui.KeyKP6) + //KeyKP7 Key = Key(imgui.KeyKP7) + //KeyKP8 Key = Key(imgui.KeyKP8) + //KeyKP9 Key = Key(imgui.KeyKP9) + //KeyKPDecimal Key = Key(imgui.KeyKPDecimal) + //KeyKPDivide Key = Key(imgui.KeyKPDivide) + //KeyKPMultiply Key = Key(imgui.KeyKPMultiply) + //KeyKPSubtract Key = Key(imgui.KeyKPSubtract) + //KeyKPAdd Key = Key(imgui.KeyKPAdd) + //KeyKPEnter Key = Key(imgui.KeyKPEnter) + //KeyKPEqual Key = Key(imgui.KeyKPEqual) + KeyLeftShift Key = Key(imgui.KeyLeftShift) + KeyLeftControl Key = Key(imgui.KeyLeftCtrl) + KeyLeftAlt Key = Key(imgui.KeyLeftAlt) + KeyLeftSuper Key = Key(imgui.KeyLeftSuper) + KeyRightShift Key = Key(imgui.KeyRightShift) + KeyRightControl Key = Key(imgui.KeyRightCtrl) + KeyRightAlt Key = Key(imgui.KeyRightAlt) + KeyRightSuper Key = Key(imgui.KeyRightSuper) + KeyMenu Key = Key(imgui.KeyMenu) + //KeyLast Key = Key(imgui.KeyLast) ) -// Modifier represents glfw.Modifier. -type Modifier glfw.ModifierKey +// Modifier represents imgui.Modifier. +// TODO: consider if it is necessary and ad constants +type Modifier imgui.Key -// modifier keys. -const ( - ModNone Modifier = iota - ModControl Modifier = Modifier(glfw.ModControl) - ModAlt Modifier = Modifier(glfw.ModAlt) - ModSuper Modifier = Modifier(glfw.ModSuper) - ModShift Modifier = Modifier(glfw.ModShift) - ModCapsLock Modifier = Modifier(glfw.ModCapsLock) - ModNumLock Modifier = Modifier(glfw.ModNumLock) -) +//modifier keys. +//const ( +// ModNone Modifier = iota +// ModControl Modifier = Modifier(imgui.ModControl) +// ModAlt Modifier = Modifier(imgui.ModAlt) +// ModSuper Modifier = Modifier(imgui.ModSuper) +// ModShift Modifier = Modifier(imgui.ModShift) +// ModCapsLock Modifier = Modifier(imgui.ModCapsLock) +// ModNumLock Modifier = Modifier(imgui.ModNumLock) +//) -type Action glfw.Action +type Action int const ( - Release Action = Action(glfw.Release) - Press Action = Action(glfw.Press) - Repeat Action = Action(glfw.Repeat) + Press Action = iota + // Release Action = Action(imgui.Release) + // Press Action = Action(imgui.Press) + // Repeat Action = Action(imgui.Repeat) ) diff --git a/ListClipper.go b/ListClipper.go index 760b8a58..7ff6e6c7 100644 --- a/ListClipper.go +++ b/ListClipper.go @@ -1,7 +1,7 @@ package giu import ( - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) var _ Widget = &ListClipperWrapper{} @@ -34,9 +34,9 @@ func (l *ListClipperWrapper) Build() { }) clipper := imgui.NewListClipper() - defer clipper.Delete() + defer clipper.Destroy() - clipper.Begin(len(layout)) + clipper.Begin(int32(len(layout))) for clipper.Step() { for i := clipper.DisplayStart(); i < clipper.DisplayEnd(); i++ { diff --git a/Markdown.go b/Markdown.go index df7dc11b..e168e4a5 100644 --- a/Markdown.go +++ b/Markdown.go @@ -1,134 +1,142 @@ +// package giu +// +// import ( +// +// "image" +// "image/color" +// "net/http" +// "strings" +// "time" +// +// "github.com/AllenDang/cimgui-go" +// "github.com/faiface/mainthread" +// +// ) +// +// // MarkdownWidget implements DearImGui markdown extension +// // https://github.com/juliettef/imgui_markdown +// // It is like LabelWidget but with md formatting. +// +// type MarkdownWidget struct { +// md *string +// linkCb func(url string) +// headers []imgui.MarkdownHeaderData +// } +// +// // Markdown creates new markdown widget. +// +// func Markdown(md *string) *MarkdownWidget { +// return &MarkdownWidget{ +// md: md, +// linkCb: OpenURL, +// } +// } +// +// // OnLink sets another than default link callback. +// +// func (m *MarkdownWidget) OnLink(cb func(url string)) *MarkdownWidget { +// m.linkCb = cb +// return m +// } +// +// // Header sets header formatting +// // NOTE: level (counting from 0!) is header level. (for instance, header `# H1` will have level 0). +// +// func (m *MarkdownWidget) Header(level int, font *FontInfo, separator bool) *MarkdownWidget { +// // ensure if header data are at least as long as level +// if m.headers == nil { +// m.headers = make([]imgui.MarkdownHeaderData, level) +// } +// +// if level <= len(m.headers) { +// m.headers = append(m.headers, make([]imgui.MarkdownHeaderData, len(m.headers)-level+1)...) +// } +// +// if font != nil { +// if f, ok := Context.FontAtlas.extraFontMap[font.String()]; ok { +// m.headers[level].Font = *f +// } +// } +// +// m.headers[level].HasSeparator = separator +// +// return m +// } +// +// // Build implements Widget interface. +// +// func (m *MarkdownWidget) Build() { +// imgui.Markdown(Context.FontAtlas.RegisterStringPointer(m.md), m.linkCb, loadImage, m.headers) +// } +// +// func loadImage(path string) imgui.MarkdownImageData { +// var img *image.RGBA +// +// var err error +// +// switch { +// case strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://"): +// // Load image from url +// client := &http.Client{Timeout: 5 * time.Second} +// resp, respErr := client.Get(path) +// +// if respErr != nil { +// return imgui.MarkdownImageData{} +// } +// +// defer func() { +// closeErr := resp.Body.Close() +// Assert((closeErr == nil), "MarkdownWidget", "loadImage", "Could not close http request!") +// }() +// +// rgba, _, imgErr := image.Decode(resp.Body) +// if imgErr != nil { +// return imgui.MarkdownImageData{} +// } +// +// img = ImageToRgba(rgba) +// default: +// img, err = LoadImage(path) +// if err != nil { +// return imgui.MarkdownImageData{} +// } +// } +// +// size := img.Bounds() +// +// //nolint:gocritic // TODO/BUG: figure out, why it doesn't work as expected and consider +// // if current workaround is save +// /* +// tex := &Texture{} +// NewTextureFromRgba(img, func(t *Texture) { +// fmt.Println("creating texture") +// tex.id = t.id +// }) +// */ +// +// var id imgui.TextureID +// +// mainthread.Call(func() { +// var err error +// id, err = Context.renderer.LoadImage(img) +// if err != nil { +// return +// } +// }) +// +// return imgui.MarkdownImageData{ +// TextureID: &id, +// Scale: true, +// Size: imgui.Vec2{ +// X: float32(size.Dx()), +// Y: float32(size.Dy()), +// }, +// UseLinkCallback: true, +// // default values +// Uv0: ToVec2(image.Point{0, 0}), +// Uv1: ToVec2(image.Point{1, 1}), +// TintColor: ToVec4Color(color.RGBA{255, 255, 255, 255}), +// BorderColor: ToVec4Color(color.RGBA{0, 0, 0, 0}), +// } +// } package giu - -import ( - "image" - "image/color" - "net/http" - "strings" - "time" - - "github.com/AllenDang/imgui-go" - "github.com/faiface/mainthread" -) - -// MarkdownWidget implements DearImGui markdown extension -// https://github.com/juliettef/imgui_markdown -// It is like LabelWidget but with md formatting. -type MarkdownWidget struct { - md *string - linkCb func(url string) - headers []imgui.MarkdownHeaderData -} - -// Markdown creates new markdown widget. -func Markdown(md *string) *MarkdownWidget { - return &MarkdownWidget{ - md: md, - linkCb: OpenURL, - } -} - -// OnLink sets another than default link callback. -func (m *MarkdownWidget) OnLink(cb func(url string)) *MarkdownWidget { - m.linkCb = cb - return m -} - -// Header sets header formatting -// NOTE: level (counting from 0!) is header level. (for instance, header `# H1` will have level 0). -func (m *MarkdownWidget) Header(level int, font *FontInfo, separator bool) *MarkdownWidget { - // ensure if header data are at least as long as level - if m.headers == nil { - m.headers = make([]imgui.MarkdownHeaderData, level) - } - - if level <= len(m.headers) { - m.headers = append(m.headers, make([]imgui.MarkdownHeaderData, len(m.headers)-level+1)...) - } - - if font != nil { - if f, ok := Context.FontAtlas.extraFontMap[font.String()]; ok { - m.headers[level].Font = *f - } - } - - m.headers[level].HasSeparator = separator - - return m -} - -// Build implements Widget interface. -func (m *MarkdownWidget) Build() { - imgui.Markdown(Context.FontAtlas.RegisterStringPointer(m.md), m.linkCb, loadImage, m.headers) -} - -func loadImage(path string) imgui.MarkdownImageData { - var img *image.RGBA - - var err error - - switch { - case strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://"): - // Load image from url - client := &http.Client{Timeout: 5 * time.Second} - resp, respErr := client.Get(path) - - if respErr != nil { - return imgui.MarkdownImageData{} - } - - defer func() { - closeErr := resp.Body.Close() - Assert((closeErr == nil), "MarkdownWidget", "loadImage", "Could not close http request!") - }() - - rgba, _, imgErr := image.Decode(resp.Body) - if imgErr != nil { - return imgui.MarkdownImageData{} - } - - img = ImageToRgba(rgba) - default: - img, err = LoadImage(path) - if err != nil { - return imgui.MarkdownImageData{} - } - } - - size := img.Bounds() - - //nolint:gocritic // TODO/BUG: figure out, why it doesn't work as expected and consider - // if current workaround is save - /* - tex := &Texture{} - NewTextureFromRgba(img, func(t *Texture) { - fmt.Println("creating texture") - tex.id = t.id - }) - */ - - var id imgui.TextureID - - mainthread.Call(func() { - var err error - id, err = Context.renderer.LoadImage(img) - if err != nil { - return - } - }) - - return imgui.MarkdownImageData{ - TextureID: &id, - Scale: true, - Size: imgui.Vec2{ - X: float32(size.Dx()), - Y: float32(size.Dy()), - }, - UseLinkCallback: true, - // default values - Uv0: ToVec2(image.Point{0, 0}), - Uv1: ToVec2(image.Point{1, 1}), - TintColor: ToVec4Color(color.RGBA{255, 255, 255, 255}), - BorderColor: ToVec4Color(color.RGBA{0, 0, 0, 0}), - } -} diff --git a/MasterWindow.go b/MasterWindow.go index af72e5a0..d19bdb08 100644 --- a/MasterWindow.go +++ b/MasterWindow.go @@ -3,12 +3,10 @@ package giu import ( "image" "image/color" - "runtime" "time" - "github.com/AllenDang/imgui-go" + imgui "github.com/AllenDang/cimgui-go" "github.com/faiface/mainthread" - "github.com/go-gl/glfw/v3.3/glfw" "gopkg.in/eapache/queue.v1" ) @@ -30,16 +28,18 @@ const ( ) // DontCare could be used as an argument to (*MasterWindow).SetSizeLimits. -var DontCare int = imgui.GlfwDontCare +// var DontCare int = imgui.GlfwDontCare // MasterWindow represents a glfw master window // It is a base for a windows (see Window.go). type MasterWindow struct { + backend imgui.Backend + width int height int clearColor [4]float32 title string - context *imgui.Context + context imgui.Context io *imgui.IO updateFunc func() @@ -52,28 +52,22 @@ type MasterWindow struct { // it should be called in main function. For more details and use cases, // see examples/helloworld/. func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) *MasterWindow { - context := imgui.CreateContext(nil) - imgui.ImPlotCreateContext() - imgui.ImNodesCreateContext() + ctx := imgui.CreateContext() + imgui.PlotCreateContext() + //imgui.ImNodesCreateContext() io := imgui.CurrentIO() - io.SetConfigFlags(imgui.ConfigFlagEnablePowerSavingMode | imgui.BackendFlagsRendererHasVtxOffset) + // TODO: removed ConfigFlagEnablePowerSavingMode + io.SetConfigFlags(imgui.BackendFlagsRendererHasVtxOffset) // Disable imgui.ini io.SetIniFilename("") - p, err := imgui.NewGLFW(io, title, width, height, imgui.GLFWWindowFlags(flags)) - if err != nil { - panic(err) - } - - r, err := imgui.NewOpenGL3(io, 1.0) - if err != nil { - panic(err) - } + backend := imgui.CreateBackend() + backend.CreateWindow(title, width, height, imgui.GLFWWindowFlags(flags)) - Context = CreateContext(p, r) + Context = CreateContext(backend) // init texture loading queue Context.textureLoadingQueue = queue.New() @@ -84,14 +78,13 @@ func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) * height: height, title: title, io: &io, - context: context, - platform: p, - renderer: r, + context: ctx, } mw.SetInputHandler(newInputHandler()) - p.SetSizeChangeCallback(mw.sizeChange) + // TODO + //p.SetSizeChangeCallback(mw.sizeChange) mw.setTheme() @@ -99,67 +92,69 @@ func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) * } func (w *MasterWindow) setTheme() { - style := imgui.CurrentStyle() + //style := imgui.CurrentStyle() // Scale DPI in windows - if runtime.GOOS == "windows" { - style.ScaleAllSizes(Context.GetPlatform().GetContentScale()) - } + // TODO + //if runtime.GOOS == "windows" { + // style.ScaleAllSizes(Context.GetPlatform().GetContentScale()) + //} imgui.PushStyleVarFloat(imgui.StyleVarWindowRounding, 2) imgui.PushStyleVarFloat(imgui.StyleVarFrameRounding, 4) imgui.PushStyleVarFloat(imgui.StyleVarGrabRounding, 4) imgui.PushStyleVarFloat(imgui.StyleVarFrameBorderSize, 1) - style.SetColor(imgui.StyleColorText, imgui.Vec4{X: 0.95, Y: 0.96, Z: 0.98, W: 1.00}) - style.SetColor(imgui.StyleColorTextDisabled, imgui.Vec4{X: 0.36, Y: 0.42, Z: 0.47, W: 1.00}) - style.SetColor(imgui.StyleColorWindowBg, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) - style.SetColor(imgui.StyleColorChildBg, imgui.Vec4{X: 0.15, Y: 0.18, Z: 0.22, W: 1.00}) - style.SetColor(imgui.StyleColorPopupBg, imgui.Vec4{X: 0.08, Y: 0.08, Z: 0.08, W: 0.94}) - style.SetColor(imgui.StyleColorBorder, imgui.Vec4{X: 0.08, Y: 0.10, Z: 0.12, W: 1.00}) - style.SetColor(imgui.StyleColorBorderShadow, imgui.Vec4{X: 0.00, Y: 0.00, Z: 0.00, W: 0.00}) - style.SetColor(imgui.StyleColorFrameBg, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - style.SetColor(imgui.StyleColorFrameBgHovered, imgui.Vec4{X: 0.12, Y: 0.20, Z: 0.28, W: 1.00}) - style.SetColor(imgui.StyleColorFrameBgActive, imgui.Vec4{X: 0.09, Y: 0.12, Z: 0.14, W: 1.00}) - style.SetColor(imgui.StyleColorTitleBg, imgui.Vec4{X: 0.09, Y: 0.12, Z: 0.14, W: 0.65}) - style.SetColor(imgui.StyleColorTitleBgActive, imgui.Vec4{X: 0.08, Y: 0.10, Z: 0.12, W: 1.00}) - style.SetColor(imgui.StyleColorTitleBgCollapsed, imgui.Vec4{X: 0.00, Y: 0.00, Z: 0.00, W: 0.51}) - style.SetColor(imgui.StyleColorMenuBarBg, imgui.Vec4{X: 0.15, Y: 0.18, Z: 0.22, W: 1.00}) - style.SetColor(imgui.StyleColorScrollbarBg, imgui.Vec4{X: 0.02, Y: 0.02, Z: 0.02, W: 0.39}) - style.SetColor(imgui.StyleColorScrollbarGrab, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - style.SetColor(imgui.StyleColorScrollbarGrabHovered, imgui.Vec4{X: 0.18, Y: 0.22, Z: 0.25, W: 1.00}) - style.SetColor(imgui.StyleColorScrollbarGrabActive, imgui.Vec4{X: 0.09, Y: 0.21, Z: 0.31, W: 1.00}) - style.SetColor(imgui.StyleColorCheckMark, imgui.Vec4{X: 0.28, Y: 0.56, Z: 1.00, W: 1.00}) - style.SetColor(imgui.StyleColorSliderGrab, imgui.Vec4{X: 0.28, Y: 0.56, Z: 1.00, W: 1.00}) - style.SetColor(imgui.StyleColorSliderGrabActive, imgui.Vec4{X: 0.37, Y: 0.61, Z: 1.00, W: 1.00}) - style.SetColor(imgui.StyleColorButton, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - style.SetColor(imgui.StyleColorButtonHovered, imgui.Vec4{X: 0.28, Y: 0.56, Z: 1.00, W: 1.00}) - style.SetColor(imgui.StyleColorButtonActive, imgui.Vec4{X: 0.06, Y: 0.53, Z: 0.98, W: 1.00}) - style.SetColor(imgui.StyleColorHeader, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 0.55}) - style.SetColor(imgui.StyleColorHeaderHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.80}) - style.SetColor(imgui.StyleColorHeaderActive, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 1.00}) - style.SetColor(imgui.StyleColorSeparator, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - style.SetColor(imgui.StyleColorSeparatorHovered, imgui.Vec4{X: 0.10, Y: 0.40, Z: 0.75, W: 0.78}) - style.SetColor(imgui.StyleColorSeparatorActive, imgui.Vec4{X: 0.10, Y: 0.40, Z: 0.75, W: 1.00}) - style.SetColor(imgui.StyleColorResizeGrip, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.25}) - style.SetColor(imgui.StyleColorResizeGripHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.67}) - style.SetColor(imgui.StyleColorResizeGripActive, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.95}) - style.SetColor(imgui.StyleColorTab, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) - style.SetColor(imgui.StyleColorTabHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.80}) - style.SetColor(imgui.StyleColorTabActive, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - style.SetColor(imgui.StyleColorTabUnfocused, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) - style.SetColor(imgui.StyleColorTabUnfocusedActive, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) - style.SetColor(imgui.StyleColorPlotLines, imgui.Vec4{X: 0.61, Y: 0.61, Z: 0.61, W: 1.00}) - style.SetColor(imgui.StyleColorPlotLinesHovered, imgui.Vec4{X: 1.00, Y: 0.43, Z: 0.35, W: 1.00}) - style.SetColor(imgui.StyleColorPlotHistogram, imgui.Vec4{X: 0.90, Y: 0.70, Z: 0.00, W: 1.00}) - style.SetColor(imgui.StyleColorPlotHistogramHovered, imgui.Vec4{X: 1.00, Y: 0.60, Z: 0.00, W: 1.00}) - style.SetColor(imgui.StyleColorTextSelectedBg, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.35}) - style.SetColor(imgui.StyleColorDragDropTarget, imgui.Vec4{X: 1.00, Y: 1.00, Z: 0.00, W: 0.90}) - style.SetColor(imgui.StyleColorNavHighlight, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 1.00}) - style.SetColor(imgui.StyleColorNavWindowingHighlight, imgui.Vec4{X: 1.00, Y: 1.00, Z: 1.00, W: 0.70}) - style.SetColor(imgui.StyleColorTableHeaderBg, imgui.Vec4{X: 0.12, Y: 0.20, Z: 0.28, W: 1.00}) - style.SetColor(imgui.StyleColorTableBorderStrong, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - style.SetColor(imgui.StyleColorTableBorderLight, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 0.70}) + // TODO: idk why but I can't find these functions... + //style.SetColor(imgui.ColText, imgui.Vec4{X: 0.95, Y: 0.96, Z: 0.98, W: 1.00}) + //style.SetColor(imgui.ColTextDisabled, imgui.Vec4{X: 0.36, Y: 0.42, Z: 0.47, W: 1.00}) + //style.SetColor(imgui.ColWindowBg, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) + //style.SetColor(imgui.ColChildBg, imgui.Vec4{X: 0.15, Y: 0.18, Z: 0.22, W: 1.00}) + //style.SetColor(imgui.ColPopupBg, imgui.Vec4{X: 0.08, Y: 0.08, Z: 0.08, W: 0.94}) + //style.SetColor(imgui.ColBorder, imgui.Vec4{X: 0.08, Y: 0.10, Z: 0.12, W: 1.00}) + //style.SetColor(imgui.ColBorderShadow, imgui.Vec4{X: 0.00, Y: 0.00, Z: 0.00, W: 0.00}) + //style.SetColor(imgui.ColFrameBg, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + //style.SetColor(imgui.ColFrameBgHovered, imgui.Vec4{X: 0.12, Y: 0.20, Z: 0.28, W: 1.00}) + //style.SetColor(imgui.ColFrameBgActive, imgui.Vec4{X: 0.09, Y: 0.12, Z: 0.14, W: 1.00}) + //style.SetColor(imgui.ColTitleBg, imgui.Vec4{X: 0.09, Y: 0.12, Z: 0.14, W: 0.65}) + //style.SetColor(imgui.ColTitleBgActive, imgui.Vec4{X: 0.08, Y: 0.10, Z: 0.12, W: 1.00}) + //style.SetColor(imgui.ColTitleBgCollapsed, imgui.Vec4{X: 0.00, Y: 0.00, Z: 0.00, W: 0.51}) + //style.SetColor(imgui.ColMenuBarBg, imgui.Vec4{X: 0.15, Y: 0.18, Z: 0.22, W: 1.00}) + //style.SetColor(imgui.ColScrollbarBg, imgui.Vec4{X: 0.02, Y: 0.02, Z: 0.02, W: 0.39}) + //style.SetColor(imgui.ColScrollbarGrab, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + //style.SetColor(imgui.ColScrollbarGrabHovered, imgui.Vec4{X: 0.18, Y: 0.22, Z: 0.25, W: 1.00}) + //style.SetColor(imgui.ColScrollbarGrabActive, imgui.Vec4{X: 0.09, Y: 0.21, Z: 0.31, W: 1.00}) + //style.SetColor(imgui.ColCheckMark, imgui.Vec4{X: 0.28, Y: 0.56, Z: 1.00, W: 1.00}) + //style.SetColor(imgui.ColSliderGrab, imgui.Vec4{X: 0.28, Y: 0.56, Z: 1.00, W: 1.00}) + //style.SetColor(imgui.ColSliderGrabActive, imgui.Vec4{X: 0.37, Y: 0.61, Z: 1.00, W: 1.00}) + //style.SetColor(imgui.ColButton, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + //style.SetColor(imgui.ColButtonHovered, imgui.Vec4{X: 0.28, Y: 0.56, Z: 1.00, W: 1.00}) + //style.SetColor(imgui.ColButtonActive, imgui.Vec4{X: 0.06, Y: 0.53, Z: 0.98, W: 1.00}) + //style.SetColor(imgui.ColHeader, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 0.55}) + //style.SetColor(imgui.ColHeaderHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.80}) + //style.SetColor(imgui.ColHeaderActive, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 1.00}) + //style.SetColor(imgui.ColSeparator, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + //style.SetColor(imgui.ColSeparatorHovered, imgui.Vec4{X: 0.10, Y: 0.40, Z: 0.75, W: 0.78}) + //style.SetColor(imgui.ColSeparatorActive, imgui.Vec4{X: 0.10, Y: 0.40, Z: 0.75, W: 1.00}) + //style.SetColor(imgui.ColResizeGrip, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.25}) + //style.SetColor(imgui.ColResizeGripHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.67}) + //style.SetColor(imgui.ColResizeGripActive, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.95}) + //style.SetColor(imgui.ColTab, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) + //style.SetColor(imgui.ColTabHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.80}) + //style.SetColor(imgui.ColTabActive, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + //style.SetColor(imgui.ColTabUnfocused, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) + //style.SetColor(imgui.ColTabUnfocusedActive, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) + //style.SetColor(imgui.ColPlotLines, imgui.Vec4{X: 0.61, Y: 0.61, Z: 0.61, W: 1.00}) + //style.SetColor(imgui.ColPlotLinesHovered, imgui.Vec4{X: 1.00, Y: 0.43, Z: 0.35, W: 1.00}) + //style.SetColor(imgui.ColPlotHistogram, imgui.Vec4{X: 0.90, Y: 0.70, Z: 0.00, W: 1.00}) + //style.SetColor(imgui.ColPlotHistogramHovered, imgui.Vec4{X: 1.00, Y: 0.60, Z: 0.00, W: 1.00}) + //style.SetColor(imgui.ColTextSelectedBg, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.35}) + //style.SetColor(imgui.ColDragDropTarget, imgui.Vec4{X: 1.00, Y: 1.00, Z: 0.00, W: 0.90}) + //style.SetColor(imgui.ColNavHighlight, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 1.00}) + //style.SetColor(imgui.ColNavWindowingHighlight, imgui.Vec4{X: 1.00, Y: 1.00, Z: 1.00, W: 0.70}) + //style.SetColor(imgui.ColTableHeaderBg, imgui.Vec4{X: 0.12, Y: 0.20, Z: 0.28, W: 1.00}) + //style.SetColor(imgui.ColTableBorderStrong, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + //style.SetColor(imgui.ColTableBorderLight, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 0.70}) } // SetBgColor sets background color of master window. @@ -180,25 +175,27 @@ func (w *MasterWindow) sizeChange(width, height int) { } func (w *MasterWindow) render() { - if !w.platform.IsVisible() || w.platform.IsMinimized() { - return - } + // TODO + //if !w.platform.IsVisible() || w.platform.IsMinimized() { + // return + //} Context.invalidAllState() defer Context.cleanState() Context.FontAtlas.rebuildFontAtlas() - p := w.platform - r := w.renderer + //p := w.platform + //r := w.renderer mainStylesheet := Style() if s, found := Context.cssStylesheet["main"]; found { mainStylesheet = s } - p.NewFrame() - r.PreRender(w.clearColor) + // TODO + //p.NewFrame() + //r.PreRender(w.clearColor) imgui.NewFrame() mainStylesheet.Push() @@ -206,15 +203,18 @@ func (w *MasterWindow) render() { mainStylesheet.Pop() imgui.Render() - r.Render(p.DisplaySize(), p.FramebufferSize(), imgui.RenderedDrawData()) - p.PostRender() + //r.Render(p.DisplaySize(), p.FramebufferSize(), imgui.RenderedDrawData()) + //p.PostRender() } // Run the main loop to create new frame, process events and call update ui func. func (w *MasterWindow) run() { - p := w.platform + // TODO + //p := w.platform - ticker := time.NewTicker(time.Second / time.Duration(p.GetTPS())) + //ticker := time.NewTicker(time.Second / time.Duration(p.GetTPS())) + // TODO + ticker := time.NewTicker(time.Second / 60) shouldQuit := false for !shouldQuit { @@ -228,10 +228,12 @@ func (w *MasterWindow) run() { } } - p.ProcessEvents() + // TODO + //p.ProcessEvents() w.render() - shouldQuit = p.ShouldStop() + // TODO + //shouldQuit = p.ShouldStop() }) <-ticker.C @@ -240,10 +242,13 @@ func (w *MasterWindow) run() { // GetSize return size of master window. func (w *MasterWindow) GetSize() (width, height int) { - if w.platform != nil { - if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { - return glfwPlatform.GetWindow().GetSize() - } + if w.backend != nil { + // TODO + //if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { + //return glfwPlatform.GetWindow().GetSize() + //} + w, h := w.backend.DisplaySize() + return int(w), int(h) } return w.width, w.height @@ -251,10 +256,11 @@ func (w *MasterWindow) GetSize() (width, height int) { // GetPos return position of master window. func (w *MasterWindow) GetPos() (x, y int) { - if w.platform != nil { - if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { - x, y = glfwPlatform.GetWindow().GetPos() - } + if w.backend != nil { + // TODO + //if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { + // x, y = glfwPlatform.GetWindow().GetPos() + //} } return @@ -262,21 +268,20 @@ func (w *MasterWindow) GetPos() (x, y int) { // SetPos sets position of master window. func (w *MasterWindow) SetPos(x, y int) { - if w.platform != nil { - if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { - glfwPlatform.GetWindow().SetPos(x, y) - } + if w.backend != nil { + w.backend.SetWindowPos(x, y) } } // SetSize sets size of master window. func (w *MasterWindow) SetSize(x, y int) { - if w.platform != nil { - if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { - mainthread.CallNonBlock(func() { - glfwPlatform.GetWindow().SetSize(x, y) - }) - } + if w.backend != nil { + // TODO + //if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { + // mainthread.CallNonBlock(func() { + // glfwPlatform.GetWindow().SetSize(x, y) + // }) + //} } } @@ -290,12 +295,14 @@ func (w *MasterWindow) SetSize(x, y int) { // Mac OS X: Selecting Quit from the application menu will trigger the close // callback for all windows. func (w *MasterWindow) SetCloseCallback(cb func() bool) { - w.platform.SetCloseCallback(cb) + // TODO + //w.backend.SetCloseCallback(cb) } // SetDropCallback sets callback when file was dropped into the window. func (w *MasterWindow) SetDropCallback(cb func([]string)) { - w.platform.SetDropCallback(cb) + // TODO: https://github.com/AllenDang/cimgui-go/pull/145 + //w.platform.SetDropCallback(cb) } // Run runs the main loop. @@ -314,11 +321,11 @@ func (w *MasterWindow) Run(loopFunc func()) { Context.isAlive = false mainthread.Call(func() { - w.renderer.Dispose() - w.platform.Dispose() + //w.renderer.Dispose() + //w.platform.Dispose() - imgui.ImNodesDestroyContext() - imgui.ImPlotDestroyContext() + //imgui.ImNodesDestroyContext() + //imgui.ImPlotDestroyContext() w.context.Destroy() }) @@ -353,7 +360,8 @@ func (w *MasterWindow) RegisterKeyboardShortcuts(s ...WindowShortcut) *MasterWin // The desired image sizes varies depending on platform and system settings. The selected // images will be rescaled as needed. Good sizes include 16x16, 32x32 and 48x48. func (w *MasterWindow) SetIcon(icons []image.Image) { - w.platform.SetIcon(icons) + // TODO + //w.platform.SetIcon(icons) } // SetSizeLimits sets the size limits of the client area of the specified window. @@ -363,12 +371,14 @@ func (w *MasterWindow) SetIcon(icons []image.Image) { // To specify only a minimum size or only a maximum one, set the other pair to giu.DontCare. // To disable size limits for a window, set them all to giu.DontCare. func (w *MasterWindow) SetSizeLimits(minw, minh, maxw, maxh int) { - w.platform.SetSizeLimits(minw, minh, maxw, maxh) + // TODO + //w.platform.SetSizeLimits(minw, minh, maxw, maxh) } // SetTitle updates master window's title. func (w *MasterWindow) SetTitle(title string) { - w.platform.SetTitle(title) + // TODO + //w.platform.SetTitle(title) } // Close will safely close the master window. @@ -378,21 +388,23 @@ func (w *MasterWindow) Close() { // SetShouldClose sets whether master window should be closed. func (w *MasterWindow) SetShouldClose(v bool) { - w.platform.SetShouldStop(v) + // TODO + //w.platform.SetShouldStop(v) } // SetInputHandler allows to change default input handler. // see InputHandler.go. func (w *MasterWindow) SetInputHandler(handler InputHandler) { - Context.InputHandler = handler - - w.platform.SetInputCallback(func(key glfw.Key, modifier glfw.ModifierKey, action glfw.Action) { - k, m, a := Key(key), Modifier(modifier), Action(action) - handler.Handle(k, m, a) - if w.additionalInputCallback != nil { - w.additionalInputCallback(k, m, a) - } - }) + // TODO + //Context.InputHandler = handler + + //w.platform.SetInputCallback(func(key glfw.Key, modifier glfw.ModifierKey, action glfw.Action) { + // k, m, a := Key(key), Modifier(modifier), Action(action) + // handler.Handle(k, m, a) + // if w.additionalInputCallback != nil { + // w.additionalInputCallback(k, m, a) + // } + //}) } // SetAdditionalInputHandlerCallback allows to set an input callback to handle more events (not only these from giu.inputHandler). diff --git a/MemoryEditor.go b/MemoryEditor.go index 9c1a3fc4..78a0c274 100644 --- a/MemoryEditor.go +++ b/MemoryEditor.go @@ -1,56 +1,64 @@ +// package giu +// +// import ( +// +// "github.com/AllenDang/cimgui-go" +// +// ) +// +// type memoryEditorState struct { +// editor imgui.MemoryEditor +// } +// +// // Dispose implements Disposable interface. +// +// func (s *memoryEditorState) Dispose() { +// // noop +// } +// +// // MemoryEditorWidget - Mini memory editor for Dear ImGui +// // (to embed in your game/tools) +// // +// // Right-click anywhere to access the Options menu! +// // You can adjust the keyboard repeat delay/rate in ImGuiIO. +// // The code assume a mono-space font for simplicity! +// // If you don't use the default font, use ImGui::PushFont()/PopFont() to switch to a mono-space font before calling this. +// +// type MemoryEditorWidget struct { +// id string +// contents []byte +// } +// +// // MemoryEditor creates nwe memory editor widget. +// +// func MemoryEditor() *MemoryEditorWidget { +// return &MemoryEditorWidget{ +// id: GenAutoID("memoryEditor"), +// } +// } +// +// // Contents sets editor's contents. +// +// func (me *MemoryEditorWidget) Contents(contents []byte) *MemoryEditorWidget { +// me.contents = contents +// return me +// } +// +// // Build implements widget interface. +// +// func (me *MemoryEditorWidget) Build() { +// me.getState().editor.DrawContents(me.contents) +// } +// +// func (me *MemoryEditorWidget) getState() (state *memoryEditorState) { +// if state = GetState[memoryEditorState](Context, me.id); state == nil { +// state = &memoryEditorState{ +// editor: imgui.NewMemoryEditor(), +// } +// +// SetState(Context, me.id, state) +// } +// +// return state +// } package giu - -import ( - "github.com/AllenDang/imgui-go" -) - -type memoryEditorState struct { - editor imgui.MemoryEditor -} - -// Dispose implements Disposable interface. -func (s *memoryEditorState) Dispose() { - // noop -} - -// MemoryEditorWidget - Mini memory editor for Dear ImGui -// (to embed in your game/tools) -// -// Right-click anywhere to access the Options menu! -// You can adjust the keyboard repeat delay/rate in ImGuiIO. -// The code assume a mono-space font for simplicity! -// If you don't use the default font, use ImGui::PushFont()/PopFont() to switch to a mono-space font before calling this. -type MemoryEditorWidget struct { - id string - contents []byte -} - -// MemoryEditor creates nwe memory editor widget. -func MemoryEditor() *MemoryEditorWidget { - return &MemoryEditorWidget{ - id: GenAutoID("memoryEditor"), - } -} - -// Contents sets editor's contents. -func (me *MemoryEditorWidget) Contents(contents []byte) *MemoryEditorWidget { - me.contents = contents - return me -} - -// Build implements widget interface. -func (me *MemoryEditorWidget) Build() { - me.getState().editor.DrawContents(me.contents) -} - -func (me *MemoryEditorWidget) getState() (state *memoryEditorState) { - if state = GetState[memoryEditorState](Context, me.id); state == nil { - state = &memoryEditorState{ - editor: imgui.NewMemoryEditor(), - } - - SetState(Context, me.id, state) - } - - return state -} diff --git a/Plot.go b/Plot.go index 35fa90c3..af349609 100644 --- a/Plot.go +++ b/Plot.go @@ -3,7 +3,7 @@ package giu import ( "image" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // PlotWidget is implemented by all the particular plots, which can be used @@ -169,22 +169,47 @@ func (p *PlotCanvasWidget) Size(width, height int) *PlotCanvasWidget { // Build implements Widget interface. func (p *PlotCanvasWidget) Build() { if len(p.plots) > 0 { - imgui.ImPlotSetNextPlotLimits(p.xMin, p.xMax, p.yMin, p.yMax, imgui.Condition(p.axisLimitCondition)) + imgui.PlotSetupAxisLimitsV( + imgui.AxisX1, + p.xMin, + p.xMax, + imgui.PlotCond(p.axisLimitCondition), + ) + imgui.PlotSetupAxisLimitsV( + imgui.AxisY1, + p.yMin, + p.yMax, + imgui.PlotCond(p.axisLimitCondition), + ) if len(p.xTicksValue) > 0 { - imgui.ImPlotSetNextPlotTicksX(p.xTicksValue, p.xTicksLabel, p.xTicksShowDefault) + imgui.PlotSetupAxisTicksdoubleV( + imgui.AxisX1, + p.xTicksValue[0], + p.xTicksValue[1], // <- TODO: why is it so strangely saved? + -1, // TODO + p.xTicksLabel, + p.xTicksShowDefault, + ) } if len(p.yTicksValue) > 0 { - imgui.ImPlotSetNextPlotTicksY(p.yTicksValue, p.yTicksLabel, p.yTicksShowDefault, int(p.yTicksYAxis)) + imgui.PlotSetupAxisTicksdoubleV( + imgui.AxisY1, + p.xTicksValue[0], + p.xTicksValue[1], // <- TODO: why is it so strangely saved? + -1, // TODO + p.xTicksLabel, + p.xTicksShowDefault, + ) } - if imgui.ImPlotBegin( + if imgui.PlotBeginPlot( Context.FontAtlas.RegisterString(p.title), Context.FontAtlas.RegisterString(p.xLabel), Context.FontAtlas.RegisterString(p.yLabel), ToVec2(image.Pt(p.width, p.height)), - imgui.ImPlotFlags(p.flags), imgui.ImPlotAxisFlags(p.xFlags), - imgui.ImPlotAxisFlags(p.yFlags), imgui.ImPlotAxisFlags(p.y2Flags), - imgui.ImPlotAxisFlags(p.y3Flags), Context.FontAtlas.RegisterString(p.y2Label), Context.FontAtlas.RegisterString(p.y3Label), + imgui.PlotFlags(p.flags), imgui.PlotAxisFlags(p.xFlags), + imgui.PlotAxisFlags(p.yFlags), imgui.PlotAxisFlags(p.y2Flags), + imgui.PlotAxisFlags(p.y3Flags), Context.FontAtlas.RegisterString(p.y2Label), Context.FontAtlas.RegisterString(p.y3Label), ) { for _, plot := range p.plots { plot.Plot() diff --git a/Popups.go b/Popups.go index c28464d5..9f5d2b13 100644 --- a/Popups.go +++ b/Popups.go @@ -1,13 +1,13 @@ package giu import ( - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // OpenPopup opens a popup with specified id. // NOTE: you need to build this popup first (see Pop(Modal)Widget). func OpenPopup(name string) { - imgui.OpenPopup(name) + imgui.OpenPopupStr(name) } // CloseCurrentPopup closes currently opened popup. @@ -49,7 +49,7 @@ func (p *PopupWidget) Layout(widgets ...Widget) *PopupWidget { // Build implements Widget interface. func (p *PopupWidget) Build() { - if imgui.BeginPopup(p.name, int(p.flags)) { + if imgui.BeginPopupV(p.name, imgui.WindowFlags(p.flags)) { p.layout.Build() imgui.EndPopup() } @@ -98,7 +98,7 @@ func (p *PopupModalWidget) Layout(widgets ...Widget) *PopupModalWidget { // Build implements Widget interface. func (p *PopupModalWidget) Build() { - if imgui.BeginPopupModalV(p.name, p.open, int(p.flags)) { + if imgui.BeginPopupModalV(p.name, p.open, imgui.WindowFlags(p.flags)) { p.layout.Build() imgui.EndPopup() } diff --git a/ProgressIndicator.go b/ProgressIndicator.go index 0ed0ee57..ec0e5fb9 100644 --- a/ProgressIndicator.go +++ b/ProgressIndicator.go @@ -5,7 +5,7 @@ import ( "math" "time" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) var _ Disposable = &progressIndicatorState{} @@ -87,10 +87,10 @@ func (p *ProgressIndicatorWidget) Build() { int(float64(p.radius)*math.Cos(state.angle)+float64(centerPt.Y)), ) - color := imgui.CurrentStyle().GetColor(imgui.StyleColorText) + color := imgui.StyleColorVec4(imgui.ColText) rgba := Vec4ToRGBA(color) - canvas.AddCircle(centerPt, p.radius, rgba, int(p.radius), p.radius/20.0) + canvas.AddCircle(centerPt, p.radius, rgba, int32(p.radius), p.radius/20.0) canvas.AddCircleFilled(centerPt2, p.radius/5, rgba) // Draw text diff --git a/SliderWidgets.go b/SliderWidgets.go index ee11f2d5..5599ff30 100644 --- a/SliderWidgets.go +++ b/SliderWidgets.go @@ -3,7 +3,7 @@ package giu import ( "fmt" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) var _ Widget = &SliderIntWidget{} @@ -72,7 +72,7 @@ func (s *SliderIntWidget) Build() { defer PopItemWidth() } - if imgui.SliderIntV(Context.FontAtlas.RegisterString(s.label), s.value, s.min, s.max, s.format) && s.onChange != nil { + if imgui.SliderIntV(Context.FontAtlas.RegisterString(s.label), s.value, s.min, s.max, s.format, 0) && s.onChange != nil { s.onChange() } } @@ -150,7 +150,7 @@ func (vs *VSliderIntWidget) Build() { vs.min, vs.max, vs.format, - int(vs.flags), + imgui.SliderFlags(vs.flags), ) && vs.onChange != nil { vs.onChange() } diff --git a/SplitLayout.go b/SplitLayout.go index 9933e0cd..334644ec 100644 --- a/SplitLayout.go +++ b/SplitLayout.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // SplitDirection represents a direction (vertical/horizontal) of splitting layout. @@ -119,7 +119,7 @@ func (s *SplitLayoutWidget) restoreItemSpacing(layout Widget) Layout { PushItemSpacing(s.originItemSpacingX, s.originItemSpacingY) PushFramePadding(s.originFramePaddingX, s.originFramePaddingY) // Restore Child bg color - bgColor := imgui.CurrentStyle().GetColor(imgui.StyleColorChildBg) + bgColor := imgui.StyleColorVec4(imgui.ColChildBg) PushStyleColor(StyleColorChildBg, Vec4ToRGBA(bgColor)) }), layout, diff --git a/StackWidget.go b/StackWidget.go index 99d8c327..7e60f464 100644 --- a/StackWidget.go +++ b/StackWidget.go @@ -1,6 +1,6 @@ package giu -import "github.com/AllenDang/imgui-go" +import "github.com/AllenDang/cimgui-go" var _ Widget = &StackWidget{} diff --git a/Style.go b/Style.go index 0ca1418b..b345761f 100644 --- a/Style.go +++ b/Style.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // You may want to use styles in order to make your app looking more beautiful. @@ -58,52 +58,52 @@ func PopFont() { imgui.PopFont() } -// PushStyleColor wraps imgui.PushStyleColor +// PushStyleColor wraps imgui.PushStyleColorVec4 // NOTE: don't forget to call PopStyleColor()! func PushStyleColor(id StyleColorID, col color.Color) { - imgui.PushStyleColor(imgui.StyleColorID(id), ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.Col(id), ToVec4Color(col)) } // PushColorText calls PushStyleColor(StyleColorText,...) // NOTE: don't forget to call PopStyleColor()! func PushColorText(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorText, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColText, ToVec4Color(col)) } // PushColorTextDisabled calls PushStyleColor(StyleColorTextDisabled,...) // NOTE: don't forget to call PopStyleColor()! func PushColorTextDisabled(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorTextDisabled, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColTextDisabled, ToVec4Color(col)) } // PushColorWindowBg calls PushStyleColor(StyleColorWindowBg,...) // NOTE: don't forget to call PopStyleColor()! func PushColorWindowBg(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorWindowBg, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColWindowBg, ToVec4Color(col)) } // PushColorFrameBg calls PushStyleColor(StyleColorFrameBg,...) // NOTE: don't forget to call PopStyleColor()! func PushColorFrameBg(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorFrameBg, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColFrameBg, ToVec4Color(col)) } // PushColorButton calls PushStyleColor(StyleColorButton,...) // NOTE: don't forget to call PopStyleColor()! func PushColorButton(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorButton, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColButton, ToVec4Color(col)) } // PushColorButtonHovered calls PushStyleColor(StyleColorButtonHovered,...) // NOTE: don't forget to call PopStyleColor()! func PushColorButtonHovered(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorButtonHovered, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColButtonHovered, ToVec4Color(col)) } // PushColorButtonActive calls PushStyleColor(StyleColorButtonActive,...) // NOTE: don't forget to call PopStyleColor()! func PushColorButtonActive(col color.Color) { - imgui.PushStyleColor(imgui.StyleColorButtonActive, ToVec4Color(col)) + imgui.PushStyleColorVec4(imgui.ColButtonActive, ToVec4Color(col)) } // PushWindowPadding calls PushStyleVar(StyleWindowPadding,...) @@ -141,7 +141,7 @@ func PopStyle() { // PopStyleV does similarly to PopStyle, but allows to specify number // of styles you're going to pop. func PopStyleV(count int) { - imgui.PopStyleVarV(count) + imgui.PopStyleVarV(int32(count)) } // PopStyleColor is used to stop applying colors styles. @@ -155,7 +155,7 @@ func PopStyleColor() { // PopStyleColorV does similar to PopStyleColor, but allows to specify // how much style colors would you like to pop. func PopStyleColorV(count int) { - imgui.PopStyleColorV(count) + imgui.PopStyleColorV(int32(count)) } // AlignTextToFramePadding vertically aligns upcoming text baseline to @@ -194,56 +194,56 @@ func PopTextWrapPos() { } // MouseCursorType represents a type (layout) of mouse cursor. -type MouseCursorType int +type MouseCursorType imgui.MouseCursor // cursor types. const ( // MouseCursorNone no mouse cursor. - MouseCursorNone MouseCursorType = -1 + MouseCursorNone MouseCursorType = imgui.MouseCursorNone // MouseCursorArrow standard arrow mouse cursor. - MouseCursorArrow MouseCursorType = 0 + MouseCursorArrow MouseCursorType = imgui.MouseCursorArrow // MouseCursorTextInput when hovering over InputText, etc. - MouseCursorTextInput MouseCursorType = 1 + MouseCursorTextInput MouseCursorType = imgui.MouseCursorTextInput // MouseCursorResizeAll (Unused by imgui functions). - MouseCursorResizeAll MouseCursorType = 2 + MouseCursorResizeAll MouseCursorType = imgui.MouseCursorResizeAll // MouseCursorResizeNS when hovering over an horizontal border. - MouseCursorResizeNS MouseCursorType = 3 + MouseCursorResizeNS MouseCursorType = imgui.MouseCursorResizeNS // MouseCursorResizeEW when hovering over a vertical border or a column. - MouseCursorResizeEW MouseCursorType = 4 + MouseCursorResizeEW MouseCursorType = imgui.MouseCursorResizeEW // MouseCursorResizeNESW when hovering over the bottom-left corner of a window. - MouseCursorResizeNESW MouseCursorType = 5 + MouseCursorResizeNESW MouseCursorType = imgui.MouseCursorResizeNESW // MouseCursorResizeNWSE when hovering over the bottom-right corner of a window. - MouseCursorResizeNWSE MouseCursorType = 6 + MouseCursorResizeNWSE MouseCursorType = imgui.MouseCursorResizeNWSE // MouseCursorHand (Unused by imgui functions. Use for e.g. hyperlinks). - MouseCursorHand MouseCursorType = 7 - MouseCursorCount MouseCursorType = 8 + MouseCursorHand MouseCursorType = imgui.MouseCursorHand + MouseCursorCount MouseCursorType = imgui.MouseCursorCOUNT ) // SetMouseCursor sets mouse cursor layout. func SetMouseCursor(cursor MouseCursorType) { - imgui.SetMouseCursor(int(cursor)) + imgui.SetMouseCursor(imgui.MouseCursor(cursor)) } // GetWindowPadding returns window padding. func GetWindowPadding() (x, y float32) { - vec2 := imgui.CurrentStyle().WindowPadding() + vec2 := imgui.Style().GetWindowPadding() return vec2.X, vec2.Y } // GetItemSpacing returns current item spacing. func GetItemSpacing() (w, h float32) { - vec2 := imgui.CurrentStyle().ItemSpacing() + vec2 := imgui.Style().GetItemSpacing() return vec2.X, vec2.Y } // GetItemInnerSpacing returns current item inner spacing. func GetItemInnerSpacing() (w, h float32) { - vec2 := imgui.CurrentStyle().ItemInnerSpacing() + vec2 := imgui.Style().GetItemInnerSpacing() return vec2.X, vec2.Y } // GetFramePadding returns current frame padding. func GetFramePadding() (x, y float32) { - vec2 := imgui.CurrentStyle().FramePadding() + vec2 := imgui.Style().GetFramePadding() return vec2.X, vec2.Y } diff --git a/StyleIDs.go b/StyleIDs.go index f195cfd4..2015414a 100644 --- a/StyleIDs.go +++ b/StyleIDs.go @@ -1,6 +1,6 @@ package giu -import "github.com/AllenDang/imgui-go" +import "github.com/AllenDang/cimgui-go" // Here are the style IDs for styling imgui apps. // For details about each of attributes read comment above them. @@ -11,69 +11,69 @@ import "github.com/AllenDang/imgui-go" //go:generate string2enum -samepkg -type=StyleColorID,StyleVarID -output=StyleIDs_string2enum.go -linecomment // StyleColorID identifies a color in the UI style. -type StyleColorID imgui.StyleColorID +type StyleColorID imgui.Col // StyleColor identifier. // NOTE: comments are used for CSS conversion and are generated by stringer and string2enum. const ( - StyleColorText = StyleColorID(imgui.StyleColorText) // color - StyleColorTextDisabled = StyleColorID(imgui.StyleColorTextDisabled) // disabled-color - StyleColorWindowBg = StyleColorID(imgui.StyleColorWindowBg) // background-color - StyleColorChildBg = StyleColorID(imgui.StyleColorChildBg) // child-background-color - StyleColorPopupBg = StyleColorID(imgui.StyleColorPopupBg) // popup-background-color - StyleColorBorder = StyleColorID(imgui.StyleColorBorder) // border-color - StyleColorBorderShadow = StyleColorID(imgui.StyleColorBorderShadow) // border-shadow-color - StyleColorFrameBg = StyleColorID(imgui.StyleColorFrameBg) // frame-background-color - StyleColorFrameBgHovered = StyleColorID(imgui.StyleColorFrameBgHovered) // frame-background-hovered-color - StyleColorFrameBgActive = StyleColorID(imgui.StyleColorFrameBgActive) // frame-background-active-color - StyleColorTitleBg = StyleColorID(imgui.StyleColorTitleBg) // title-background-color - StyleColorTitleBgActive = StyleColorID(imgui.StyleColorTitleBgActive) // title-background-active-color - StyleColorTitleBgCollapsed = StyleColorID(imgui.StyleColorTitleBgCollapsed) // title-background-collapsed-color - StyleColorMenuBarBg = StyleColorID(imgui.StyleColorMenuBarBg) // menu-bar-background-color - StyleColorScrollbarBg = StyleColorID(imgui.StyleColorScrollbarBg) // scrollbar-background-color - StyleColorScrollbarGrab = StyleColorID(imgui.StyleColorScrollbarGrab) // scrollbar-grab-color - StyleColorScrollbarGrabHovered = StyleColorID(imgui.StyleColorScrollbarGrabHovered) // scrollbar-grab-hovered-color - StyleColorScrollbarGrabActive = StyleColorID(imgui.StyleColorScrollbarGrabActive) // scrollbar-grab-active-color - StyleColorCheckMark = StyleColorID(imgui.StyleColorCheckMark) // checkmark-color - StyleColorSliderGrab = StyleColorID(imgui.StyleColorSliderGrab) // slider-grab-color - StyleColorSliderGrabActive = StyleColorID(imgui.StyleColorSliderGrabActive) // slider-grab-active-color - StyleColorButton = StyleColorID(imgui.StyleColorButton) // button-color - StyleColorButtonHovered = StyleColorID(imgui.StyleColorButtonHovered) // button-hovered-color - StyleColorButtonActive = StyleColorID(imgui.StyleColorButtonActive) // button-active-color - StyleColorHeader = StyleColorID(imgui.StyleColorHeader) // header-color - StyleColorHeaderHovered = StyleColorID(imgui.StyleColorHeaderHovered) // header-hovered-color - StyleColorHeaderActive = StyleColorID(imgui.StyleColorHeaderActive) // header-active-color - StyleColorSeparator = StyleColorID(imgui.StyleColorSeparator) // separator-color - StyleColorSeparatorHovered = StyleColorID(imgui.StyleColorSeparatorHovered) // separator-hovered-color - StyleColorSeparatorActive = StyleColorID(imgui.StyleColorSeparatorActive) // separator-active-color - StyleColorResizeGrip = StyleColorID(imgui.StyleColorResizeGrip) // resize-grip-color - StyleColorResizeGripHovered = StyleColorID(imgui.StyleColorResizeGripHovered) // resize-grip-hovered-color - StyleColorResizeGripActive = StyleColorID(imgui.StyleColorResizeGripActive) // resize-grip-active-color - StyleColorTab = StyleColorID(imgui.StyleColorTab) // tab-color - StyleColorTabHovered = StyleColorID(imgui.StyleColorTabHovered) // tab-hovered-color - StyleColorTabActive = StyleColorID(imgui.StyleColorTabActive) // tab-active-color - StyleColorTabUnfocused = StyleColorID(imgui.StyleColorTabUnfocused) // tab-unfocused-color - StyleColorTabUnfocusedActive = StyleColorID(imgui.StyleColorTabUnfocusedActive) // tab-unfocused-active-color - StyleColorPlotLines = StyleColorID(imgui.StyleColorPlotLines) // plot-lines-color - StyleColorPlotLinesHovered = StyleColorID(imgui.StyleColorPlotLinesHovered) // plot-lines-hovered-color - StyleColorProgressBarActive = StyleColorPlotLinesHovered // progress-bar-active-color - StyleColorPlotHistogram = StyleColorID(imgui.StyleColorPlotHistogram) // plot-histogram-color - StyleColorPlotHistogramHovered = StyleColorID(imgui.StyleColorPlotHistogramHovered) // plot-histogram-hovered-color - StyleColorTableHeaderBg = StyleColorID(imgui.StyleColorTableHeaderBg) // table-header-background-color - StyleColorTableBorderStrong = StyleColorID(imgui.StyleColorTableBorderStrong) // table-border-strong-color - StyleColorTableBorderLight = StyleColorID(imgui.StyleColorTableBorderLight) // table-border-light-color - StyleColorTableRowBg = StyleColorID(imgui.StyleColorTableRowBg) // table-row-background-color - StyleColorTableRowBgAlt = StyleColorID(imgui.StyleColorTableRowBgAlt) // table-row-alternate-background-color - StyleColorTextSelectedBg = StyleColorID(imgui.StyleColorTextSelectedBg) // text-selected-background-color - StyleColorDragDropTarget = StyleColorID(imgui.StyleColorDragDropTarget) // drag-drop-target-color - StyleColorNavHighlight = StyleColorID(imgui.StyleColorNavHighlight) // navigation-highlight-color - StyleColorNavWindowingHighlight = StyleColorID(imgui.StyleColorNavWindowingHighlight) // windowing-highlight-color - StyleColorNavWindowingDimBg = StyleColorID(imgui.StyleColorNavWindowingDimBg) // windowing-dim-background-color - StyleColorModalWindowDimBg = StyleColorID(imgui.StyleColorModalWindowDimBg) // modal-window-dim-background-color + StyleColorText = StyleColorID(imgui.ColText) // color + StyleColorTextDisabled = StyleColorID(imgui.ColTextDisabled) // disabled-color + StyleColorWindowBg = StyleColorID(imgui.ColWindowBg) // background-color + StyleColorChildBg = StyleColorID(imgui.ColChildBg) // child-background-color + StyleColorPopupBg = StyleColorID(imgui.ColPopupBg) // popup-background-color + StyleColorBorder = StyleColorID(imgui.ColBorder) // border-color + StyleColorBorderShadow = StyleColorID(imgui.ColBorderShadow) // border-shadow-color + StyleColorFrameBg = StyleColorID(imgui.ColFrameBg) // frame-background-color + StyleColorFrameBgHovered = StyleColorID(imgui.ColFrameBgHovered) // frame-background-hovered-color + StyleColorFrameBgActive = StyleColorID(imgui.ColFrameBgActive) // frame-background-active-color + StyleColorTitleBg = StyleColorID(imgui.ColTitleBg) // title-background-color + StyleColorTitleBgActive = StyleColorID(imgui.ColTitleBgActive) // title-background-active-color + StyleColorTitleBgCollapsed = StyleColorID(imgui.ColTitleBgCollapsed) // title-background-collapsed-color + StyleColorMenuBarBg = StyleColorID(imgui.ColMenuBarBg) // menu-bar-background-color + StyleColorScrollbarBg = StyleColorID(imgui.ColScrollbarBg) // scrollbar-background-color + StyleColorScrollbarGrab = StyleColorID(imgui.ColScrollbarGrab) // scrollbar-grab-color + StyleColorScrollbarGrabHovered = StyleColorID(imgui.ColScrollbarGrabHovered) // scrollbar-grab-hovered-color + StyleColorScrollbarGrabActive = StyleColorID(imgui.ColScrollbarGrabActive) // scrollbar-grab-active-color + StyleColorCheckMark = StyleColorID(imgui.ColCheckMark) // checkmark-color + StyleColorSliderGrab = StyleColorID(imgui.ColSliderGrab) // slider-grab-color + StyleColorSliderGrabActive = StyleColorID(imgui.ColSliderGrabActive) // slider-grab-active-color + StyleColorButton = StyleColorID(imgui.ColButton) // button-color + StyleColorButtonHovered = StyleColorID(imgui.ColButtonHovered) // button-hovered-color + StyleColorButtonActive = StyleColorID(imgui.ColButtonActive) // button-active-color + StyleColorHeader = StyleColorID(imgui.ColHeader) // header-color + StyleColorHeaderHovered = StyleColorID(imgui.ColHeaderHovered) // header-hovered-color + StyleColorHeaderActive = StyleColorID(imgui.ColHeaderActive) // header-active-color + StyleColorSeparator = StyleColorID(imgui.ColSeparator) // separator-color + StyleColorSeparatorHovered = StyleColorID(imgui.ColSeparatorHovered) // separator-hovered-color + StyleColorSeparatorActive = StyleColorID(imgui.ColSeparatorActive) // separator-active-color + StyleColorResizeGrip = StyleColorID(imgui.ColResizeGrip) // resize-grip-color + StyleColorResizeGripHovered = StyleColorID(imgui.ColResizeGripHovered) // resize-grip-hovered-color + StyleColorResizeGripActive = StyleColorID(imgui.ColResizeGripActive) // resize-grip-active-color + StyleColorTab = StyleColorID(imgui.ColTab) // tab-color + StyleColorTabHovered = StyleColorID(imgui.ColTabHovered) // tab-hovered-color + StyleColorTabActive = StyleColorID(imgui.ColTabActive) // tab-active-color + StyleColorTabUnfocused = StyleColorID(imgui.ColTabUnfocused) // tab-unfocused-color + StyleColorTabUnfocusedActive = StyleColorID(imgui.ColTabUnfocusedActive) // tab-unfocused-active-color + StyleColorPlotLines = StyleColorID(imgui.ColPlotLines) // plot-lines-color + StyleColorPlotLinesHovered = StyleColorID(imgui.ColPlotLinesHovered) // plot-lines-hovered-color + StyleColorProgressBarActive = StyleColorPlotLinesHovered // progress-bar-active-color + StyleColorPlotHistogram = StyleColorID(imgui.ColPlotHistogram) // plot-histogram-color + StyleColorPlotHistogramHovered = StyleColorID(imgui.ColPlotHistogramHovered) // plot-histogram-hovered-color + StyleColorTableHeaderBg = StyleColorID(imgui.ColTableHeaderBg) // table-header-background-color + StyleColorTableBorderStrong = StyleColorID(imgui.ColTableBorderStrong) // table-border-strong-color + StyleColorTableBorderLight = StyleColorID(imgui.ColTableBorderLight) // table-border-light-color + StyleColorTableRowBg = StyleColorID(imgui.ColTableRowBg) // table-row-background-color + StyleColorTableRowBgAlt = StyleColorID(imgui.ColTableRowBgAlt) // table-row-alternate-background-color + StyleColorTextSelectedBg = StyleColorID(imgui.ColTextSelectedBg) // text-selected-background-color + StyleColorDragDropTarget = StyleColorID(imgui.ColDragDropTarget) // drag-drop-target-color + StyleColorNavHighlight = StyleColorID(imgui.ColNavHighlight) // navigation-highlight-color + StyleColorNavWindowingHighlight = StyleColorID(imgui.ColNavWindowingHighlight) // windowing-highlight-color + StyleColorNavWindowingDimBg = StyleColorID(imgui.ColNavWindowingDimBg) // windowing-dim-background-color + StyleColorModalWindowDimBg = StyleColorID(imgui.ColModalWindowDimBg) // modal-window-dim-background-color ) // StyleVarID identifies a style variable in the UI style. -type StyleVarID imgui.StyleVarID +type StyleVarID imgui.StyleVar // Style IDs. // comments at same line is a CSS name. diff --git a/StyleSetter.go b/StyleSetter.go index d155546e..0f42a861 100644 --- a/StyleSetter.go +++ b/StyleSetter.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) var _ Widget = &StyleSetter{} @@ -119,7 +119,7 @@ func (ss *StyleSetter) Build() { func (ss *StyleSetter) Push() { // Push colors for k, v := range ss.colors { - imgui.PushStyleColor(imgui.StyleColorID(k), ToVec4Color(v)) + imgui.PushStyleColorVec4(imgui.Col(k), ToVec4Color(v)) } // push style vars @@ -133,7 +133,7 @@ func (ss *StyleSetter) Push() { value = imgui.Vec2{X: typed, Y: typed} } - imgui.PushStyleVarVec2(imgui.StyleVarID(k), value) + imgui.PushStyleVarVec2(imgui.StyleVar(k), value) } else { var value float32 switch typed := v.(type) { @@ -143,7 +143,7 @@ func (ss *StyleSetter) Push() { value = typed.X } - imgui.PushStyleVarFloat(imgui.StyleVarID(k), value) + imgui.PushStyleVarFloat(imgui.StyleVar(k), value) } } @@ -152,7 +152,9 @@ func (ss *StyleSetter) Push() { ss.isFontPushed = PushFont(ss.font) } - imgui.BeginDisabled(ss.disabled) + if ss.disabled { + imgui.BeginDisabled() + } } // Pop allows to manually pop the whole StyleSetter (use after Push!) @@ -161,7 +163,9 @@ func (ss *StyleSetter) Pop() { imgui.PopFont() } - imgui.EndDisabled() - imgui.PopStyleColorV(len(ss.colors)) - imgui.PopStyleVarV(len(ss.styles)) + if ss.disabled { + imgui.EndDisabled() + } + imgui.PopStyleColorV(int32(len(ss.colors))) + imgui.PopStyleVarV(int32(len(ss.styles))) } diff --git a/TableWidgets.go b/TableWidgets.go index a02d59e3..5b9610b3 100644 --- a/TableWidgets.go +++ b/TableWidgets.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) type TableRowWidget struct { @@ -39,7 +39,7 @@ func (r *TableRowWidget) MinHeight(height float64) *TableRowWidget { // BuildTableRow executes table row build steps. func (r *TableRowWidget) BuildTableRow() { - imgui.TableNextRow(imgui.TableRowFlags(r.flags), r.minRowHeight) + imgui.TableNextRowV(imgui.TableRowFlags(r.flags), float32(r.minRowHeight)) for _, w := range r.layout { switch w.(type) { @@ -54,7 +54,7 @@ func (r *TableRowWidget) BuildTableRow() { } if r.bgColor != nil { - imgui.TableSetBgColor(imgui.TableBgTarget_RowBg0, uint32(imgui.GetColorU32(ToVec4Color(r.bgColor))), -1) + imgui.TableSetBgColorV(imgui.ImGuiTableBgTarget_RowBg0, uint32(imgui.GetColorU32Vec4(ToVec4Color(r.bgColor))), -1) } } @@ -91,7 +91,7 @@ func (c *TableColumnWidget) UserID(id uint32) *TableColumnWidget { // BuildTableColumn executes table column build steps. func (c *TableColumnWidget) BuildTableColumn() { - imgui.TableSetupColumn(c.label, imgui.TableColumnFlags(c.flags), c.innerWidthOrWeight, c.userID) + imgui.TableSetupColumnV(c.label, imgui.TableColumnFlags(c.flags), c.innerWidthOrWeight, c.userID) } var _ Widget = &TableWidget{} @@ -176,9 +176,9 @@ func (t *TableWidget) Build() { colCount = len(t.rows[0].layout) } - if imgui.BeginTable(t.id, colCount, imgui.TableFlags(t.flags), t.size, t.innerWidth) { + if imgui.BeginTableV(t.id, int32(colCount), imgui.TableFlags(t.flags), t.size, float32(t.innerWidth)) { if t.freezeColumn >= 0 && t.freezeRow >= 0 { - imgui.TableSetupScrollFreeze(t.freezeColumn, t.freezeRow) + imgui.TableSetupScrollFreeze(int32(t.freezeColumn), int32(t.freezeRow)) } if len(t.columns) > 0 { @@ -190,13 +190,13 @@ func (t *TableWidget) Build() { } if t.fastMode { - clipper := imgui.NewListClipper() - defer clipper.Delete() + clipper := imgui.NewImGuiListClipper() + defer clipper.Destroy() - clipper.Begin(len(t.rows)) + clipper.Begin(int32(len(t.rows))) for clipper.Step() { - for i := clipper.DisplayStart(); i < clipper.DisplayEnd(); i++ { + for i := clipper.GetDisplayStart(); i < clipper.GetDisplayEnd(); i++ { row := t.rows[i] row.BuildTableRow() } diff --git a/TextWidgets.go b/TextWidgets.go index b335abaa..5c5fb1db 100644 --- a/TextWidgets.go +++ b/TextWidgets.go @@ -4,7 +4,7 @@ import ( "fmt" "math" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" "github.com/sahilm/fuzzy" ) diff --git a/Texture.go b/Texture.go index db9f7e54..970ac16a 100644 --- a/Texture.go +++ b/Texture.go @@ -5,7 +5,7 @@ import ( "image" "runtime" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" "github.com/faiface/mainthread" ) diff --git a/Utils.go b/Utils.go index 8260b602..37d415ff 100644 --- a/Utils.go +++ b/Utils.go @@ -10,7 +10,7 @@ import ( "os" "path/filepath" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" "github.com/pkg/browser" ) @@ -143,15 +143,15 @@ func SetNextWindowSize(width, height float32) { imgui.SetNextWindowSize(imgui.Vec2{X: width, Y: height}) } -// ExecCondition represents imgui.Condition. -type ExecCondition imgui.Condition +// ExecCondition represents imgui.Cond. +type ExecCondition imgui.Cond // imgui conditions. const ( - ConditionAlways ExecCondition = ExecCondition(imgui.ConditionAlways) - ConditionOnce ExecCondition = ExecCondition(imgui.ConditionOnce) - ConditionFirstUseEver ExecCondition = ExecCondition(imgui.ConditionFirstUseEver) - ConditionAppearing ExecCondition = ExecCondition(imgui.ConditionAppearing) + ConditionAlways ExecCondition = ExecCondition(imgui.CondAlways) + ConditionOnce ExecCondition = ExecCondition(imgui.CondOnce) + ConditionFirstUseEver ExecCondition = ExecCondition(imgui.CondFirstUseEver) + ConditionAppearing ExecCondition = ExecCondition(imgui.CondAppearing) ) // SetNextWindowPos sets position of next window. @@ -159,14 +159,14 @@ func SetNextWindowPos(x, y float32) { imgui.SetNextWindowPos(imgui.Vec2{X: x, Y: y}) } -// SetNextWindowSizeV does similar to SetNextWIndowSize but allows to specify imgui.Condition. +// SetNextWindowSizeV does similar to SetNextWIndowSize but allows to specify imgui.Cond. func SetNextWindowSizeV(width, height float32, condition ExecCondition) { imgui.SetNextWindowSizeV( imgui.Vec2{ X: width, Y: height, }, - imgui.Condition(condition), + imgui.Cond(condition), ) } @@ -216,3 +216,26 @@ func OpenURL(url string) { log.Printf("Error opening %s: %v", url, err) } } + +// ColorToUint converts GO color into Uint32 color +// it is 0xRRGGBBAA +func ColorToUint(col color.Color) uint32 { + r, g, b, a := col.RGBA() + mask := uint32(0xff) + return r&mask<<24 + g&mask<<16 + b&mask<<8 + a&mask +} + +// UintToColor converts uint32 of form 0xRRGGBB into color.RGBA +func UintToColor(col uint32) *color.RGBA { + mask := 0xff + r := byte(col >> 24 & uint32(mask)) + g := byte(col >> 16 & uint32(mask)) + b := byte(col >> 8 & uint32(mask)) + a := byte(col >> 0 & uint32(mask)) + return &color.RGBA{ + R: r, + G: g, + B: b, + A: a, + } +} diff --git a/Utils_test.go b/Utils_test.go index 05810a2a..1c30a71a 100644 --- a/Utils_test.go +++ b/Utils_test.go @@ -5,7 +5,7 @@ import ( "image/color" "testing" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" "github.com/stretchr/testify/assert" ) diff --git a/Widgets.go b/Widgets.go index 2691ebb2..7678dda2 100644 --- a/Widgets.go +++ b/Widgets.go @@ -4,7 +4,7 @@ import ( "fmt" "image/color" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // GenAutoID automatically generates fidget's id. @@ -72,7 +72,7 @@ type ChildWidget struct { // Build implements Widget interface. func (c *ChildWidget) Build() { - if imgui.BeginChildV(c.id, imgui.Vec2{X: c.width, Y: c.height}, c.border, int(c.flags)) { + if imgui.BeginChildStrV(c.id, imgui.Vec2{X: c.width, Y: c.height}, c.border, imgui.WindowFlags(c.flags)) { c.layout.Build() } @@ -163,7 +163,7 @@ func (cc *ComboCustomWidget) Build() { defer imgui.PopItemWidth() } - if imgui.BeginComboV(Context.FontAtlas.RegisterString(cc.label), cc.previewValue, int(cc.flags)) { + if imgui.BeginComboV(Context.FontAtlas.RegisterString(cc.label), cc.previewValue, imgui.ComboFlags(cc.flags)) { cc.layout.Build() imgui.EndCombo() } @@ -203,9 +203,9 @@ func (c *ComboWidget) Build() { defer imgui.PopItemWidth() } - if imgui.BeginComboV(Context.FontAtlas.RegisterString(c.label), c.previewValue, int(c.flags)) { + if imgui.BeginComboV(Context.FontAtlas.RegisterString(c.label), c.previewValue, imgui.ComboFlags(c.flags)) { for i, item := range c.items { - if imgui.Selectable(item) { + if imgui.SelectableBool(item) { *c.selected = int32(i) if c.onChange != nil { c.onChange() @@ -268,7 +268,7 @@ func (c *ContextMenuWidget) ID(id string) *ContextMenuWidget { // Build implements Widget interface. func (c *ContextMenuWidget) Build() { - if imgui.BeginPopupContextItemV(c.id, int(c.mouseButton)) { + if imgui.BeginPopupContextItemV(c.id, imgui.ImGuiPopupFlags(c.mouseButton)) { c.layout.Build() imgui.EndPopup() } @@ -308,7 +308,7 @@ func (d *DragIntWidget) Format(format string) *DragIntWidget { // Build implements Widget interface. func (d *DragIntWidget) Build() { - imgui.DragIntV(Context.FontAtlas.RegisterString(d.label), d.value, d.speed, d.min, d.max, d.format) + imgui.DragIntV(Context.FontAtlas.RegisterString(d.label), d.value, d.speed, d.min, d.max, d.format, 0) } var _ Widget = &ColumnWidget{} @@ -430,7 +430,7 @@ func (m *MenuItemWidget) OnClick(onClick func()) *MenuItemWidget { // Build implements Widget interface. func (m *MenuItemWidget) Build() { - if imgui.MenuItemV(Context.FontAtlas.RegisterString(m.label), m.shortcut, m.selected, m.enabled) && m.onClick != nil { + if imgui.MenuItemBoolV(Context.FontAtlas.RegisterString(m.label), m.shortcut, m.selected, m.enabled) && m.onClick != nil { m.onClick() } } @@ -589,7 +589,7 @@ func (t *TabItemWidget) Layout(widgets ...Widget) *TabItemWidget { // BuildTabItem executes tab item build steps. func (t *TabItemWidget) BuildTabItem() { - if imgui.BeginTabItemV(t.label, t.open, int(t.flags)) { + if imgui.BeginTabItemV(t.label, t.open, imgui.TabItemFlags(t.flags)) { t.layout.Build() imgui.EndTabItem() } @@ -627,7 +627,7 @@ func (t *TabBarWidget) TabItems(items ...*TabItemWidget) *TabBarWidget { // Build implements Widget interface. func (t *TabBarWidget) Build() { - if imgui.BeginTabBarV(t.id, int(t.flags)) { + if imgui.BeginTabBarV(t.id, imgui.TabBarFlags(t.flags)) { for _, ti := range t.tabItems { ti.BuildTabItem() } @@ -699,7 +699,7 @@ func ColorEdit(label string, c *color.RGBA) *ColorEditWidget { return &ColorEditWidget{ label: GenAutoID(label), color: c, - flags: ColorEditFlagsNone, + // flags: ColorEditFlagsNone, } } diff --git a/Window.go b/Window.go index 2d7def68..93de1eeb 100644 --- a/Window.go +++ b/Window.go @@ -3,7 +3,7 @@ package giu import ( "fmt" - "github.com/AllenDang/imgui-go" + "github.com/AllenDang/cimgui-go" ) // SingleWindow creates one window filling all available space @@ -15,11 +15,11 @@ func SingleWindow() *WindowWidget { return Window(title). Flags( - imgui.WindowFlagsNoTitleBar| - imgui.WindowFlagsNoCollapse| - imgui.WindowFlagsNoScrollbar| - imgui.WindowFlagsNoMove| - imgui.WindowFlagsNoResize). + WindowFlags(imgui.WindowFlagsNoTitleBar)| + WindowFlags(imgui.WindowFlagsNoCollapse)| + WindowFlags(imgui.WindowFlagsNoScrollbar)| + WindowFlags(imgui.WindowFlagsNoMove)| + WindowFlags(imgui.WindowFlagsNoResize)). Size(size[0], size[1]) } @@ -30,12 +30,12 @@ func SingleWindowWithMenuBar() *WindowWidget { return Window(title). Flags( - imgui.WindowFlagsNoTitleBar| - imgui.WindowFlagsNoCollapse| - imgui.WindowFlagsNoScrollbar| - imgui.WindowFlagsNoMove| - imgui.WindowFlagsMenuBar| - imgui.WindowFlagsNoResize).Size(size[0], size[1]) + WindowFlags(imgui.WindowFlagsNoTitleBar)| + WindowFlags(imgui.WindowFlagsNoCollapse)| + WindowFlags(imgui.WindowFlagsNoScrollbar)| + WindowFlags(imgui.WindowFlagsNoMove)| + WindowFlags(imgui.WindowFlagsMenuBar)| + WindowFlags(imgui.WindowFlagsNoResize)).Size(size[0], size[1]) } var _ Disposable = &windowState{} @@ -109,12 +109,12 @@ func (w *WindowWidget) Layout(widgets ...Widget) { ws := w.getState() - if w.flags&imgui.WindowFlagsNoMove != 0 && w.flags&imgui.WindowFlagsNoResize != 0 { + if w.flags&WindowFlags(imgui.WindowFlagsNoMove) != 0 && w.flags&WindowFlags(imgui.WindowFlagsNoResize) != 0 { imgui.SetNextWindowPos(imgui.Vec2{X: w.x, Y: w.y}) imgui.SetNextWindowSize(imgui.Vec2{X: w.width, Y: w.height}) } else { - imgui.SetNextWindowPosV(imgui.Vec2{X: w.x, Y: w.y}, imgui.ConditionFirstUseEver, imgui.Vec2{X: 0, Y: 0}) - imgui.SetNextWindowSizeV(imgui.Vec2{X: w.width, Y: w.height}, imgui.ConditionFirstUseEver) + imgui.SetNextWindowPosV(imgui.Vec2{X: w.x, Y: w.y}, imgui.CondFirstUseEver, imgui.Vec2{X: 0, Y: 0}) + imgui.SetNextWindowSizeV(imgui.Vec2{X: w.width, Y: w.height}, imgui.CondFirstUseEver) } if w.bringToFront { @@ -132,12 +132,12 @@ func (w *WindowWidget) Layout(widgets ...Widget) { ws.hasFocus = hasFocus - ws.currentPosition = imgui.WindowPos() - ws.currentSize = imgui.WindowSize() + ws.currentPosition = imgui.GetWindowPos() + ws.currentSize = imgui.GetWindowSize() }), ) - showed := imgui.BeginV(Context.FontAtlas.RegisterString(w.title), w.open, int(w.flags)) + showed := imgui.BeginV(Context.FontAtlas.RegisterString(w.title), w.open, imgui.WindowFlags(w.flags)) if showed { Layout(widgets).Build() diff --git a/examples/canvas/canvas.go b/examples/canvas/canvas.go index 4b21ff90..c210bcf6 100644 --- a/examples/canvas/canvas.go +++ b/examples/canvas/canvas.go @@ -16,7 +16,7 @@ func loop() { canvas := g.GetCanvas() pos := g.GetCursorScreenPos() color := color.RGBA{200, 75, 75, 255} - canvas.AddLine(pos, pos.Add(image.Pt(100, 100)), color, 1) + canvas.AddLineV(pos, pos.Add(image.Pt(100, 100)), color, 1) canvas.AddRect(pos.Add(image.Pt(110, 0)), pos.Add(image.Pt(200, 100)), color, 5, g.DrawFlagsRoundCornersAll, 1) canvas.AddRectFilled(pos.Add(image.Pt(220, 0)), pos.Add(image.Pt(320, 100)), color, 0, 0) diff --git a/examples/codeeditor/codeeditor.go b/examples/codeeditor/codeeditor.go index cb0bb5e1..85468d6e 100644 --- a/examples/codeeditor/codeeditor.go +++ b/examples/codeeditor/codeeditor.go @@ -3,9 +3,9 @@ package main import ( "fmt" + "github.com/AllenDang/cimgui-go" "github.com/AllenDang/giu" g "github.com/AllenDang/giu" - "github.com/AllenDang/imgui-go" ) var ( diff --git a/examples/discussion-648/main.go b/examples/discussion-648/main.go new file mode 100644 index 00000000..b1ef4af1 --- /dev/null +++ b/examples/discussion-648/main.go @@ -0,0 +1,22 @@ +package main + +import "github.com/AllenDang/giu" + +func loop() { + giu.Window("wnd").Layout( + giu.Custom(func() { + const footerPercentage = 0.2 + _, availableH := giu.GetAvailableRegion() + _, itemSpacingH := giu.GetItemSpacing() + giu.Layout{ + giu.Child().Layout(giu.Label("your layout")).Size(-1, (availableH-itemSpacingH)*(1-footerPercentage)), + giu.Child().Layout(giu.Label("footer")).Size(-1, (availableH-itemSpacingH)*footerPercentage), + }.Build() + }), + ) +} + +func main() { + wnd := giu.NewMasterWindow("How do I make this Child show as a footer? #648", 640, 480, 0) + wnd.Run(loop) +} diff --git a/examples/discussion-652/main.go b/examples/discussion-652/main.go new file mode 100644 index 00000000..333d85ad --- /dev/null +++ b/examples/discussion-652/main.go @@ -0,0 +1,23 @@ +package main + +import "github.com/AllenDang/giu" + +func loop() { + giu.SingleWindow().Layout( + giu.Table().Columns( + giu.TableColumn("State").InnerWidthOrWeight(20).Flags(giu.TableColumnFlagsWidthFixed), + ).Rows( + giu.TableRow( + giu.Label("1"), + ), + giu.TableRow( + giu.Label("2"), + ), + ), + ) +} + +func main() { + wnd := giu.NewMasterWindow("Width of table column [discussion 652]", 64, 480, 0) + wnd.Run(loop) +} diff --git a/examples/dragdrop/dragdrop.go b/examples/dragdrop/dragdrop.go index 9cb92c3a..5ef308b8 100644 --- a/examples/dragdrop/dragdrop.go +++ b/examples/dragdrop/dragdrop.go @@ -3,8 +3,8 @@ package main import ( "fmt" + "github.com/AllenDang/cimgui-go" g "github.com/AllenDang/giu" - "github.com/AllenDang/imgui-go" ) var ( diff --git a/examples/imguidemo/imguidemo.go b/examples/imguidemo/imguidemo.go index 17f685c8..4f7200e5 100644 --- a/examples/imguidemo/imguidemo.go +++ b/examples/imguidemo/imguidemo.go @@ -1,8 +1,8 @@ package main import ( + "github.com/AllenDang/cimgui-go" g "github.com/AllenDang/giu" - "github.com/AllenDang/imgui-go" ) func loop() { diff --git a/examples/transparent/transparent.go b/examples/transparent/transparent.go index 0062b711..7dc26dd0 100644 --- a/examples/transparent/transparent.go +++ b/examples/transparent/transparent.go @@ -4,8 +4,8 @@ import ( "image" "image/color" + "github.com/AllenDang/cimgui-go" g "github.com/AllenDang/giu" - "github.com/AllenDang/imgui-go" ) func loop() { @@ -17,7 +17,7 @@ func loop() { canvas := g.GetCanvas() pos := g.GetCursorScreenPos() color := color.RGBA{200, 75, 75, 255} - canvas.AddLine(pos, pos.Add(image.Pt(100, 100)), color, 1) + canvas.AddLineV(pos, pos.Add(image.Pt(100, 100)), color, 1) canvas.AddRect(pos.Add(image.Pt(110, 0)), pos.Add(image.Pt(200, 100)), color, 5, g.DrawFlagsRoundCornersAll, 1) canvas.AddRectFilled(pos.Add(image.Pt(220, 0)), pos.Add(image.Pt(320, 100)), color, 0, 0) diff --git a/examples/widgets/widgets.zip b/examples/widgets/widgets.zip new file mode 100644 index 00000000..84a6dc67 Binary files /dev/null and b/examples/widgets/widgets.zip differ diff --git a/go.mod b/go.mod index 94c7aeed..f6740f06 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/AllenDang/giu go 1.18 require ( + github.com/AllenDang/cimgui-go v0.0.0-20230426074355-28d4043c870b github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8 - github.com/AllenDang/imgui-go v1.12.1-0.20221124025851-59b862ca5a0c github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b github.com/mazznoer/csscolorparser v0.1.3 @@ -18,7 +18,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect diff --git a/go.sum b/go.sum index 696547b7..b5778ffd 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,12 @@ +github.com/AllenDang/cimgui-go v0.0.0-20230426074355-28d4043c870b h1:pR7HmLFgkwbfnL+FrcJMyJ4pDVspPk3mW43EZfV1qb0= +github.com/AllenDang/cimgui-go v0.0.0-20230426074355-28d4043c870b/go.mod h1:iNfbIyOBN8k3XScMxULbrwYbPsXEAUD0Jb6UwrspQb8= 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/AllenDang/imgui-go v1.12.1-0.20221124025851-59b862ca5a0c h1:kiXjH0n0KzOpvhgy3nDFkPmKfg4A+QWsEOwxwWy6yuI= -github.com/AllenDang/imgui-go v1.12.1-0.20221124025851-59b862ca5a0c/go.mod h1:kuPs9RWleaUuK7D49bE6HPxyRA36Lp4ICKGp+5OnnbY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 h1:baVdMKlASEHrj19iqjARrPbaRisD7EuZEVJj6ZMLl1Q= github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3/go.mod h1:VEPNJUlxl5KdWjDvz6Q1l+rJlxF2i6xqDeGuGAxa87M= -github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk= -github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b h1:GgabKamyOYguHqHjSkDACcgoPIz3w0Dis/zJ1wyHHHU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -18,6 +15,8 @@ github.com/mazznoer/csscolorparser v0.1.3 h1:vug4zh6loQxAUxfU1DZEu70gTPufDPspamZ github.com/mazznoer/csscolorparser v0.1.3/go.mod h1:Aj22+L/rYN/Y6bj3bYqO3N6g1dtdHtGfQ32xZ5PJQic= github.com/napsy/go-css v0.0.0-20221107082635-4ed403047a64 h1:7LWtWY3Ei9ghnamqn8xCu7LOXAKaQrcfbcf0sU33LG4= github.com/napsy/go-css v0.0.0-20221107082635-4ed403047a64/go.mod h1:HqZYcKcNnv50fgOTdGUn9YbJa2qC9oJ3kLnyrwwVzUI= +github.com/neclepsio/cimgui-go v0.0.0-20230110143046-e2590f5e36f7 h1:Bp6/3un98IfhcAa5zcZ6TrhxB6Mn5WKw+LJY4LBo/4s= +github.com/neclepsio/cimgui-go v0.0.0-20230110143046-e2590f5e36f7/go.mod h1:vIyZDtr51WCmf1gWopQS4pAWdS5ma/PJ9Ypc1PbvLDE= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -27,7 +26,6 @@ github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=