summaryrefslogtreecommitdiff
path: root/gtk/gtkstack.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2016-10-22 16:06:14 +0200
committerTimm Bäder <mail@baedert.org>2016-10-22 19:05:47 +0200
commit9992a616efa47205ac16ed8be255eda5e7aadf6c (patch)
tree3879538642de33a77472bafe3e6e8afea3b3e343 /gtk/gtkstack.c
parent6525b95e2502080c08b65317c910204c2b6125da (diff)
downloadgtk+-9992a616efa47205ac16ed8be255eda5e7aadf6c.tar.gz
widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget implementations have to override instead of the old get_preferred_width, get_preferred_height, get_preferred_width_for_height, get_preferred_height_for_width and get_preferred_height_and_baseline_for_width.
Diffstat (limited to 'gtk/gtkstack.c')
-rw-r--r--gtk/gtkstack.c93
1 files changed, 19 insertions, 74 deletions
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index bed1fe67cd..fb30df8ea7 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -178,20 +178,13 @@ static void gtk_stack_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_stack_draw (GtkWidget *widget,
cairo_t *cr);
-static void gtk_stack_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height);
-static void gtk_stack_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-static void gtk_stack_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static void gtk_stack_get_preferred_width_for_height (GtkWidget *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width);
+static void gtk_stack_measure_ (GtkWidget *widget,
+ GtkOrientation orientation,
+ int for_size,
+ int *minimum,
+ int *natural,
+ int *minimum_baseline,
+ int *natural_baseline);
static void gtk_stack_finalize (GObject *obj);
static void gtk_stack_get_property (GObject *object,
guint property_id,
@@ -433,10 +426,7 @@ gtk_stack_class_init (GtkStackClass *klass)
widget_class->unrealize = gtk_stack_unrealize;
widget_class->map = gtk_stack_map;
widget_class->unmap = gtk_stack_unmap;
- widget_class->get_preferred_height = gtk_stack_get_preferred_height;
- widget_class->get_preferred_height_for_width = gtk_stack_get_preferred_height_for_width;
- widget_class->get_preferred_width = gtk_stack_get_preferred_width;
- widget_class->get_preferred_width_for_height = gtk_stack_get_preferred_width_for_height;
+ widget_class->measure = gtk_stack_measure_;
widget_class->compute_expand = gtk_stack_compute_expand;
container_class->add = gtk_stack_add;
@@ -2287,67 +2277,22 @@ gtk_stack_allocate (GtkCssGadget *gadget,
gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
}
-
-static void
-gtk_stack_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GtkStack *stack = GTK_STACK (widget);
- GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
-
- gtk_css_gadget_get_preferred_size (priv->gadget,
- GTK_ORIENTATION_HORIZONTAL,
- -1,
- minimum, natural,
- NULL, NULL);
-}
-
-static void
-gtk_stack_get_preferred_width_for_height (GtkWidget *widget,
- gint height,
- gint *minimum,
- gint *natural)
-{
- GtkStack *stack = GTK_STACK (widget);
- GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
-
- gtk_css_gadget_get_preferred_size (priv->gadget,
- GTK_ORIENTATION_HORIZONTAL,
- height,
- minimum, natural,
- NULL, NULL);
-}
-
static void
-gtk_stack_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
+gtk_stack_measure_ (GtkWidget *widget,
+ GtkOrientation orientation,
+ int for_size,
+ int *minimum,
+ int *natural,
+ int *minimum_baseline,
+ int *natural_baseline)
{
- GtkStack *stack = GTK_STACK (widget);
- GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
-
- gtk_css_gadget_get_preferred_size (priv->gadget,
- GTK_ORIENTATION_VERTICAL,
- -1,
- minimum, natural,
- NULL, NULL);
-}
-
-static void
-gtk_stack_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum,
- gint *natural)
-{
- GtkStack *stack = GTK_STACK (widget);
- GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
+ GtkStackPrivate *priv = gtk_stack_get_instance_private (GTK_STACK (widget));
gtk_css_gadget_get_preferred_size (priv->gadget,
- GTK_ORIENTATION_VERTICAL,
- width,
+ orientation,
+ for_size,
minimum, natural,
- NULL, NULL);
+ minimum_baseline, natural_baseline);
}
#define LERP(a, b, t) ((a) + (((b) - (a)) * (1.0 - (t))))