Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to remove status bar from raygui Panels #386

Closed
michaeldelgado1 opened this issue May 14, 2024 · 11 comments · Fixed by #388
Closed

Unable to remove status bar from raygui Panels #386

michaeldelgado1 opened this issue May 14, 2024 · 11 comments · Fixed by #388

Comments

@michaeldelgado1
Copy link

Code example:

container := rl.Rectangle{
  X: 20,
  Y: 20,
  Width: 100,
  Height: 100,
}

rg.Panel(container, "")

Expected Result:
A panel is drawn with no status bar

Actual Result:
A panel is drawn with a status bar and no text

@gen2brain
Copy link
Owner

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.

@michaeldelgado1
Copy link
Author

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.

@michaeldelgado1
Copy link
Author

@gen2brain
Copy link
Owner

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.

@michaeldelgado1
Copy link
Author

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

@JupiterRider
Copy link
Contributor

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):
Screenshot_20240516_190912

And here with a nil passed (JupiterRider@c212c33):
Screenshot_20240516_190942

@michaeldelgado1
Copy link
Author

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

@JupiterRider
Copy link
Contributor

@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))
}

@michaeldelgado1
Copy link
Author

I totally missed that. Thanks for pointing it out. I was reading on mobile 🤦

@gen2brain
Copy link
Owner

@JupiterRider Nice, can you send the PR? Is that the only function/place where it needs nil?

@JupiterRider
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants