[gtk+/portal-race: 62/129] widget: Add new allocation accessors
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/portal-race: 62/129] widget: Add new allocation accessors
- Date: Sun, 2 Jul 2017 18:41:31 +0000 (UTC)
commit ce7e967cb2ef3932a300faa44b55c2ead0b8d60b
Author: Timm Bäder <mail baedert org>
Date: Fri Jun 16 18:08:04 2017 +0200
widget: Add new allocation accessors
gtk/gtkwidget.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkwidgetprivate.h | 8 ++++++-
2 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 0e67b66..d3aad7d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13529,6 +13529,57 @@ gtk_widget_get_allocation (GtkWidget *widget,
}
void
+gtk_widget_get_outer_allocation (GtkWidget *widget,
+ GdkRectangle *allocation)
+{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GtkBorder margin;
+ GtkCssStyle *style;
+
+ style = gtk_css_node_get_style (priv->cssnode);
+ get_box_margin (style, &margin);
+
+ *allocation = priv->allocation;
+
+ allocation->x += margin.left;
+ allocation->y += margin.top;
+ allocation->width -= margin.left + margin.right;
+ allocation->height -= margin.top + margin.bottom;
+}
+
+void
+gtk_widget_get_own_allocation (GtkWidget *widget,
+ GdkRectangle *allocation)
+{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GtkBorder margin, border, padding;
+ GtkCssStyle *style;
+
+ style = gtk_css_node_get_style (priv->cssnode);
+ get_box_margin (style, &margin);
+ get_box_border (style, &border);
+ get_box_padding (style, &padding);
+
+ allocation->x = -padding.left - border.left;
+ allocation->y = -padding.top - border.top;
+ allocation->width = priv->allocation.width - margin.left - margin.right;
+ allocation->height = priv->allocation.height -margin.top - margin.bottom;
+}
+
+void
+gtk_widget_get_content_size (GtkWidget *widget,
+ int *width,
+ int *height)
+{
+ GtkAllocation alloc;
+
+ gtk_widget_get_content_allocation (widget, &alloc);
+
+ *width = alloc.width;
+ *height = alloc.height;
+}
+
+void
gtk_widget_get_content_allocation (GtkWidget *widget,
GtkAllocation *allocation)
{
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 6702c86..18f7dc4 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -324,7 +324,13 @@ void gtk_widget_get_border_allocation (GtkWidget *wi
GtkAllocation *allocation);
void gtk_widget_get_margin_allocation (GtkWidget *widget,
GtkAllocation *allocation);
-
+void gtk_widget_get_outer_allocation (GtkWidget *widget,
+ GtkAllocation *allocation);
+void gtk_widget_get_own_allocation (GtkWidget *widget,
+ GtkAllocation *allocation);
+void gtk_widget_get_content_size (GtkWidget *widget,
+ int *width,
+ int *height);
GtkWidget * gtk_widget_common_ancestor (GtkWidget *widget_a,
GtkWidget *widget_b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]