[gtk] widget: Save baseline without CSS values applied
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] widget: Save baseline without CSS values applied
- Date: Tue, 27 Nov 2018 05:18:51 +0000 (UTC)
commit f92745aacf70e88e5b4ec62dd27e2911fa3e8e31
Author: Timm Bäder <mail baedert org>
Date: Tue Nov 27 05:59:47 2018 +0100
widget: Save baseline without CSS values applied
Similar to what we do with width/height.
gtk/gtkwidget.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index eeb5bc6423..a05bc068cc 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -662,9 +662,6 @@ static GtkSizeRequestMode gtk_widget_real_get_request_mode (GtkWidget
static void gtk_widget_queue_tooltip_query (GtkWidget *widget);
-static void gtk_widget_adjust_baseline_allocation (GtkWidget *widget,
- gint *baseline);
-
static void template_data_free (GtkWidgetTemplate*template_data);
static void gtk_widget_set_usize_internal (GtkWidget *widget,
@@ -4185,10 +4182,7 @@ gtk_widget_size_allocate (GtkWidget *widget,
&adjusted_allocation.y,
&adjusted_allocation.height);
if (baseline >= 0)
- {
- gtk_widget_adjust_baseline_allocation (widget, &baseline);
- baseline -= margin.top + border.top + padding.top;
- }
+ baseline -= priv->margin.top;
if (adjusted_allocation.x < real_allocation.x ||
adjusted_allocation.y < real_allocation.y ||
@@ -4260,6 +4254,9 @@ gtk_widget_size_allocate (GtkWidget *widget,
real_allocation.height -= margin.top + border.top + padding.top +
margin.bottom + border.bottom + padding.bottom;
+ if (baseline >= 0)
+ baseline -= margin.top + border.top + padding.top;
+
if (g_signal_has_handler_pending (widget, widget_signals[SIZE_ALLOCATE], 0, FALSE))
g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0,
real_allocation.width,
@@ -4640,15 +4637,6 @@ gtk_widget_adjust_size_allocation (GtkWidget *widget,
}
}
-static void
-gtk_widget_adjust_baseline_allocation (GtkWidget *widget,
- gint *baseline)
-{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
-
- *baseline -= priv->margin.top;
-}
-
static gboolean
gtk_widget_real_can_activate_accel (GtkWidget *widget,
guint signal_id)
@@ -11430,10 +11418,20 @@ int
gtk_widget_get_allocated_baseline (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GtkCssStyle *style;
+ GtkBorder margin, border, padding;
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
- return priv->allocated_baseline;
+ if (priv->allocated_baseline == -1)
+ return -1;
+
+ style = gtk_css_node_get_style (priv->cssnode);
+ get_box_margin (style, &margin);
+ get_box_border (style, &border);
+ get_box_padding (style, &padding);
+
+ return priv->allocated_baseline - margin.top - border.top - padding.top;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]