Skip to content

revealer: Fix child size allocation at small scales

Alexander Larsson requested to merge alexl/gtk:fix-revealer-scale into master

As pointed out in #1481 (closed) and seen from critical warnings with swinging revealers in widget-factory there are some size allocation issues in GtkRevealer.

What happens is that we request a size of the revealer itself based on the child natural size and the current stage of the transition by applying a scale to the natural size. We then round up to nearest int size. However, we want the widget to render as if it did get the natural size so we can transform it, rather than the scaled down size. For example, a label should not start ellipsizing in the animation. So we inverse the scale when allocating the child.

Unfortunately, for very small scales the inversion of the scale can result in very large sizes, and for such scales we rounded up the requested size to 1, so we will be allocating huuuuge children.

In order to avoid such issue we pick an arbitrary maximum upscale scale factor of 100. This means that in the case where the allocated size is 1 we never allocate the child at > 100 px. This means that in large downscaling cases we may run into the clipping issue described above. However, at these downscaling levels (100 times!) we're unlikely to notice much detail anyway.

Merge request reports