summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@redhat.com>2018-08-03 17:28:01 +0200
committerCarlos Soriano <csoriano@redhat.com>2018-09-03 18:13:39 +0200
commit6211541ff2fd931fa373450ded0ac19a45491a79 (patch)
tree6a61a4d9e644147dd32afda767cbc3a4f1c09d41
parentf459bd6c195e3c1e9c15c1a55110aeb09dfcf92d (diff)
downloadgtk+-min-size-revealer.tar.gz
gtkrevealer: support minimum size of childmin-size-revealer
GtkRevealer always allocates the natural size of the child so the bin_window can take care of the animation with the full allocation of the child. However when GtkRevealer allocates the child doesn't take into account the minimum size of the child. On the other hand it does take into account the minimum size of the child when reporting the preferred size to the parent of the GtkRevealer. This behaviour clips the child of the GtkRevealer if the parent allocates less than the natural size. To fix this inconsistency, the patch makes the child adapt the allocation of the GtkRevealer as long as it's not under the minimum size of the child. Closes https://gitlab.gnome.org/GNOME/gtk/issues/635
-rw-r--r--gtk/gtkrevealer.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index 84cb1ca851..a7f7cbc437 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -307,9 +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 minimum_width, minimum_height;
gint vertical_padding, horizontal_padding;
g_return_if_fail (revealer != NULL);
@@ -322,24 +324,46 @@ 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))
{
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);
+ switch (transition)
+ {
+ case GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT:
+ gtk_widget_get_preferred_width_for_height (child, child_allocation->height,
+ &minimum_width, NULL);
+ child_allocation->width = MAX (minimum_width,
+ child_allocation->width * priv->current_pos);
+ child_allocation->x = (allocation->width - horizontal_padding) - child_allocation->width;
+ break;
+ case GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT:
+ gtk_widget_get_preferred_width_for_height (child, child_allocation->height,
+ &minimum_width, NULL);
+ child_allocation->width = MAX (minimum_width,
+ child_allocation->width * priv->current_pos);
+ break;
+ case GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN:
+ gtk_widget_get_preferred_height_for_width (child, child_allocation->width,
+ &minimum_height, NULL);
+ child_allocation->height = MAX (minimum_height,
+ child_allocation->height * priv->current_pos);
+ child_allocation->y = (allocation->height - vertical_padding) - child_allocation->height;
+ case GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP:
+ gtk_widget_get_preferred_height_for_width (child, child_allocation->width,
+ &minimum_height, NULL);
+ child_allocation->height = MAX (minimum_height,
+ child_allocation->height * priv->current_pos);
+ break;
+
+ case GTK_REVEALER_TRANSITION_TYPE_NONE:
+ case GTK_REVEALER_TRANSITION_TYPE_CROSSFADE:
+ default:
+ break;
+ }
}
-
- child_allocation->width = MAX (child_allocation->width, allocation->width - horizontal_padding);
- child_allocation->height = MAX (child_allocation->height, allocation->height - vertical_padding);
}
static void