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

Row widget: strange behaviour when using CustomWidget #572

Closed
gucio321 opened this issue Oct 18, 2022 · 3 comments
Closed

Row widget: strange behaviour when using CustomWidget #572

gucio321 opened this issue Oct 18, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@gucio321
Copy link
Collaborator

What happend?

when using CustomWidget inside RowWidget (especially as a last of the widgets), imgui.SameLine() is called incorrectly.

Code example

main.go
giu.Row(
   giu.Label("Hi!"),
   giu.Custom(func() { fmt.Println("Hello world!") }),
),
giu.Label("I'll be next to Hi label... - it shouldn't happen"),

To Reproduce

  1. Run my demo
  2. You'll see that both labels are in the same line

Version

(latest)

OS

fedora workstation 36

@gucio321 gucio321 added the bug Something isn't working label Oct 18, 2022
@gucio321
Copy link
Collaborator Author

@AllenDang what do you think about the following solution, I've tought about:
in (*RowWidget).Build:

  • before rendering widget save giu.GetCursorPos()
  • render widget
  • check if new CursorPos is diffrent and (if so) call imgui.Sameline

sadly, it could affect performency... maybe add something like giu.Row(...).AutoDetectCursorMove(true)?

@AllenDang
Copy link
Owner

@gucio321 RowWidget has a list of types inside to decide whether to call SameLine or not, I think this is the best solution right now to leverage performance.

@gucio321
Copy link
Collaborator Author

I think we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants