Skip to content

Commit

Permalink
add more missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Oct 1, 2024
1 parent 612202a commit f49fa7e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions ClickableWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CodeEditor.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions Keycode.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ const (
ModNumLock = Modifier(glfwbackend.GLFWModNumLock)
)

// Action represents key status change type.
type Action int

// Actions.
const (
Release Action = iota
Press
Expand Down
2 changes: 1 addition & 1 deletion Markdown.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 20 additions & 2 deletions Plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ func (p *LineXYPlot) Plot() {
}

// PieChartPlot represents a pie chart.
// TODO: support PlotPieChartFlags.
type PieChartPlot struct {
labels []string
values []float64
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -552,17 +560,19 @@ 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
xscale, x0 float64
offset int
}

// Scatter adds scatter plot to the canvas.
func Scatter(label string, values []float64) *ScatterPlot {
return &ScatterPlot{
label: label,
Expand All @@ -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),
Expand All @@ -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,
Expand All @@ -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),
Expand Down
1 change: 1 addition & 0 deletions TextWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f49fa7e

Please sign in to comment.