Skip to content

Commit

Permalink
linter: fix some lint errors
Browse files Browse the repository at this point in the history
in recent go releases a new built-in golang keyword appeared: min and max; and now gocritic/shadow complains
  • Loading branch information
gucio321 committed May 7, 2024
1 parent 9454522 commit 4a1167e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ 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 int32) {
c.DrawList.PathArcToV(ToVec2(center), radius, min, max, numSegments)
func (c *Canvas) PathArcTo(center image.Point, radius, minV, maxV float32, numSegments int32) {
c.DrawList.PathArcToV(ToVec2(center), radius, minV, maxV, numSegments)
}

func (c *Canvas) PathArcToFast(center image.Point, radius float32, min12, max12 int32) {
Expand Down
11 changes: 6 additions & 5 deletions CodeEditor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:gocritic // this file is TODO. We don't want commentedOutCode linter issues here yet.
package giu

import (
Expand Down Expand Up @@ -70,10 +71,10 @@ func (ce *CodeEditorWidget) TabSize(size int) *CodeEditorWidget {
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,
// LanguageDefinitionSQL: s.editor.SetLanguageDefinitionSQL,
// LanguageDefinitionCPP: s.editor.SetLanguageDefinitionCPP,
// LanguageDefinitionLua: s.editor.SetLanguageDefinitionLua,
// LanguageDefinitionC: s.editor.SetLanguageDefinitionC,
}

setter, correctDefinition := lookup[definition]
Expand Down Expand Up @@ -216,7 +217,7 @@ func (ce *CodeEditorWidget) Build() {
func (ce *CodeEditorWidget) getState() (state *codeEditorState) {
if state = GetState[codeEditorState](Context, ce.title); state == nil {
state = &codeEditorState{
//editor: imgui.NewTextEditor(),
// editor: imgui.NewTextEditor(),
}

SetState(Context, ce.title, state)
Expand Down
1 change: 1 addition & 0 deletions Markdown.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:gocritic // this file is TODO. We don't want commentedOutCode lint issues here.
package giu

// MarkdownWidget implements DearImGui markdown extension
Expand Down
10 changes: 5 additions & 5 deletions Plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (p *BarPlot) Plot() {
p.shift,
0, // TODO: implement
int32(p.offset),
8, // sizeof(double) = 8
8, // in fact this is sizeof(double) = 8
)
}

Expand Down Expand Up @@ -404,7 +404,7 @@ func (p *LinePlot) Plot() {
p.x0,
0, // flags
int32(p.offset),
8, // sizeof(double) = 8
8, // in fact this is sizeof(double) = 8
)
}

Expand Down Expand Up @@ -448,7 +448,7 @@ func (p *LineXYPlot) Plot() {
int32(len(p.xs)),
0, // flags
int32(p.offset),
8, // sizeof(double) = 8
8, // in fact this is sizeof(double) = 8
)
}

Expand Down Expand Up @@ -548,7 +548,7 @@ func (p *ScatterPlot) Plot() {
p.x0,
0, // TODO: implement flags
int32(p.offset),
8, // sizeof(double) = 8
8, // in fact this is sizeof(double) = 8
)
}

Expand Down Expand Up @@ -580,6 +580,6 @@ func (p *ScatterXYPlot) Plot() {
int32(len(p.xs)),
0, // TODO: implement
int32(p.offset),
8, // sizeof(double) = 8
8, // in fact this is sizeof(double) = 8
)
}
2 changes: 1 addition & 1 deletion ProgressIndicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (p *ProgressIndicatorWidget) Build() {
canvas.AddCircleFilled(centerPt2, p.radius/5, rgba)

// Draw text
if len(p.label) > 0 {
if p.label != "" {
labelWidth, _ := CalcTextSize(Context.FontAtlas.RegisterString(p.label))
labelPos := centerPt.Add(image.Pt(-1*int(labelWidth/2), int(p.radius+p.radius/5+8)))
canvas.AddText(labelPos, rgba, p.label)
Expand Down
50 changes: 25 additions & 25 deletions SliderWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ var _ Widget = &SliderIntWidget{}
type SliderIntWidget struct {
label string
value *int32
min int32
max int32
minValue int32
maxValue int32
format string
width float32
onChange func()
}

// SliderInt constructs new SliderIntWidget.
func SliderInt(value *int32, min, max int32) *SliderIntWidget {
func SliderInt(value *int32, minValue, maxValue int32) *SliderIntWidget {
return &SliderIntWidget{
label: GenAutoID("##SliderInt"),
value: value,
min: min,
max: max,
minValue: minValue,
maxValue: maxValue,
format: "%d",
width: 0,
onChange: nil,
Expand Down Expand Up @@ -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, 0) && s.onChange != nil {
if imgui.SliderIntV(Context.FontAtlas.RegisterString(s.label), s.value, s.minValue, s.maxValue, s.format, 0) && s.onChange != nil {
s.onChange()
}
}
Expand All @@ -85,24 +85,24 @@ type VSliderIntWidget struct {
width float32
height float32
value *int32
min int32
max int32
minValue int32
maxValue int32
format string
flags SliderFlags
onChange func()
}

// VSliderInt creates new vslider int.
func VSliderInt(value *int32, min, max int32) *VSliderIntWidget {
func VSliderInt(value *int32, minValue, maxValue int32) *VSliderIntWidget {
return &VSliderIntWidget{
label: GenAutoID("##VSliderInt"),
width: 18,
height: 60,
value: value,
min: min,
max: max,
format: "%d",
flags: SliderFlagsNone,
label: GenAutoID("##VSliderInt"),
width: 18,
height: 60,
value: value,
minValue: minValue,
maxValue: maxValue,
format: "%d",
flags: SliderFlagsNone,
}
}

Expand Down Expand Up @@ -147,8 +147,8 @@ func (vs *VSliderIntWidget) Build() {
Context.FontAtlas.RegisterString(vs.label),
imgui.Vec2{X: vs.width, Y: vs.height},
vs.value,
vs.min,
vs.max,
vs.minValue,
vs.maxValue,
vs.format,
imgui.SliderFlags(vs.flags),
) && vs.onChange != nil {
Expand All @@ -163,20 +163,20 @@ var _ Widget = &SliderFloatWidget{}
type SliderFloatWidget struct {
label string
value *float32
min float32
max float32
minValue float32
maxValue float32
format string
width float32
onChange func()
}

// SliderFloat creates new slider float widget.
func SliderFloat(value *float32, min, max float32) *SliderFloatWidget {
func SliderFloat(value *float32, minValue, maxValue float32) *SliderFloatWidget {
return &SliderFloatWidget{
label: GenAutoID("##SliderFloat"),
value: value,
min: min,
max: max,
minValue: minValue,
maxValue: maxValue,
format: "%.3f",
width: 0,
onChange: nil,
Expand Down Expand Up @@ -222,7 +222,7 @@ func (sf *SliderFloatWidget) Build() {
defer PopItemWidth()
}

if imgui.SliderFloatV(Context.FontAtlas.RegisterString(sf.label), sf.value, sf.min, sf.max, sf.format, 1.0) && sf.onChange != nil {
if imgui.SliderFloatV(Context.FontAtlas.RegisterString(sf.label), sf.value, sf.minValue, sf.maxValue, sf.format, 1.0) && sf.onChange != nil {
sf.onChange()
}
}
2 changes: 1 addition & 1 deletion cmd/gmdeploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func main() {
// Prepare PkgInfo
save(filepath.Join(contentsPath, "PkgInfo"), darwinPkginfo())

if len(iconPath) > 0 && filepath.Ext(iconPath) == iconExtension {
if iconPath != "" && filepath.Ext(iconPath) == iconExtension {
// Prepare icon
resourcesPath := filepath.Join(contentsPath, "Resources")
mkdirAll(resourcesPath)
Expand Down

0 comments on commit 4a1167e

Please sign in to comment.