summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-04-28 15:18:13 -0400
committerMatthias Clasen <mclasen@redhat.com>2023-04-28 15:18:13 -0400
commit3ea289751db4b2b6afc160151cf91431dd38d620 (patch)
treeb8e224712738d2672c0ed01aba142f3338b86b51
parent8205c7032a66c85a302e0b27ad44bdeed535e374 (diff)
downloadgtk+-3ea289751db4b2b6afc160151cf91431dd38d620.tar.gz
Add gtk_widget_get_baseline
This is just a renaming of gtk_widget_get_allocated_baseline that fits better with gtk_widget_get_width/height.
-rw-r--r--gtk/gtkwidget.c22
-rw-r--r--gtk/gtkwidget.h2
2 files changed, 23 insertions, 1 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 20bb2eba25..dc9cb14cf3 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -241,7 +241,7 @@
*
* If a widget ends up baseline aligned it will be allocated all the space in
* the parent as if it was %GTK_ALIGN_FILL, but the selected baseline can be
- * found via [id@gtk_widget_get_allocated_baseline]. If the baseline has a
+ * found via [id@gtk_widget_get_baseline]. If the baseline has a
* value other than -1 you need to align the widget such that the baseline
* appears at the position.
*
@@ -10480,6 +10480,26 @@ gtk_widget_get_allocated_height (GtkWidget *widget)
int
gtk_widget_get_allocated_baseline (GtkWidget *widget)
{
+ return gtk_widget_get_baseline (widget);
+}
+
+/**
+ * gtk_widget_get_baseline:
+ * @widget: the widget to query
+ *
+ * Returns the baseline that has currently been allocated to @widget.
+ *
+ * This function is intended to be used when implementing handlers
+ * for the `GtkWidget`Class.snapshot() function, and when allocating
+ * child widgets in `GtkWidget`Class.size_allocate().
+ *
+ * Returns: the baseline of the @widget, or -1 if none
+ *
+ * Since: 4.12
+ */
+int
+gtk_widget_get_baseline (GtkWidget *widget)
+{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkCssStyle *style;
GtkBorder margin, border, padding;
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 7b39d83901..70ddb1b91a 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -497,6 +497,8 @@ GDK_AVAILABLE_IN_ALL
int gtk_widget_get_width (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
int gtk_widget_get_height (GtkWidget *widget);
+GDK_AVAILABLE_IN_4_12
+int gtk_widget_get_baseline (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
int gtk_widget_get_size (GtkWidget *widget,
GtkOrientation orientation);