diff --git a/Context.go b/Context.go index d92a21d8..736a756c 100644 --- a/Context.go +++ b/Context.go @@ -4,7 +4,9 @@ import ( "fmt" "sync" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/backend" + "github.com/AllenDang/cimgui-go/backend/glfwbackend" + "github.com/AllenDang/cimgui-go/imgui" "gopkg.in/eapache/queue.v1" ) @@ -42,7 +44,7 @@ type state struct { } type context struct { - backend imgui.Backend[imgui.GLFWWindowFlags] + backend backend.Backend[glfwbackend.GLFWWindowFlags] isRunning bool @@ -64,7 +66,7 @@ type context struct { m *sync.Mutex } -func CreateContext(b imgui.Backend[imgui.GLFWWindowFlags]) *context { +func CreateContext(b backend.Backend[glfwbackend.GLFWWindowFlags]) *context { result := context{ cssStylesheet: make(cssStylesheet), backend: b, @@ -125,7 +127,7 @@ func (c *context) cleanState() { c.widgetIndex = make(map[string]int) } -func (c *context) Backend() imgui.Backend[imgui.GLFWWindowFlags] { +func (c *context) Backend() backend.Backend[glfwbackend.GLFWWindowFlags] { return c.backend } diff --git a/Direction.go b/Direction.go index c9c58787..899cebf4 100644 --- a/Direction.go +++ b/Direction.go @@ -1,6 +1,6 @@ package giu -import imgui "github.com/AllenDang/cimgui-go" +import "github.com/AllenDang/cimgui-go/imgui" // Direction represents a ArrowButton direction. type Direction imgui.Dir diff --git a/Events.go b/Events.go index a108f86d..f803350c 100644 --- a/Events.go +++ b/Events.go @@ -1,6 +1,6 @@ package giu -import imgui "github.com/AllenDang/cimgui-go" +import "github.com/AllenDang/cimgui-go/imgui" // MouseButton represents imgui.MouseButton. type MouseButton imgui.MouseButton diff --git a/ExtraWidgets.go b/ExtraWidgets.go index 9bc571d9..31fe9649 100644 --- a/ExtraWidgets.go +++ b/ExtraWidgets.go @@ -5,7 +5,7 @@ import ( "image" "time" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) var _ Widget = &SplitterWidget{} diff --git a/Flags.go b/Flags.go index 4de7e185..087b074f 100644 --- a/Flags.go +++ b/Flags.go @@ -1,6 +1,10 @@ package giu -import imgui "github.com/AllenDang/cimgui-go" +import ( + "github.com/AllenDang/cimgui-go/backend/glfwbackend" + "github.com/AllenDang/cimgui-go/imgui" + "github.com/AllenDang/cimgui-go/implot" +) // InputTextFlags represents input text flags. type InputTextFlags imgui.InputTextFlags @@ -51,7 +55,7 @@ const ( ) // WindowFlags represents a window flags (see (*WindowWidget).Flags. -type WindowFlags imgui.GLFWWindowFlags +type WindowFlags glfwbackend.GLFWWindowFlags // window flags. const ( @@ -145,7 +149,7 @@ const ( // SelectableFlagsNone default = 0. SelectableFlagsNone = SelectableFlags(imgui.SelectableFlagsNone) // SelectableFlagsDontClosePopups makes clicking the selectable not close any parent popup windows. - SelectableFlagsDontClosePopups = SelectableFlags(imgui.SelectableFlagsDontClosePopups) + SelectableFlagsDontClosePopups = SelectableFlags(imgui.SelectableFlagsNoAutoClosePopups) // SelectableFlagsSpanAllColumns allows the selectable frame to span all columns (text will still fit in current column). SelectableFlagsSpanAllColumns = SelectableFlags(imgui.SelectableFlagsSpanAllColumns) // SelectableFlagsAllowDoubleClick generates press events on double clicks too. @@ -463,47 +467,47 @@ const ( SliderFlagsInvalidMask = SliderFlags(imgui.SliderFlagsInvalidMask) ) -// PlotFlags represents imgui.PlotFlags. -type PlotFlags imgui.PlotFlags +// PlotFlags represents implot.PlotFlags. +type PlotFlags implot.PlotFlags // plot flags. const ( - 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) + PlotFlagsNone = PlotFlags(implot.PlotFlagsNone) + PlotFlagsNoTitle = PlotFlags(implot.PlotFlagsNoTitle) + PlotFlagsNoLegend = PlotFlags(implot.PlotFlagsNoLegend) + PlotFlagsNoMenus = PlotFlags(implot.PlotFlagsNoMenus) + PlotFlagsNoBoxSelect = PlotFlags(implot.PlotFlagsNoBoxSelect) + // PlotFlagsNoMousePos = PlotFlags(implot.PlotFlagsNoMousePos) + // PlotFlagsNoHighlight = PlotFlags(implot.PlotFlagsNoHighlight) + // PlotFlagsNoChild = PlotFlags(implot.PlotFlagsNoChild). + PlotFlagsEqual = PlotFlags(implot.PlotFlagsEqual) + // PlotFlagsYAxis2 = PlotFlags(implot.PlotFlagsYAxis2) + // PlotFlagsYAxis3 = PlotFlags(implot.PlotFlagsYAxis3) + // PlotFlagsQuery = PlotFlags(implot.PlotFlagsQuery) + PlotFlagsCrosshairs = PlotFlags(implot.PlotFlagsCrosshairs) + // PlotFlagsAntiAliased = PlotFlags(implot.PlotFlagsAntiAliased) + PlotFlagsCanvasOnly = PlotFlags(implot.PlotFlagsCanvasOnly) ) -// PlotAxisFlags represents imgui.PlotAxisFlags. -type PlotAxisFlags imgui.PlotAxisFlags +// PlotAxisFlags represents implot.PlotAxisFlags. +type PlotAxisFlags implot.PlotAxisFlags // plot axis flags. const ( - 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) + PlotAxisFlagsNone PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNone) + PlotAxisFlagsNoLabel PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNoLabel) + PlotAxisFlagsNoGridLines PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNoGridLines) + PlotAxisFlagsNoTickMarks PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNoTickMarks) + PlotAxisFlagsNoTickLabels PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNoTickLabels) + PlotAxisFlagsForeground PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsForeground) + // PlotAxisFlagsLogScale PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsLogScale) + // PlotAxisFlagsTime PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsTime) + PlotAxisFlagsInvert PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsInvert) + PlotAxisFlagsNoInitialFit PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNoInitialFit) + PlotAxisFlagsAutoFit PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsAutoFit) + PlotAxisFlagsRangeFit PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsRangeFit) + PlotAxisFlagsLockMin PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsLockMin) + PlotAxisFlagsLockMax PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsLockMax) + PlotAxisFlagsLock PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsLock) + PlotAxisFlagsNoDecorations PlotAxisFlags = PlotAxisFlags(implot.PlotAxisFlagsNoDecorations) ) diff --git a/FontAtlasProsessor.go b/FontAtlasProsessor.go index 80a8b684..008d009f 100644 --- a/FontAtlasProsessor.go +++ b/FontAtlasProsessor.go @@ -8,7 +8,7 @@ import ( "sync" "unsafe" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" "github.com/AllenDang/go-findfont" ) diff --git a/ImageWidgets.go b/ImageWidgets.go index 2b553795..7c76e48c 100644 --- a/ImageWidgets.go +++ b/ImageWidgets.go @@ -9,7 +9,7 @@ import ( "reflect" "time" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) var _ Widget = &ImageWidget{} diff --git a/Keycode.go b/Keycode.go index 261a2514..c59c3901 100644 --- a/Keycode.go +++ b/Keycode.go @@ -4,7 +4,8 @@ import "C" import ( "log" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/backend/glfwbackend" + "github.com/AllenDang/cimgui-go/imgui" ) // Key represents a imgui key. @@ -94,23 +95,23 @@ const ( KeyF10 = Key(imgui.KeyF10) KeyF11 = Key(imgui.KeyF11) KeyF12 = Key(imgui.KeyF12) - KeyNumPad0 = Key(imgui.GLFWKeyKp0) - KeyNumPad1 = Key(imgui.GLFWKeyKp1) - KeyNumPad2 = Key(imgui.GLFWKeyKp2) - KeyNumPad3 = Key(imgui.GLFWKeyKp3) - KeyNumPad4 = Key(imgui.GLFWKeyKp4) - KeyNumPad5 = Key(imgui.GLFWKeyKp5) - KeyNumPad6 = Key(imgui.GLFWKeyKp6) - KeyNumPad7 = Key(imgui.GLFWKeyKp7) - KeyNumPad8 = Key(imgui.GLFWKeyKp8) - KeyNumPad9 = Key(imgui.GLFWKeyKp9) - KeyNumPadDecimal = Key(imgui.GLFWKeyKpDecimal) - KeyNumPadDivide = Key(imgui.GLFWKeyKpDivide) - KeyNumPadMultiply = Key(imgui.GLFWKeyKpMultiply) - KeyNumPadSubtract = Key(imgui.GLFWKeyKpSubtract) - KeyNumPadAdd = Key(imgui.GLFWKeyKpAdd) - KeyNumPadEnter = Key(imgui.GLFWKeyKpEnter) - KeyNumPadEqual = Key(imgui.GLFWKeyKpEqual) + KeyNumPad0 = Key(glfwbackend.GLFWKeyKp0) + KeyNumPad1 = Key(glfwbackend.GLFWKeyKp1) + KeyNumPad2 = Key(glfwbackend.GLFWKeyKp2) + KeyNumPad3 = Key(glfwbackend.GLFWKeyKp3) + KeyNumPad4 = Key(glfwbackend.GLFWKeyKp4) + KeyNumPad5 = Key(glfwbackend.GLFWKeyKp5) + KeyNumPad6 = Key(glfwbackend.GLFWKeyKp6) + KeyNumPad7 = Key(glfwbackend.GLFWKeyKp7) + KeyNumPad8 = Key(glfwbackend.GLFWKeyKp8) + KeyNumPad9 = Key(glfwbackend.GLFWKeyKp9) + KeyNumPadDecimal = Key(glfwbackend.GLFWKeyKpDecimal) + KeyNumPadDivide = Key(glfwbackend.GLFWKeyKpDivide) + KeyNumPadMultiply = Key(glfwbackend.GLFWKeyKpMultiply) + KeyNumPadSubtract = Key(glfwbackend.GLFWKeyKpSubtract) + KeyNumPadAdd = Key(glfwbackend.GLFWKeyKpAdd) + KeyNumPadEnter = Key(glfwbackend.GLFWKeyKpEnter) + KeyNumPadEqual = Key(glfwbackend.GLFWKeyKpEqual) KeyLeftShift = Key(imgui.KeyLeftShift) KeyLeftControl = Key(imgui.KeyLeftCtrl) KeyLeftAlt = Key(imgui.KeyLeftAlt) @@ -120,122 +121,122 @@ const ( KeyRightAlt = Key(imgui.KeyRightAlt) KeyRightSuper = Key(imgui.KeyRightSuper) KeyMenu = Key(imgui.KeyMenu) - KeyWorld1 = Key(imgui.GLFWKeyWorld1) - KeyWorld2 = Key(imgui.GLFWKeyWorld2) + KeyWorld1 = Key(glfwbackend.GLFWKeyWorld1) + KeyWorld2 = Key(glfwbackend.GLFWKeyWorld2) KeyUnknown = Key(-1) ) // refer glfw3.h. -func keyFromGLFWKey(k imgui.GLFWKey) Key { - data := map[imgui.GLFWKey]Key{ - imgui.GLFWKeySpace: KeySpace, - imgui.GLFWKeyApostrophe: KeyApostrophe, - imgui.GLFWKeyComma: KeyComma, - imgui.GLFWKeyMinus: KeyMinus, - imgui.GLFWKeyPeriod: KeyPeriod, - imgui.GLFWKeySlash: KeySlash, - imgui.GLFWKey0: Key0, - imgui.GLFWKey1: Key1, - imgui.GLFWKey2: Key2, - imgui.GLFWKey3: Key3, - imgui.GLFWKey4: Key4, - imgui.GLFWKey5: Key5, - imgui.GLFWKey6: Key6, - imgui.GLFWKey7: Key7, - imgui.GLFWKey8: Key8, - imgui.GLFWKey9: Key9, - imgui.GLFWKeySemicolon: KeySemicolon, - imgui.GLFWKeyEqual: KeyEqual, - imgui.GLFWKeyA: KeyA, - imgui.GLFWKeyB: KeyB, - imgui.GLFWKeyC: KeyC, - imgui.GLFWKeyD: KeyD, - imgui.GLFWKeyE: KeyE, - imgui.GLFWKeyF: KeyF, - imgui.GLFWKeyG: KeyG, - imgui.GLFWKeyH: KeyH, - imgui.GLFWKeyI: KeyI, - imgui.GLFWKeyJ: KeyJ, - imgui.GLFWKeyK: KeyK, - imgui.GLFWKeyL: KeyL, - imgui.GLFWKeyM: KeyM, - imgui.GLFWKeyN: KeyN, - imgui.GLFWKeyO: KeyO, - imgui.GLFWKeyP: KeyP, - imgui.GLFWKeyQ: KeyQ, - imgui.GLFWKeyR: KeyR, - imgui.GLFWKeyS: KeyS, - imgui.GLFWKeyT: KeyT, - imgui.GLFWKeyU: KeyU, - imgui.GLFWKeyV: KeyV, - imgui.GLFWKeyW: KeyW, - imgui.GLFWKeyX: KeyX, - imgui.GLFWKeyY: KeyY, - imgui.GLFWKeyZ: KeyZ, - imgui.GLFWKeyLeftBracket: KeyLeftBracket, - imgui.GLFWKeyBackslash: KeyBackslash, - imgui.GLFWKeyRightBracket: KeyRightBracket, - imgui.GLFWKeyGraveAccent: KeyGraveAccent, - imgui.GLFWKeyEscape: KeyEscape, - imgui.GLFWKeyEnter: KeyEnter, - imgui.GLFWKeyTab: KeyTab, - imgui.GLFWKeyBackspace: KeyBackspace, - imgui.GLFWKeyInsert: KeyInsert, - imgui.GLFWKeyDelete: KeyDelete, - imgui.GLFWKeyRight: KeyRight, - imgui.GLFWKeyLeft: KeyLeft, - imgui.GLFWKeyDown: KeyDown, - imgui.GLFWKeyUp: KeyUp, - imgui.GLFWKeyPageUp: KeyPageUp, - imgui.GLFWKeyPageDown: KeyPageDown, - imgui.GLFWKeyHome: KeyHome, - imgui.GLFWKeyEnd: KeyEnd, - imgui.GLFWKeyCapsLock: KeyCapsLock, - imgui.GLFWKeyScrollLock: KeyScrollLock, - imgui.GLFWKeyNumLock: KeyNumLock, - imgui.GLFWKeyPrintScreen: KeyPrintScreen, - imgui.GLFWKeyPause: KeyPause, - imgui.GLFWKeyF1: KeyF1, - imgui.GLFWKeyF2: KeyF2, - imgui.GLFWKeyF3: KeyF3, - imgui.GLFWKeyF4: KeyF4, - imgui.GLFWKeyF5: KeyF5, - imgui.GLFWKeyF6: KeyF6, - imgui.GLFWKeyF7: KeyF7, - imgui.GLFWKeyF8: KeyF8, - imgui.GLFWKeyF9: KeyF9, - imgui.GLFWKeyF10: KeyF10, - imgui.GLFWKeyF11: KeyF11, - imgui.GLFWKeyF12: KeyF12, - imgui.GLFWKeyKp0: KeyNumPad0, - imgui.GLFWKeyKp1: KeyNumPad1, - imgui.GLFWKeyKp2: KeyNumPad2, - imgui.GLFWKeyKp3: KeyNumPad3, - imgui.GLFWKeyKp4: KeyNumPad4, - imgui.GLFWKeyKp5: KeyNumPad5, - imgui.GLFWKeyKp6: KeyNumPad6, - imgui.GLFWKeyKp7: KeyNumPad7, - imgui.GLFWKeyKp8: KeyNumPad8, - imgui.GLFWKeyKp9: KeyNumPad9, - imgui.GLFWKeyKpDecimal: KeyNumPadDecimal, - imgui.GLFWKeyKpDivide: KeyNumPadDivide, - imgui.GLFWKeyKpMultiply: KeyNumPadMultiply, - imgui.GLFWKeyKpSubtract: KeyNumPadSubtract, - imgui.GLFWKeyKpAdd: KeyNumPadAdd, - imgui.GLFWKeyKpEnter: KeyNumPadEnter, - imgui.GLFWKeyKpEqual: KeyNumPadEqual, - imgui.GLFWKeyLeftShift: KeyLeftShift, - imgui.GLFWKeyLeftControl: KeyLeftControl, - imgui.GLFWKeyLeftAlt: KeyLeftAlt, - imgui.GLFWKeyLeftSuper: KeyLeftSuper, - imgui.GLFWKeyRightShift: KeyRightShift, - imgui.GLFWKeyRightControl: KeyRightControl, - imgui.GLFWKeyRightAlt: KeyRightAlt, - imgui.GLFWKeyRightSuper: KeyRightSuper, - imgui.GLFWKeyMenu: KeyMenu, - imgui.GLFWKeyWorld1: KeyWorld1, - imgui.GLFWKeyWorld2: KeyWorld2, - -1: KeyUnknown, +func keyFromGLFWKey(k glfwbackend.GLFWKey) Key { + data := map[glfwbackend.GLFWKey]Key{ + glfwbackend.GLFWKeySpace: KeySpace, + glfwbackend.GLFWKeyApostrophe: KeyApostrophe, + glfwbackend.GLFWKeyComma: KeyComma, + glfwbackend.GLFWKeyMinus: KeyMinus, + glfwbackend.GLFWKeyPeriod: KeyPeriod, + glfwbackend.GLFWKeySlash: KeySlash, + glfwbackend.GLFWKey0: Key0, + glfwbackend.GLFWKey1: Key1, + glfwbackend.GLFWKey2: Key2, + glfwbackend.GLFWKey3: Key3, + glfwbackend.GLFWKey4: Key4, + glfwbackend.GLFWKey5: Key5, + glfwbackend.GLFWKey6: Key6, + glfwbackend.GLFWKey7: Key7, + glfwbackend.GLFWKey8: Key8, + glfwbackend.GLFWKey9: Key9, + glfwbackend.GLFWKeySemicolon: KeySemicolon, + glfwbackend.GLFWKeyEqual: KeyEqual, + glfwbackend.GLFWKeyA: KeyA, + glfwbackend.GLFWKeyB: KeyB, + glfwbackend.GLFWKeyC: KeyC, + glfwbackend.GLFWKeyD: KeyD, + glfwbackend.GLFWKeyE: KeyE, + glfwbackend.GLFWKeyF: KeyF, + glfwbackend.GLFWKeyG: KeyG, + glfwbackend.GLFWKeyH: KeyH, + glfwbackend.GLFWKeyI: KeyI, + glfwbackend.GLFWKeyJ: KeyJ, + glfwbackend.GLFWKeyK: KeyK, + glfwbackend.GLFWKeyL: KeyL, + glfwbackend.GLFWKeyM: KeyM, + glfwbackend.GLFWKeyN: KeyN, + glfwbackend.GLFWKeyO: KeyO, + glfwbackend.GLFWKeyP: KeyP, + glfwbackend.GLFWKeyQ: KeyQ, + glfwbackend.GLFWKeyR: KeyR, + glfwbackend.GLFWKeyS: KeyS, + glfwbackend.GLFWKeyT: KeyT, + glfwbackend.GLFWKeyU: KeyU, + glfwbackend.GLFWKeyV: KeyV, + glfwbackend.GLFWKeyW: KeyW, + glfwbackend.GLFWKeyX: KeyX, + glfwbackend.GLFWKeyY: KeyY, + glfwbackend.GLFWKeyZ: KeyZ, + glfwbackend.GLFWKeyLeftBracket: KeyLeftBracket, + glfwbackend.GLFWKeyBackslash: KeyBackslash, + glfwbackend.GLFWKeyRightBracket: KeyRightBracket, + glfwbackend.GLFWKeyGraveAccent: KeyGraveAccent, + glfwbackend.GLFWKeyEscape: KeyEscape, + glfwbackend.GLFWKeyEnter: KeyEnter, + glfwbackend.GLFWKeyTab: KeyTab, + glfwbackend.GLFWKeyBackspace: KeyBackspace, + glfwbackend.GLFWKeyInsert: KeyInsert, + glfwbackend.GLFWKeyDelete: KeyDelete, + glfwbackend.GLFWKeyRight: KeyRight, + glfwbackend.GLFWKeyLeft: KeyLeft, + glfwbackend.GLFWKeyDown: KeyDown, + glfwbackend.GLFWKeyUp: KeyUp, + glfwbackend.GLFWKeyPageUp: KeyPageUp, + glfwbackend.GLFWKeyPageDown: KeyPageDown, + glfwbackend.GLFWKeyHome: KeyHome, + glfwbackend.GLFWKeyEnd: KeyEnd, + glfwbackend.GLFWKeyCapsLock: KeyCapsLock, + glfwbackend.GLFWKeyScrollLock: KeyScrollLock, + glfwbackend.GLFWKeyNumLock: KeyNumLock, + glfwbackend.GLFWKeyPrintScreen: KeyPrintScreen, + glfwbackend.GLFWKeyPause: KeyPause, + glfwbackend.GLFWKeyF1: KeyF1, + glfwbackend.GLFWKeyF2: KeyF2, + glfwbackend.GLFWKeyF3: KeyF3, + glfwbackend.GLFWKeyF4: KeyF4, + glfwbackend.GLFWKeyF5: KeyF5, + glfwbackend.GLFWKeyF6: KeyF6, + glfwbackend.GLFWKeyF7: KeyF7, + glfwbackend.GLFWKeyF8: KeyF8, + glfwbackend.GLFWKeyF9: KeyF9, + glfwbackend.GLFWKeyF10: KeyF10, + glfwbackend.GLFWKeyF11: KeyF11, + glfwbackend.GLFWKeyF12: KeyF12, + glfwbackend.GLFWKeyKp0: KeyNumPad0, + glfwbackend.GLFWKeyKp1: KeyNumPad1, + glfwbackend.GLFWKeyKp2: KeyNumPad2, + glfwbackend.GLFWKeyKp3: KeyNumPad3, + glfwbackend.GLFWKeyKp4: KeyNumPad4, + glfwbackend.GLFWKeyKp5: KeyNumPad5, + glfwbackend.GLFWKeyKp6: KeyNumPad6, + glfwbackend.GLFWKeyKp7: KeyNumPad7, + glfwbackend.GLFWKeyKp8: KeyNumPad8, + glfwbackend.GLFWKeyKp9: KeyNumPad9, + glfwbackend.GLFWKeyKpDecimal: KeyNumPadDecimal, + glfwbackend.GLFWKeyKpDivide: KeyNumPadDivide, + glfwbackend.GLFWKeyKpMultiply: KeyNumPadMultiply, + glfwbackend.GLFWKeyKpSubtract: KeyNumPadSubtract, + glfwbackend.GLFWKeyKpAdd: KeyNumPadAdd, + glfwbackend.GLFWKeyKpEnter: KeyNumPadEnter, + glfwbackend.GLFWKeyKpEqual: KeyNumPadEqual, + glfwbackend.GLFWKeyLeftShift: KeyLeftShift, + glfwbackend.GLFWKeyLeftControl: KeyLeftControl, + glfwbackend.GLFWKeyLeftAlt: KeyLeftAlt, + glfwbackend.GLFWKeyLeftSuper: KeyLeftSuper, + glfwbackend.GLFWKeyRightShift: KeyRightShift, + glfwbackend.GLFWKeyRightControl: KeyRightControl, + glfwbackend.GLFWKeyRightAlt: KeyRightAlt, + glfwbackend.GLFWKeyRightSuper: KeyRightSuper, + glfwbackend.GLFWKeyMenu: KeyMenu, + glfwbackend.GLFWKeyWorld1: KeyWorld1, + glfwbackend.GLFWKeyWorld2: KeyWorld2, + -1: KeyUnknown, } if v, ok := data[k]; ok { @@ -253,12 +254,12 @@ type Modifier imgui.Key // modifier keys. const ( ModNone Modifier = 0 - ModControl = Modifier(imgui.GLFWModControl) - ModAlt = Modifier(imgui.GLFWModAlt) - ModSuper = Modifier(imgui.GLFWModSuper) - ModShift = Modifier(imgui.GLFWModShift) - ModCapsLock = Modifier(imgui.GLFWModCapsLock) - ModNumLock = Modifier(imgui.GLFWModNumLock) + ModControl = Modifier(glfwbackend.GLFWModControl) + ModAlt = Modifier(glfwbackend.GLFWModAlt) + ModSuper = Modifier(glfwbackend.GLFWModSuper) + ModShift = Modifier(glfwbackend.GLFWModShift) + ModCapsLock = Modifier(glfwbackend.GLFWModCapsLock) + ModNumLock = Modifier(glfwbackend.GLFWModNumLock) ) type Action int diff --git a/ListClipper.go b/ListClipper.go index 55a3779d..c48f0f81 100644 --- a/ListClipper.go +++ b/ListClipper.go @@ -1,6 +1,6 @@ package giu -import imgui "github.com/AllenDang/cimgui-go" +import "github.com/AllenDang/cimgui-go/imgui" var _ Widget = &ListClipperWrapper{} diff --git a/MasterWindow.go b/MasterWindow.go index 2a8d958c..10670f2b 100644 --- a/MasterWindow.go +++ b/MasterWindow.go @@ -6,7 +6,11 @@ import ( "image/color" "runtime" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/backend" + "github.com/AllenDang/cimgui-go/backend/glfwbackend" + "github.com/AllenDang/cimgui-go/imgui" + "github.com/AllenDang/cimgui-go/imnodes" + "github.com/AllenDang/cimgui-go/implot" "golang.org/x/image/colornames" ) @@ -29,18 +33,18 @@ const ( MasterWindowFlagsHidden ) -// parseAndApply converts MasterWindowFlags to appropriate imgui.GLFWWindowFlags. -func (m MasterWindowFlags) parseAndApply(b imgui.Backend[imgui.GLFWWindowFlags]) { +// parseAndApply converts MasterWindowFlags to appropriate glfwbackend.GLFWWindowFlags. +func (m MasterWindowFlags) parseAndApply(b backend.Backend[glfwbackend.GLFWWindowFlags]) { data := map[MasterWindowFlags]struct { - f imgui.GLFWWindowFlags + f glfwbackend.GLFWWindowFlags value int // value isn't always true (sometimes false). Also WindowHint takes int not bool }{ - MasterWindowFlagsNotResizable: {imgui.GLFWWindowFlagsResizable, 0}, - MasterWindowFlagsMaximized: {imgui.GLFWWindowFlagsMaximized, 1}, - MasterWindowFlagsFloating: {imgui.GLFWWindowFlagsFloating, 1}, - MasterWindowFlagsFrameless: {imgui.GLFWWindowFlagsDecorated, 0}, - MasterWindowFlagsTransparent: {imgui.GLFWWindowFlagsTransparent, 1}, - MasterWindowFlagsHidden: {imgui.GLFWWindowFlagsVisible, 0}, + MasterWindowFlagsNotResizable: {glfwbackend.GLFWWindowFlagsResizable, 0}, + MasterWindowFlagsMaximized: {glfwbackend.GLFWWindowFlagsMaximized, 1}, + MasterWindowFlagsFloating: {glfwbackend.GLFWWindowFlagsFloating, 1}, + MasterWindowFlagsFrameless: {glfwbackend.GLFWWindowFlagsDecorated, 0}, + MasterWindowFlagsTransparent: {glfwbackend.GLFWWindowFlagsTransparent, 1}, + MasterWindowFlagsHidden: {glfwbackend.GLFWWindowFlagsVisible, 0}, } for flag, d := range data { @@ -57,7 +61,7 @@ func (m MasterWindowFlags) parseAndApply(b imgui.Backend[imgui.GLFWWindowFlags]) // MasterWindow represents a glfw master window // It is a base for a windows (see Window.go). type MasterWindow struct { - backend imgui.Backend[imgui.GLFWWindowFlags] + backend backend.Backend[glfwbackend.GLFWWindowFlags] width int height int @@ -77,8 +81,8 @@ type MasterWindow struct { // see examples/helloworld/. func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) *MasterWindow { imGuiContext := imgui.CreateContext() - imgui.PlotCreateContext() - imgui.ImNodesCreateContext() + implot.PlotCreateContext() + imnodes.ImNodesCreateContext() io := imgui.CurrentIO() @@ -89,13 +93,13 @@ func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) * // Disable imgui.ini io.SetIniFilename("") - backend, err := imgui.CreateBackend(imgui.NewGLFWBackend()) - if err != nil && !errors.Is(err, imgui.CExposerError) { + currentBackend, err := backend.CreateBackend(glfwbackend.NewGLFWBackend()) + if err != nil && !errors.Is(err, backend.CExposerError) { panic(err) } // Create GIU context - Context = CreateContext(backend) + Context = CreateContext(currentBackend) mw := &MasterWindow{ clearColor: imgui.Vec4{X: 0, Y: 0, Z: 0, W: 1}, @@ -104,14 +108,14 @@ func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) * title: title, io: io, context: imGuiContext, - backend: backend, + backend: currentBackend, } - backend.SetBeforeRenderHook(mw.beforeRender) - backend.SetAfterRenderHook(mw.afterRender) - backend.SetBeforeDestroyContextHook(mw.beforeDestroy) - flags.parseAndApply(backend) - backend.CreateWindow(title, width, height) + currentBackend.SetBeforeRenderHook(mw.beforeRender) + currentBackend.SetAfterRenderHook(mw.afterRender) + currentBackend.SetBeforeDestroyContextHook(mw.beforeDestroy) + flags.parseAndApply(currentBackend) + currentBackend.CreateWindow(title, width, height) mw.SetInputHandler(newInputHandler()) @@ -169,9 +173,9 @@ func (w *MasterWindow) setTheme() (fin func()) { imgui.PushStyleColorVec4(imgui.ColResizeGripActive, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.95}) imgui.PushStyleColorVec4(imgui.ColTab, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) imgui.PushStyleColorVec4(imgui.ColTabHovered, imgui.Vec4{X: 0.26, Y: 0.59, Z: 0.98, W: 0.80}) - imgui.PushStyleColorVec4(imgui.ColTabActive, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) - imgui.PushStyleColorVec4(imgui.ColTabUnfocused, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) - imgui.PushStyleColorVec4(imgui.ColTabUnfocusedActive, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) + imgui.PushStyleColorVec4(imgui.ColTabSelected, imgui.Vec4{X: 0.20, Y: 0.25, Z: 0.29, W: 1.00}) + imgui.PushStyleColorVec4(imgui.ColTabDimmed, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) + imgui.PushStyleColorVec4(imgui.ColTabDimmedSelected, imgui.Vec4{X: 0.11, Y: 0.15, Z: 0.17, W: 1.00}) imgui.PushStyleColorVec4(imgui.ColPlotLines, imgui.Vec4{X: 0.61, Y: 0.61, Z: 0.61, W: 1.00}) imgui.PushStyleColorVec4(imgui.ColPlotLinesHovered, imgui.Vec4{X: 1.00, Y: 0.43, Z: 0.35, W: 1.00}) imgui.PushStyleColorVec4(imgui.ColPlotHistogram, imgui.Vec4{X: 0.90, Y: 0.70, Z: 0.00, W: 1.00}) @@ -212,8 +216,8 @@ func (w *MasterWindow) afterRender() { } func (w *MasterWindow) beforeDestroy() { - imgui.PlotDestroyContext() - imgui.ImNodesDestroyContext() + implot.PlotDestroyContext() + imnodes.ImNodesDestroyContext() } func (w *MasterWindow) render() { @@ -320,7 +324,7 @@ 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.backend.SetCloseCallback(func(b imgui.Backend[imgui.GLFWWindowFlags]) { + w.backend.SetCloseCallback(func(b backend.Backend[glfwbackend.GLFWWindowFlags]) { b.SetShouldClose(cb()) }) } @@ -391,7 +395,7 @@ func (w *MasterWindow) SetInputHandler(handler InputHandler) { Context.InputHandler = handler w.backend.SetKeyCallback(func(key, scanCode, action, modifier int) { - k, m, a := keyFromGLFWKey(imgui.GLFWKey(key)), Modifier(modifier), Action(action) + k, m, a := keyFromGLFWKey(glfwbackend.GLFWKey(key)), Modifier(modifier), Action(action) handler.Handle(k, m, a) if w.additionalInputCallback != nil { diff --git a/Plot.go b/Plot.go index 3c83ae8d..c1a8968f 100644 --- a/Plot.go +++ b/Plot.go @@ -3,21 +3,21 @@ package giu import ( "image" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/implot" ) type ( - PlotXAxis = imgui.PlotAxisEnum - PlotYAxis = imgui.PlotAxisEnum + PlotXAxis = implot.PlotAxisEnum + PlotYAxis = implot.PlotAxisEnum ) const ( - AxisX1 = imgui.AxisX1 - AxisX2 = imgui.AxisX2 - AxisX3 = imgui.AxisX3 - AxisY1 = imgui.AxisY1 - AxisY2 = imgui.AxisY2 - AxisY3 = imgui.AxisY3 + AxisX1 = implot.AxisX1 + AxisX2 = implot.AxisX2 + AxisX3 = implot.AxisX3 + AxisY1 = implot.AxisY1 + AxisY2 = implot.AxisY2 + AxisY3 = implot.AxisY3 ) // PlotWidget is implemented by all the particular plots, which can be used @@ -212,27 +212,27 @@ func (p *PlotCanvasWidget) Build() { return } - if imgui.PlotBeginPlotV( + if implot.PlotBeginPlotV( Context.FontAtlas.RegisterString(p.title), ToVec2(image.Pt(p.width, p.height)), - imgui.PlotFlags(p.flags), + implot.PlotFlags(p.flags), ) { - imgui.PlotSetupAxisLimitsV( - imgui.AxisX1, + implot.PlotSetupAxisLimitsV( + implot.AxisX1, p.xMin, p.xMax, - imgui.PlotCond(p.axisLimitCondition), + implot.PlotCond(p.axisLimitCondition), ) - imgui.PlotSetupAxisLimitsV( - imgui.AxisY1, + implot.PlotSetupAxisLimitsV( + implot.AxisY1, p.yMin, p.yMax, - imgui.PlotCond(p.axisLimitCondition), + implot.PlotCond(p.axisLimitCondition), ) if len(p.xTicksValue) > 0 { - imgui.PlotSetupAxisTicksdoublePtrV( - imgui.AxisX1, + implot.PlotSetupAxisTicksdoublePtrV( + implot.AxisX1, &p.xTicksValue, int32(len(p.xTicksValue)), p.xTicksLabel, @@ -241,8 +241,8 @@ func (p *PlotCanvasWidget) Build() { } if len(p.yTicksValue) > 0 { - imgui.PlotSetupAxisTicksdoublePtrV( - imgui.AxisY1, + implot.PlotSetupAxisTicksdoublePtrV( + implot.AxisY1, &p.yTicksValue, int32(len(p.yTicksValue)), p.yTicksLabel, @@ -250,31 +250,31 @@ func (p *PlotCanvasWidget) Build() { ) } - imgui.PlotSetupAxisV( - imgui.AxisX1, + implot.PlotSetupAxisV( + implot.AxisX1, Context.FontAtlas.RegisterString(p.xLabel), - imgui.PlotAxisFlags(p.xFlags), + implot.PlotAxisFlags(p.xFlags), ) - imgui.PlotSetupAxisV( - imgui.AxisY1, + implot.PlotSetupAxisV( + implot.AxisY1, Context.FontAtlas.RegisterString(p.yLabel), - imgui.PlotAxisFlags(p.yFlags), + implot.PlotAxisFlags(p.yFlags), ) if p.y2Label != "" { - imgui.PlotSetupAxisV( - imgui.AxisY2, + implot.PlotSetupAxisV( + implot.AxisY2, Context.FontAtlas.RegisterString(p.y2Label), - imgui.PlotAxisFlags(p.y2Flags), + implot.PlotAxisFlags(p.y2Flags), ) } if p.y3Label != "" { - imgui.PlotSetupAxisV( - imgui.AxisY3, + implot.PlotSetupAxisV( + implot.AxisY3, Context.FontAtlas.RegisterString(p.y3Label), - imgui.PlotAxisFlags(p.y3Flags), + implot.PlotAxisFlags(p.y3Flags), ) } @@ -282,13 +282,13 @@ func (p *PlotCanvasWidget) Build() { plot.Plot() } - imgui.PlotEndPlot() + implot.PlotEndPlot() } } func SwitchPlotAxes(x PlotXAxis, y PlotYAxis) PlotWidget { return Custom(func() { - imgui.PlotSetAxes(x, y) + implot.PlotSetAxes(x, y) }) } @@ -331,7 +331,7 @@ func (p *BarPlot) Offset(offset int) *BarPlot { // Plot implements Plot interface. func (p *BarPlot) Plot() { - imgui.PlotPlotBarsdoublePtrIntV( + implot.PlotPlotBarsdoublePtrIntV( p.title, &p.data, int32(len(p.data)), @@ -383,13 +383,13 @@ func (p *BarHPlot) Offset(offset int) *BarHPlot { // Plot implements plot interface. func (p *BarHPlot) Plot() { - imgui.PlotPlotBarsdoublePtrIntV( + implot.PlotPlotBarsdoublePtrIntV( Context.FontAtlas.RegisterString(p.title), &p.data, int32(len(p.data)), p.height, p.shift, - imgui.PlotBarsFlagsHorizontal, + implot.PlotBarsFlagsHorizontal, int32(p.offset), 0, ) @@ -441,11 +441,11 @@ func (p *LinePlot) Offset(offset int) *LinePlot { // Plot implements Plot interface. func (p *LinePlot) Plot() { - imgui.PlotSetAxis( - imgui.PlotAxisEnum(p.yAxis), + implot.PlotSetAxis( + implot.PlotAxisEnum(p.yAxis), ) - imgui.PlotPlotLinedoublePtrIntV( + implot.PlotPlotLinedoublePtrIntV( Context.FontAtlas.RegisterString(p.title), &p.values, int32(len(p.values)), @@ -489,8 +489,8 @@ func (p *LineXYPlot) Offset(offset int) *LineXYPlot { // Plot implements Plot interface. func (p *LineXYPlot) Plot() { - imgui.PlotSetAxis(imgui.PlotAxisEnum(p.yAxis)) - imgui.PlotPlotLinedoublePtrdoublePtrV( + implot.PlotSetAxis(implot.PlotAxisEnum(p.yAxis)) + implot.PlotPlotLinedoublePtrdoublePtrV( Context.FontAtlas.RegisterString(p.title), &p.xs, &p.ys, @@ -543,7 +543,7 @@ func (p *PieChartPlot) Angle0(a float64) *PieChartPlot { func (p *PieChartPlot) Plot() { // TODO: p.normalized not used anymore - replace with flags - imgui.PlotPlotPieChartdoublePtrStrV( + implot.PlotPlotPieChartdoublePtrStrV( Context.FontAtlas.RegisterStringSlice(p.labels), &p.values, int32(len(p.values)), @@ -552,7 +552,7 @@ func (p *PieChartPlot) Plot() { p.radius, p.labelFormat, p.angle0, - imgui.PlotPieChartFlagsNormalize, + implot.PlotPieChartFlagsNormalize, ) } @@ -589,7 +589,7 @@ func (p *ScatterPlot) Offset(offset int) *ScatterPlot { } func (p *ScatterPlot) Plot() { - imgui.PlotPlotScatterdoublePtrIntV( + implot.PlotPlotScatterdoublePtrIntV( Context.FontAtlas.RegisterString(p.label), &p.values, int32(len(p.values)), @@ -622,7 +622,7 @@ func (p *ScatterXYPlot) Offset(offset int) *ScatterXYPlot { } func (p *ScatterXYPlot) Plot() { - imgui.PlotPlotScatterdoublePtrdoublePtrV( + implot.PlotPlotScatterdoublePtrdoublePtrV( Context.FontAtlas.RegisterString(p.label), &p.xs, &p.ys, diff --git a/Popups.go b/Popups.go index 2d8446ad..e32b4c51 100644 --- a/Popups.go +++ b/Popups.go @@ -1,7 +1,7 @@ package giu import ( - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) // OpenPopup opens a popup with specified id. diff --git a/ProgressIndicator.go b/ProgressIndicator.go index 02448aea..75aea552 100644 --- a/ProgressIndicator.go +++ b/ProgressIndicator.go @@ -6,7 +6,7 @@ import ( "sync" "time" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) var _ Disposable = &progressIndicatorState{} diff --git a/SliderWidgets.go b/SliderWidgets.go index b06fa608..bf87d3d6 100644 --- a/SliderWidgets.go +++ b/SliderWidgets.go @@ -3,7 +3,7 @@ package giu import ( "fmt" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) var _ Widget = &SliderIntWidget{} diff --git a/SplitLayout.go b/SplitLayout.go index 00ad879d..290fa4fc 100644 --- a/SplitLayout.go +++ b/SplitLayout.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) // SplitDirection represents a direction (vertical/horizontal) of splitting layout. diff --git a/StackWidget.go b/StackWidget.go index bce8a2dd..e6a2e675 100644 --- a/StackWidget.go +++ b/StackWidget.go @@ -1,6 +1,6 @@ package giu -import imgui "github.com/AllenDang/cimgui-go" +import "github.com/AllenDang/cimgui-go/imgui" var _ Widget = &StackWidget{} diff --git a/Style.go b/Style.go index b5ccde69..dd406048 100644 --- a/Style.go +++ b/Style.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) // You may want to use styles in order to make your app looking more beautiful. diff --git a/StyleIDs.go b/StyleIDs.go index 74820ffc..259e96d1 100644 --- a/StyleIDs.go +++ b/StyleIDs.go @@ -1,6 +1,6 @@ package giu -import imgui "github.com/AllenDang/cimgui-go" +import "github.com/AllenDang/cimgui-go/imgui" // Here are the style IDs for styling imgui apps. // For details about each of attributes read comment above them. @@ -51,9 +51,9 @@ const ( 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 + StyleColorTabActive = StyleColorID(imgui.ColTabSelected) // tab-active-color + StyleColorTabUnfocused = StyleColorID(imgui.ColTabDimmed) // tab-unfocused-color + StyleColorTabUnfocusedActive = StyleColorID(imgui.ColTabDimmedSelected) // 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 diff --git a/StyleIDs_string.go b/StyleIDs_string.go index a0707632..88e6ed18 100644 --- a/StyleIDs_string.go +++ b/StyleIDs_string.go @@ -41,45 +41,55 @@ func _() { _ = x[StyleColorResizeGrip-30] _ = x[StyleColorResizeGripHovered-31] _ = x[StyleColorResizeGripActive-32] - _ = x[StyleColorTab-33] - _ = x[StyleColorTabHovered-34] + _ = x[StyleColorTab-34] + _ = x[StyleColorTabHovered-33] _ = x[StyleColorTabActive-35] - _ = x[StyleColorTabUnfocused-36] - _ = x[StyleColorTabUnfocusedActive-37] - _ = x[StyleColorPlotLines-40] - _ = x[StyleColorPlotLinesHovered-41] - _ = x[StyleColorPlotHistogram-42] - _ = x[StyleColorPlotHistogramHovered-43] - _ = x[StyleColorTableHeaderBg-44] - _ = x[StyleColorTableBorderStrong-45] - _ = x[StyleColorTableBorderLight-46] - _ = x[StyleColorTableRowBg-47] - _ = x[StyleColorTableRowBgAlt-48] - _ = x[StyleColorTextSelectedBg-49] - _ = x[StyleColorDragDropTarget-50] - _ = x[StyleColorNavHighlight-51] - _ = x[StyleColorNavWindowingHighlight-52] - _ = x[StyleColorNavWindowingDimBg-53] - _ = x[StyleColorModalWindowDimBg-54] + _ = x[StyleColorTabUnfocused-37] + _ = x[StyleColorTabUnfocusedActive-38] + _ = x[StyleColorPlotLines-42] + _ = x[StyleColorPlotLinesHovered-43] + _ = x[StyleColorPlotHistogram-44] + _ = x[StyleColorPlotHistogramHovered-45] + _ = x[StyleColorTableHeaderBg-46] + _ = x[StyleColorTableBorderStrong-47] + _ = x[StyleColorTableBorderLight-48] + _ = x[StyleColorTableRowBg-49] + _ = x[StyleColorTableRowBgAlt-50] + _ = x[StyleColorTextSelectedBg-52] + _ = x[StyleColorDragDropTarget-53] + _ = x[StyleColorNavHighlight-54] + _ = x[StyleColorNavWindowingHighlight-55] + _ = x[StyleColorNavWindowingDimBg-56] + _ = x[StyleColorModalWindowDimBg-57] } const ( - _StyleColorID_name_0 = "colordisabled-colorbackground-colorchild-background-colorpopup-background-colorborder-colorborder-shadow-colorframe-background-colorframe-background-hovered-colorframe-background-active-colortitle-background-colortitle-background-active-colortitle-background-collapsed-colormenu-bar-background-colorscrollbar-background-colorscrollbar-grab-colorscrollbar-grab-hovered-colorscrollbar-grab-active-colorcheckmark-colorslider-grab-colorslider-grab-active-colorbutton-colorbutton-hovered-colorbutton-active-colorheader-colorheader-hovered-colorheader-active-colorseparator-colorseparator-hovered-colorseparator-active-colorresize-grip-colorresize-grip-hovered-colorresize-grip-active-colortab-colortab-hovered-colortab-active-colortab-unfocused-colortab-unfocused-active-color" - _StyleColorID_name_1 = "plot-lines-colorplot-lines-hovered-colorplot-histogram-colorplot-histogram-hovered-colortable-header-background-colortable-border-strong-colortable-border-light-colortable-row-background-colortable-row-alternate-background-colortext-selected-background-colordrag-drop-target-colornavigation-highlight-colorwindowing-highlight-colorwindowing-dim-background-colormodal-window-dim-background-color" + _StyleColorID_name_0 = "colordisabled-colorbackground-colorchild-background-colorpopup-background-colorborder-colorborder-shadow-colorframe-background-colorframe-background-hovered-colorframe-background-active-colortitle-background-colortitle-background-active-colortitle-background-collapsed-colormenu-bar-background-colorscrollbar-background-colorscrollbar-grab-colorscrollbar-grab-hovered-colorscrollbar-grab-active-colorcheckmark-colorslider-grab-colorslider-grab-active-colorbutton-colorbutton-hovered-colorbutton-active-colorheader-colorheader-hovered-colorheader-active-colorseparator-colorseparator-hovered-colorseparator-active-colorresize-grip-colorresize-grip-hovered-colorresize-grip-active-colortab-hovered-colortab-colortab-active-color" + _StyleColorID_name_1 = "tab-unfocused-colortab-unfocused-active-color" + _StyleColorID_name_2 = "plot-lines-colorplot-lines-hovered-colorplot-histogram-colorplot-histogram-hovered-colortable-header-background-colortable-border-strong-colortable-border-light-colortable-row-background-colortable-row-alternate-background-color" + _StyleColorID_name_3 = "text-selected-background-colordrag-drop-target-colornavigation-highlight-colorwindowing-highlight-colorwindowing-dim-background-colormodal-window-dim-background-color" ) var ( - _StyleColorID_index_0 = [...]uint16{0, 5, 19, 35, 57, 79, 91, 110, 132, 162, 191, 213, 242, 274, 299, 325, 345, 373, 400, 415, 432, 456, 468, 488, 507, 519, 539, 558, 573, 596, 618, 635, 660, 684, 693, 710, 726, 745, 771} - _StyleColorID_index_1 = [...]uint16{0, 16, 40, 60, 88, 117, 142, 166, 192, 228, 258, 280, 306, 331, 361, 394} + _StyleColorID_index_0 = [...]uint16{0, 5, 19, 35, 57, 79, 91, 110, 132, 162, 191, 213, 242, 274, 299, 325, 345, 373, 400, 415, 432, 456, 468, 488, 507, 519, 539, 558, 573, 596, 618, 635, 660, 684, 701, 710, 726} + _StyleColorID_index_1 = [...]uint8{0, 19, 45} + _StyleColorID_index_2 = [...]uint8{0, 16, 40, 60, 88, 117, 142, 166, 192, 228} + _StyleColorID_index_3 = [...]uint8{0, 30, 52, 78, 103, 133, 166} ) func (i StyleColorID) String() string { switch { - case 0 <= i && i <= 37: + case 0 <= i && i <= 35: return _StyleColorID_name_0[_StyleColorID_index_0[i]:_StyleColorID_index_0[i+1]] - case 40 <= i && i <= 54: - i -= 40 + case 37 <= i && i <= 38: + i -= 37 return _StyleColorID_name_1[_StyleColorID_index_1[i]:_StyleColorID_index_1[i+1]] + case 42 <= i && i <= 50: + i -= 42 + return _StyleColorID_name_2[_StyleColorID_index_2[i]:_StyleColorID_index_2[i+1]] + case 52 <= i && i <= 57: + i -= 52 + return _StyleColorID_name_3[_StyleColorID_index_3[i]:_StyleColorID_index_3[i+1]] default: return "StyleColorID(" + strconv.FormatInt(int64(i), 10) + ")" } @@ -111,22 +121,36 @@ func _() { _ = x[StyleVarGrabMinSize-20] _ = x[StyleVarGrabRounding-21] _ = x[StyleVarTabRounding-22] - _ = x[StyleVarTabBarBorderSize-23] - _ = x[StyleVarButtonTextAlign-24] - _ = x[StyleVarSelectableTextAlign-25] - _ = x[StyleVarSeparatorTextBorderSize-26] - _ = x[StyleVarSeparatorTextAlign-27] - _ = x[StyleVarSeparatorTextPadding-28] - _ = x[StyleVarDockingSeparatorSize-29] + _ = x[StyleVarTabBarBorderSize-24] + _ = x[StyleVarButtonTextAlign-28] + _ = x[StyleVarSelectableTextAlign-29] + _ = x[StyleVarSeparatorTextBorderSize-30] + _ = x[StyleVarSeparatorTextAlign-31] + _ = x[StyleVarSeparatorTextPadding-32] + _ = x[StyleVarDockingSeparatorSize-33] } -const _StyleVarID_name = "alphadisabled-alphawindow-paddingwindow-roundingwindow-border-sizewindow-minValue-sizewindow-title-alignchild-roundingchild-border-sizepopup-roundingpopup-border-sizeframe-paddingframe-roundingframe-border-sizeitem-spacingitem-inner-spacingindent-spacingStyleVarCellPaddingscrollbar-sizescrollbar-roundinggrab-minValue-sizegrab-roundingtab-roundingStyleVarTabBarBorderSizebutton-text-alignselectable-text-alignStyleVarSeparatorTextBorderSizeStyleVarSeparatorTextAlignStyleVarSeparatorTextPaddingStyleVarDockingSeparatorSize" +const ( + _StyleVarID_name_0 = "alphadisabled-alphawindow-paddingwindow-roundingwindow-border-sizewindow-minValue-sizewindow-title-alignchild-roundingchild-border-sizepopup-roundingpopup-border-sizeframe-paddingframe-roundingframe-border-sizeitem-spacingitem-inner-spacingindent-spacingStyleVarCellPaddingscrollbar-sizescrollbar-roundinggrab-minValue-sizegrab-roundingtab-rounding" + _StyleVarID_name_1 = "StyleVarTabBarBorderSize" + _StyleVarID_name_2 = "button-text-alignselectable-text-alignStyleVarSeparatorTextBorderSizeStyleVarSeparatorTextAlignStyleVarSeparatorTextPaddingStyleVarDockingSeparatorSize" +) -var _StyleVarID_index = [...]uint16{0, 5, 19, 33, 48, 66, 86, 104, 118, 135, 149, 166, 179, 193, 210, 222, 240, 254, 273, 287, 305, 323, 336, 348, 372, 389, 410, 441, 467, 495, 523} +var ( + _StyleVarID_index_0 = [...]uint16{0, 5, 19, 33, 48, 66, 86, 104, 118, 135, 149, 166, 179, 193, 210, 222, 240, 254, 273, 287, 305, 323, 336, 348} + _StyleVarID_index_2 = [...]uint8{0, 17, 38, 69, 95, 123, 151} +) func (i StyleVarID) String() string { - if i < 0 || i >= StyleVarID(len(_StyleVarID_index)-1) { + switch { + case 0 <= i && i <= 22: + return _StyleVarID_name_0[_StyleVarID_index_0[i]:_StyleVarID_index_0[i+1]] + case i == 24: + return _StyleVarID_name_1 + case 28 <= i && i <= 33: + i -= 28 + return _StyleVarID_name_2[_StyleVarID_index_2[i]:_StyleVarID_index_2[i+1]] + default: return "StyleVarID(" + strconv.FormatInt(int64(i), 10) + ")" } - return _StyleVarID_name[_StyleVarID_index[i]:_StyleVarID_index[i+1]] } diff --git a/StyleIDs_string2enum.go b/StyleIDs_string2enum.go index 5b20a5f0..e1b4fb7f 100644 --- a/StyleIDs_string2enum.go +++ b/StyleIDs_string2enum.go @@ -16,7 +16,17 @@ func StyleColorIDFromString(s string) StyleColorID { } for i := range _StyleColorID_index_1[:len(_StyleColorID_index_1)-1] { if s == _StyleColorID_name_1[_StyleColorID_index_1[i]:_StyleColorID_index_1[i+1]] { - return StyleColorID(i + 40) + return StyleColorID(i + 37) + } + } + for i := range _StyleColorID_index_2[:len(_StyleColorID_index_2)-1] { + if s == _StyleColorID_name_2[_StyleColorID_index_2[i]:_StyleColorID_index_2[i+1]] { + return StyleColorID(i + 42) + } + } + for i := range _StyleColorID_index_3[:len(_StyleColorID_index_3)-1] { + if s == _StyleColorID_name_3[_StyleColorID_index_3[i]:_StyleColorID_index_3[i+1]] { + return StyleColorID(i + 52) } } panic(fmt.Errorf("unable to locate StyleColorID enum corresponding to %q", s)) @@ -92,44 +102,44 @@ func _(s string) { // 32 case "resize-grip-active-color": // 33 - case "tab-color": - // 34 case "tab-hovered-color": + // 34 + case "tab-color": // 35 case "tab-active-color": - // 36 - case "tab-unfocused-color": // 37 + case "tab-unfocused-color": + // 38 case "tab-unfocused-active-color": - // 40 + // 42 case "plot-lines-color": - // 41 + // 43 case "plot-lines-hovered-color": - // 42 + // 44 case "plot-histogram-color": - // 43 + // 45 case "plot-histogram-hovered-color": - // 44 + // 46 case "table-header-background-color": - // 45 + // 47 case "table-border-strong-color": - // 46 + // 48 case "table-border-light-color": - // 47 + // 49 case "table-row-background-color": - // 48 + // 50 case "table-row-alternate-background-color": - // 49 + // 52 case "text-selected-background-color": - // 50 + // 53 case "drag-drop-target-color": - // 51 + // 54 case "navigation-highlight-color": - // 52 + // 55 case "windowing-highlight-color": - // 53 + // 56 case "windowing-dim-background-color": - // 54 + // 57 case "modal-window-dim-background-color": } } @@ -139,9 +149,17 @@ func StyleVarIDFromString(s string) StyleVarID { if len(s) == 0 { return 0 } - for i := range _StyleVarID_index[:len(_StyleVarID_index)-1] { - if s == _StyleVarID_name[_StyleVarID_index[i]:_StyleVarID_index[i+1]] { - return StyleVarID(i) + for i := range _StyleVarID_index_0[:len(_StyleVarID_index_0)-1] { + if s == _StyleVarID_name_0[_StyleVarID_index_0[i]:_StyleVarID_index_0[i+1]] { + return StyleVarID(i + 0) + } + } + if s == _StyleVarID_name_1 { + return StyleVarID(24) + } + for i := range _StyleVarID_index_2[:len(_StyleVarID_index_2)-1] { + if s == _StyleVarID_name_2[_StyleVarID_index_2[i]:_StyleVarID_index_2[i+1]] { + return StyleVarID(i + 28) } } panic(fmt.Errorf("unable to locate StyleVarID enum corresponding to %q", s)) @@ -196,19 +214,19 @@ func _(s string) { case "grab-rounding": // 22 case "tab-rounding": - // 23 - case "StyleVarTabBarBorderSize": // 24 + case "StyleVarTabBarBorderSize": + // 28 case "button-text-align": - // 25 + // 29 case "selectable-text-align": - // 26 + // 30 case "StyleVarSeparatorTextBorderSize": - // 27 + // 31 case "StyleVarSeparatorTextAlign": - // 28 + // 32 case "StyleVarSeparatorTextPadding": - // 29 + // 33 case "StyleVarDockingSeparatorSize": } } diff --git a/StyleSetter.go b/StyleSetter.go index 3f9f3500..b52bab39 100644 --- a/StyleSetter.go +++ b/StyleSetter.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) var _ Widget = &StyleSetter{} diff --git a/TableWidgets.go b/TableWidgets.go index 831d8e3c..09a991a8 100644 --- a/TableWidgets.go +++ b/TableWidgets.go @@ -3,7 +3,7 @@ package giu import ( "image/color" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) type TableRowWidget struct { diff --git a/TextWidgets.go b/TextWidgets.go index 736eaf99..0964d19c 100644 --- a/TextWidgets.go +++ b/TextWidgets.go @@ -6,7 +6,7 @@ import ( "golang.org/x/image/colornames" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" "github.com/sahilm/fuzzy" ) diff --git a/Texture.go b/Texture.go index a98913b3..e9dc4ae1 100644 --- a/Texture.go +++ b/Texture.go @@ -3,13 +3,14 @@ package giu import ( "image" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/backend" + "github.com/AllenDang/cimgui-go/imgui" ) // Texture represents imgui.TextureID. // It is base unit of images in imgui. type Texture struct { - tex *imgui.Texture + tex *backend.Texture } type textureLoadRequest struct { @@ -27,14 +28,14 @@ func EnqueueNewTextureFromRgba(rgba image.Image, loadCb func(t *Texture)) { // NewTextureFromRgba creates a new texture from image.Image and, when it is done, calls loadCallback(loadedTexture). func NewTextureFromRgba(rgba image.Image, loadCallback func(*Texture)) { - tex := imgui.NewTextureFromRgba(ImageToRgba(rgba)) + tex := backend.NewTextureFromRgba(ImageToRgba(rgba)) loadCallback(&Texture{ tex, }) } -// ToTexture converts imgui.Texture to Texture. -func ToTexture(texture *imgui.Texture) *Texture { +// ToTexture converts backend.Texture to Texture. +func ToTexture(texture *backend.Texture) *Texture { return &Texture{tex: texture} } diff --git a/Utils.go b/Utils.go index 08ffc208..fdf59a0d 100644 --- a/Utils.go +++ b/Utils.go @@ -10,7 +10,7 @@ import ( "os" "path/filepath" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" "github.com/pkg/browser" ) diff --git a/Utils_test.go b/Utils_test.go index 2d89a840..16aeb4a6 100644 --- a/Utils_test.go +++ b/Utils_test.go @@ -5,7 +5,7 @@ import ( "image/color" "testing" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" "github.com/stretchr/testify/assert" ) diff --git a/Widgets.go b/Widgets.go index a0bb17cd..a61c316e 100644 --- a/Widgets.go +++ b/Widgets.go @@ -4,7 +4,7 @@ import ( "fmt" "image/color" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) var _ Widget = &RowWidget{} @@ -69,7 +69,7 @@ type ChildWidget struct { func (c *ChildWidget) Build() { if imgui.BeginChildStrV(c.id.String(), imgui.Vec2{X: c.width, Y: c.height}, func() imgui.ChildFlags { if c.border { - return imgui.ChildFlagsBorder + return imgui.ChildFlagsBorders } return 0 diff --git a/Window.go b/Window.go index e140f3cf..861dc119 100644 --- a/Window.go +++ b/Window.go @@ -3,7 +3,7 @@ package giu import ( "fmt" - imgui "github.com/AllenDang/cimgui-go" + "github.com/AllenDang/cimgui-go/imgui" ) // SingleWindow creates one window filling all available space