Skip to content

Commit

Permalink
fix remaining lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed May 7, 2024
1 parent 4a1167e commit b2da78c
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 27 deletions.
1 change: 1 addition & 0 deletions Alignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func AlignManually(alignmentType AlignmentType, widget Widget, widgetWidth float

if forceApplyWidth {
PushItemWidth(widgetWidth)

defer PopItemWidth()
}

Expand Down
3 changes: 2 additions & 1 deletion CodeEditor.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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"),
}
Expand Down
3 changes: 3 additions & 0 deletions Context.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (c *context) invalidAllState() {
s.valid = false
c.m.Unlock()
}

return true
})
}
Expand All @@ -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
})

Expand Down
2 changes: 0 additions & 2 deletions ExtraWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@ func (d *DatePickerWidget) Build() {
// --- [Build year/month widget] ---
imgui.AlignTextToFramePadding()

const yearButtonSize = 25

Table().
Size(0, 50).
Flags(0).
Expand Down
8 changes: 4 additions & 4 deletions Flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions FontAtlasProsessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions InputHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions Layout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Markdown.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions MasterWindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions StyleIDs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion StyleIDs_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions StyleIDs_string2enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions Widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}

Expand All @@ -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{}
Expand Down

0 comments on commit b2da78c

Please sign in to comment.