giu icon indicating copy to clipboard operation
giu copied to clipboard

Row widget: strange behaviour when using CustomWidget

Open gucio321 opened this issue 3 years ago • 2 comments

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 avatar Oct 18 '22 14:10 gucio321

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

gucio321 avatar Oct 18 '22 14:10 gucio321

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

AllenDang avatar Oct 19 '22 02:10 AllenDang

I think we can close this.

gucio321 avatar Jul 10 '24 12:07 gucio321