API: widget: Add gtk_widget_get_allocated_size()

See docs for what this is.
This commit is contained in:
Benjamin Otte 2015-09-14 06:11:36 +02:00
parent ab2d236d3d
commit d3d9f52365
4 changed files with 48 additions and 0 deletions

View File

@ -5553,6 +5553,7 @@ gtk_widget_get_allocated_height
gtk_widget_get_allocation gtk_widget_get_allocation
gtk_widget_set_allocation gtk_widget_set_allocation
gtk_widget_get_allocated_baseline gtk_widget_get_allocated_baseline
gtk_widget_get_allocated_size
gtk_widget_get_clip gtk_widget_get_clip
gtk_widget_set_clip gtk_widget_set_clip
gtk_widget_get_app_paintable gtk_widget_get_app_paintable

View File

@ -5864,6 +5864,9 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
old_baseline = priv->allocated_baseline; old_baseline = priv->allocated_baseline;
real_allocation = *allocation; real_allocation = *allocation;
priv->allocated_size = *allocation;
priv->allocated_size_baseline = baseline;
adjusted_allocation = real_allocation; adjusted_allocation = real_allocation;
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH) if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{ {
@ -8898,6 +8901,8 @@ _gtk_widget_set_visible_flag (GtkWidget *widget,
priv->allocation.width = 1; priv->allocation.width = 1;
priv->allocation.height = 1; priv->allocation.height = 1;
memset (&priv->clip, 0, sizeof (priv->clip)); memset (&priv->clip, 0, sizeof (priv->clip));
memset (&priv->allocated_size, 0, sizeof (priv->allocated_size));
priv->allocated_size_baseline = 0;
} }
} }
@ -15532,6 +15537,42 @@ _gtk_widget_set_simple_clip (GtkWidget *widget,
gtk_widget_set_clip (widget, &clip); gtk_widget_set_clip (widget, &clip);
} }
/**
* gtk_widget_get_allocated_size:
* @widget: a #GtkWidget
* @allocation: (out) (allow-none): a pointer to a #GtkAllocation to copy to
* @baseline: (out) (allow-none): a pointer to an integer to copy to
*
* Retrieves the widgets allocated size.
*
* This function returns the last values passed to
* gtk_widget_size_allocate_with_baseline(). The value differs from
* the size returned in gtk_widget_get_allocation() in that functions
* like gtk_widget_set_halign() can adjust the allocation, but not
* the value returned by this function.
*
* If a widget is not visible, its allocated size is 0.
*
* Since: 3.20
*/
void
gtk_widget_get_allocated_size (GtkWidget *widget,
GtkAllocation *allocation,
int *baseline)
{
GtkWidgetPrivate *priv;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (allocation != NULL);
priv = widget->priv;
if (allocation)
*allocation = priv->allocated_size;
if (baseline)
*baseline = priv->allocated_size_baseline;
}
/** /**
* gtk_widget_get_allocation: * gtk_widget_get_allocation:
* @widget: a #GtkWidget * @widget: a #GtkWidget

View File

@ -918,6 +918,10 @@ GDK_AVAILABLE_IN_ALL
int gtk_widget_get_allocated_height (GtkWidget *widget); int gtk_widget_get_allocated_height (GtkWidget *widget);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
int gtk_widget_get_allocated_baseline (GtkWidget *widget); int gtk_widget_get_allocated_baseline (GtkWidget *widget);
GDK_AVAILABLE_IN_3_20
void gtk_widget_get_allocated_size (GtkWidget *widget,
GtkAllocation *allocation,
int *baseline);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_widget_get_allocation (GtkWidget *widget, void gtk_widget_get_allocation (GtkWidget *widget,

View File

@ -130,6 +130,8 @@ struct _GtkWidgetPrivate
GtkStyleContext *context; GtkStyleContext *context;
/* The widget's allocated size */ /* The widget's allocated size */
GtkAllocation allocated_size;
gint allocated_size_baseline;
GtkAllocation allocation; GtkAllocation allocation;
GtkAllocation clip; GtkAllocation clip;
gint allocated_baseline; gint allocated_baseline;