how to get widget size
Hi there,
I'm thinking about a package-level Align method.
it could look like:
g.Align(giu.AlignToCenter).To(/* any widgets*/),
is there any way to get a size (width, height) of any widget?
e.g. I can get label size by CalcTextSize:
// ...
if label, isLabel := widget.(*Label); isLabel {
width,height = CalcTextSize(label.label)
}
// ...
Is there any way to do it for any layout? maybe with GetCursorPos?
okey, I got it: imgui.GetItemRectSize()
hmm, well, but is there anything like CalcItemRectSize?
I need to get this value before rendering a widget
@gucio321 Check this https://github.com/ocornut/imgui/issues/3714
okey. so there is workaround code:
startPos := GetCursorPos()
var widgetWidth float32
// render widget with 0 alpha and store thems widths
imgui.PushStyleVarFloat(imgui.StyleVarID(StyleVarAlpha), 0)
mywidget.Build()
size := imgui.GetItemRectSize()
widgetWidth = size.X
imgui.PopStyleVar()
// reset cursor pos
SetCursorPos(startPos)
@allenDang should we keep the issue open?
@gucio321 I think we should keep it open until upstream solution comes.