Skip to content

Commit

Permalink
add godot linter
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Sep 29, 2021
1 parent 0c43040 commit a83cfe4
Show file tree
Hide file tree
Showing 22 changed files with 352 additions and 352 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ linters:
- forcetypeassert
#- funlen
- gci
#- godot
- godot
#- gochecknoglobals
#- gochecknoinits
- gocognit
Expand Down
6 changes: 3 additions & 3 deletions Alignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ type AlignmentSetter struct {
//
// - BUG: DatePickerWidget doesn't work properly
// - BUG: there is some bug with SelectableWidget
// - BUG: ComboWidget and ComboCustomWidgets doesn't work properly
// - BUG: ComboWidget and ComboCustomWidgets doesn't work properly.
func Align(at AlignmentType) *AlignmentSetter {
return &AlignmentSetter{
alignType: at,
id: GenAutoID("alignSetter"),
}
}

// To sets a layout, alignment should be applied to
// To sets a layout, alignment should be applied to.
func (a *AlignmentSetter) To(widgets ...Widget) *AlignmentSetter {
a.layout = Layout(widgets)
return a
}

// ID allows to manually set AlignmentSetter ID (it shouldn't be used
// in a normal conditions)
// in a normal conditions).
func (a *AlignmentSetter) ID(id string) *AlignmentSetter {
a.id = id
return a
Expand Down
32 changes: 16 additions & 16 deletions Canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ import (
)

// Canvas represents imgui.DrawList
// for more details see examples/canvas
// for more details see examples/canvas.
type Canvas struct {
drawlist imgui.DrawList
}

// GetCanvas creates new Canvas
// GetCanvas creates new Canvas.
func GetCanvas() *Canvas {
return &Canvas{
drawlist: imgui.GetWindowDrawList(),
}
}

// AddLine draws a line (from p1 to p2)
// AddLine draws a line (from p1 to p2).
func (c *Canvas) AddLine(p1, p2 image.Point, col color.RGBA, thickness float32) {
c.drawlist.AddLine(ToVec2(p1), ToVec2(p2), ToVec4Color(col), thickness)
}

// DrawFlags represents imgui.DrawFlags
// DrawFlags represents imgui.DrawFlags.
type DrawFlags int

// draw flags enum:
// draw flags enum:.
const (
DrawFlagsNone DrawFlags = 0
// PathStroke(), AddPolyline(): specify that shape should be closed (portant: this is always == 1 for legacy reason)
// PathStroke(), AddPolyline(): specify that shape should be closed (portant: this is always == 1 for legacy reason).
DrawFlagsClosed DrawFlags = 1 << 0
// AddRect(), AddRectFilled(), PathRect(): enable rounding top-left corner only (when rounding > 0.0f, we default to all corners).
// Was 0x01.
Expand All @@ -58,52 +58,52 @@ const (
DrawFlagsRoundCornersMask DrawFlags = DrawFlagsRoundCornersAll | DrawFlagsRoundCornersNone
)

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

// AddRectFilled draws a rectangle filled with `col`
// AddRectFilled draws a rectangle filled with `col`.
func (c *Canvas) AddRectFilled(pMin, pMax image.Point, col color.RGBA, rounding float32, roundingCorners DrawFlags) {
c.drawlist.AddRectFilled(ToVec2(pMin), ToVec2(pMax), ToVec4Color(col), rounding, int(roundingCorners))
}

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

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

// AddTriangle draws a triangle
// AddTriangle draws a triangle.
func (c *Canvas) AddTriangle(p1, p2, p3 image.Point, col color.RGBA, thickness float32) {
c.drawlist.AddTriangle(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec4Color(col), thickness)
}

// AddTriangleFilled draws a filled triangle
// AddTriangleFilled draws a filled triangle.
func (c *Canvas) AddTriangleFilled(p1, p2, p3 image.Point, col color.RGBA) {
c.drawlist.AddTriangleFilled(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec4Color(col))
}

// AddCircle draws a circle
// AddCircle draws a circle.
func (c *Canvas) AddCircle(center image.Point, radius float32, col color.RGBA, segments int, thickness float32) {
c.drawlist.AddCircle(ToVec2(center), radius, ToVec4Color(col), segments, thickness)
}

// AddCircleFilled draws a filled circle
// AddCircleFilled draws a filled circle.
func (c *Canvas) AddCircleFilled(center image.Point, radius float32, col color.RGBA) {
c.drawlist.AddCircleFilled(ToVec2(center), radius, ToVec4Color(col))
}

// AddQuad draws a quad
// AddQuad draws a quad.
func (c *Canvas) AddQuad(p1, p2, p3, p4 image.Point, col color.RGBA, thickness float32) {
c.drawlist.AddQuad(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ToVec4Color(col), thickness)
}

// AddQuadFilled draws a filled quad
// AddQuadFilled draws a filled quad.
func (c *Canvas) AddQuadFilled(p1, p2, p3, p4 image.Point, col color.RGBA) {
c.drawlist.AddQuadFilled(ToVec2(p1), ToVec2(p2), ToVec2(p3), ToVec2(p4), ToVec4Color(col))
}
Expand Down
54 changes: 27 additions & 27 deletions CodeEditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/AllenDang/imgui-go"
)

// LanguageDefinition represents code editor's language definition
// LanguageDefinition represents code editor's language definition.
type LanguageDefinition byte

// language definitions:
// language definitions:.
const (
LanguageDefinitionSQL LanguageDefinition = iota
LanguageDefinitionCPP
Expand All @@ -23,15 +23,15 @@ type codeEditorState struct {
editor imgui.TextEditor
}

// Dispose implements Disposable interface
// Dispose implements Disposable interface.
func (s *codeEditorState) Dispose() {
// noop
}

// static check if code editor implements Widget interface
// static check if code editor implements Widget interface.
var _ Widget = &CodeEditorWidget{}

// CodeEditorWidget represents imgui.TextEditor
// CodeEditorWidget represents imgui.TextEditor.
type CodeEditorWidget struct {
title string
width,
Expand All @@ -52,19 +52,19 @@ func (ce *CodeEditorWidget) ID(id string) *CodeEditorWidget {
return ce
}

// ShowWhitespaces sets if whitespaces are shown in code editor
// ShowWhitespaces sets if whitespaces are shown in code editor.
func (ce *CodeEditorWidget) ShowWhitespaces(s bool) *CodeEditorWidget {
ce.getState().editor.SetShowWhitespaces(s)
return ce
}

// TabSize sets editor's tab size
// TabSize sets editor's tab size.
func (ce *CodeEditorWidget) TabSize(size int) *CodeEditorWidget {
ce.getState().editor.SetTabSize(size)
return ce
}

// LanguageDefinition sets code editor language definition
// LanguageDefinition sets code editor language definition.
func (ce *CodeEditorWidget) LanguageDefinition(definition LanguageDefinition) *CodeEditorWidget {
s := ce.getState()
lookup := map[LanguageDefinition]func(){
Expand All @@ -84,77 +84,77 @@ func (ce *CodeEditorWidget) LanguageDefinition(definition LanguageDefinition) *C
return ce
}

// Text sets editor's text
// Text sets editor's text.
func (ce *CodeEditorWidget) Text(str string) *CodeEditorWidget {
ce.getState().editor.SetText(str)
return ce
}

// ErrorMarkers sets error markers
// ErrorMarkers sets error markers.
func (ce *CodeEditorWidget) ErrorMarkers(markers imgui.ErrorMarkers) *CodeEditorWidget {
ce.getState().editor.SetErrorMarkers(markers)
return ce
}

// HandleKeyboardInputs sets if editor should handle keyboard input
// HandleKeyboardInputs sets if editor should handle keyboard input.
func (ce *CodeEditorWidget) HandleKeyboardInputs(b bool) *CodeEditorWidget {
ce.getState().editor.SetHandleKeyboardInputs(b)
return ce
}

// Size sets editor's size
// Size sets editor's size.
func (ce *CodeEditorWidget) Size(w, h float32) *CodeEditorWidget {
ce.width, ce.height = w, h
return ce
}

// Border sets editors borders
// Border sets editors borders.
func (ce *CodeEditorWidget) Border(border bool) *CodeEditorWidget {
ce.border = border
return ce
}

// HasSelection returns true if some text is selected
// HasSelection returns true if some text is selected.
func (ce *CodeEditorWidget) HasSelection() bool {
return ce.getState().editor.HasSelection()
}

// GetSelectedText returns selected text
// GetSelectedText returns selected text.
func (ce *CodeEditorWidget) GetSelectedText() string {
return ce.getState().editor.GetSelectedText()
}

// GetText returns whole text from editor
// GetText returns whole text from editor.
func (ce *CodeEditorWidget) GetText() string {
return ce.getState().editor.GetText()
}

// GetCurrentLineText returns current line
// GetCurrentLineText returns current line.
func (ce *CodeEditorWidget) GetCurrentLineText() string {
return ce.getState().editor.GetCurrentLineText()
}

// GetCursorPos returns cursor position
// GetCursorPos returns cursor position.
func (ce *CodeEditorWidget) GetCursorPos() (x, y int) {
return ce.getState().editor.GetCursorPos()
}

// GetSelectionStart returns star pos of selection
// GetSelectionStart returns star pos of selection.
func (ce *CodeEditorWidget) GetSelectionStart() (x, y int) {
return ce.getState().editor.GetSelectionStart()
}

// InsertText inserts the `text`
// InsertText inserts the `text`.
func (ce *CodeEditorWidget) InsertText(text string) {
ce.getState().editor.InsertText(text)
}

// GetWordUnderCursor returns the word under the cursor
// GetWordUnderCursor returns the word under the cursor.
func (ce *CodeEditorWidget) GetWordUnderCursor() string {
return ce.getState().editor.GetWordUnderCursor()
}

// SelectWordUnderCursor selects the word under cursor
// SelectWordUnderCursor selects the word under cursor.
func (ce *CodeEditorWidget) SelectWordUnderCursor() {
ce.getState().editor.SelectWordUnderCursor()
}
Expand All @@ -167,27 +167,27 @@ func (ce *CodeEditorWidget) GetScreenCursorPos() (x, y int) {
return ce.getState().editor.GetScreenCursorPos()
}

// Copy copies selection
// Copy copies selection.
func (ce *CodeEditorWidget) Copy() {
ce.getState().editor.Copy()
}

// Cut cuts selection
// Cut cuts selection.
func (ce *CodeEditorWidget) Cut() {
ce.getState().editor.Cut()
}

// Paste does the same as Ctrl+V
// Paste does the same as Ctrl+V.
func (ce *CodeEditorWidget) Paste() {
ce.getState().editor.Paste()
}

// Delete deletes the selection
// Delete deletes the selection.
func (ce *CodeEditorWidget) Delete() {
ce.getState().editor.Delete()
}

// Build implements Widget interface
// Build implements Widget interface.
func (ce *CodeEditorWidget) Build() {
s := ce.getState()

Expand Down
2 changes: 1 addition & 1 deletion Context.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *context) GetState(id string) interface{} {
return nil
}

// Get widget index for current layout
// Get widget index for current layout.
func (c *context) GetWidgetIndex() int {
i := c.widgetIndexCounter
c.widgetIndexCounter++
Expand Down
4 changes: 2 additions & 2 deletions Direction.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package giu

// Direction represents a ArrowButton direction
// Direction represents a ArrowButton direction.
type Direction uint8

// directions
// directions.
const (
DirectionLeft Direction = iota
DirectionRight
Expand Down
Loading

0 comments on commit a83cfe4

Please sign in to comment.