diff options
author | Carlos Soriano <csoriano@redhat.com> | 2018-08-03 17:28:01 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@redhat.com> | 2018-08-03 17:28:01 +0200 |
commit | 4c64df1245f23e26917b4cea2f8d688c862da3fe (patch) | |
tree | 2b9bc9bdc64c8f3c8a9fb5cee20d2d0300d2e02c | |
parent | e0807fcf54c5df00b6f5cc26f035106cd4c33e32 (diff) | |
download | gtk+-test-revealer.tar.gz |
test revealertest-revealer
-rw-r--r-- | gtk/gtkrevealer.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c index 84cb1ca851..95ace1f8b0 100644 --- a/gtk/gtkrevealer.c +++ b/gtk/gtkrevealer.c @@ -307,10 +307,11 @@ gtk_revealer_get_child_allocation (GtkRevealer *revealer, GtkAllocation *allocation, GtkAllocation *child_allocation) { + GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); GtkWidget *child; GtkRevealerTransitionType transition; GtkBorder padding; - gint vertical_padding, horizontal_padding; + gint minimum, vertical_padding, horizontal_padding; g_return_if_fail (revealer != NULL); g_return_if_fail (allocation != NULL); @@ -322,24 +323,33 @@ gtk_revealer_get_child_allocation (GtkRevealer *revealer, child_allocation->x = 0; child_allocation->y = 0; - child_allocation->width = 0; - child_allocation->height = 0; + child_allocation->width = allocation->width - horizontal_padding; + child_allocation->height = allocation->height - vertical_padding; child = gtk_bin_get_child (GTK_BIN (revealer)); - if (child != NULL && gtk_widget_get_visible (child)) + if (child != NULL && priv->current_pos != 1.0 && gtk_widget_get_visible (child)) { transition = effective_transition (revealer); - if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT || - transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) - gtk_widget_get_preferred_width_for_height (child, MAX (0, allocation->height - vertical_padding), NULL, - &child_allocation->width); - else - gtk_widget_get_preferred_height_for_width (child, MAX (0, allocation->width - horizontal_padding), NULL, - &child_allocation->height); - } - child_allocation->width = MAX (child_allocation->width, allocation->width - horizontal_padding); - child_allocation->height = MAX (child_allocation->height, allocation->height - vertical_padding); + switch (transition) + { + case GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT: + case GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT: + gtk_widget_get_preferred_width_for_height (child, child_allocation->height, &minimum, NULL); + child_allocation->width = MIN (minimum, child_allocation->width * (1 / priv->current_pos)); + break; + case GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN: + case GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP: + gtk_widget_get_preferred_height_for_width (child, child_allocation->width, &minimum, NULL); + child_allocation->height = MIN (minimum, child_allocation->height * (1 / priv->current_pos)); + break; + + case GTK_REVEALER_TRANSITION_TYPE_NONE: + case GTK_REVEALER_TRANSITION_TYPE_CROSSFADE: + default: + break; + } + } } static void |