[gtk+/wip/baseline2] Add gtk_widget_get_preferred_size_and_baseline
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baseline2] Add gtk_widget_get_preferred_size_and_baseline
- Date: Mon, 25 Mar 2013 16:57:18 +0000 (UTC)
commit 7918b3d1a3d46116b27c0ab903bf2e86233cc996
Author: Alexander Larsson <alexl redhat com>
Date: Mon Mar 25 17:55:59 2013 +0100
Add gtk_widget_get_preferred_size_and_baseline
This is needed by baseline & h4w/w4h aware containers.
gtk/gtksizerequest.c | 68 ++++++++++++++++++++++++++++---------------------
gtk/gtkwidget.h | 5 +++
2 files changed, 44 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index dfc776c..9c23af9 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -576,31 +576,12 @@ gtk_widget_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
natural_baseline);
}
-/**
- * gtk_widget_get_preferred_size:
- * @widget: a #GtkWidget instance
- * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
- * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
- *
- * Retrieves the minimum and natural size of a widget, taking
- * into account the widget's preference for height-for-width management.
- *
- * This is used to retrieve a suitable size by container widgets which do
- * not impose any restrictions on the child placement. It can be used
- * to deduce toplevel window and menu sizes as well as child widgets in
- * free-form containers such as GtkLayout.
- *
- * <note><para>Handle with care. Note that the natural height of a height-for-width
- * widget will generally be a smaller size than the minimum height, since the required
- * height for the natural width is generally smaller than the required height for
- * the minimum width.</para></note>
- *
- * Since: 3.0
- */
void
-gtk_widget_get_preferred_size (GtkWidget *widget,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
+gtk_widget_get_preferred_size_and_baseline (GtkWidget *widget,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size,
+ gint *minimum_baseline,
+ gint *natural_baseline)
{
gint min_width, nat_width;
gint min_height, nat_height;
@@ -614,20 +595,20 @@ gtk_widget_get_preferred_size (GtkWidget *widget,
if (minimum_size)
{
minimum_size->width = min_width;
- gtk_widget_get_preferred_height_for_width (widget, min_width,
- &minimum_size->height, NULL);
+ gtk_widget_get_preferred_height_and_baseline_for_width (widget, min_width,
+ &minimum_size->height, NULL,
minimum_baseline, NULL);
}
if (natural_size)
{
natural_size->width = nat_width;
- gtk_widget_get_preferred_height_for_width (widget, nat_width,
- NULL, &natural_size->height);
+ gtk_widget_get_preferred_height_and_baseline_for_width (widget, nat_width,
+ NULL, &natural_size->height, NULL,
natural_baseline);
}
}
else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT or CONSTANT_SIZE */
{
- gtk_widget_get_preferred_height (widget, &min_height, &nat_height);
+ gtk_widget_get_preferred_height_and_baseline_for_width (widget, -1, &min_height, &nat_height,
minimum_baseline, natural_baseline);
if (minimum_size)
{
@@ -645,6 +626,35 @@ gtk_widget_get_preferred_size (GtkWidget *widget,
}
}
+/**
+ * gtk_widget_get_preferred_size:
+ * @widget: a #GtkWidget instance
+ * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
+ * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
+ *
+ * Retrieves the minimum and natural size of a widget, taking
+ * into account the widget's preference for height-for-width management.
+ *
+ * This is used to retrieve a suitable size by container widgets which do
+ * not impose any restrictions on the child placement. It can be used
+ * to deduce toplevel window and menu sizes as well as child widgets in
+ * free-form containers such as GtkLayout.
+ *
+ * <note><para>Handle with care. Note that the natural height of a height-for-width
+ * widget will generally be a smaller size than the minimum height, since the required
+ * height for the natural width is generally smaller than the required height for
+ * the minimum width.</para></note>
+ *
+ * Since: 3.0
+ */
+void
+gtk_widget_get_preferred_size (GtkWidget *widget,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size)
+{
+ gtk_widget_get_preferred_size_and_baseline (widget, minimum_size, natural_size,
+ NULL, NULL);
+}
static gint
compare_gap (gconstpointer p1,
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 6fbdecf..4a1202c 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -535,6 +535,11 @@ void gtk_widget_get_preferred_height_and_baseline_for_width (GtkWidget *wi
void gtk_widget_get_preferred_size (GtkWidget *widget,
GtkRequisition *minimum_size,
GtkRequisition *natural_size);
+void gtk_widget_get_preferred_size_and_baseline (GtkWidget *widget,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size,
+ gint *minimum_baseline,
+ gint *natural_baseline);
GDK_DEPRECATED_IN_3_0_FOR(gtk_widget_get_preferred_size)
void gtk_widget_get_child_requisition (GtkWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]