diff options
author | Timm Bäder <mail@baedert.org> | 2016-10-22 16:06:14 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2016-10-22 19:05:47 +0200 |
commit | 9992a616efa47205ac16ed8be255eda5e7aadf6c (patch) | |
tree | 3879538642de33a77472bafe3e6e8afea3b3e343 /gtk/gtkfixed.c | |
parent | 6525b95e2502080c08b65317c910204c2b6125da (diff) | |
download | gtk+-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/gtkfixed.c')
-rw-r--r-- | gtk/gtkfixed.c | 70 |
1 files changed, 28 insertions, 42 deletions
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 9e6b681036..2e57c661b9 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -86,12 +86,15 @@ enum { }; static void gtk_fixed_realize (GtkWidget *widget); -static void gtk_fixed_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_fixed_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural); +static void gtk_fixed_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minimum_baseline, + int *natural_baseline); + + static void gtk_fixed_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gboolean gtk_fixed_draw (GtkWidget *widget, @@ -129,8 +132,7 @@ gtk_fixed_class_init (GtkFixedClass *class) container_class = (GtkContainerClass*) class; widget_class->realize = gtk_fixed_realize; - widget_class->get_preferred_width = gtk_fixed_get_preferred_width; - widget_class->get_preferred_height = gtk_fixed_get_preferred_height; + widget_class->measure = gtk_fixed_measure; widget_class->size_allocate = gtk_fixed_size_allocate; widget_class->draw = gtk_fixed_draw; @@ -368,9 +370,13 @@ gtk_fixed_realize (GtkWidget *widget) } static void -gtk_fixed_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) +gtk_fixed_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minimum_baseline, + int *natural_baseline) { GtkFixed *fixed = GTK_FIXED (widget); GtkFixedPrivate *priv = fixed->priv; @@ -388,38 +394,18 @@ gtk_fixed_get_preferred_width (GtkWidget *widget, if (!gtk_widget_get_visible (child->widget)) continue; - gtk_widget_get_preferred_width (child->widget, &child_min, &child_nat); - - *minimum = MAX (*minimum, child->x + child_min); - *natural = MAX (*natural, child->x + child_nat); - } -} - -static void -gtk_fixed_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkFixed *fixed = GTK_FIXED (widget); - GtkFixedPrivate *priv = fixed->priv; - GtkFixedChild *child; - GList *children; - gint child_min, child_nat; + gtk_widget_measure (child->widget, orientation, -1, &child_min, &child_nat, NULL, NULL); - *minimum = 0; - *natural = 0; - - for (children = priv->children; children; children = children->next) - { - child = children->data; - - if (!gtk_widget_get_visible (child->widget)) - continue; - - gtk_widget_get_preferred_height (child->widget, &child_min, &child_nat); - - *minimum = MAX (*minimum, child->y + child_min); - *natural = MAX (*natural, child->y + child_nat); + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + *minimum = MAX (*minimum, child->x + child_min); + *natural = MAX (*natural, child->x + child_nat); + } + else /* VERTICAL */ + { + *minimum = MAX (*minimum, child->y + child_min); + *natural = MAX (*natural, child->y + child_nat); + } } } |