Skip to content

Commit

Permalink
fix golints
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Sep 14, 2021
1 parent 9a59f79 commit b40c1de
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 85 deletions.
24 changes: 12 additions & 12 deletions Canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ const (
DrawFlagsRoundCornersMask DrawFlags = DrawFlagsRoundCornersAll | DrawFlagsRoundCornersNone
)

func (c *Canvas) AddRect(pMin, pMax image.Point, color color.RGBA, rounding float32, rounding_corners DrawFlags, thickness float32) {
c.drawlist.AddRect(ToVec2(pMin), ToVec2(pMax), ToVec4Color(color), rounding, int(rounding_corners), thickness)
func (c *Canvas) AddRect(pMin, pMax image.Point, color color.RGBA, rounding float32, roundingCorners DrawFlags, thickness float32) {
c.drawlist.AddRect(ToVec2(pMin), ToVec2(pMax), ToVec4Color(color), rounding, int(roundingCorners), thickness)
}

func (c *Canvas) AddRectFilled(pMin, pMax image.Point, color color.RGBA, rounding float32, rounding_corners DrawFlags) {
c.drawlist.AddRectFilled(ToVec2(pMin), ToVec2(pMax), ToVec4Color(color), rounding, int(rounding_corners))
func (c *Canvas) AddRectFilled(pMin, pMax image.Point, color color.RGBA, rounding float32, roundingCorners DrawFlags) {
c.drawlist.AddRectFilled(ToVec2(pMin), ToVec2(pMax), ToVec4Color(color), rounding, int(roundingCorners))
}

func (c *Canvas) AddText(pos image.Point, color color.RGBA, text string) {
c.drawlist.AddText(ToVec2(pos), ToVec4Color(color), tStr(text))
}

func (c *Canvas) AddBezierCubic(pos0, cp0, cp1, pos1 image.Point, color color.RGBA, thickness float32, num_segments int) {
c.drawlist.AddBezierCubic(ToVec2(pos0), ToVec2(cp0), ToVec2(cp1), ToVec2(pos1), ToVec4Color(color), thickness, num_segments)
func (c *Canvas) AddBezierCubic(pos0, cp0, cp1, pos1 image.Point, color color.RGBA, thickness float32, numSegments int) {
c.drawlist.AddBezierCubic(ToVec2(pos0), ToVec2(cp0), ToVec2(cp1), ToVec2(pos1), ToVec4Color(color), thickness, numSegments)
}

func (c *Canvas) AddTriangle(p1, p2, p3 image.Point, color color.RGBA, thickness float32) {
Expand Down Expand Up @@ -102,16 +102,16 @@ func (c *Canvas) PathStroke(color color.RGBA, closed bool, thickness float32) {
c.drawlist.PathStroke(ToVec4Color(color), closed, thickness)
}

func (c *Canvas) PathArcTo(center image.Point, radius, a_min, a_max float32, num_segments int) {
c.drawlist.PathArcTo(ToVec2(center), radius, a_min, a_max, num_segments)
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) PathArcToFast(center image.Point, radius float32, a_min_of_12, a_max_of_12 int) {
c.drawlist.PathArcToFast(ToVec2(center), radius, a_min_of_12, a_max_of_12)
func (c *Canvas) PathArcToFast(center image.Point, radius float32, min12, max12 int) {
c.drawlist.PathArcToFast(ToVec2(center), radius, min12, max12)
}

func (c *Canvas) PathBezierCubicCurveTo(p1, p2, p3 image.Point, num_segments int) {
c.drawlist.PathBezierCubicCurveTo(ToVec2(p1), ToVec2(p2), ToVec2(p3), num_segments)
func (c *Canvas) PathBezierCubicCurveTo(p1, p2, p3 image.Point, numSegments int) {
c.drawlist.PathBezierCubicCurveTo(ToVec2(p1), ToVec2(p2), ToVec2(p3), numSegments)
}

func (c *Canvas) AddImage(texture *Texture, pMin, pMax image.Point) {
Expand Down
2 changes: 1 addition & 1 deletion Context.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ func (c *context) GetState(id string) interface{} {
// Get widget index for current layout
func (c *context) GetWidgetIndex() int {
i := c.widgetIndexCounter
c.widgetIndexCounter += 1
c.widgetIndexCounter++
return i
}
14 changes: 7 additions & 7 deletions Msgbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func buildMsgboxButtons(buttons MsgboxButtons, callback DialogResultCallback) La
}
}

const msgboxId string = "###Msgbox"
const msgboxID string = "###Msgbox"

// Embed various Msgboxs to layout. Invoke this function in the same layout level where you call g.Msgbox.
func PrepareMsgbox() Layout {
Expand All @@ -89,24 +89,24 @@ func PrepareMsgbox() Layout {
var state *MsgboxState

// Register state.
stateRaw := Context.GetState(msgboxId)
stateRaw := Context.GetState(msgboxID)

if stateRaw == nil {
state = &MsgboxState{title: "Info", content: "Content", buttons: MsgboxButtonsOk, resultCallback: nil, open: false}
Context.SetState(msgboxId, state)
Context.SetState(msgboxID, state)
} else {
state = stateRaw.(*MsgboxState)
}

if state.open {
OpenPopup(msgboxId)
OpenPopup(msgboxID)
state.open = false
}
SetNextWindowSize(300, 0)
PopupModal(fmt.Sprintf("%s%s", state.title, msgboxId)).Layout(
PopupModal(fmt.Sprintf("%s%s", state.title, msgboxID)).Layout(
Custom(func() {
// Ensure the state is valid.
Context.GetState(msgboxId)
Context.GetState(msgboxID)
}),
Label(state.content).Wrapped(true),
buildMsgboxButtons(state.buttons, state.resultCallback),
Expand All @@ -118,7 +118,7 @@ func PrepareMsgbox() Layout {
type MsgboxWidget struct{}

func (m *MsgboxWidget) getState() *MsgboxState {
stateRaw := Context.GetState(msgboxId)
stateRaw := Context.GetState(msgboxID)
if stateRaw == nil {
panic("Msgbox is not prepared. Invoke giu.PrepareMsgbox in the end of the layout.")
}
Expand Down
8 changes: 4 additions & 4 deletions ProgressIndicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (ps *ProgressIndicatorState) Dispose() {
}

type ProgressIndicatorWidget struct {
internalId string
internalID string
width float32
height float32
radius float32
Expand All @@ -42,7 +42,7 @@ type ProgressIndicatorWidget struct {

func ProgressIndicator(label string, width, height, radius float32) *ProgressIndicatorWidget {
return &ProgressIndicatorWidget{
internalId: "###giu-progress-indicator",
internalID: "###giu-progress-indicator",
width: width * Context.GetPlatform().GetContentScale(),
height: height * Context.GetPlatform().GetContentScale(),
radius: radius * Context.GetPlatform().GetContentScale(),
Expand All @@ -52,10 +52,10 @@ func ProgressIndicator(label string, width, height, radius float32) *ProgressInd

func (p *ProgressIndicatorWidget) Build() {
// State exists
if s := Context.GetState(p.internalId); s == nil {
if s := Context.GetState(p.internalID); s == nil {
// Register state and start go routine
ps := ProgressIndicatorState{angle: 0.0, stop: false}
Context.SetState(p.internalId, &ps)
Context.SetState(p.internalID, &ps)
go ps.Update()
} else {
state := s.(*ProgressIndicatorState)
Expand Down
6 changes: 3 additions & 3 deletions SplitLayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ func (s *SplitLayoutWidget) Build() {

var splitLayoutState *SplitLayoutState
// Register state
stateId := fmt.Sprintf("SplitLayout_%s", s.id)
if state := Context.GetState(stateId); state == nil {
stateID := fmt.Sprintf("SplitLayout_%s", s.id)
if state := Context.GetState(stateID); state == nil {
splitLayoutState = &SplitLayoutState{delta: 0.0, sashPos: s.sashPos}
Context.SetState(stateId, splitLayoutState)
Context.SetState(stateID, splitLayoutState)
} else {
splitLayoutState = state.(*SplitLayoutState)
}
Expand Down
8 changes: 4 additions & 4 deletions Style.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ func Style() *StyleSetter {
return &ss
}

func (ss *StyleSetter) SetColor(colorId StyleColorID, col color.RGBA) *StyleSetter {
ss.colors[colorId] = col
func (ss *StyleSetter) SetColor(colorID StyleColorID, col color.RGBA) *StyleSetter {
ss.colors[colorID] = col
return ss
}

func (ss *StyleSetter) SetStyle(varId StyleVarID, width, height float32) *StyleSetter {
ss.styles[varId] = imgui.Vec2{X: width, Y: height}
func (ss *StyleSetter) SetStyle(varID StyleVarID, width, height float32) *StyleSetter {
ss.styles[varID] = imgui.Vec2{X: width, Y: height}
return ss
}

Expand Down
4 changes: 2 additions & 2 deletions Texture.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func NewTextureFromRgba(rgba image.Image, loadCallback func(*Texture)) {
go func() {
Update()
result := mainthread.CallVal(func() interface{} {
texId, err := Context.renderer.LoadImage(ImageToRgba(rgba))
return &loadImageResult{id: texId, err: err}
texID, err := Context.renderer.LoadImage(ImageToRgba(rgba))
return &loadImageResult{id: texID, err: err}
})

tid, ok := result.(*loadImageResult)
Expand Down
Loading

0 comments on commit b40c1de

Please sign in to comment.