Commit f686ee3a authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko
Browse files

flap: Properly calculate minimum and natural sizes

Currently, we always calculate minimum and natural size the same way. This
technically works, but is incorrect semantically. For example, it means
that flap's natural size changes depending on whether it's currently
folded, while folding state may change depending on the allocated size.

Instead, calculate natural size as follows:

* When the flap is always folded, do the same thing as berore
* When it's never folded, assume natural to be what the flap will be like
  when fully revealed
* For the automatic policy, an important distinction is whether the flap is
  locked or not. If it's not locked, we can safely assume the size when
  unfolded and fully revealed as well, but if it is locked and the flap is
  not revealed, we assume that to be the natural size, because the flap
  will never be auto-revealed on resizeing, and unlike the never folded
  state, revealing the flap will not cause a widget resize either.

Additionally, never account for the separator size for the flap's
orientation. When folded, the separator will end up completely offscreen,
and it's expected and supported situation.
parent 44499adc
Pipeline #244448 passed with stages
in 14 minutes and 37 seconds
......@@ -1014,12 +1014,31 @@ hdy_flap_measure (GtkWidget *widget,
if (self->separator.widget)
get_preferred_size (self->separator.widget, orientation, &separator_min, &separator_nat);
if (self->orientation == orientation &&
self->fold_policy != HDY_FLAP_FOLD_POLICY_AUTO) {
gdouble progress = (1 - self->fold_progress) * self->reveal_progress;
if (self->orientation == orientation) {
gdouble min_progress, nat_progress;
switch (self->fold_policy) {
case HDY_FLAP_FOLD_POLICY_NEVER:
min_progress = (1 - self->fold_progress) * self->reveal_progress;
nat_progress = 1;
break;
case HDY_FLAP_FOLD_POLICY_ALWAYS:
min_progress = 0;
nat_progress = 0;
break;
case HDY_FLAP_FOLD_POLICY_AUTO:
min_progress = 0;
nat_progress = self->locked ? self->reveal_progress : 1;
break;
default:
g_assert_not_reached ();
}
min = MAX (content_min + (gint) round ((flap_min + separator_min) * progress), flap_min);
nat = MAX (content_nat + (gint) round ((flap_nat + separator_nat) * progress), flap_nat);
min = MAX (content_min + (gint) round ((flap_min + separator_min) * min_progress), flap_min);
nat = MAX (content_nat + (gint) round ((flap_nat + separator_min) * nat_progress), flap_nat);
} else {
min = MAX (MAX (content_min, flap_min), separator_min);
nat = MAX (MAX (content_nat, flap_nat), separator_nat);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment