OnSizeChange() difference

Started by Xdesign, 15 January 2022, 20:33:25

Xdesign

Is there a way to get difference of new size - old size on size change?
I made a custom container similar to tgui::Grid and i want it to resize auto on child resize function
I mean i can store old size and just subtract it but i saw this "The size of the widget changed. Optimal parametar : new size" on definition of OnSizeChange()
I dont get where this parametar goes and how to do it
Thank you in advance!

texus

QuoteIs there a way to get difference of new size - old size on size change?
No, you will just have to store the old size yourself.

QuoteI dont get where this parametar goes and how to do it
Callback functions can have optional parameters. The onSizeChange member is of type SignalVector2f, which allows your callback function to either have no arguments or take a tgui::Vector2f as parameter. So both of these lines are valid:
Code (cpp) Select
w->onSizeChange([](){ std::cout << "size changed\n" << std::endl; });
w->onSizeChange([](tgui::Vector2f newSize){ std::cout << "size changed\n" << std::endl; });

More information about the signals can be found in the tutorial: https://tgui.eu/tutorials/0.10/signals/

Xdesign