Closed michaeldelgado1 closed 2 weeks ago
Why do you think that the expected result is a panel with no status bar? Does that behavior differ from C behavior? The function just says bounds and text, with no mention of the status bar.
Yes it's in the C implementation. https://github.com/raysan5/raygui/blob/12804826d01bfb636e36f816bda19eaa23b4ace7/src/raygui.h#L1793
I've used it pretty recently. I'm not familiar with cgo, but if you do a length check in the string, I assume you can pass null instead of a blank string.
Some reproducible example would be nice, you mention Panel, and then you link to ScrollPanel. I am guessing based on the checks you sent that some function should pass nil
if the string is empty but that is just a guess.
The implementation is the same for both panel and scroll panel... https://github.com/raysan5/raygui/blob/12804826d01bfb636e36f816bda19eaa23b4ace7/src/raygui.h#L1693
As far as an example goes, I don't have much time to provide one at the moment. Both your project and the original C implement have Scroll panel examples. It's possible to check those
Some reproducible example would be nice, you mention Panel, and then you link to ScrollPanel. I am guessing based on the checks you sent that some function should pass
nil
if the string is empty but that is just a guess.
@gen2brain I think you are right.
Here is the current state (I ran the example gui/scroll_panel/scroll_panel.go
):
And here with a nil passed (https://github.com/JupiterRider/raylib-go/commit/c212c3388657742aa15f3996db911dac0cf53961):
Nice implementation @JupiterRider my only gripe would be to do a nil check in the free so we don't attempt to free a nil pointer
@michaeldelgado1 The free is inside the if statement:
var ctext *C.char
if len(text) > 0 {
ctext = C.CString(text)
defer C.free(unsafe.Pointer(ctext))
}
I totally missed that. Thanks for pointing it out. I was reading on mobile 🤦
@JupiterRider Nice, can you send the PR? Is that the only function/place where it needs nil?
@gen2brain I don't know every place, where a NULL string affects the appearance, but C-raygui has NULL-checks, so we can safely pass them instead of an empty string.
Code example:
Expected Result: A panel is drawn with no status bar
Actual Result: A panel is drawn with a status bar and no text