Skip to content

Commit

Permalink
add more docs!
Browse files Browse the repository at this point in the history
  • Loading branch information
gucio321 committed Oct 1, 2024
1 parent 470f4fc commit 941f575
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions Context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions InputHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion MasterWindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (w *MasterWindow) setTheme() (fin func()) {
}
}

func (w *MasterWindow) sizeChange(width, height int) {
func (w *MasterWindow) sizeChange(_, _ int) {
// noop
}

Expand Down
6 changes: 6 additions & 0 deletions Plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions SliderWidgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion Widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 941f575

Please sign in to comment.