[gnome-shell/wip/clutter-deprecation-fixes: 9/27] st-scroll-bar: Clean up get_preferred_width/height
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/clutter-deprecation-fixes: 9/27] st-scroll-bar: Clean up get_preferred_width/height
- Date: Tue, 14 Feb 2012 16:48:41 +0000 (UTC)
commit d44ebb6b4edaef3a0dc36295e04340bdab9c4a1d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Feb 13 23:18:36 2012 -0500
st-scroll-bar: Clean up get_preferred_width/height
With the steppers gone, we can remove this macro madness
src/st/st-scroll-bar.c | 90 ++++++++++++++++--------------------------------
1 files changed, 30 insertions(+), 60 deletions(-)
---
diff --git a/src/st/st-scroll-bar.c b/src/st/st-scroll-bar.c
index e6d1062..9c41dcb 100644
--- a/src/st/st-scroll-bar.c
+++ b/src/st/st-scroll-bar.c
@@ -323,47 +323,32 @@ st_scroll_bar_get_preferred_width (ClutterActor *self,
StScrollBar *bar = ST_SCROLL_BAR (self);
StScrollBarPrivate *priv = bar->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
+ gfloat trough_min_width, trough_natural_width;
+ gfloat handle_min_width, handle_natural_width;
st_theme_node_adjust_for_height (theme_node, &for_height);
- if (min_width_p)
- *min_width_p = 0;
+ _st_actor_get_preferred_width (priv->trough, for_height, TRUE,
+ &trough_min_width, &trough_natural_width);
+
+ _st_actor_get_preferred_width (priv->handle, for_height, TRUE,
+ &handle_min_width, &handle_natural_width);
- if (natural_width_p)
- *natural_width_p = 0;
if (priv->vertical)
{
- gfloat tmin_width_p, tnatural_width_p;
-
- #define ADJUST_WIDTH_IF_LARGER(actor) \
- _st_actor_get_preferred_width (actor, for_height, TRUE, \
- &tmin_width_p, &tnatural_width_p); \
- if (min_width_p && tmin_width_p > *min_width_p) \
- *min_width_p = tmin_width_p; \
- if (natural_width_p && tnatural_width_p > *natural_width_p) \
- *natural_width_p = tnatural_width_p;
-
- ADJUST_WIDTH_IF_LARGER (priv->trough);
- ADJUST_WIDTH_IF_LARGER (priv->handle);
+ if (min_width_p)
+ *min_width_p = MAX (trough_min_width, handle_min_width);
- #undef ADJUST_WIDTH_IF_LARGER
+ if (natural_width_p)
+ *natural_width_p = MAX (trough_natural_width, handle_natural_width);
}
else
{
- gfloat tmin_width_p, tnatural_width_p;
-
- #define ADD_TO_WIDTH(actor) \
- _st_actor_get_preferred_width (actor, for_height, TRUE, \
- &tmin_width_p, &tnatural_width_p); \
- if (min_width_p) \
- *min_width_p += tmin_width_p; \
- if (natural_width_p ) \
- *natural_width_p += tnatural_width_p;
-
- ADD_TO_WIDTH (priv->trough);
- ADD_TO_WIDTH (priv->handle);
+ if (min_width_p)
+ *min_width_p = trough_min_width + handle_min_width;
- #undef ADD_TO_WIDTH
+ if (natural_width_p)
+ *natural_width_p = trough_natural_width + handle_natural_width;
}
st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p);
@@ -378,47 +363,32 @@ st_scroll_bar_get_preferred_height (ClutterActor *self,
StScrollBar *bar = ST_SCROLL_BAR (self);
StScrollBarPrivate *priv = bar->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
+ gfloat trough_min_height, trough_natural_height;
+ gfloat handle_min_height, handle_natural_height;
st_theme_node_adjust_for_width (theme_node, &for_width);
- if (min_height_p)
- *min_height_p = 0;
+ _st_actor_get_preferred_height (priv->trough, for_width, TRUE,
+ &trough_min_height, &trough_natural_height);
+
+ _st_actor_get_preferred_height (priv->handle, for_width, TRUE,
+ &handle_min_height, &handle_natural_height);
- if (natural_height_p)
- *natural_height_p = 0;
if (priv->vertical)
{
- gfloat tmin_height_p, tnatural_height_p;
-
- #define ADD_TO_HEIGHT(actor) \
- _st_actor_get_preferred_height (actor, for_width, FALSE, \
- &tmin_height_p, &tnatural_height_p); \
- if (min_height_p) \
- *min_height_p += tmin_height_p; \
- if (natural_height_p) \
- *natural_height_p += tnatural_height_p;
-
- ADD_TO_HEIGHT (priv->trough);
- ADD_TO_HEIGHT (priv->handle);
+ if (min_height_p)
+ *min_height_p = trough_min_height + handle_min_height;
- #undef ADD_TO_HEIGHT
+ if (natural_height_p)
+ *natural_height_p = trough_natural_height + handle_natural_height;
}
else
{
- gfloat tmin_height_p, tnatural_height_p;
-
- #define ADJUST_HEIGHT_IF_LARGER(actor) \
- _st_actor_get_preferred_height (actor, for_width, FALSE, \
- &tmin_height_p, &tnatural_height_p); \
- if (min_height_p && tmin_height_p > *min_height_p) \
- *min_height_p = tmin_height_p; \
- if (natural_height_p && tnatural_height_p > *natural_height_p) \
- *natural_height_p = tnatural_height_p;
-
- ADJUST_HEIGHT_IF_LARGER (priv->trough);
- ADJUST_HEIGHT_IF_LARGER (priv->handle);
+ if (min_height_p)
+ *min_height_p = MAX (trough_min_height, handle_min_height);
- #undef ADJUST_HEIGHT_IF_LARGER
+ if (natural_height_p)
+ *natural_height_p = MAX (trough_natural_height, handle_natural_height);
}
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]