Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 125 additions & 32 deletions cimplot_funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions cimplot_structs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cmd/codegen/arguments_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func argWrapper(argType string) (wrapper argumentWrapper, err error) {
"ImPlotPoint": wrappableW("PlotPoint"),
"const ImPlotPoint": wrappableW("PlotPoint"),
"ImPlotPoint*": wrappablePtrW("*PlotPoint", "C.ImPlotPoint"),
"const ImPlotTime": wrappableW("PlotTime"),
"ImPlotTime*": wrappablePtrW("*PlotTime", "C.ImPlotTime"),
}

if wrapper, ok := argWrapperMap[argType]; ok {
Expand Down
1 change: 0 additions & 1 deletion cmd/codegen/gencpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ extern "C" {
strings.Contains(f.FuncName, "TextRange") ||
strings.Contains(f.FuncName, "ImVector") ||
strings.Contains(f.FuncName, "Allocator") ||
strings.Contains(f.FuncName, "ImPlotTime") ||
strings.Contains(f.FuncName, "MakeTime") ||
strings.Contains(f.FuncName, "__") {
shouldSkip = true
Expand Down
1 change: 1 addition & 0 deletions cmd/codegen/gengo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var skippedStructs = map[string]bool{
"ImVec4": true,
"ImColor": true,
"ImRect": true,
"ImPlotTime": true,
"StbUndoRecord": true,
"StbUndoState": true,
"StbTexteditRow": true,
Expand Down
1 change: 1 addition & 0 deletions cmd/codegen/return_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func getReturnTypeWrapperFunc(returnType string) (returnWrapper, error) {
"ImColor": wrappableR("Color"),
"ImPlotPoint": wrappableR("PlotPoint"),
"ImRect": wrappableR("Rect"),
"ImPlotTime": wrappableR("PlotTime"),
"ImGuiTableColumnIdx": simpleR("TableColumnIdx"),
"ImGuiTableDrawChannelIdx": simpleR("TableDrawChannelIdx"),
"void*": simpleR("unsafe.Pointer"),
Expand Down
1 change: 1 addition & 0 deletions cmd/codegen/structures_deffinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func shouldSkipStruct(name string) bool {
"ImRect": true,
"ImColor": true,
"ImPlotPoint": true,
"ImPlotTime": true,
}

if !strings.HasPrefix(name, "Im") {
Expand Down
31 changes: 30 additions & 1 deletion extra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package imgui
// #include "cimgui_wrapper.h"
// #include "cimplot_wrapper.h"
import "C"
import "image/color"
import (
"image/color"
"time"
)

type (
Wchar C.uint
Expand Down Expand Up @@ -176,6 +179,32 @@ func (p PlotPoint) toC() C.ImPlotPoint {
return C.ImPlotPoint{x: C.double(p.X), y: C.double(p.Y)}
}

type PlotTime struct {
S int // second part
Us int // microsecond part
}

func NewPlotTime(t time.Time) PlotTime {
ts := t.UnixMicro()
return PlotTime{
S: int(ts / 1e6),
Us: int(ts % 1e6),
}
}

func (i PlotTime) Time() time.Time {
return time.Unix(int64(i.S), int64(i.Us)*int64(time.Microsecond))
}

func (i *PlotTime) fromC(p C.ImPlotTime) *PlotTime {
*i = PlotTime{int(p.S), int(p.Us)}
return i
}

func (p PlotTime) toC() C.ImPlotTime {
return C.ImPlotTime{S: C.long(p.S), Us: C.int(p.Us)}
}

// wrappableType represents a GO type that can be converted into a C value
// and back - into a GO value.
// CTYPE represents the equivalent C type of self.
Expand Down