diff --git a/Context.go b/Context.go index 88e3a78a..f9ad465f 100644 --- a/Context.go +++ b/Context.go @@ -43,6 +43,7 @@ type state struct { data Disposable } +// GUIContext represents a giu context. (Current context is giu.Context. type GIUContext struct { backend backend.Backend[glfwbackend.GLFWWindowFlags] diff --git a/InputHandler.go b/InputHandler.go index b78572a1..8618cb82 100644 --- a/InputHandler.go +++ b/InputHandler.go @@ -29,6 +29,7 @@ const ( LocalShortcut ShortcutType = false ) +// InputHandlerHandleCallback is a callback which is called when a shortcut is triggered. type InputHandlerHandleCallback func(Key, Modifier, Action) // InputHandler is an interface which needs to be implemented diff --git a/MasterWindow.go b/MasterWindow.go index 346e9757..0931dd64 100644 --- a/MasterWindow.go +++ b/MasterWindow.go @@ -195,7 +195,7 @@ func (w *MasterWindow) setTheme() (fin func()) { } } -func (w *MasterWindow) sizeChange(width, height int) { +func (w *MasterWindow) sizeChange(_, _ int) { // noop } diff --git a/Plot.go b/Plot.go index 9bbaacb5..e7262065 100644 --- a/Plot.go +++ b/Plot.go @@ -6,11 +6,13 @@ import ( "github.com/AllenDang/cimgui-go/implot" ) +// PlotAxis types. type ( PlotXAxis = implot.PlotAxisEnum PlotYAxis = implot.PlotAxisEnum ) +// Available axes. const ( AxisX1 = implot.AxisX1 AxisX2 = implot.AxisX2 @@ -89,6 +91,7 @@ func Plot(title string) *PlotCanvasWidget { } } +// SetXAxisLabel sets x axis label. func (p *PlotCanvasWidget) SetXAxisLabel(axis PlotXAxis, label string) *PlotCanvasWidget { switch axis { case AxisX1: @@ -102,6 +105,7 @@ func (p *PlotCanvasWidget) SetXAxisLabel(axis PlotXAxis, label string) *PlotCanv return p } +// SetYAxisLabel sets y axis label. func (p *PlotCanvasWidget) SetYAxisLabel(axis PlotYAxis, label string) *PlotCanvasWidget { switch axis { case AxisY1: @@ -286,6 +290,7 @@ func (p *PlotCanvasWidget) Build() { } } +// SwitchPlotAxes switches plot axes. func SwitchPlotAxes(x PlotXAxis, y PlotYAxis) PlotWidget { return Custom(func() { implot.PlotSetAxes(x, y) @@ -301,6 +306,7 @@ type BarPlot struct { offset int } +// Bar adds plot bars to the canvas. func Bar(title string, data []float64) *BarPlot { return &BarPlot{ title: title, diff --git a/SliderWidgets.go b/SliderWidgets.go index bf87d3d6..da22dec1 100644 --- a/SliderWidgets.go +++ b/SliderWidgets.go @@ -224,6 +224,7 @@ func (sf *SliderFloatWidget) Labelf(format string, args ...any) *SliderFloatWidg return sf.Label(fmt.Sprintf(format, args...)) } +// ID manually sets widget id. func (sf *SliderFloatWidget) ID(id ID) *SliderFloatWidget { sf.label = id return sf diff --git a/Widgets.go b/Widgets.go index 86cdca4a..92fdf282 100644 --- a/Widgets.go +++ b/Widgets.go @@ -246,12 +246,14 @@ func (c *ComboWidget) OnChange(onChange func()) *ComboWidget { var _ Widget = &ContextMenuWidget{} +// ContextMenuWidget is a context menu on another widget. (e.g. right-click menu on button). type ContextMenuWidget struct { id ID mouseButton MouseButton layout Layout } +// ContextMenu creates new ContextMenuWidget. func ContextMenu() *ContextMenuWidget { return &ContextMenuWidget{ mouseButton: MouseButtonRight, @@ -260,16 +262,19 @@ func ContextMenu() *ContextMenuWidget { } } +// Layout sets layout of the context menu. func (c *ContextMenuWidget) Layout(widgets ...Widget) *ContextMenuWidget { c.layout = Layout(widgets) return c } +// MouseButton sets mouse button that will trigger the context menu. func (c *ContextMenuWidget) MouseButton(mouseButton MouseButton) *ContextMenuWidget { c.mouseButton = mouseButton return c } +// ID sets the interval id of context menu. func (c *ContextMenuWidget) ID(id ID) *ContextMenuWidget { c.id = id return c @@ -285,6 +290,7 @@ func (c *ContextMenuWidget) Build() { var _ Widget = &DragIntWidget{} +// DragIntWidget is a widget that allows to drag an integer value. type DragIntWidget struct { label ID value *int32 @@ -294,6 +300,7 @@ type DragIntWidget struct { format string } +// DragInt creates new DragIntWidget. func DragInt(label string, value *int32, minValue, maxValue int32) *DragIntWidget { return &DragIntWidget{ label: GenAutoID(label), @@ -305,11 +312,13 @@ func DragInt(label string, value *int32, minValue, maxValue int32) *DragIntWidge } } +// Speed sets speed of the dragging. func (d *DragIntWidget) Speed(speed float32) *DragIntWidget { d.speed = speed return d } +// Format sets format of the value. func (d *DragIntWidget) Format(format string) *DragIntWidget { d.format = format return d @@ -758,7 +767,7 @@ func (t *TooltipWidget) buildTooltip() { var _ Widget = &SpacingWidget{} -// Spacing increases a spacing between two widgets a bit. +// SpacingWidget increases a spacing between two widgets a bit. type SpacingWidget struct{} // Spacing creates new SpacingWidget.