You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, when you resize the window slowly, everything looks fine, But when you resize it quickly, the size of the content doesn't keep up with the size of the window:
It's even worse on Android, because the layout gets stuck in its initial state where the size of the container hasn't even been calculated yet. And you can't generally force a refresh by resizing the app at will, although if the app contains a TextInput you may be able to do it by showing the keyboard.
This is happening because Widget.refresh currently calls self.refresh_sublayouts before super().refresh. So when a container is resized, its content will be laid out using the old size, not the new one:
"""Refresh the layout and appearance of the tree this node is contained in."""
ifself._root:
self._root.refresh()
else:
self.refresh_sublayouts()
super().refresh(self._impl.viewport)
Reversing the order of these two lines fixes the issue, at least on Windows. However, I see that they have already been reversed by #814 (commits), with the message:
refresh_sublayouts before we refresh ourself
this fixes when adding children to widget which is the content of another (e.g. ScrollWidget) where the content dimensions would not be updated before the containing widget is refreshed
@samschott: Can you remember what this means? Why would you want the content dimensions to be refreshed before the containing widget, when the size constraints flow in the opposite direction?
Environment:
Operating System: Windows 10 and Android API level 33, at least
Reversing the order of these two lines fixes the issue on Windows, but not on Android. This may be because changes to the size of an Android widget aren't visible in its getWidth and getHeight methods until after the next layout pass is complete. In which case, we might need to attach an OnGlobalLayoutListener to each AndroidViewport, which refreshes the content's layout as soon as the container's size change has taken effect.
Run the following app (based on #1604):
On Windows, when you resize the window slowly, everything looks fine, But when you resize it quickly, the size of the content doesn't keep up with the size of the window:
It's even worse on Android, because the layout gets stuck in its initial state where the size of the container hasn't even been calculated yet. And you can't generally force a refresh by resizing the app at will, although if the app contains a TextInput you may be able to do it by showing the keyboard.
This is happening because
Widget.refresh
currently callsself.refresh_sublayouts
beforesuper().refresh
. So when a container is resized, its content will be laid out using the old size, not the new one:toga/src/core/toga/widgets/base.py
Lines 210 to 216 in 6379ab8
Reversing the order of these two lines fixes the issue, at least on Windows. However, I see that they have already been reversed by #814 (commits), with the message:
@samschott: Can you remember what this means? Why would you want the content dimensions to be refreshed before the containing widget, when the size constraints flow in the opposite direction?
Environment:
The text was updated successfully, but these errors were encountered: