GUI changes between portrait/landscapemode

When having a dynamically changing GUI layout with portrait and landscape mode I am making some changes in e.g. texts, node’s positions etc. Then, when the phone is rotated and the mode is changed (window resize event is triggered) the GUI shows everything as in the initial state for the mode - initial positions as seen in Editor for actual mode and default texts. How can I perform a persistent change on those positions or texts, so it can survive mode change? Do I have to save all those values constantly and watch for a window resize event to reconstruct the latest state before the change from the saved data?

Yes, you need to store the state of your UI somewhere (on self or in a module) and the reapply the state to the UI components when UI has changed. You should be able to add a window listener using window.set_listener() and then also check gui.get_layout() to detect a change. I haven’t tried this myself, but hopefully you get the WINDOW_EVENT_RESIZE after the layout has changed and not before. Let me know if that isn’t true because then we might need to fix that or add another way of detecting a layout change.

Indeed, that’s true and that’s why I was trying this workaround with saving data. So, why is the GUI properties changing after the layout’s change?

I think we’re recreating the entire gui with all nodes and everything created anew with the properties from the new layout. It’s a simple solution to an otherwise quite complex problem.

1 Like