[gtk+/wip/baedert/drawing: 5/5] revealer: Stop calculating paddings ourselves
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing: 5/5] revealer: Stop calculating paddings ourselves
- Date: Fri, 5 May 2017 16:57:21 +0000 (UTC)
commit a4fcff2079a7e8c8018660c3de3ac748c57ace9a
Author: Timm Bäder <mail baedert org>
Date: Fri May 5 18:56:48 2017 +0200
revealer: Stop calculating paddings ourselves
GtkWidget does it not for all widgets.
gtk/gtkrevealer.c | 114 ++++++++++++----------------------------------------
1 files changed, 27 insertions(+), 87 deletions(-)
---
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index a42b862..7a2e285 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -116,18 +116,6 @@ static void gtk_revealer_snapshot (GtkWidget
G_DEFINE_TYPE_WITH_PRIVATE (GtkRevealer, gtk_revealer, GTK_TYPE_BIN)
static void
-gtk_revealer_get_padding (GtkRevealer *revealer,
- GtkBorder *padding)
-{
- GtkWidget *widget = GTK_WIDGET (revealer);
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (widget);
-
- gtk_style_context_get_padding (context, padding);
-}
-
-static void
gtk_revealer_init (GtkRevealer *revealer)
{
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
@@ -300,17 +288,10 @@ gtk_revealer_get_child_allocation (GtkRevealer *revealer,
{
GtkWidget *child;
GtkRevealerTransitionType transition;
- GtkBorder padding;
- gint vertical_padding, horizontal_padding;
g_return_if_fail (revealer != NULL);
g_return_if_fail (allocation != NULL);
- /* See explanation on gtk_revealer_real_size_allocate */
- gtk_revealer_get_padding (revealer, &padding);
- vertical_padding = padding.top + padding.bottom;
- horizontal_padding = padding.left + padding.right;
-
child_allocation->x = 0;
child_allocation->y = 0;
child_allocation->width = 0;
@@ -323,16 +304,16 @@ gtk_revealer_get_child_allocation (GtkRevealer *revealer,
if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT ||
transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL,
- MAX (0, allocation->height - vertical_padding),
+ MAX (0, allocation->height),
NULL, &child_allocation->width, NULL, NULL);
else
gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL,
- MAX (0, allocation->width - horizontal_padding),
+ MAX (0, allocation->width),
NULL, &child_allocation->height, NULL, NULL);
}
- child_allocation->width = MAX (child_allocation->width, allocation->width - horizontal_padding);
- child_allocation->height = MAX (child_allocation->height, allocation->height - vertical_padding);
+ child_allocation->width = MAX (child_allocation->width, allocation->width);
+ child_allocation->height = MAX (child_allocation->height, allocation->height);
}
static void
@@ -344,7 +325,6 @@ gtk_revealer_real_realize (GtkWidget *widget)
GtkAllocation child_allocation;
GtkWidget *child;
GtkRevealerTransitionType transition;
- GtkBorder padding;
GTK_WIDGET_CLASS (gtk_revealer_parent_class)->realize (widget);
@@ -358,24 +338,22 @@ gtk_revealer_real_realize (GtkWidget *widget)
gtk_revealer_get_child_allocation (revealer, &allocation, &child_allocation);
- gtk_revealer_get_padding (revealer, &padding);
-
/* See explanation on gtk_revealer_real_size_allocate */
transition = effective_transition (revealer);
if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN)
{
- child_allocation.y = allocation.height - child_allocation.height - padding.bottom;
- child_allocation.x = padding.left;
+ child_allocation.y = allocation.height - child_allocation.height;
+ child_allocation.x = 0;
}
else if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
{
- child_allocation.y = padding.top;
- child_allocation.x = allocation.width - child_allocation.width - padding.right;
+ child_allocation.y = 0;
+ child_allocation.x = allocation.width - child_allocation.width;
}
else
{
- child_allocation.y = padding.top;
- child_allocation.x = padding.left;
+ child_allocation.y = 0;
+ child_allocation.x = 0;
}
priv->bin_window =
@@ -434,7 +412,6 @@ gtk_revealer_real_size_allocate (GtkWidget *widget,
gboolean window_visible;
int bin_x, bin_y;
GtkRevealerTransitionType transition;
- GtkBorder padding;
GtkAllocation clip = *allocation;
g_return_if_fail (allocation != NULL);
@@ -467,7 +444,6 @@ gtk_revealer_real_size_allocate (GtkWidget *widget,
allocation->x, allocation->y,
allocation->width, allocation->height);
- gtk_revealer_get_padding (revealer, &padding);
bin_x = 0;
bin_y = 0;
@@ -496,19 +472,14 @@ gtk_revealer_real_size_allocate (GtkWidget *widget,
*/
if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN)
{
- bin_y = allocation->height - child_allocation.height - padding.bottom;
- bin_x = padding.left;
+ bin_y = allocation->height - child_allocation.height;
+ bin_x = 0;
}
else if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
{
- bin_y = padding.top;
- bin_x = allocation->width - child_allocation.width - padding.right;
+ bin_y = 0;
+ bin_x = allocation->width - child_allocation.width;
}
- else
- {
- bin_x = padding.left;
- bin_y = padding.top;
- }
gdk_window_move_resize (priv->bin_window,
bin_x, bin_y,
@@ -743,69 +714,39 @@ gtk_revealer_get_child_revealed (GtkRevealer *revealer)
*/
static void
-set_height_with_paddings (GtkRevealer *revealer,
- gint preferred_minimum_height,
- gint preferred_natural_height,
- gint *minimum_height_out,
- gint *natural_height_out)
+set_height (GtkRevealer *revealer,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
- gint minimum_height;
- gint natural_height;
GtkRevealerTransitionType transition;
- GtkBorder padding;
- gint vertical_padding;
-
- gtk_revealer_get_padding (revealer, &padding);
- vertical_padding = padding.top + padding.bottom;
- minimum_height = preferred_minimum_height + vertical_padding;
- natural_height = preferred_natural_height + vertical_padding;
transition = effective_transition (revealer);
if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE ||
transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP ||
transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN)
{
- /* Padding are included in the animation */
- minimum_height = round (minimum_height * priv->current_pos);
- natural_height = round (natural_height * priv->current_pos);
+ *minimum_height = round (*minimum_height * priv->current_pos);
+ *natural_height = round (*natural_height * priv->current_pos);
}
-
- *minimum_height_out = MIN (minimum_height, natural_height);
- *natural_height_out = natural_height;
}
static void
-set_width_with_paddings (GtkRevealer *revealer,
- gint preferred_minimum_width,
- gint preferred_natural_width,
- gint *minimum_width_out,
- gint *natural_width_out)
+set_width (GtkRevealer *revealer,
+ gint *minimum_width,
+ gint *natural_width)
{
GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
- gint minimum_width;
- gint natural_width;
GtkRevealerTransitionType transition;
- GtkBorder padding;
- gint horizontal_padding;
-
- gtk_revealer_get_padding (revealer, &padding);
- horizontal_padding = padding.left + padding.right;
- minimum_width = preferred_minimum_width + horizontal_padding;
- natural_width = preferred_natural_width + horizontal_padding;
transition = effective_transition (revealer);
if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE ||
transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT ||
transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
{
- /* Paddings are included in the animation */
- minimum_width = round (minimum_width * priv->current_pos);
- natural_width = round (natural_width * priv->current_pos);
+ *minimum_width = round (*minimum_width * priv->current_pos);
+ *natural_width = round (*natural_width * priv->current_pos);
}
-
- *minimum_width_out = MIN (minimum_width, natural_width);
- *natural_width_out = natural_width;
}
static void
@@ -817,16 +758,15 @@ gtk_revealer_measure (GtkWidget *widget,
int *minimum_baseline,
int *natural_baseline)
{
- int min_size, nat_size;
GTK_WIDGET_CLASS (gtk_revealer_parent_class)->measure (widget,
orientation,
for_size,
- &min_size, &nat_size,
+ minimum, natural,
NULL, NULL);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- set_width_with_paddings (GTK_REVEALER (widget), min_size, nat_size, minimum, natural);
+ set_width (GTK_REVEALER (widget), minimum, natural);
else
- set_height_with_paddings (GTK_REVEALER (widget), min_size, nat_size, minimum, natural);
+ set_height (GTK_REVEALER (widget), minimum, natural);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]