From f49fa7e8f429399373d78f34e720fe82535cf7d7 Mon Sep 17 00:00:00 2001 From: gucio321 Date: Tue, 1 Oct 2024 10:32:21 +0200 Subject: [PATCH] add more missing docs --- Canvas.go | 2 +- ClickableWidgets.go | 1 + CodeEditor.go | 2 +- Keycode.go | 2 ++ Markdown.go | 2 +- Plot.go | 22 ++++++++++++++++++++-- TextWidgets.go | 1 + 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Canvas.go b/Canvas.go index 12f8ee91..c1b93675 100644 --- a/Canvas.go +++ b/Canvas.go @@ -156,7 +156,7 @@ func (c *Canvas) PathArcToFast(center image.Point, radius float32, min12, max12 c.DrawList.PathArcToFast(ToVec2(center), radius, min12, max12) } -// PathBezierQuadraticCurveTo adds a quadratic bezier curve. +// PathBezierCubicCurveTo adds a cubic bezier curve. func (c *Canvas) PathBezierCubicCurveTo(p1, p2, p3 image.Point, numSegments int32) { c.DrawList.PathBezierCubicCurveToV(ToVec2(p1), ToVec2(p2), ToVec2(p3), numSegments) } diff --git a/ClickableWidgets.go b/ClickableWidgets.go index 498b0b5f..55124b37 100644 --- a/ClickableWidgets.go +++ b/ClickableWidgets.go @@ -56,6 +56,7 @@ func (b *ButtonWidget) Size(width, height float32) *ButtonWidget { return b } +// ID allows to manually set widget's id. func (b *ButtonWidget) ID(id ID) *ButtonWidget { b.id = id return b diff --git a/CodeEditor.go b/CodeEditor.go index d5497952..0abcae4b 100644 --- a/CodeEditor.go +++ b/CodeEditor.go @@ -1,4 +1,4 @@ -//nolint:gocritic,govet,unused // this file is TODO. We don't want commentedOutCode linter issues here yet. +//nolint:gocritic,govet,unused,revive // this file is TODO. We don't want commentedOutCode linter issues here yet. package giu import ( diff --git a/Keycode.go b/Keycode.go index c59c3901..3ecc91c9 100644 --- a/Keycode.go +++ b/Keycode.go @@ -262,8 +262,10 @@ const ( ModNumLock = Modifier(glfwbackend.GLFWModNumLock) ) +// Action represents key status change type. type Action int +// Actions. const ( Release Action = iota Press diff --git a/Markdown.go b/Markdown.go index 39e9e063..9aa407fc 100644 --- a/Markdown.go +++ b/Markdown.go @@ -1,4 +1,4 @@ -//nolint:gocritic,govet,wsl // this file is TODO. We don't want commentedOutCode lint issues here. +//nolint:gocritic,govet,wsl,revive // this file is TODO. We don't want commentedOutCode lint issues here. package giu // MarkdownWidget implements DearImGui markdown extension diff --git a/Plot.go b/Plot.go index c1a8968f..9bbaacb5 100644 --- a/Plot.go +++ b/Plot.go @@ -502,6 +502,7 @@ func (p *LineXYPlot) Plot() { } // PieChartPlot represents a pie chart. +// TODO: support PlotPieChartFlags. type PieChartPlot struct { labels []string values []float64 @@ -525,6 +526,7 @@ func PieChart(labels []string, values []float64, x, y, radius float64) *PieChart } } +// Normalize sets normalize flag. func (p *PieChartPlot) Normalize(n bool) *PieChartPlot { p.normalize = n return p @@ -536,13 +538,19 @@ func (p *PieChartPlot) LabelFormat(fmtStr string) *PieChartPlot { return p } +// Angle0 sets start angle. func (p *PieChartPlot) Angle0(a float64) *PieChartPlot { p.angle0 = a return p } +// Plot implements Plot interface. func (p *PieChartPlot) Plot() { - // TODO: p.normalized not used anymore - replace with flags + var flags implot.PlotPieChartFlags + if p.normalize { + flags |= implot.PlotPieChartFlagsNormalize + } + implot.PlotPlotPieChartdoublePtrStrV( Context.FontAtlas.RegisterStringSlice(p.labels), &p.values, @@ -552,10 +560,11 @@ func (p *PieChartPlot) Plot() { p.radius, p.labelFormat, p.angle0, - implot.PlotPieChartFlagsNormalize, + flags, ) } +// ScatterPlot represents a scatter plot. type ScatterPlot struct { label string values []float64 @@ -563,6 +572,7 @@ type ScatterPlot struct { offset int } +// Scatter adds scatter plot to the canvas. func Scatter(label string, values []float64) *ScatterPlot { return &ScatterPlot{ label: label, @@ -573,21 +583,25 @@ func Scatter(label string, values []float64) *ScatterPlot { } } +// XScale sets x-axis scale. func (p *ScatterPlot) XScale(s float64) *ScatterPlot { p.xscale = s return p } +// X0 sets start position on x axis. func (p *ScatterPlot) X0(x float64) *ScatterPlot { p.x0 = x return p } +// Offset sets chart offset. func (p *ScatterPlot) Offset(offset int) *ScatterPlot { p.offset = offset return p } +// Plot implements Plot interface. func (p *ScatterPlot) Plot() { implot.PlotPlotScatterdoublePtrIntV( Context.FontAtlas.RegisterString(p.label), @@ -601,12 +615,14 @@ func (p *ScatterPlot) Plot() { ) } +// ScatterXYPlot represents a scatter plot with possibility to set x and y values. type ScatterXYPlot struct { label string xs, ys []float64 offset int } +// ScatterXY adds scatter plot with x and y values. func ScatterXY(label string, xs, ys []float64) *ScatterXYPlot { return &ScatterXYPlot{ label: label, @@ -616,11 +632,13 @@ func ScatterXY(label string, xs, ys []float64) *ScatterXYPlot { } } +// Offset sets chart offset. func (p *ScatterXYPlot) Offset(offset int) *ScatterXYPlot { p.offset = offset return p } +// Plot implements Plot interface. func (p *ScatterXYPlot) Plot() { implot.PlotPlotScatterdoublePtrdoublePtrV( Context.FontAtlas.RegisterString(p.label), diff --git a/TextWidgets.go b/TextWidgets.go index 0964d19c..57cc2c19 100644 --- a/TextWidgets.go +++ b/TextWidgets.go @@ -48,6 +48,7 @@ func (i *InputTextMultilineWidget) Labelf(format string, args ...any) *InputText return i.Label(fmt.Sprintf(format, args...)) } +// ID sets widget's id. func (i *InputTextMultilineWidget) ID(id ID) *InputTextMultilineWidget { i.label = id return i