diff --git a/Alignment.go b/Alignment.go index 9d36a036..ca681c6e 100644 --- a/Alignment.go +++ b/Alignment.go @@ -66,6 +66,7 @@ func AlignManually(alignmentType AlignmentType, widget Widget, widgetWidth float if forceApplyWidth { PushItemWidth(widgetWidth) + defer PopItemWidth() } diff --git a/CodeEditor.go b/CodeEditor.go index de38cb99..37924698 100644 --- a/CodeEditor.go +++ b/CodeEditor.go @@ -1,4 +1,4 @@ -//nolint:gocritic // this file is TODO. We don't want commentedOutCode linter issues here yet. +//nolint:gocritic,govet,unused // this file is TODO. We don't want commentedOutCode linter issues here yet. package giu import ( @@ -41,6 +41,7 @@ type CodeEditorWidget struct { // CodeEditor creates new code editor widget. func CodeEditor() *CodeEditorWidget { panic("Code Editor is not implemented yet!") + return &CodeEditorWidget{ title: GenAutoID("##CodeEditor"), } diff --git a/Context.go b/Context.go index 7cde56da..21607e1a 100644 --- a/Context.go +++ b/Context.go @@ -85,6 +85,7 @@ func (c *context) invalidAllState() { s.valid = false c.m.Unlock() } + return true }) } @@ -95,11 +96,13 @@ func (c *context) cleanState() { c.m.Lock() valid := s.valid c.m.Unlock() + if !valid { c.state.Delete(k) s.data.Dispose() } } + return true }) diff --git a/ExtraWidgets.go b/ExtraWidgets.go index c63885b7..29ebdbf8 100644 --- a/ExtraWidgets.go +++ b/ExtraWidgets.go @@ -480,8 +480,6 @@ func (d *DatePickerWidget) Build() { // --- [Build year/month widget] --- imgui.AlignTextToFramePadding() - const yearButtonSize = 25 - Table(). Size(0, 50). Flags(0). diff --git a/Flags.go b/Flags.go index 310d630f..4de7e185 100644 --- a/Flags.go +++ b/Flags.go @@ -122,12 +122,12 @@ const ( ComboFlagsNone = ComboFlags(imgui.ComboFlagsNone) // ComboFlagsPopupAlignLeft aligns the popup toward the left by default. ComboFlagsPopupAlignLeft = ComboFlags(imgui.ComboFlagsPopupAlignLeft) - // ComboFlagsHeightSmall has max ~4 items visible. + // ComboFlagsHeightSmall has maxValue ~4 items visible. // Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo(). ComboFlagsHeightSmall = ComboFlags(imgui.ComboFlagsHeightSmall) - // ComboFlagsHeightRegular has max ~8 items visible (default). + // ComboFlagsHeightRegular has maxValue ~8 items visible (default). ComboFlagsHeightRegular = ComboFlags(imgui.ComboFlagsHeightRegular) - // ComboFlagsHeightLarge has max ~20 items visible. + // ComboFlagsHeightLarge has maxValue ~20 items visible. ComboFlagsHeightLarge = ComboFlags(imgui.ComboFlagsHeightLarge) // ComboFlagsHeightLargest has as many fitting items as possible. ComboFlagsHeightLargest = ComboFlags(imgui.ComboFlagsHeightLargest) @@ -449,7 +449,7 @@ type SliderFlags imgui.SliderFlags // slider flags. const ( 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. + // Clamp value to minValue/maxValue bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. SliderFlagsAlwaysClamp = SliderFlags(imgui.SliderFlagsAlwaysClamp) // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlagsNoRoundToFormat = SliderFlags(imgui.SliderFlagsNoRoundToFormat) // a format-string with small amount of digits. diff --git a/FontAtlasProsessor.go b/FontAtlasProsessor.go index a3a63267..80a8b684 100644 --- a/FontAtlasProsessor.go +++ b/FontAtlasProsessor.go @@ -248,6 +248,7 @@ func (a *FontAtlas) rebuildFontAtlas() { a.stringMap.Range(func(k, v any) bool { a.stringMap.Store(k, true) + if ks, ok := k.(rune); ok { sb.WriteRune(ks) } diff --git a/InputHandler_test.go b/InputHandler_test.go index e8524255..b163a9af 100644 --- a/InputHandler_test.go +++ b/InputHandler_test.go @@ -34,6 +34,7 @@ func Test_InputHandle_RegisterKeyboardShortcuts(t *testing.T) { Callback: tt.cb, IsGlobal: tt.isGlobal, }) + combo := keyCombo{ key: tt.key, modifier: tt.mod, @@ -42,6 +43,7 @@ func Test_InputHandle_RegisterKeyboardShortcuts(t *testing.T) { shortcut, exist := i.shortcuts[combo] a.True(exist, "shortcut wasn't registered in input manager") + if tt.isGlobal { // TODO: figure out why it doesn't work // a.Equal(shortcut.global, tt.cb, "wrong shortcut set in input manager") diff --git a/Layout_test.go b/Layout_test.go index 313a883d..1a906999 100644 --- a/Layout_test.go +++ b/Layout_test.go @@ -53,6 +53,7 @@ func Test_Layout_Range(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { counter := 0 + test.layout.Range(func(w Widget) { if _, isTestwidget := w.(*testwidget); isTestwidget { counter++ @@ -95,6 +96,7 @@ func Test_Layout_Build(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { counter := 0 + test.layout.Range(func(w Widget) { if tw, isTestwidget := w.(*testwidget); isTestwidget { tw.counter = &counter diff --git a/Markdown.go b/Markdown.go index e42c4233..39e9e063 100644 --- a/Markdown.go +++ b/Markdown.go @@ -1,4 +1,4 @@ -//nolint:gocritic // this file is TODO. We don't want commentedOutCode lint issues here. +//nolint:gocritic,govet,wsl // this file is TODO. We don't want commentedOutCode lint issues here. package giu // MarkdownWidget implements DearImGui markdown extension @@ -14,6 +14,7 @@ type MarkdownWidget struct { // Markdown creates new markdown widget. func Markdown(md *string) *MarkdownWidget { panic("MarkdownWidget is not implemented yet!") + return &MarkdownWidget{ md: md, linkCb: OpenURL, diff --git a/MasterWindow.go b/MasterWindow.go index 782e2663..ed388154 100644 --- a/MasterWindow.go +++ b/MasterWindow.go @@ -389,6 +389,7 @@ func (w *MasterWindow) SetInputHandler(handler InputHandler) { w.backend.SetKeyCallback(func(key, scanCode, action, modifier int) { k, m, a := keyFromGLFWKey(imgui.GLFWKey(key)), Modifier(modifier), Action(action) handler.Handle(k, m, a) + if w.additionalInputCallback != nil { w.additionalInputCallback(k, m, a) } diff --git a/StyleIDs.go b/StyleIDs.go index 4f40c34f..74820ffc 100644 --- a/StyleIDs.go +++ b/StyleIDs.go @@ -89,7 +89,7 @@ const ( // StyleVarWindowBorderSize is a float. StyleVarWindowBorderSize = StyleVarID(imgui.StyleVarWindowBorderSize) // window-border-size // StyleVarWindowMinSize is a Vec2. - StyleVarWindowMinSize = StyleVarID(imgui.StyleVarWindowMinSize) // window-min-size + StyleVarWindowMinSize = StyleVarID(imgui.StyleVarWindowMinSize) // window-minValue-size // StyleVarWindowTitleAlign is a Vec2. StyleVarWindowTitleAlign = StyleVarID(imgui.StyleVarWindowTitleAlign) // window-title-align // StyleVarChildRounding is a float. @@ -119,7 +119,7 @@ const ( // StyleVarScrollbarRounding is a float. StyleVarScrollbarRounding = StyleVarID(imgui.StyleVarScrollbarRounding) // scrollbar-rounding // StyleVarGrabMinSize is a float. - StyleVarGrabMinSize = StyleVarID(imgui.StyleVarGrabMinSize) // grab-min-size + StyleVarGrabMinSize = StyleVarID(imgui.StyleVarGrabMinSize) // grab-minValue-size // StyleVarGrabRounding is a float. StyleVarGrabRounding = StyleVarID(imgui.StyleVarGrabRounding) // grab-rounding // StyleVarTabRounding is a float. diff --git a/StyleIDs_string.go b/StyleIDs_string.go index ae18fb74..97383160 100644 --- a/StyleIDs_string.go +++ b/StyleIDs_string.go @@ -120,7 +120,7 @@ func _() { _ = x[StyleVarDockingSeparatorSize-29] } -const _StyleVarID_name = "alphadisabled-alphawindow-paddingwindow-roundingwindow-border-sizewindow-min-sizewindow-title-alignchild-roundingchild-border-sizepopup-roundingpopup-border-sizeframe-paddingframe-roundingframe-border-sizeitem-spacingitem-inner-spacingindent-spacingStyleVarCellPaddingscrollbar-sizescrollbar-roundinggrab-min-sizegrab-roundingtab-roundingStyleVarTabBarBorderSizebutton-text-alignselectable-text-alignStyleVarSeparatorTextBorderSizeStyleVarSeparatorTextAlignStyleVarSeparatorTextPaddingStyleVarDockingSeparatorSize" +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" var _StyleVarID_index = [...]uint16{0, 5, 19, 33, 48, 66, 81, 99, 113, 130, 144, 161, 174, 188, 205, 217, 235, 249, 268, 282, 300, 313, 326, 338, 362, 379, 400, 431, 457, 485, 513} diff --git a/StyleIDs_string2enum.go b/StyleIDs_string2enum.go index 30cb6eb0..5b20a5f0 100644 --- a/StyleIDs_string2enum.go +++ b/StyleIDs_string2enum.go @@ -161,7 +161,7 @@ func _(s string) { // 4 case "window-border-size": // 5 - case "window-min-size": + case "window-minValue-size": // 6 case "window-title-align": // 7 @@ -191,7 +191,7 @@ func _(s string) { // 19 case "scrollbar-rounding": // 20 - case "grab-min-size": + case "grab-minValue-size": // 21 case "grab-rounding": // 22 diff --git a/Widgets.go b/Widgets.go index d9126fc4..2cc572bd 100644 --- a/Widgets.go +++ b/Widgets.go @@ -284,22 +284,22 @@ func (c *ContextMenuWidget) Build() { var _ Widget = &DragIntWidget{} type DragIntWidget struct { - label string - value *int32 - speed float32 - min int32 - max int32 - format string + label string + value *int32 + speed float32 + minValue int32 + maxValue int32 + format string } -func DragInt(label string, value *int32, min, max int32) *DragIntWidget { +func DragInt(label string, value *int32, minValue, maxValue int32) *DragIntWidget { return &DragIntWidget{ - label: GenAutoID(label), - value: value, - speed: 1.0, - min: min, - max: max, - format: "%d", + label: GenAutoID(label), + value: value, + speed: 1.0, + minValue: minValue, + maxValue: maxValue, + format: "%d", } } @@ -315,7 +315,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, 0) + imgui.DragIntV(Context.FontAtlas.RegisterString(d.label), d.value, d.speed, d.minValue, d.maxValue, d.format, 0) } var _ Widget = &ColumnWidget{}