AllenDang / cimgui-go

Auto generated Go wrapper for Dear ImGui via cimgui
MIT License
332 stars 51 forks source link

Vector type and iterator opportunities #269

Open 38dh91 opened 7 months ago

38dh91 commented 7 months ago

Good day!

I have a snippet of code like this:

dockNode := imgui.InternalDockBuilderGetNode(dockId)
tabs := dockNode.TabBar().Tabs()

Method Tabs() returns Vector type and in my mind such type must have some type of iterator, but it isn't.

Can you help me to realize how can I use this type to iterate over all TabItems in TabBar?

Thank you in advance!

gucio321 commented 6 months ago

Hi sorry I didn't respond - I had to miss this issue somehow.

I think you should do something like this:

        slice := []int{1, 2, 3, 4, 5}
        ptr := &slice[0]
        convertedSlice := (*[5]int)(unsafe.Pointer(ptr))[:]
        fmt.Println(convertedSlice) 

I'll try to add it to cimgui-go

gucio321 commented 6 months ago

I've tried to add a generic version for that and there is a problem: to add some iterator I need to know base type, when our type T is in fact a pointer. I've tried to make it a base type and Data field just a pointer to T but I found out that it sometimes can be string (char*) and its quite difficult to find out what to do then. I'll think about that