bindParentSize ?

Started by Nafffen, 07 October 2023, 18:43:04

Nafffen

I there a way to define a size binding to a parent size without actually knowing it ?
I would like to do something like this :
    auto min = tgui::bindMin(tgui::bindParentWidth(ptr), tgui::bindParentHeight(ptr));
    ptr->setSize(min*0.16, min*0.16);
    //...somewhere else in the code...
    gui.add(ptr)

texus

The bind functions require you to know the widget, but you can do it when the layout is a string because that gets parsed again after the widget is added to a parent.

So something like this should work:
Code (cpp) Select
ptr->setSize("min(parent.width, parent.height)*0.16", "min(parent.width, parent.height)*0.16");

Nafffen