diff --git a/.golangci.yml b/.golangci.yml index ff206e57..9e60792d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -44,7 +44,7 @@ linters: - forcetypeassert #- funlen - gci - #- godot + - godot #- gochecknoglobals #- gochecknoinits - gocognit diff --git a/Alignment.go b/Alignment.go index 8f3a0195..96ee184f 100644 --- a/Alignment.go +++ b/Alignment.go @@ -26,7 +26,7 @@ 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, @@ -34,14 +34,14 @@ func Align(at AlignmentType) *AlignmentSetter { } } -// 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 diff --git a/Canvas.go b/Canvas.go index 1403c745..8a8b2999 100644 --- a/Canvas.go +++ b/Canvas.go @@ -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. @@ -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)) } diff --git a/CodeEditor.go b/CodeEditor.go index af8ffaee..366be398 100644 --- a/CodeEditor.go +++ b/CodeEditor.go @@ -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 @@ -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, @@ -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(){ @@ -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() } @@ -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() diff --git a/Context.go b/Context.go index ad19d6ec..40ffc7ff 100644 --- a/Context.go +++ b/Context.go @@ -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++ diff --git a/Direction.go b/Direction.go index 60ecd0de..d8876771 100644 --- a/Direction.go +++ b/Direction.go @@ -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 diff --git a/EventHandler.go b/EventHandler.go index c7398537..5712942f 100644 --- a/EventHandler.go +++ b/EventHandler.go @@ -6,7 +6,7 @@ type eventHandlerState struct { isActive bool } -// Dispose implements Disposable interface +// Dispose implements Disposable interface. func (s *eventHandlerState) Dispose() { // noop } @@ -26,7 +26,7 @@ type keyEvent struct { var _ Widget = &EventHandler{} // EventHandler is a universal event handler for giu widgets. -// put giu.Event()... after any widget to handle any event +// put giu.Event()... after any widget to handle any event. type EventHandler struct { hover func() mouseEvents []mouseEvent @@ -35,7 +35,7 @@ type EventHandler struct { onDeactivate func() } -// Event adds a new event to widget above +// Event adds a new event to widget above. func Event() *EventHandler { return &EventHandler{ mouseEvents: make([]mouseEvent, 0), @@ -43,19 +43,19 @@ func Event() *EventHandler { } } -// OnHover sets callback when item gets hovered +// OnHover sets callback when item gets hovered. func (eh *EventHandler) OnHover(onHover func()) *EventHandler { eh.hover = onHover return eh } -// OnActivate sets callback when item gets activated +// OnActivate sets callback when item gets activated. func (eh *EventHandler) OnActivate(cb func()) *EventHandler { eh.onActivate = cb return eh } -// OnDeactivate sets callback when item gets deactivated +// OnDeactivate sets callback when item gets deactivated. func (eh *EventHandler) OnDeactivate(cb func()) *EventHandler { eh.onDeactivate = cb return eh @@ -63,19 +63,19 @@ func (eh *EventHandler) OnDeactivate(cb func()) *EventHandler { // Key events -// OnKeyDown sets callback when key `key` is down +// OnKeyDown sets callback when key `key` is down. func (eh *EventHandler) OnKeyDown(key Key, cb func()) *EventHandler { eh.keyEvents = append(eh.keyEvents, keyEvent{key, cb, IsKeyDown}) return eh } -// OnKeyPressed sets callback when key `key` is pressed +// OnKeyPressed sets callback when key `key` is pressed. func (eh *EventHandler) OnKeyPressed(key Key, cb func()) *EventHandler { eh.keyEvents = append(eh.keyEvents, keyEvent{key, cb, IsKeyPressed}) return eh } -// OnKeyReleased sets callback when key `key` is released +// OnKeyReleased sets callback when key `key` is released. func (eh *EventHandler) OnKeyReleased(key Key, cb func()) *EventHandler { eh.keyEvents = append(eh.keyEvents, keyEvent{key, cb, IsKeyReleased}) return eh @@ -83,25 +83,25 @@ func (eh *EventHandler) OnKeyReleased(key Key, cb func()) *EventHandler { // Mouse events -// OnClick sets callback when mouse button `mouseButton` is clicked +// OnClick sets callback when mouse button `mouseButton` is clicked. func (eh *EventHandler) OnClick(mouseButton MouseButton, callback func()) *EventHandler { eh.mouseEvents = append(eh.mouseEvents, mouseEvent{mouseButton, callback, IsMouseClicked}) return eh } -// OnDClick sets callback when mouse button `mouseButton` is double-clicked +// OnDClick sets callback when mouse button `mouseButton` is double-clicked. func (eh *EventHandler) OnDClick(mouseButton MouseButton, callback func()) *EventHandler { eh.mouseEvents = append(eh.mouseEvents, mouseEvent{mouseButton, callback, IsMouseDoubleClicked}) return eh } -// OnMouseDown sets callback when mouse button `mouseButton` is down +// OnMouseDown sets callback when mouse button `mouseButton` is down. func (eh *EventHandler) OnMouseDown(mouseButton MouseButton, callback func()) *EventHandler { eh.mouseEvents = append(eh.mouseEvents, mouseEvent{mouseButton, callback, IsMouseDown}) return eh } -// OnMouseReleased sets callback when mouse button `mouseButton` is released +// OnMouseReleased sets callback when mouse button `mouseButton` is released. func (eh *EventHandler) OnMouseReleased(mouseButton MouseButton, callback func()) *EventHandler { eh.mouseEvents = append(eh.mouseEvents, mouseEvent{mouseButton, callback, IsMouseReleased}) return eh diff --git a/Events.go b/Events.go index 509c3aed..502ef3d5 100644 --- a/Events.go +++ b/Events.go @@ -15,69 +15,69 @@ func IsItemHovered() bool { } // IsItemClicked returns true if mouse is clicked -// NOTE: if you're looking for clicking detection, see EventHandler.go +// NOTE: if you're looking for clicking detection, see EventHandler.go. func IsItemClicked(mouseButton MouseButton) bool { return imgui.IsItemClicked(int(mouseButton)) } -// IsItemActive returns true if item is active +// IsItemActive returns true if item is active. func IsItemActive() bool { return imgui.IsItemActive() } -// IsKeyDown returns true if key `key` is down +// IsKeyDown returns true if key `key` is down. func IsKeyDown(key Key) bool { return imgui.IsKeyDown(int(key)) } -// IsKeyPressed returns true if key `key` is pressed +// IsKeyPressed returns true if key `key` is pressed. func IsKeyPressed(key Key) bool { return imgui.IsKeyPressed(int(key)) } -// IsKeyReleased returns true if key `key` is released +// IsKeyReleased returns true if key `key` is released. func IsKeyReleased(key Key) bool { return imgui.IsKeyReleased(int(key)) } -// IsMouseDown returns true if mouse button `button` is down +// IsMouseDown returns true if mouse button `button` is down. func IsMouseDown(button MouseButton) bool { return imgui.IsMouseDown(int(button)) } // IsMouseClicked returns true if mouse button `button` is clicked -// NOTE: if you're looking for clicking detection, see EventHandler.go +// NOTE: if you're looking for clicking detection, see EventHandler.go. func IsMouseClicked(button MouseButton) bool { return imgui.IsMouseClicked(int(button)) } -// IsMouseReleased returns true if mouse button `button` is released +// IsMouseReleased returns true if mouse button `button` is released. func IsMouseReleased(button MouseButton) bool { return imgui.IsMouseReleased(int(button)) } -// IsMouseDoubleClicked returns true if mouse button `button` is double clicked +// IsMouseDoubleClicked returns true if mouse button `button` is double clicked. func IsMouseDoubleClicked(button MouseButton) bool { return imgui.IsMouseDoubleClicked(int(button)) } -// IsWindowAppearing returns true if window is appearing +// IsWindowAppearing returns true if window is appearing. func IsWindowAppearing() bool { return imgui.IsWindowAppearing() } -// IsWindowCollapsed returns true if window is disappearing +// IsWindowCollapsed returns true if window is disappearing. func IsWindowCollapsed() bool { return imgui.IsWindowCollapsed() } // IsWindowFocused returns true if window is focused -// NOTE: see also (*Window).HasFocus and (*Window).BringToFront +// NOTE: see also (*Window).HasFocus and (*Window).BringToFront. func IsWindowFocused(flags FocusedFlags) bool { return imgui.IsWindowFocused(int(flags)) } -// IsWindowHovered returns true if the window is hovered +// IsWindowHovered returns true if the window is hovered. func IsWindowHovered(flags HoveredFlags) bool { return imgui.IsWindowHovered(int(flags)) } diff --git a/Flags.go b/Flags.go index 7d2bd8a6..f66a0ae4 100644 --- a/Flags.go +++ b/Flags.go @@ -7,9 +7,9 @@ type InputTextFlags int const ( // InputTextFlagsNone sets everything default. InputTextFlagsNone InputTextFlags = imgui.InputTextFlagsNone - // InputTextFlagsCharsDecimal allows 0123456789.+- + // InputTextFlagsCharsDecimal allows 0123456789.+-. InputTextFlagsCharsDecimal InputTextFlags = imgui.InputTextFlagsCharsDecimal - // InputTextFlagsCharsHexadecimal allow 0123456789ABCDEFabcdef + // InputTextFlagsCharsHexadecimal allow 0123456789ABCDEFabcdef. InputTextFlagsCharsHexadecimal InputTextFlags = imgui.InputTextFlagsCharsHexadecimal // InputTextFlagsCharsUppercase turns a..z into A..Z. InputTextFlagsCharsUppercase InputTextFlags = imgui.InputTextFlagsCharsUppercase @@ -51,7 +51,7 @@ const ( type WindowFlags int const ( - // WindowFlagsNone default = 0 + // WindowFlagsNone default = 0. WindowFlagsNone WindowFlags = imgui.WindowFlagsNone // WindowFlagsNoTitleBar disables title-bar. WindowFlagsNoTitleBar WindowFlags = imgui.WindowFlagsNoTitleBar @@ -96,7 +96,7 @@ const ( // WindowFlagsNoNavInputs has no gamepad/keyboard navigation within the window. WindowFlagsNoNavInputs WindowFlags = imgui.WindowFlagsNoNavInputs // WindowFlagsNoNavFocus has no focusing toward this window with gamepad/keyboard navigation - // (e.g. skipped by CTRL+TAB) + // (e.g. skipped by CTRL+TAB). WindowFlagsNoNavFocus WindowFlags = imgui.WindowFlagsNoNavFocus // WindowFlagsUnsavedDocument appends '*' to title without affecting the ID, as a convenience to avoid using the // ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one @@ -115,7 +115,7 @@ const ( type ComboFlags int const ( - // ComboFlagNone default = 0 + // ComboFlagNone default = 0. ComboFlagNone ComboFlags = imgui.ComboFlagNone // ComboFlagPopupAlignLeft aligns the popup toward the left by default. ComboFlagPopupAlignLeft ComboFlags = imgui.ComboFlagPopupAlignLeft @@ -134,11 +134,11 @@ const ( ComboFlagNoPreview ComboFlags = imgui.ComboFlagNoPreview ) -// SelectableFlags represents imgui.SelectableFlags +// SelectableFlags represents imgui.SelectableFlags. type SelectableFlags int const ( - // SelectableFlagsNone default = 0 + // SelectableFlagsNone default = 0. SelectableFlagsNone SelectableFlags = imgui.SelectableFlagsNone // SelectableFlagsDontClosePopups makes clicking the selectable not close any parent popup windows. SelectableFlagsDontClosePopups SelectableFlags = imgui.SelectableFlagsDontClosePopups @@ -150,23 +150,23 @@ const ( SelectableFlagsDisabled SelectableFlags = imgui.SelectableFlagsDisabled ) -// TabItemFlags represents tab item flags +// TabItemFlags represents tab item flags. type TabItemFlags int const ( - // TabItemFlagsNone default = 0 + // TabItemFlagsNone default = 0. TabItemFlagsNone TabItemFlags = imgui.TabItemFlagsNone // TabItemFlagsUnsavedDocument Append '*' to title without affecting the ID, as a convenience to avoid using the // ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it // without flicker. TabItemFlagsUnsavedDocument TabItemFlags = imgui.TabItemFlagsUnsavedDocument - // TabItemFlagsSetSelected Trigger flag to programmatically make the tab selected when calling BeginTabItem() + // TabItemFlagsSetSelected Trigger flag to programmatically make the tab selected when calling BeginTabItem(). TabItemFlagsSetSelected TabItemFlags = imgui.TabItemFlagsSetSelected // TabItemFlagsNoCloseWithMiddleMouseButton Disable behavior of closing tabs (that are submitted with // p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if // (IsItemHovered() && IsMouseClicked(2)) *p_open = false. TabItemFlagsNoCloseWithMiddleMouseButton TabItemFlags = imgui.TabItemFlagsNoCloseWithMiddleMouseButton - // TabItemFlagsNoPushID Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem() + // TabItemFlagsNoPushID Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem(). TabItemFlagsNoPushID TabItemFlags = imgui.TabItemFlagsNoPushID ) @@ -175,37 +175,37 @@ type TabBarFlags int const ( // TabBarFlagsNone default = 0. TabBarFlagsNone TabBarFlags = imgui.TabBarFlagsNone - // TabBarFlagsReorderable Allow manually dragging tabs to re-order them + New tabs are appended at the end of list + // TabBarFlagsReorderable Allow manually dragging tabs to re-order them + New tabs are appended at the end of list. TabBarFlagsReorderable TabBarFlags = imgui.TabBarFlagsReorderable - // TabBarFlagsAutoSelectNewTabs Automatically select new tabs when they appear + // TabBarFlagsAutoSelectNewTabs Automatically select new tabs when they appear. TabBarFlagsAutoSelectNewTabs TabBarFlags = imgui.TabBarFlagsAutoSelectNewTabs - // TabBarFlagsTabListPopupButton Disable buttons to open the tab list popup + // TabBarFlagsTabListPopupButton Disable buttons to open the tab list popup. TabBarFlagsTabListPopupButton TabBarFlags = imgui.TabBarFlagsTabListPopupButton // TabBarFlagsNoCloseWithMiddleMouseButton Disable behavior of closing tabs (that are submitted with p_open != NULL) // with middle mouse button. You can still repro this behavior on user's side with if // (IsItemHovered() && IsMouseClicked(2)) *p_open = false. TabBarFlagsNoCloseWithMiddleMouseButton TabBarFlags = imgui.TabBarFlagsNoCloseWithMiddleMouseButton // TabBarFlagsNoTabListScrollingButtons Disable scrolling buttons (apply when fitting policy is - // TabBarFlagsFittingPolicyScroll) + // TabBarFlagsFittingPolicyScroll). TabBarFlagsNoTabListScrollingButtons TabBarFlags = imgui.TabBarFlagsNoTabListScrollingButtons - // TabBarFlagsNoTooltip Disable tooltips when hovering a tab + // TabBarFlagsNoTooltip Disable tooltips when hovering a tab. TabBarFlagsNoTooltip TabBarFlags = imgui.TabBarFlagsNoTooltip - // TabBarFlagsFittingPolicyResizeDown Resize tabs when they don't fit + // TabBarFlagsFittingPolicyResizeDown Resize tabs when they don't fit. TabBarFlagsFittingPolicyResizeDown TabBarFlags = imgui.TabBarFlagsFittingPolicyResizeDown - // TabBarFlagsFittingPolicyScroll Add scroll buttons when tabs don't fit + // TabBarFlagsFittingPolicyScroll Add scroll buttons when tabs don't fit. TabBarFlagsFittingPolicyScroll TabBarFlags = imgui.TabBarFlagsFittingPolicyScroll // TabBarFlagsFittingPolicyMask combines - // TabBarFlagsFittingPolicyResizeDown and TabBarFlagsFittingPolicyScroll + // TabBarFlagsFittingPolicyResizeDown and TabBarFlagsFittingPolicyScroll. TabBarFlagsFittingPolicyMask TabBarFlags = imgui.TabBarFlagsFittingPolicyMask - // TabBarFlagsFittingPolicyDefault alias for TabBarFlagsFittingPolicyResizeDown + // TabBarFlagsFittingPolicyDefault alias for TabBarFlagsFittingPolicyResizeDown. TabBarFlagsFittingPolicyDefault TabBarFlags = imgui.TabBarFlagsFittingPolicyDefault ) -// TreeNodeFlags represents tree node widget flags +// TreeNodeFlags represents tree node widget flags. type TreeNodeFlags int const ( - // TreeNodeFlagsNone default = 0 + // TreeNodeFlagsNone default = 0. TreeNodeFlagsNone TreeNodeFlags = imgui.TreeNodeFlagsNone // TreeNodeFlagsSelected draws as selected. TreeNodeFlagsSelected TreeNodeFlags = imgui.TreeNodeFlagsSelected @@ -241,21 +241,21 @@ const ( // TreeNodeFlagsSpanFullWidth extends hit box to the left-most and right-most edges (bypass the indented area). TreeNodeFlagsSpanFullWidth TreeNodeFlags = imgui.TreeNodeFlagsSpanFullWidth // TreeNodeFlagsNavLeftJumpsBackHere (WIP) Nav: left direction may move to this TreeNode() from any of its child - // (items submitted between TreeNode and TreePop) + // (items submitted between TreeNode and TreePop). TreeNodeFlagsNavLeftJumpsBackHere TreeNodeFlags = imgui.TreeNodeFlagsNavLeftJumpsBackHere // TreeNodeFlagsCollapsingHeader combines TreeNodeFlagsFramed and TreeNodeFlagsNoAutoOpenOnLog. TreeNodeFlagsCollapsingHeader TreeNodeFlags = imgui.TreeNodeFlagsCollapsingHeader ) -// FocusedFlags represents imgui.FocusedFlags +// FocusedFlags represents imgui.FocusedFlags. type FocusedFlags int const ( - // FocusedFlagsNone default FocusedFlags = 0 + // FocusedFlagsNone default FocusedFlags = 0. FocusedFlagsNone FocusedFlags = 0 - // FocusedFlagsChildWindows matches if any children of the window is focused + // FocusedFlagsChildWindows matches if any children of the window is focused. FocusedFlagsChildWindows FocusedFlags = 1 << 0 - // FocusedFlagsRootWindow tests from root window (top most parent of the current hierarchy) + // FocusedFlagsRootWindow tests from root window (top most parent of the current hierarchy). FocusedFlagsRootWindow FocusedFlags = 1 << 1 // FocusedFlagsAnyWindow matches if any window is focused. FocusedFlagsAnyWindow FocusedFlags = 1 << 2 @@ -263,7 +263,7 @@ const ( FocusedFlagsRootAndChildWindows = FocusedFlagsRootWindow | FocusedFlagsChildWindows ) -// HoveredFlags represents a hovered flags +// HoveredFlags represents a hovered flags. type HoveredFlags int const ( @@ -281,9 +281,9 @@ const ( // HoveredFlagsAllowWhenBlockedByActiveItem Return true even if an active item is blocking access to this item/window. // Useful for Drag and Drop patterns. HoveredFlagsAllowWhenBlockedByActiveItem HoveredFlags = imgui.HoveredFlagsAllowWhenBlockedByActiveItem - // HoveredFlagsAllowWhenOverlapped Return true even if the position is overlapped by another window + // HoveredFlagsAllowWhenOverlapped Return true even if the position is overlapped by another window. HoveredFlagsAllowWhenOverlapped HoveredFlags = imgui.HoveredFlagsAllowWhenOverlapped - // HoveredFlagsAllowWhenDisabled Return true even if the item is disabled + // HoveredFlagsAllowWhenDisabled Return true even if the item is disabled. HoveredFlagsAllowWhenDisabled HoveredFlags = imgui.HoveredFlagsAllowWhenDisabled ) @@ -291,7 +291,7 @@ const ( type ColorEditFlags int const ( - // ColorEditFlagsNone default = 0 + // ColorEditFlagsNone default = 0. ColorEditFlagsNone ColorEditFlags = imgui.ColorEditFlagsNone // ColorEditFlagsNoAlpha ignores Alpha component (read 3 components from the input pointer). ColorEditFlagsNoAlpha ColorEditFlags = imgui.ColorEditFlagsNoAlpha @@ -299,7 +299,7 @@ const ( ColorEditFlagsNoPicker ColorEditFlags = imgui.ColorEditFlagsNoPicker // ColorEditFlagsNoOptions disables toggling options menu when right-clicking on inputs/small preview. ColorEditFlagsNoOptions ColorEditFlags = imgui.ColorEditFlagsNoOptions - // ColorEditFlagsNoSmallPreview disables colored square preview next to the inputs. (e.g. to show only the inputs) + // ColorEditFlagsNoSmallPreview disables colored square preview next to the inputs. (e.g. to show only the inputs). ColorEditFlagsNoSmallPreview ColorEditFlags = imgui.ColorEditFlagsNoSmallPreview // ColorEditFlagsNoInputs disables inputs sliders/text widgets (e.g. to show only the small preview colored square). ColorEditFlagsNoInputs ColorEditFlags = imgui.ColorEditFlagsNoInputs @@ -323,11 +323,11 @@ const ( // ColorEditFlagsHDR = (WIP) surrently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use // ImGuiColorEditFlags_Float flag as well). ColorEditFlagsHDR ColorEditFlags = imgui.ColorEditFlagsHDR - // ColorEditFlagsRGB sets the format as RGB + // ColorEditFlagsRGB sets the format as RGB. ColorEditFlagsRGB ColorEditFlags = imgui.ColorEditFlagsRGB - // ColorEditFlagsHSV sets the format as HSV + // ColorEditFlagsHSV sets the format as HSV. ColorEditFlagsHSV ColorEditFlags = imgui.ColorEditFlagsHSV - // ColorEditFlagsHEX sets the format as HEX + // ColorEditFlagsHEX sets the format as HEX. ColorEditFlagsHEX ColorEditFlags = imgui.ColorEditFlagsHEX // ColorEditFlagsUint8 _display_ values formatted as 0..255. ColorEditFlagsUint8 ColorEditFlags = imgui.ColorEditFlagsUint8 @@ -335,10 +335,10 @@ const ( ColorEditFlagsFloat ColorEditFlags = imgui.ColorEditFlagsFloat ) -// TableFlags represents table flags +// TableFlags represents table flags. type TableFlags int -// Table flags enum: +// Table flags enum:. const ( TableFlagsNone TableFlags = TableFlags(imgui.TableFlags_None) TableFlagsResizable TableFlags = TableFlags(imgui.TableFlags_Resizable) @@ -382,14 +382,14 @@ type TableRowFlags int const ( TableRowFlagsNone TableRowFlags = TableRowFlags(imgui.TableRowFlags_None) - // Identify header row (set default background color + width of its contents accounted different for auto column width) + // Identify header row (set default background color + width of its contents accounted different for auto column width). TableRowFlagsHeaders TableRowFlags = TableRowFlags(imgui.TableRowFlags_Headers) ) type TableColumnFlags int const ( - // Input configuration flags + // Input configuration flags. TableColumnFlagsNone TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_None) TableColumnFlagsDefaultHide TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_DefaultHide) TableColumnFlagsDefaultSort TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_DefaultSort) @@ -408,13 +408,13 @@ const ( TableColumnFlagsIndentEnable TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IndentEnable) TableColumnFlagsIndentDisable TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IndentDisable) - // Output status flags read-only via TableGetColumnFlags() + // Output status flags read-only via TableGetColumnFlags(). TableColumnFlagsIsEnabled TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsEnabled) TableColumnFlagsIsVisible TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsVisible) TableColumnFlagsIsSorted TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsSorted) TableColumnFlagsIsHovered TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IsHovered) - // [Internal] Combinations and masks + // [Internal] Combinations and masks. TableColumnFlagsWidthMask_ TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_WidthMask_) TableColumnFlagsIndentMask_ TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_IndentMask_) TableColumnFlagsStatusMask_ TableColumnFlags = TableColumnFlags(imgui.TableColumnFlags_StatusMask_) @@ -430,9 +430,9 @@ const ( // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlagsNoRoundToFormat with this if using // a format-string with small amount of digits. SliderFlagsLogarithmic SliderFlags = 1 << 5 - // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits) + // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits). SliderFlagsNoRoundToFormat SliderFlags = 1 << 6 - // Disable CTRL+Click or Enter key allowing to input text directly into the widget + // Disable CTRL+Click or Enter key allowing to input text directly into the widget. SliderFlagsNoInput SliderFlags = 1 << 7 // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast // to this enum, and will trigger an assert if needed. diff --git a/FontAtlasProsessor.go b/FontAtlasProsessor.go index 85c0d406..74443c74 100644 --- a/FontAtlasProsessor.go +++ b/FontAtlasProsessor.go @@ -78,7 +78,7 @@ func init() { } } -// SetDefaultFont changes default font +// SetDefaultFont changes default font. func SetDefaultFont(fontName string, size float32) { fontPath, err := findfont.Find(fontName) if err != nil { @@ -120,7 +120,7 @@ func AddFont(fontName string, size float32) *FontInfo { return &fi } -// AddFontFromBytes does similar to AddFont, but using data from memory +// AddFontFromBytes does similar to AddFont, but using data from memory. func AddFontFromBytes(fontName string, fontBytes []byte, size float32) *FontInfo { fi := FontInfo{ fontName: fontName, diff --git a/InputHandler.go b/InputHandler.go index 303b5586..04103f82 100644 --- a/InputHandler.go +++ b/InputHandler.go @@ -1,25 +1,25 @@ package giu -// input menager is used to register a keyboard shortcuts in an app +// input menager is used to register a keyboard shortcuts in an app. import ( "github.com/go-gl/glfw/v3.3/glfw" ) -// store keyboard shortcuts +// store keyboard shortcuts. var shortcuts map[keyCombo]*callbacks func init() { shortcuts = make(map[keyCombo]*callbacks) } -// ShortcutType represens a type of shortcut (global or local) +// ShortcutType represens a type of shortcut (global or local). type ShortcutType bool const ( - // GlobalShortcut is registered for all the app + // GlobalShortcut is registered for all the app. GlobalShortcut ShortcutType = true - // LocLShortcut is registered for current window only + // LocLShortcut is registered for current window only. LocalShortcut ShortcutType = false ) @@ -84,7 +84,7 @@ func handler(key glfw.Key, mod glfw.ModifierKey, action glfw.Action) { } // WindowShortcut represents a window-level shortcut -// could be used as an argument to (*Window).RegisterKeyboardShortcuts +// could be used as an argument to (*Window).RegisterKeyboardShortcuts. type WindowShortcut struct { Key Key Modifier Modifier diff --git a/Keycode.go b/Keycode.go index b898a0b4..e54a125c 100644 --- a/Keycode.go +++ b/Keycode.go @@ -2,7 +2,7 @@ package giu import "github.com/go-gl/glfw/v3.3/glfw" -// Key represents a glfw key +// Key represents a glfw key. type Key glfw.Key // These key codes are inspired by the USB HID Usage Tables v1.12 (p. 53-60), @@ -133,10 +133,10 @@ const ( KeyLast Key = Key(glfw.KeyLast) ) -// Modifier represents glfw.Modifier +// Modifier represents glfw.Modifier. type Modifier glfw.ModifierKey -// modifier keys +// modifier keys. const ( ModNone Modifier = iota ModControl Modifier = Modifier(glfw.ModControl) diff --git a/Layout.go b/Layout.go index e43cabb0..c8b3706b 100644 --- a/Layout.go +++ b/Layout.go @@ -1,7 +1,7 @@ package giu const ( - // Auto is used to widget.Size to indicate height or width to occupy available spaces + // Auto is used to widget.Size to indicate height or width to occupy available spaces. Auto float32 = -1 ) @@ -21,7 +21,7 @@ var ( // Layout can be used as a widget. type Layout []Widget -// Build implements Widget interface +// Build implements Widget interface. func (l Layout) Build() { for _, w := range l { if w != nil { diff --git a/MasterWindow.go b/MasterWindow.go index de99e034..a4dfc1d7 100644 --- a/MasterWindow.go +++ b/MasterWindow.go @@ -9,7 +9,7 @@ import ( "github.com/faiface/mainthread" ) -// MasterWindowFlags wrapps imgui.GLFWWindowFlags +// MasterWindowFlags wrapps imgui.GLFWWindowFlags. type MasterWindowFlags imgui.GLFWWindowFlags const ( @@ -25,11 +25,11 @@ const ( MasterWindowFlagsTransparent MasterWindowFlags = MasterWindowFlags(imgui.GLFWWindowFlagsTransparent) ) -// DontCare could be used as an argument to (*MasterWindow).SetSizeLimits +// DontCare could be used as an argument to (*MasterWindow).SetSizeLimits. var DontCare int = imgui.GlfwDontCare // MasterWindow represents a glfw master window -// It is a base for a windows (see Window.go) +// It is a base for a windows (see Window.go). type MasterWindow struct { width int height int @@ -44,7 +44,7 @@ type MasterWindow struct { // NewMasterWindow creates a new master window and initializes GLFW. // it should be called in main function. For more details and use cases, -// see examples/helloworld/ +// see examples/helloworld/. func NewMasterWindow(title string, width, height int, flags MasterWindowFlags) *MasterWindow { context := imgui.CreateContext(nil) imgui.ImPlotCreateContext() @@ -246,7 +246,7 @@ func (w *MasterWindow) SetPos(x, y int) { } } -// SetSize sets size of master window +// SetSize sets size of master window. func (w *MasterWindow) SetSize(x, y int) { if w.platform != nil { if glfwPlatform, ok := w.platform.(*imgui.GLFW); ok { @@ -299,7 +299,7 @@ func (w *MasterWindow) Run(loopFunc func()) { }) } -// RegisterKeyboardShortcuts registers a global - master window - keyboard shortcuts +// RegisterKeyboardShortcuts registers a global - master window - keyboard shortcuts. func (w *MasterWindow) RegisterKeyboardShortcuts(s ...WindowShortcut) *MasterWindow { for _, shortcut := range s { RegisterKeyboardShortcuts(Shortcut{ @@ -339,17 +339,17 @@ func (w *MasterWindow) SetSizeLimits(minw, minh, maxw, maxh int) { w.platform.SetSizeLimits(minw, minh, maxw, maxh) } -// SetTitle updates master window's title +// SetTitle updates master window's title. func (w *MasterWindow) SetTitle(title string) { w.platform.SetTitle(title) } -// Close will savely close the master window +// Close will savely close the master window. func (w *MasterWindow) Close() { w.SetShouldClose(true) } -// SetShouldClose sets whether master window should be closed +// SetShouldClose sets whether master window should be closed. func (w *MasterWindow) SetShouldClose(v bool) { w.platform.SetShouldStop(v) } diff --git a/Msgbox.go b/Msgbox.go index 50a9dd18..fe923441 100644 --- a/Msgbox.go +++ b/Msgbox.go @@ -3,10 +3,10 @@ package giu import "fmt" // DialogResult represents dialog result -// dialog resullt is bool. if OK/Yes it is true, else (Cancel/No) - false +// dialog resullt is bool. if OK/Yes it is true, else (Cancel/No) - false. type DialogResult bool -// dialog results +// dialog results. const ( DialogResultOK DialogResult = true DialogResultCancel DialogResult = false @@ -18,17 +18,17 @@ const ( // MsgboxButtons determines which buttons are in the dialog. type MsgboxButtons uint8 -// button sets +// button sets. const ( - // Yes-No question + // Yes-No question. MsgboxButtonsYesNo MsgboxButtons = 1 << iota - // Ok / Cancel dialog + // Ok / Cancel dialog. MsgboxButtonsOkCancel - // info + // info. MsgboxButtonsOk ) -// DialogResultCallback is a callback for dialogs +// DialogResultCallback is a callback for dialogs. type DialogResultCallback func(DialogResult) var _ Disposable = &msgboxState{} @@ -41,7 +41,7 @@ type msgboxState struct { open bool } -// Dispose implements disposable interface +// Dispose implements disposable interface. func (ms *msgboxState) Dispose() { // Nothing to do here. } @@ -131,7 +131,7 @@ func PrepareMsgbox() Layout { } } -// MsgboxWidget represents message dialog +// MsgboxWidget represents message dialog. type MsgboxWidget struct{} func (m *MsgboxWidget) getState() *msgboxState { @@ -145,7 +145,7 @@ func (m *MsgboxWidget) getState() *msgboxState { // Msgbox opens message box. // call it whenever you want to open popup with -// question / info +// question / info. func Msgbox(title, content string) *MsgboxWidget { result := &MsgboxWidget{} @@ -161,14 +161,14 @@ func Msgbox(title, content string) *MsgboxWidget { return result } -// Buttons sets which buttons should be possible +// Buttons sets which buttons should be possible. func (m *MsgboxWidget) Buttons(buttons MsgboxButtons) *MsgboxWidget { s := m.getState() s.buttons = buttons return m } -// ResultCallback sets result callback +// ResultCallback sets result callback. func (m *MsgboxWidget) ResultCallback(cb DialogResultCallback) *MsgboxWidget { s := m.getState() s.resultCallback = cb diff --git a/Plot.go b/Plot.go index 56125f47..67922266 100644 --- a/Plot.go +++ b/Plot.go @@ -7,22 +7,22 @@ import ( ) // PlotWidget is implemented by all the particular plots, which can be used -// in (*PlotCanvasWidget).Plots +// in (*PlotCanvasWidget).Plots. type PlotWidget interface { Plot() } -// ImPlotYAxis represents y axis settings +// ImPlotYAxis represents y axis settings. type ImPlotYAxis int -// ImPlotYAxis enum: +// ImPlotYAxis enum:. const ( ImPlotYAxisLeft ImPlotYAxis = 0 // left (default) ImPlotYAxisFirstOnRight ImPlotYAxis = 1 // first on right side ImPlotYAxisSecondOnRight ImPlotYAxis = 2 // second on right side ) -// PlotTicker represents axis ticks +// PlotTicker represents axis ticks. type PlotTicker struct { Position float64 Label string @@ -75,7 +75,7 @@ func Plot(title string) *PlotCanvasWidget { } } -// AxisLimits sets X and Y axis limits +// AxisLimits sets X and Y axis limits. func (p *PlotCanvasWidget) AxisLimits(xmin, xmax, ymin, ymax float64, cond ExecCondition) *PlotCanvasWidget { p.xMin = xmin p.xMax = xmax @@ -86,7 +86,7 @@ func (p *PlotCanvasWidget) AxisLimits(xmin, xmax, ymin, ymax float64, cond ExecC return p } -// XTicks sets x axis ticks +// XTicks sets x axis ticks. func (p *PlotCanvasWidget) XTicks(ticks []PlotTicker, showDefault bool) *PlotCanvasWidget { length := len(ticks) if length == 0 { @@ -107,7 +107,7 @@ func (p *PlotCanvasWidget) XTicks(ticks []PlotTicker, showDefault bool) *PlotCan return p } -// YTicks sets y axis ticks +// YTicks sets y axis ticks. func (p *PlotCanvasWidget) YTicks(ticks []PlotTicker, showDefault bool, yAxis ImPlotYAxis) *PlotCanvasWidget { length := len(ticks) if length == 0 { @@ -129,19 +129,19 @@ func (p *PlotCanvasWidget) YTicks(ticks []PlotTicker, showDefault bool, yAxis Im return p } -// Flags sets plot canvas flags +// Flags sets plot canvas flags. func (p *PlotCanvasWidget) Flags(flags PlotFlags) *PlotCanvasWidget { p.flags = flags return p } -// XAxeFlags sets x axis fags +// XAxeFlags sets x axis fags. func (p *PlotCanvasWidget) XAxeFlags(flags PlotAxisFlags) *PlotCanvasWidget { p.xFlags = flags return p } -// YAxeFlags sets y axis flags +// YAxeFlags sets y axis flags. func (p *PlotCanvasWidget) YAxeFlags(yFlags, y2Flags, y3Flags PlotAxisFlags) *PlotCanvasWidget { p.yFlags = yFlags p.y2Flags = y2Flags @@ -149,20 +149,20 @@ func (p *PlotCanvasWidget) YAxeFlags(yFlags, y2Flags, y3Flags PlotAxisFlags) *Pl return p } -// Plots adds plots to plot canvas +// Plots adds plots to plot canvas. func (p *PlotCanvasWidget) Plots(plots ...PlotWidget) *PlotCanvasWidget { p.plots = plots return p } -// Size set canvas size +// Size set canvas size. func (p *PlotCanvasWidget) Size(width, height int) *PlotCanvasWidget { p.width = width p.height = height return p } -// Build implements Widget interface +// Build implements Widget interface. func (p *PlotCanvasWidget) Build() { if len(p.plots) > 0 { imgui.ImPlotSetNextPlotLimits(p.xMin, p.xMax, p.yMin, p.yMax, imgui.Condition(p.axisLimitCondition)) @@ -190,7 +190,7 @@ func (p *PlotCanvasWidget) Build() { } } -// PlotBarWidget adds bar plot (column chart) to the canvas +// PlotBarWidget adds bar plot (column chart) to the canvas. type PlotBarWidget struct { title string data []float64 @@ -199,7 +199,7 @@ type PlotBarWidget struct { offset int } -// PlotBar adds a plot bar (column chart) +// PlotBar adds a plot bar (column chart). func PlotBar(title string, data []float64) *PlotBarWidget { return &PlotBarWidget{ title: title, @@ -210,30 +210,30 @@ func PlotBar(title string, data []float64) *PlotBarWidget { } } -// Width sets bar width +// Width sets bar width. func (p *PlotBarWidget) Width(width float64) *PlotBarWidget { p.width = width return p } -// Shift sets shift of the bar +// Shift sets shift of the bar. func (p *PlotBarWidget) Shift(shift float64) *PlotBarWidget { p.shift = shift return p } -// Offset sets bar's offset +// Offset sets bar's offset. func (p *PlotBarWidget) Offset(offset int) *PlotBarWidget { p.offset = offset return p } -// Plot implements Plot interface +// Plot implements Plot interface. func (p *PlotBarWidget) Plot() { imgui.ImPlotBars(p.title, p.data, p.width, p.shift, p.offset) } -// PlotBarHWidget represents a column chart on Y axis +// PlotBarHWidget represents a column chart on Y axis. type PlotBarHWidget struct { title string data []float64 @@ -242,7 +242,7 @@ type PlotBarHWidget struct { offset int } -// PlotBarH adds plot bars on y axis +// PlotBarH adds plot bars on y axis. func PlotBarH(title string, data []float64) *PlotBarHWidget { return &PlotBarHWidget{ title: title, @@ -253,30 +253,30 @@ func PlotBarH(title string, data []float64) *PlotBarHWidget { } } -// Height sets bar height (in fact bars' width) +// Height sets bar height (in fact bars' width). func (p *PlotBarHWidget) Height(height float64) *PlotBarHWidget { p.height = height return p } -// Shift sets shift +// Shift sets shift. func (p *PlotBarHWidget) Shift(shift float64) *PlotBarHWidget { p.shift = shift return p } -// Offset sets offset +// Offset sets offset. func (p *PlotBarHWidget) Offset(offset int) *PlotBarHWidget { p.offset = offset return p } -// Plot implements plot interface +// Plot implements plot interface. func (p *PlotBarHWidget) Plot() { imgui.ImPlotBarsH(tStr(p.title), p.data, p.height, p.shift, p.offset) } -// PlotLineWidget represents a plot line (linear chart) +// PlotLineWidget represents a plot line (linear chart). type PlotLineWidget struct { title string values []float64 @@ -285,7 +285,7 @@ type PlotLineWidget struct { yAxis ImPlotYAxis } -// PlotLine adds a new plot line to the canvas +// PlotLine adds a new plot line to the canvas. func PlotLine(title string, values []float64) *PlotLineWidget { return &PlotLineWidget{ title: title, @@ -296,37 +296,37 @@ func PlotLine(title string, values []float64) *PlotLineWidget { } } -// SetPlotYAxis sets yAxis parameters +// SetPlotYAxis sets yAxis parameters. func (p *PlotLineWidget) SetPlotYAxis(yAxis ImPlotYAxis) *PlotLineWidget { p.yAxis = yAxis return p } -// XScale sets x-axis-scale +// XScale sets x-axis-scale. func (p *PlotLineWidget) XScale(scale float64) *PlotLineWidget { p.xScale = scale return p } -// X0 sets a start position on x axis +// X0 sets a start position on x axis. func (p *PlotLineWidget) X0(x0 float64) *PlotLineWidget { p.x0 = x0 return p } -// Offset sets chart offset +// Offset sets chart offset. func (p *PlotLineWidget) Offset(offset int) *PlotLineWidget { p.offset = offset return p } -// Plot implements Plot interface +// Plot implements Plot interface. func (p *PlotLineWidget) Plot() { imgui.ImPlotSetPlotYAxis(imgui.ImPlotYAxis(p.yAxis)) imgui.ImPlotLine(tStr(p.title), p.values, p.xScale, p.x0, p.offset) } -// PlotLineXYWidget adds XY plot line +// PlotLineXYWidget adds XY plot line. type PlotLineXYWidget struct { title string xs, ys []float64 @@ -334,7 +334,7 @@ type PlotLineXYWidget struct { yAxis ImPlotYAxis } -// PlotLineXY adds XY plot line to canvas +// PlotLineXY adds XY plot line to canvas. func PlotLineXY(title string, xvalues, yvalues []float64) *PlotLineXYWidget { return &PlotLineXYWidget{ title: title, @@ -344,25 +344,25 @@ func PlotLineXY(title string, xvalues, yvalues []float64) *PlotLineXYWidget { } } -// SetPlotYAxis sets yAxis parameters +// SetPlotYAxis sets yAxis parameters. func (p *PlotLineXYWidget) SetPlotYAxis(yAxis ImPlotYAxis) *PlotLineXYWidget { p.yAxis = yAxis return p } -// Offset sets chart's offset +// Offset sets chart's offset. func (p *PlotLineXYWidget) Offset(offset int) *PlotLineXYWidget { p.offset = offset return p } -// Plot implements Plot interface +// Plot implements Plot interface. func (p *PlotLineXYWidget) Plot() { imgui.ImPlotSetPlotYAxis(imgui.ImPlotYAxis(p.yAxis)) imgui.ImPlotLineXY(tStr(p.title), p.xs, p.ys, p.offset) } -// PlotPieChartWidget represents a pie chart +// PlotPieChartWidget represents a pie chart. type PlotPieChartWidget struct { labels []string values []float64 @@ -372,7 +372,7 @@ type PlotPieChartWidget struct { angle0 float64 } -// PlotPieChart adds pie chart to the canvas +// PlotPieChart adds pie chart to the canvas. func PlotPieChart(labels []string, values []float64, x, y, radius float64) *PlotPieChartWidget { return &PlotPieChartWidget{ labels: labels, @@ -391,7 +391,7 @@ func (p *PlotPieChartWidget) Normalize(n bool) *PlotPieChartWidget { return p } -// LabelFormat sets format of labels +// LabelFormat sets format of labels. func (p *PlotPieChartWidget) LabelFormat(fmtStr string) *PlotPieChartWidget { p.labelFormat = fmtStr return p diff --git a/ProgressIndicator.go b/ProgressIndicator.go index 20c3f23e..009005b2 100644 --- a/ProgressIndicator.go +++ b/ProgressIndicator.go @@ -30,16 +30,16 @@ func (ps *progressIndicatorState) update() { ticker.Stop() } -// Dispose implements Disposable interface +// Dispose implements Disposable interface. func (ps *progressIndicatorState) Dispose() { ps.stop = true } -// static check to ensure if ProgressIndicatorWidget implements Widget interface +// static check to ensure if ProgressIndicatorWidget implements Widget interface. var _ Widget = &ProgressIndicatorWidget{} // ProgressIndicatorWidget represents progress indicator widget -// see examples/extrawidgets/ +// see examples/extrawidgets/. type ProgressIndicatorWidget struct { internalID string width float32 @@ -48,7 +48,7 @@ type ProgressIndicatorWidget struct { label string } -// ProgressIndicator creates a new ProgressIndicatorWidget +// ProgressIndicator creates a new ProgressIndicatorWidget. func ProgressIndicator(label string, width, height, radius float32) *ProgressIndicatorWidget { return &ProgressIndicatorWidget{ internalID: "###giu-progress-indicator", @@ -59,7 +59,7 @@ func ProgressIndicator(label string, width, height, radius float32) *ProgressInd } } -// Build implements Widget interface +// Build implements Widget interface. func (p *ProgressIndicatorWidget) Build() { // State exists if s := Context.GetState(p.internalID); s == nil { diff --git a/SplitLayout.go b/SplitLayout.go index 4f79385e..de6069c0 100644 --- a/SplitLayout.go +++ b/SplitLayout.go @@ -20,7 +20,7 @@ type SplitLayoutState struct { sashPos float32 } -// Dispose implements Disposable interface +// Dispose implements Disposable interface. func (s *SplitLayoutState) Dispose() { // Nothing to do here. } diff --git a/Style.go b/Style.go index a878cec4..2432f595 100644 --- a/Style.go +++ b/Style.go @@ -8,7 +8,7 @@ import ( // PushFont sets font to "font" // NOTE: PopFont has to be called -// NOTE: Don't use PushFont. use StyleSetter instead +// NOTE: Don't use PushFont. use StyleSetter instead. func PushFont(font *FontInfo) bool { if font == nil { return false @@ -22,7 +22,7 @@ func PushFont(font *FontInfo) bool { return false } -// PopFont pops the font (should be called after PushFont) +// PopFont pops the font (should be called after PushFont). func PopFont() { imgui.PopFont() } @@ -102,13 +102,13 @@ func PushSelectableTextAlign(width, height float32) { // PopStyle should be called to stop applying style. // It should be called as much times, as you Called PushStyle... -// NOTE: If you don't call PopStyle imgui will panic +// NOTE: If you don't call PopStyle imgui will panic. func PopStyle() { imgui.PopStyleVar() } // PopStyleV does similarly to PopStyle, but allows to specify number -// of styles you're going to pop +// of styles you're going to pop. func PopStyleV(count int) { imgui.PopStyleVarV(count) } @@ -116,13 +116,13 @@ func PopStyleV(count int) { // PopStyleColor is used to stop applying colors styles. // It should be called after each PushStyleColor... (for each push) // If PopStyleColor wasn't called after PushColor... or was called -// inproperly, imgui will panic +// inproperly, imgui will panic. func PopStyleColor() { imgui.PopStyleColor() } // PopStyleColorV does similar to PopStyleColor, but allows to specify -// how much style colors would you like to pop +// how much style colors would you like to pop. func PopStyleColorV(count int) { imgui.PopStyleColorV(count) } @@ -136,13 +136,13 @@ func AlignTextToFramePadding() { // PushItemWidth sets following item's widths // NOTE: don't forget to call PopItemWidth! If you don't do so, imgui -// will panic +// will panic. func PushItemWidth(width float32) { imgui.PushItemWidth(width) } // PopItemWidth should be called to stop applying PushItemWidth effect -// If it isn't called imgui will panic +// If it isn't called imgui will panic. func PopItemWidth() { imgui.PopItemWidth() } @@ -155,55 +155,55 @@ func PopTextWrapPos() { imgui.PopTextWrapPos() } -// MouseCursorType represents a type (layout) of mouse cursor +// MouseCursorType represents a type (layout) of mouse cursor. type MouseCursorType int const ( - // MouseCursorNone no mouse cursor + // MouseCursorNone no mouse cursor. MouseCursorNone MouseCursorType = -1 - // MouseCursorArrow standard arrow mouse cursor + // MouseCursorArrow standard arrow mouse cursor. MouseCursorArrow MouseCursorType = 0 // MouseCursorTextInput when hovering over InputText, etc. MouseCursorTextInput MouseCursorType = 1 - // MouseCursorResizeAll (Unused by imgui functions) + // MouseCursorResizeAll (Unused by imgui functions). MouseCursorResizeAll MouseCursorType = 2 - // MouseCursorResizeNS when hovering over an horizontal border + // MouseCursorResizeNS when hovering over an horizontal border. MouseCursorResizeNS MouseCursorType = 3 - // MouseCursorResizeEW when hovering over a vertical border or a column + // MouseCursorResizeEW when hovering over a vertical border or a column. MouseCursorResizeEW MouseCursorType = 4 - // MouseCursorResizeNESW when hovering over the bottom-left corner of a window + // MouseCursorResizeNESW when hovering over the bottom-left corner of a window. MouseCursorResizeNESW MouseCursorType = 5 - // MouseCursorResizeNWSE when hovering over the bottom-right corner of a window + // MouseCursorResizeNWSE when hovering over the bottom-right corner of a window. MouseCursorResizeNWSE MouseCursorType = 6 - // MouseCursorHand (Unused by imgui functions. Use for e.g. hyperlinks) + // MouseCursorHand (Unused by imgui functions. Use for e.g. hyperlinks). MouseCursorHand MouseCursorType = 7 MouseCursorCount MouseCursorType = 8 ) -// SetMouseCursor sets mouse cursor layout +// SetMouseCursor sets mouse cursor layout. func SetMouseCursor(cursor MouseCursorType) { imgui.SetMouseCursor(int(cursor)) } -// GetWindowPadding returns window padding +// GetWindowPadding returns window padding. func GetWindowPadding() (x, y float32) { vec2 := imgui.CurrentStyle().WindowPadding() return vec2.X, vec2.Y } -// GetItemSpacing returns current item spacing +// GetItemSpacing returns current item spacing. func GetItemSpacing() (w, h float32) { vec2 := imgui.CurrentStyle().ItemSpacing() return vec2.X, vec2.Y } -// GetItemInnerSpacing returns current item inner spacing +// GetItemInnerSpacing returns current item inner spacing. func GetItemInnerSpacing() (w, h float32) { vec2 := imgui.CurrentStyle().ItemInnerSpacing() return vec2.X, vec2.Y } -// GetFramePadding returns current frame padding +// GetFramePadding returns current frame padding. func GetFramePadding() (x, y float32) { vec2 := imgui.CurrentStyle().FramePadding() return vec2.X, vec2.Y @@ -212,7 +212,7 @@ func GetFramePadding() (x, y float32) { // StyleColorID identifies a color in the UI style. type StyleColorID int -// StyleColor identifier +// StyleColor identifier. const ( StyleColorText StyleColorID = 0 StyleColorTextDisabled StyleColorID = 1 @@ -273,61 +273,61 @@ const ( // StyleVarID identifies a style variable in the UI style. type StyleVarID int -// Style IDs +// Style IDs. const ( - // StyleVarAlpha is a float + // StyleVarAlpha is a float. StyleVarAlpha StyleVarID = iota - // float DisabledAlpha + // float DisabledAlpha. StyleVarDisabledAlpha - // StyleVarWindowPadding is a Vec2 + // StyleVarWindowPadding is a Vec2. StyleVarWindowPadding - // StyleVarWindowRounding is a float + // StyleVarWindowRounding is a float. StyleVarWindowRounding - // StyleVarWindowBorderSize is a float + // StyleVarWindowBorderSize is a float. StyleVarWindowBorderSize - // StyleVarWindowMinSize is a Vec2 + // StyleVarWindowMinSize is a Vec2. StyleVarWindowMinSize - // StyleVarWindowTitleAlign is a Vec2 + // StyleVarWindowTitleAlign is a Vec2. StyleVarWindowTitleAlign - // StyleVarChildRounding is a float + // StyleVarChildRounding is a float. StyleVarChildRounding - // StyleVarChildBorderSize is a float + // StyleVarChildBorderSize is a float. StyleVarChildBorderSize - // StyleVarPopupRounding is a float + // StyleVarPopupRounding is a float. StyleVarPopupRounding - // StyleVarPopupBorderSize is a float + // StyleVarPopupBorderSize is a float. StyleVarPopupBorderSize - // StyleVarFramePadding is a Vec2 + // StyleVarFramePadding is a Vec2. StyleVarFramePadding - // StyleVarFrameRounding is a float + // StyleVarFrameRounding is a float. StyleVarFrameRounding - // StyleVarFrameBorderSize is a float + // StyleVarFrameBorderSize is a float. StyleVarFrameBorderSize - // StyleVarItemSpacing is a Vec2 + // StyleVarItemSpacing is a Vec2. StyleVarItemSpacing - // StyleVarItemInnerSpacing is a Vec2 + // StyleVarItemInnerSpacing is a Vec2. StyleVarItemInnerSpacing - // StyleVarIndentSpacing is a float + // StyleVarIndentSpacing is a float. StyleVarIndentSpacing - // StyleVarScrollbarSize is a float + // StyleVarScrollbarSize is a float. StyleVarScrollbarSize - // StyleVarScrollbarRounding is a float + // StyleVarScrollbarRounding is a float. StyleVarScrollbarRounding - // StyleVarGrabMinSize is a float + // StyleVarGrabMinSize is a float. StyleVarGrabMinSize - // StyleVarGrabRounding is a float + // StyleVarGrabRounding is a float. StyleVarGrabRounding - // StyleVarTabRounding is a float + // StyleVarTabRounding is a float. StyleVarTabRounding - // StyleVarButtonTextAlign is a Vec2 + // StyleVarButtonTextAlign is a Vec2. StyleVarButtonTextAlign - // StyleVarSelectableTextAlign is a Vec2 + // StyleVarSelectableTextAlign is a Vec2. StyleVarSelectableTextAlign ) var _ Widget = &StyleSetter{} -// StyleSetter is a user-friendly way to manage imgui styles +// StyleSetter is a user-friendly way to manage imgui styles. type StyleSetter struct { colors map[StyleColorID]color.RGBA styles map[StyleVarID]imgui.Vec2 @@ -336,7 +336,7 @@ type StyleSetter struct { layout Layout } -// Style initializes a style setter (see examples/setstyle) +// Style initializes a style setter (see examples/setstyle). func Style() *StyleSetter { var ss StyleSetter ss.colors = make(map[StyleColorID]color.RGBA) @@ -345,19 +345,19 @@ func Style() *StyleSetter { return &ss } -// SetColor sets colorID's color +// SetColor sets colorID's color. func (ss *StyleSetter) SetColor(colorID StyleColorID, col color.RGBA) *StyleSetter { ss.colors[colorID] = col return ss } -// SetStyle sets styleVarID to width and height +// SetStyle sets styleVarID to width and height. func (ss *StyleSetter) SetStyle(varID StyleVarID, width, height float32) *StyleSetter { ss.styles[varID] = imgui.Vec2{X: width, Y: height} return ss } -// SetFont sets font +// SetFont sets font. func (ss *StyleSetter) SetFont(font *FontInfo) *StyleSetter { ss.font = font return ss @@ -380,19 +380,19 @@ func (ss *StyleSetter) SetFontSize(size float32) *StyleSetter { return ss } -// SetDisabled sets if items are disabled +// SetDisabled sets if items are disabled. func (ss *StyleSetter) SetDisabled(d bool) *StyleSetter { ss.disabled = d return ss } -// To allows to specify a layout, StyleSetter should apply style for +// To allows to specify a layout, StyleSetter should apply style for. func (ss *StyleSetter) To(widgets ...Widget) *StyleSetter { ss.layout = widgets return ss } -// Build implements Widget +// Build implements Widget. func (ss *StyleSetter) Build() { if ss.layout == nil || len(ss.layout) == 0 { return diff --git a/Utils.go b/Utils.go index 78c56781..f041d606 100644 --- a/Utils.go +++ b/Utils.go @@ -13,7 +13,7 @@ import ( "github.com/AllenDang/imgui-go" ) -// LoadImage loads image from file and returns *image.RGBA +// LoadImage loads image from file and returns *image.RGBA. func LoadImage(imgPath string) (*image.RGBA, error) { imgFile, err := os.Open(filepath.Clean(imgPath)) if err != nil { @@ -35,7 +35,7 @@ func LoadImage(imgPath string) (*image.RGBA, error) { return ImageToRgba(img), nil } -// ImageToRgba converts image.Image to *image.RGBA +// ImageToRgba converts image.Image to *image.RGBA. func ImageToRgba(img image.Image) *image.RGBA { switch trueImg := img.(type) { case *image.RGBA: @@ -47,7 +47,7 @@ func ImageToRgba(img image.Image) *image.RGBA { } } -// ToVec4Color converts rgba color to imgui.Vec4 +// ToVec4Color converts rgba color to imgui.Vec4. func ToVec4Color(col color.RGBA) imgui.Vec4 { return imgui.Vec4{ X: float32(col.R) / 255, @@ -57,7 +57,7 @@ func ToVec4Color(col color.RGBA) imgui.Vec4 { } } -// ToVec2 converts image.Point to imgui.Vec2 +// ToVec2 converts image.Point to imgui.Vec2. func ToVec2(pt image.Point) imgui.Vec2 { return imgui.Vec2{ X: float32(pt.X), @@ -65,7 +65,7 @@ func ToVec2(pt image.Point) imgui.Vec2 { } } -// Vec4ToRGBA converts imgui's Vec4 to golang rgba color +// Vec4ToRGBA converts imgui's Vec4 to golang rgba color. func Vec4ToRGBA(vec4 imgui.Vec4) color.RGBA { return color.RGBA{ R: uint8(vec4.X * 255), @@ -87,29 +87,29 @@ func Update() { } } -// GetCursorScreenPos returns imgui drawing cursor on the screen +// GetCursorScreenPos returns imgui drawing cursor on the screen. func GetCursorScreenPos() image.Point { pos := imgui.CursorScreenPos() return image.Pt(int(pos.X), int(pos.Y)) } -// SetCursorScreenPos sets imgui drawing cursor on the screen +// SetCursorScreenPos sets imgui drawing cursor on the screen. func SetCursorScreenPos(pos image.Point) { imgui.SetCursorScreenPos(imgui.Vec2{X: float32(pos.X), Y: float32(pos.Y)}) } -// GetCursorPos gets imgui drawing cursor inside of current window +// GetCursorPos gets imgui drawing cursor inside of current window. func GetCursorPos() image.Point { pos := imgui.CursorPos() return image.Pt(int(pos.X), int(pos.Y)) } -// SetCursorPos sets imgui drawing cursor inside of current window +// SetCursorPos sets imgui drawing cursor inside of current window. func SetCursorPos(pos image.Point) { imgui.SetCursorPos(imgui.Vec2{X: float32(pos.X), Y: float32(pos.Y)}) } -// GetMousePos returns mouse position +// GetMousePos returns mouse position. func GetMousePos() image.Point { pos := imgui.MousePos() return image.Pt(int(pos.X), int(pos.Y)) @@ -120,26 +120,26 @@ func GetAvailableRegion() (width, height float32) { return region.X, region.Y } -// CalcTextSize calls CalcTextSizeV(text, false, -1) +// CalcTextSize calls CalcTextSizeV(text, false, -1). func CalcTextSize(text string) (width, height float32) { return CalcTextSizeV(text, false, -1) } -// CalcTextSizeV calculates text dimensions +// CalcTextSizeV calculates text dimensions. func CalcTextSizeV(text string, hideAfterDoubleHash bool, wrapWidth float32) (w, h float32) { size := imgui.CalcTextSize(text, hideAfterDoubleHash, wrapWidth) return size.X, size.Y } -// SetNextWindowSize sets size of the next window +// SetNextWindowSize sets size of the next window. func SetNextWindowSize(width, height float32) { imgui.SetNextWindowSize(imgui.Vec2{X: width, Y: height}) } -// ExecCondition represents imgui.Condition +// ExecCondition represents imgui.Condition. type ExecCondition imgui.Condition -// imgui conditions +// imgui conditions. const ( ConditionAlways ExecCondition = ExecCondition(imgui.ConditionAlways) ConditionOnce ExecCondition = ExecCondition(imgui.ConditionOnce) @@ -147,12 +147,12 @@ const ( ConditionAppearing ExecCondition = ExecCondition(imgui.ConditionAppearing) ) -// SetNextWindowPos sets position of next window +// SetNextWindowPos sets position of next window. func SetNextWindowPos(x, y float32) { imgui.SetNextWindowPos(imgui.Vec2{X: x, Y: y}) } -// SetNextWindowSizeV does similar to SetNextWIndowSize but allows to specify imgui.Condition +// SetNextWindowSizeV does similar to SetNextWIndowSize but allows to specify imgui.Condition. func SetNextWindowSizeV(width, height float32, condition ExecCondition) { imgui.SetNextWindowSizeV( imgui.Vec2{ @@ -163,12 +163,12 @@ func SetNextWindowSizeV(width, height float32, condition ExecCondition) { ) } -// SetItemDefaultFocus set the item focused by default +// SetItemDefaultFocus set the item focused by default. func SetItemDefaultFocus() { imgui.SetItemDefaultFocus() } -// SetKeyboardFocusHere sets keyboard focus at the widget +// SetKeyboardFocusHere sets keyboard focus at the widget. func SetKeyboardFocusHere() { SetKeyboardFocusHereV(0) } diff --git a/Widgets.go b/Widgets.go index 150a5dad..f274bd9b 100644 --- a/Widgets.go +++ b/Widgets.go @@ -14,7 +14,7 @@ import ( "github.com/sahilm/fuzzy" ) -// GenAutoID automatically generates fidget's id +// GenAutoID automatically generates fidget's id. func GenAutoID(id string) string { return fmt.Sprintf("%s##%d", id, Context.GetWidgetIndex()) } @@ -22,19 +22,19 @@ func GenAutoID(id string) string { var _ Widget = &RowWidget{} // RowWidget joins a layout into one line -// calls imgui.SameLine() +// calls imgui.SameLine(). type RowWidget struct { widgets Layout } -// Row creates RowWidget +// Row creates RowWidget. func Row(widgets ...Widget) *RowWidget { return &RowWidget{ widgets: widgets, } } -// Build implements Widget interface +// Build implements Widget interface. func (l *RowWidget) Build() { isFirst := true l.widgets.Range(func(w Widget) { @@ -60,7 +60,7 @@ func (l *RowWidget) Build() { } // SameLine wrapps imgui.SomeLine -// Don't use if you don't have to (use RowWidget instead) +// Don't use if you don't have to (use RowWidget instead). func SameLine() { imgui.SameLine() } @@ -68,7 +68,7 @@ func SameLine() { var _ Widget = &InputTextMultilineWidget{} // InputTextMultilineWidget represents multiline text input widget -// see examples/widgets/ +// see examples/widgets/. type InputTextMultilineWidget struct { label string text *string @@ -78,7 +78,7 @@ type InputTextMultilineWidget struct { onChange func() } -// InputTextMultiline creates InputTextMultilineWidget +// InputTextMultiline creates InputTextMultilineWidget. func InputTextMultiline(text *string) *InputTextMultilineWidget { return &InputTextMultilineWidget{ text: text, @@ -91,18 +91,18 @@ func InputTextMultiline(text *string) *InputTextMultilineWidget { } } -// Label sets input field label +// Label sets input field label. func (i *InputTextMultilineWidget) Label(label string) *InputTextMultilineWidget { i.label = label return i } -// Labelf is formatting version of Label +// Labelf is formatting version of Label. func (i *InputTextMultilineWidget) Labelf(format string, args ...interface{}) *InputTextMultilineWidget { return i.Label(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (i *InputTextMultilineWidget) Build() { if imgui.InputTextMultilineV( tStr(i.label), @@ -147,7 +147,7 @@ type ButtonWidget struct { onClick func() } -// Build implements Widget interface +// Build implements Widget interface. func (b *ButtonWidget) Build() { if b.disabled { imgui.BeginDisabled(true) @@ -195,7 +195,7 @@ func Bullet() *BulletWidget { return &BulletWidget{} } -// Build implements Widget interface +// Build implements Widget interface. func (b *BulletWidget) Build() { imgui.Bullet() } @@ -216,7 +216,7 @@ func BulletTextf(format string, args ...interface{}) *BulletTextWidget { return BulletText(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (bt *BulletTextWidget) Build() { imgui.BulletText(bt.text) } @@ -247,7 +247,7 @@ func (b *ArrowButtonWidget) ID(id string) *ArrowButtonWidget { return b } -// Build implements Widget interface +// Build implements Widget interface. func (b *ArrowButtonWidget) Build() { if imgui.ArrowButton(b.id, uint8(b.dir)) && b.onClick != nil { b.onClick() @@ -277,7 +277,7 @@ func SmallButtonf(format string, args ...interface{}) *SmallButtonWidget { return SmallButton(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (b *SmallButtonWidget) Build() { if imgui.SmallButton(tStr(b.id)) && b.onClick != nil { b.onClick() @@ -317,7 +317,7 @@ func InvisibleButton() *InvisibleButtonWidget { } } -// Build implements Widget interface +// Build implements Widget interface. func (b *InvisibleButtonWidget) Build() { if imgui.InvisibleButton(tStr(b.id), imgui.Vec2{X: b.width, Y: b.height}) && b.onClick != nil { b.onClick() @@ -338,7 +338,7 @@ type ImageButtonWidget struct { onClick func() } -// Build implements Widget interface +// Build implements Widget interface. func (b *ImageButtonWidget) Build() { if b.texture == nil && b.texture.id == 0 { return @@ -445,7 +445,7 @@ func (b *ImageButtonWithRgbaWidget) FramePadding(padding int) *ImageButtonWithRg return b } -// Build implements Widget interface +// Build implements Widget interface. func (b *ImageButtonWithRgbaWidget) Build() { if state := Context.GetState(b.id); state == nil { Context.SetState(b.id, &ImageState{}) @@ -471,7 +471,7 @@ type CheckboxWidget struct { onChange func() } -// Build implements Widget interface +// Build implements Widget interface. func (c *CheckboxWidget) Build() { if imgui.Checkbox(tStr(c.text), c.selected) && c.onChange != nil { c.onChange() @@ -499,7 +499,7 @@ type RadioButtonWidget struct { onChange func() } -// Build implements Widget interface +// Build implements Widget interface. func (r *RadioButtonWidget) Build() { if imgui.RadioButton(tStr(r.text), r.active) && r.onChange != nil { r.onChange() @@ -530,7 +530,7 @@ type ChildWidget struct { layout Layout } -// Build implements Widget interface +// Build implements Widget interface. func (c *ChildWidget) Build() { if imgui.BeginChildV(c.id, imgui.Vec2{X: c.width, Y: c.height}, c.border, int(c.flags)) { c.layout.Build() @@ -605,7 +605,7 @@ func (cc *ComboCustomWidget) Size(width float32) *ComboCustomWidget { return cc } -// Build implements Widget interface +// Build implements Widget interface. func (cc *ComboCustomWidget) Build() { if cc.width > 0 { imgui.PushItemWidth(cc.width) @@ -647,7 +647,7 @@ func (c *ComboWidget) Flags(flags ComboFlags) *ComboWidget { return c } -// Build implements Widget interface +// Build implements Widget interface. func (c *ComboWidget) Build() { if c.width > 0 { imgui.PushItemWidth(c.width) @@ -709,7 +709,7 @@ func (c *ContextMenuWidget) ID(id string) *ContextMenuWidget { return c } -// Build implements Widget interface +// Build implements Widget interface. func (c *ContextMenuWidget) Build() { if imgui.BeginPopupContextItemV(c.id, int(c.mouseButton)) { c.layout.Build() @@ -749,7 +749,7 @@ func (d *DragIntWidget) Format(format string) *DragIntWidget { return d } -// Build implements Widget interface +// Build implements Widget interface. func (d *DragIntWidget) Build() { imgui.DragIntV(tStr(d.label), d.value, d.speed, d.min, d.max, d.format) } @@ -767,7 +767,7 @@ func Column(widgets ...Widget) *ColumnWidget { } } -// Build implements Widget interface +// Build implements Widget interface. func (g *ColumnWidget) Build() { imgui.BeginGroup() @@ -824,7 +824,7 @@ func (i *ImageWidget) Size(width, height float32) *ImageWidget { return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *ImageWidget) Build() { size := imgui.Vec2{X: i.width, Y: i.height} rect := imgui.ContentRegionAvail() @@ -895,7 +895,7 @@ func (i *ImageWithRgbaWidget) OnClick(cb func()) *ImageWithRgbaWidget { return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *ImageWithRgbaWidget) Build() { if i.rgba != nil { var imgState *ImageState @@ -944,7 +944,7 @@ func (i *ImageWithFileWidget) OnClick(cb func()) *ImageWithFileWidget { return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *ImageWithFileWidget) Build() { imgState := &ImageState{} if state := Context.GetState(i.id); state == nil { @@ -1027,7 +1027,7 @@ func (i *ImageWithURLWidget) LayoutForFailure(widgets ...Widget) *ImageWithURLWi return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *ImageWithURLWidget) Build() { imgState := &ImageState{} @@ -1141,7 +1141,7 @@ func (i *InputTextWidget) Labelf(format string, args ...interface{}) *InputTextW } // AutoComplete enables auto complete popup by using fuzzy search of current value against candidates -// Press enter to confirm the first candidate +// Press enter to confirm the first candidate. func (i *InputTextWidget) AutoComplete(candidates []string) *InputTextWidget { i.candidates = candidates return i @@ -1172,7 +1172,7 @@ func (i *InputTextWidget) OnChange(onChange func()) *InputTextWidget { return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *InputTextWidget) Build() { // Get state var state *inputTextState @@ -1273,7 +1273,7 @@ func (i *InputIntWidget) OnChange(onChange func()) *InputIntWidget { return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *InputIntWidget) Build() { if i.width != 0 { PushItemWidth(i.width) @@ -1336,7 +1336,7 @@ func (i *InputFloatWidget) OnChange(onChange func()) *InputFloatWidget { return i } -// Build implements Widget interface +// Build implements Widget interface. func (i *InputFloatWidget) Build() { if i.width != 0 { PushItemWidth(i.width) @@ -1377,7 +1377,7 @@ func (l *LabelWidget) Font(font *FontInfo) *LabelWidget { return l } -// Build implements Widget interface +// Build implements Widget interface. func (l *LabelWidget) Build() { if l.wrapped { PushTextWrapPos() @@ -1410,7 +1410,7 @@ func (m *MainMenuBarWidget) Layout(widgets ...Widget) *MainMenuBarWidget { return m } -// Build implements Widget interface +// Build implements Widget interface. func (m *MainMenuBarWidget) Build() { if imgui.BeginMainMenuBar() { m.layout.Build() @@ -1435,7 +1435,7 @@ func (m *MenuBarWidget) Layout(widgets ...Widget) *MenuBarWidget { return m } -// Build implements Widget interface +// Build implements Widget interface. func (m *MenuBarWidget) Build() { if imgui.BeginMenuBar() { m.layout.Build() @@ -1480,7 +1480,7 @@ func (m *MenuItemWidget) OnClick(onClick func()) *MenuItemWidget { return m } -// Build implements Widget interface +// Build implements Widget interface. func (m *MenuItemWidget) Build() { if imgui.MenuItemV(tStr(m.label), "", m.selected, m.enabled) && m.onClick != nil { m.onClick() @@ -1517,7 +1517,7 @@ func (m *MenuWidget) Layout(widgets ...Widget) *MenuWidget { return m } -// Build implements Widget interface +// Build implements Widget interface. func (m *MenuWidget) Build() { if imgui.BeginMenuV(tStr(m.label), m.enabled) { m.layout.Build() @@ -1551,7 +1551,7 @@ func (p *PopupWidget) Layout(widgets ...Widget) *PopupWidget { return p } -// Build implements Widget interface +// Build implements Widget interface. func (p *PopupWidget) Build() { if imgui.BeginPopup(p.name, int(p.flags)) { p.layout.Build() @@ -1592,7 +1592,7 @@ func (p *PopupModalWidget) Layout(widgets ...Widget) *PopupModalWidget { return p } -// Build implements Widget interface +// Build implements Widget interface. func (p *PopupModalWidget) Build() { if imgui.BeginPopupModalV(p.name, p.open, int(p.flags)) { p.layout.Build() @@ -1640,7 +1640,7 @@ func (p *ProgressBarWidget) Overlayf(format string, args ...interface{}) *Progre return p.Overlay(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (p *ProgressBarWidget) Build() { imgui.ProgressBarV(p.fraction, imgui.Vec2{X: p.width, Y: p.height}, p.overlay) } @@ -1693,13 +1693,13 @@ func (s *SelectableWidget) OnClick(onClick func()) *SelectableWidget { } // OnDClick handles mouse left button's double click event. -// SelectableFlagsAllowDoubleClick will set once tonDClick callback is notnull +// SelectableFlagsAllowDoubleClick will set once tonDClick callback is notnull. func (s *SelectableWidget) OnDClick(onDClick func()) *SelectableWidget { s.onDClick = onDClick return s } -// Build implements Widget interface +// Build implements Widget interface. func (s *SelectableWidget) Build() { // If onDClick is set, check flags and set related flag when necessary if s.onDClick != nil && s.flags&SelectableFlagsAllowDoubleClick != 0 { @@ -1719,7 +1719,7 @@ var _ Widget = &SeparatorWidget{} type SeparatorWidget struct{} -// Build implements Widget interface +// Build implements Widget interface. func (s *SeparatorWidget) Build() { imgui.Separator() } @@ -1777,7 +1777,7 @@ func (s *SliderIntWidget) Labelf(format string, args ...interface{}) *SliderIntW return s.Label(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (s *SliderIntWidget) Build() { if s.width != 0 { PushItemWidth(s.width) @@ -1845,7 +1845,7 @@ func (vs *VSliderIntWidget) Labelf(format string, args ...interface{}) *VSliderI return vs.Label(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (vs *VSliderIntWidget) Build() { if imgui.VSliderIntV( tStr(vs.label), @@ -1909,7 +1909,7 @@ func (sf *SliderFloatWidget) Labelf(format string, args ...interface{}) *SliderF return sf.Label(fmt.Sprintf(format, args...)) } -// Build implements Widget interface +// Build implements Widget interface. func (sf *SliderFloatWidget) Build() { if sf.width != 0 { PushItemWidth(sf.width) @@ -1928,7 +1928,7 @@ type DummyWidget struct { height float32 } -// Build implements Widget interface +// Build implements Widget interface. func (d *DummyWidget) Build() { w, h := GetAvailableRegion() @@ -2139,7 +2139,7 @@ func (t *TabItemWidget) Layout(widgets ...Widget) *TabItemWidget { return t } -// Build implements Widget interface +// Build implements Widget interface. func (t *TabItemWidget) Build() { if imgui.BeginTabItemV(t.label, t.open, int(t.flags)) { t.layout.Build() @@ -2177,7 +2177,7 @@ func (t *TabBarWidget) TabItems(items ...*TabItemWidget) *TabBarWidget { return t } -// Build implements Widget interface +// Build implements Widget interface. func (t *TabBarWidget) Build() { if imgui.BeginTabBarV(t.id, int(t.flags)) { for _, ti := range t.tabItems { @@ -2220,7 +2220,7 @@ func (r *TableRowWidget) MinHeight(height float64) *TableRowWidget { return r } -// Build implements Widget interface +// Build implements Widget interface. func (r *TableRowWidget) Build() { imgui.TableNextRow(imgui.TableRowFlags(r.flags), r.minRowHeight) @@ -2274,7 +2274,7 @@ func (c *TableColumnWidget) UserID(id uint32) *TableColumnWidget { return c } -// Build implements Widget interface +// Build implements Widget interface. func (c *TableColumnWidget) Build() { imgui.TableSetupColumn(c.label, imgui.TableColumnFlags(c.flags), c.innerWidthOrWeight, c.userID) } @@ -2343,7 +2343,7 @@ func (t *TableWidget) Flags(flags TableFlags) *TableWidget { return t } -// Build implements Widget interface +// Build implements Widget interface. func (t *TableWidget) Build() { if len(t.rows) == 0 { return @@ -2414,7 +2414,7 @@ func (ttr *TreeTableRowWidget) Flags(flags TreeNodeFlags) *TreeTableRowWidget { return ttr } -// Build implements Widget interface +// Build implements Widget interface. func (ttr *TreeTableRowWidget) Build() { imgui.TableNextRow(0, 0) imgui.TableNextColumn() @@ -2496,7 +2496,7 @@ func (tt *TreeTableWidget) Rows(rows ...*TreeTableRowWidget) *TreeTableWidget { return tt } -// Build implements Widget interface +// Build implements Widget interface. func (tt *TreeTableWidget) Build() { if len(tt.rows) == 0 { return @@ -2534,7 +2534,7 @@ type TooltipWidget struct { layout Layout } -// Build implements Widget interface +// Build implements Widget interface. func (t *TooltipWidget) Build() { if imgui.IsItemHovered() { if t.layout != nil { @@ -2591,7 +2591,7 @@ func (t *TreeNodeWidget) Flags(flags TreeNodeFlags) *TreeNodeWidget { } // Event create TreeNode with eventHandler -// You could detect events (e.g. IsItemClicked IsMouseDoubleClicked etc...) and handle them for TreeNode inside eventHandler +// You could detect events (e.g. IsItemClicked IsMouseDoubleClicked etc...) and handle them for TreeNode inside eventHandler. func (t *TreeNodeWidget) Event(handler func()) *TreeNodeWidget { t.eventHandler = handler return t @@ -2602,7 +2602,7 @@ func (t *TreeNodeWidget) Layout(widgets ...Widget) *TreeNodeWidget { return t } -// Build implements Widget interface +// Build implements Widget interface. func (t *TreeNodeWidget) Build() { open := imgui.TreeNodeV(t.label, int(t.flags)) @@ -2622,7 +2622,7 @@ var _ Widget = &SpacingWidget{} type SpacingWidget struct{} -// Build implements Widget interface +// Build implements Widget interface. func (s *SpacingWidget) Build() { imgui.Spacing() } @@ -2637,7 +2637,7 @@ type CustomWidget struct { builder func() } -// Build implements Widget interface +// Build implements Widget interface. func (c *CustomWidget) Build() { if c.builder != nil { c.builder() @@ -2666,7 +2666,7 @@ func Condition(cond bool, layoutIf, layoutElse Layout) *ConditionWidget { } } -// Build implements Widget interface +// Build implements Widget interface. func (c *ConditionWidget) Build() { if c.cond { if c.layoutIf != nil { @@ -2854,7 +2854,7 @@ func (d *DatePickerWidget) OnChange(onChange func()) *DatePickerWidget { return d } -// Build implements Widget interface +// Build implements Widget interface. func (d *DatePickerWidget) Build() { if d.date == nil { return @@ -2940,7 +2940,7 @@ func (d *DatePickerWidget) Build() { } } -// store month days sorted in weeks +// store month days sorted in weeks. func (d *DatePickerWidget) getDaysGroups() (days [][]int) { firstDay := time.Date(d.date.Year(), d.date.Month(), 1, 0, 0, 0, 0, time.Local) lastDay := firstDay.AddDate(0, 1, 0).Add(time.Nanosecond * -1) @@ -3042,7 +3042,7 @@ func (ce *ColorEditWidget) Size(width float32) *ColorEditWidget { return ce } -// Build implements Widget interface +// Build implements Widget interface. func (ce *ColorEditWidget) Build() { c := ToVec4Color(*ce.color) col := [4]float32{ diff --git a/Window.go b/Window.go index 759dc0a1..d024623a 100644 --- a/Window.go +++ b/Window.go @@ -43,7 +43,7 @@ type windowState struct { currentSize imgui.Vec2 } -// Dispose implements Disposable interface +// Dispose implements Disposable interface. func (s *windowState) Dispose() { // noop } @@ -51,7 +51,7 @@ func (s *windowState) Dispose() { // WindowWidget represents imgui.Window // Windows are used to display ui widgets. // They are in second place in the giu hierarchy (after the MasterWindow) -// NOTE: to disable multiple window, use SingleWindow +// NOTE: to disable multiple window, use SingleWindow. type WindowWidget struct { title string open *bool @@ -61,20 +61,20 @@ type WindowWidget struct { bringToFront bool } -// Window creates a WindowWidget +// Window creates a WindowWidget. func Window(title string) *WindowWidget { return &WindowWidget{ title: title, } } -// IsOpen sets if window widget is `opened` (minimalized) +// IsOpen sets if window widget is `opened` (minimalized). func (w *WindowWidget) IsOpen(open *bool) *WindowWidget { w.open = open return w } -// Flags sets window flags +// Flags sets window flags. func (w *WindowWidget) Flags(flags WindowFlags) *WindowWidget { w.flags = flags return w @@ -82,7 +82,7 @@ func (w *WindowWidget) Flags(flags WindowFlags) *WindowWidget { // Size sets window size // NOTE: size can be changed by user, if you want to prevent -// user from changing window size, use NoResize flag +// user from changing window size, use NoResize flag. func (w *WindowWidget) Size(width, height float32) *WindowWidget { w.width, w.height = width, height return w @@ -91,7 +91,7 @@ func (w *WindowWidget) Size(width, height float32) *WindowWidget { // Pos sets the window start position // NOTE: The position could be changed by user later. // To prevent user from changin window position use -// WIndowFlagsNoMove +// WIndowFlagsNoMove. func (w *WindowWidget) Pos(x, y float32) *WindowWidget { w.x, w.y = x, y return w @@ -142,30 +142,30 @@ func (w *WindowWidget) Layout(widgets ...Widget) { imgui.End() } -// CurrentPosition returns a current position of the window +// CurrentPosition returns a current position of the window. func (w *WindowWidget) CurrentPosition() (x, y float32) { pos := w.getState().currentPosition return pos.X, pos.Y } -// CurrentSize returns current size of the window +// CurrentSize returns current size of the window. func (w *WindowWidget) CurrentSize() (width, height float32) { size := w.getState().currentSize return size.X, size.Y } -// BringToFront sets window focused +// BringToFront sets window focused. func (w *WindowWidget) BringToFront() { w.bringToFront = true } -// HasFocus returns true if window is focused +// HasFocus returns true if window is focused. func (w *WindowWidget) HasFocus() bool { return w.getState().hasFocus } // RegisterKeyboardShortcuts adds local (window-level) keyboard shortcuts -// see InputHandler.go +// see InputHandler.go. func (w *WindowWidget) RegisterKeyboardShortcuts(s ...WindowShortcut) *WindowWidget { if w.HasFocus() { for _, shortcut := range s { @@ -185,7 +185,7 @@ func (w *WindowWidget) getStateID() string { return fmt.Sprintf("%s_windowState", w.title) } -// returns window state +// returns window state. func (w *WindowWidget) getState() (state *windowState) { if s := Context.GetState(w.getStateID()); s != nil { var isOk bool