static void st_bin_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StBinPrivate *priv = ST_BIN (self)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); st_theme_node_adjust_for_height (theme_node, &for_height); if (priv->child == NULL) { if (min_width_p) *min_width_p = 0; if (natural_width_p) *natural_width_p = 0; } else { _st_actor_get_preferred_width (priv->child, for_height, priv->y_fill, min_width_p, natural_width_p); } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void shell_slicer_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { ClutterActor *child = st_bin_get_child (ST_BIN (self)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); st_theme_node_adjust_for_height (theme_node, &for_height); if (min_width_p) *min_width_p = 0; if (child == NULL) { if (natural_width_p) *natural_width_p = 0; } else { _st_actor_get_preferred_width (child, for_height, FALSE, NULL, natural_width_p); } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_bar_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollBar *bar = ST_SCROLL_BAR (self); StScrollBarPrivate *priv = bar->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); st_theme_node_adjust_for_height (theme_node, &for_height); if (min_width_p) *min_width_p = 0; 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->bw_stepper); ADJUST_WIDTH_IF_LARGER (priv->fw_stepper); ADJUST_WIDTH_IF_LARGER (priv->trough); ADJUST_WIDTH_IF_LARGER (priv->handle); #undef ADJUST_WIDTH_IF_LARGER } 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->bw_stepper); ADD_TO_WIDTH (priv->fw_stepper); ADD_TO_WIDTH (priv->trough); ADD_TO_WIDTH (priv->handle); #undef ADD_TO_WIDTH } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_view_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gfloat min_width = 0, natural_width; gfloat child_min_width, child_natural_width; if (!priv->child) return; st_theme_node_adjust_for_height (theme_node, &for_height); clutter_actor_get_preferred_width (priv->child, -1, &child_min_width, &child_natural_width); natural_width = child_natural_width; switch (priv->hscrollbar_policy) { case GTK_POLICY_NEVER: min_width = child_min_width; break; case GTK_POLICY_ALWAYS: case GTK_POLICY_AUTOMATIC: case GTK_POLICY_EXTERNAL: /* Should theoretically use the min width of the hscrollbar, * but that's not cleanly defined at the moment */ min_width = 0; break; default: g_warn_if_reached(); break; } if (priv->vscrollbar_policy != GTK_POLICY_NEVER) { float sb_width = get_scrollbar_width (ST_SCROLL_VIEW (actor), for_height); min_width += sb_width; natural_width += sb_width; } if (min_width_p) *min_width_p = min_width; if (natural_width_p) *natural_width_p = natural_width; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void sagarmatha_stack_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { SagarmathaStack *stack = SAGARMATHA_STACK (actor); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gboolean first = TRUE; float min = 0, natural = 0; GList *iter; GList *children; st_theme_node_adjust_for_height (theme_node, &for_height); children = st_container_get_children_list (ST_CONTAINER (stack)); for (iter = children; iter; iter = iter->next) { ClutterActor *child = iter->data; float child_min, child_natural; clutter_actor_get_preferred_width (child, for_height, &child_min, &child_natural); if (first) { first = FALSE; min = child_min; natural = child_natural; } else { if (child_min > min) min = child_min; if (child_natural > natural) natural = child_natural; } } if (min_width_p) *min_width_p = min; if (natural_width_p) *natural_width_p = natural; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_table_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { gfloat total_min_width, total_pref_width; StTablePrivate *priv = ST_TABLE (self)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); gint i; DimensionData *columns; if (priv->n_cols < 1) { *min_width_p = 0; *natural_width_p = 0; return; } /* use min_widths to help allocation of height-for-width widgets */ st_table_calculate_dimensions (ST_TABLE (self), -1, for_height); columns = &g_array_index (priv->columns, DimensionData, 0); /* start off with row spacing */ total_min_width = (priv->visible_cols - 1) * (float)(priv->col_spacing); total_pref_width = total_min_width; for (i = 0; i < priv->n_cols; i++) { total_min_width += columns[i].min_size; total_pref_width += columns[i].pref_size; } /* If we were requested width-for-height, then we reported minimum/natural * heights based on our natural width. If we were allocated less than our * natural width, then we need more height. So in the width-for-height * case we need to disable shrinking. */ if (for_height >= 0) total_min_width = total_pref_width; if (min_width_p) *min_width_p = total_min_width; if (natural_width_p) *natural_width_p = total_pref_width; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void shell_stack_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gboolean first = TRUE; float min = 0, natural = 0; ClutterActor *child; st_theme_node_adjust_for_height (theme_node, &for_height); for (child = clutter_actor_get_first_child (actor); child != NULL; child = clutter_actor_get_next_sibling (child)) { float child_min, child_natural; clutter_actor_get_preferred_width (child, for_height, &child_min, &child_natural); if (first) { first = FALSE; min = child_min; natural = child_natural; } else { if (child_min > min) min = child_min; if (child_natural > natural) natural = child_natural; } } if (min_width_p) *min_width_p = min; if (natural_width_p) *natural_width_p = natural; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_box_layout_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); st_theme_node_adjust_for_height (theme_node, &for_height); get_content_preferred_width (ST_BOX_LAYOUT (actor), for_height, min_width_p, natural_width_p); st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_icon_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *nat_width_p) { StIconPrivate *priv = ST_ICON (actor)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); if (min_width_p) *min_width_p = priv->icon_size; if (nat_width_p) *nat_width_p = priv->icon_size; st_theme_node_adjust_preferred_width (theme_node, min_width_p, nat_width_p); }
static void st_entry_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StEntryPrivate *priv = ST_ENTRY_PRIV (actor); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gfloat icon_w; st_theme_node_adjust_for_height (theme_node, &for_height); clutter_actor_get_preferred_width (priv->entry, for_height, min_width_p, natural_width_p); if (priv->primary_icon) { clutter_actor_get_preferred_width (priv->primary_icon, -1, NULL, &icon_w); if (min_width_p) *min_width_p += icon_w + priv->spacing; if (natural_width_p) *natural_width_p += icon_w + priv->spacing; } if (priv->secondary_icon) { clutter_actor_get_preferred_width (priv->secondary_icon, -1, NULL, &icon_w); if (min_width_p) *min_width_p += icon_w + priv->spacing; if (natural_width_p) *natural_width_p += icon_w + priv->spacing; } st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void cinnamon_generic_container_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { CinnamonGenericContainerAllocation *alloc = g_slice_new0 (CinnamonGenericContainerAllocation); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); st_theme_node_adjust_for_height (theme_node, &for_height); alloc->_refcount = 1; g_signal_emit (G_OBJECT (actor), cinnamon_generic_container_signals[GET_PREFERRED_WIDTH], 0, for_height, alloc); if (min_width_p) *min_width_p = alloc->min_size; if (natural_width_p) *natural_width_p = alloc->natural_size; cinnamon_generic_container_allocation_unref (alloc); st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_bar_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { 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); _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 (priv->vertical) { if (min_width_p) *min_width_p = MAX (trough_min_width, handle_min_width); if (natural_width_p) *natural_width_p = MAX (trough_natural_width, handle_natural_width); } else { if (min_width_p) *min_width_p = trough_min_width + handle_min_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); }
static void st_widget_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); /* Most subclasses will override this and not chain down. However, * if they do not, then we need to override ClutterActor's default * behavior (request 0x0) to take CSS-specified minimums into * account (which st_theme_node_adjust_preferred_width() will do.) */ if (min_width_p) *min_width_p = 0; if (natural_width_p) *natural_width_p = 0; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_table_get_preferred_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { gint *min_widths, *pref_widths; gfloat total_min_width, total_pref_width; StTablePrivate *priv = ST_TABLE (self)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); gint i; ClutterActor *child; if (priv->n_cols < 1) { *min_width_p = 0; *natural_width_p = 0; return; } /* Setting size to zero and then what we want it to be causes a clear if * clear flag is set (which it should be.) */ g_array_set_size (priv->min_widths, 0); g_array_set_size (priv->pref_widths, 0); g_array_set_size (priv->min_widths, priv->n_cols); g_array_set_size (priv->pref_widths, priv->n_cols); min_widths = (gint *) priv->min_widths->data; pref_widths = (gint *) priv->pref_widths->data; /* calculate minimum row widths */ for (child = clutter_actor_get_first_child (self); child != NULL; child = clutter_actor_get_next_sibling (child)) { gint col, col_span; gfloat w_min, w_pref; StTableChild *meta; meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child); if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child)) continue; /* get child properties */ col = meta->col; col_span = meta->col_span; _st_actor_get_preferred_width (child, -1, meta->y_fill, &w_min, &w_pref); if (col_span == 1 && w_min > min_widths[col]) min_widths[col] = w_min; if (col_span == 1 && w_pref > pref_widths[col]) pref_widths[col] = w_pref; } total_min_width = (priv->n_cols - 1) * (float) priv->col_spacing; total_pref_width = total_min_width; for (i = 0; i < priv->n_cols; i++) { total_min_width += min_widths[i]; total_pref_width += pref_widths[i]; } /* If we were requested width-for-height, then we reported minimum/natural * heights based on our natural width. If we were allocated less than our * natural width, then we need more height. So in the width-for-height * case we need to disable shrinking. */ if (for_height >= 0) total_min_width = total_pref_width; if (min_width_p) *min_width_p = total_min_width; if (natural_width_p) *natural_width_p = total_pref_width; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }
static void st_scroll_view_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv; StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); gboolean account_for_vscrollbar = FALSE; gfloat min_width = 0, natural_width; gfloat child_min_width, child_natural_width; if (!priv->child) return; st_theme_node_adjust_for_height (theme_node, &for_height); clutter_actor_get_preferred_width (priv->child, -1, &child_min_width, &child_natural_width); natural_width = child_natural_width; switch (priv->hscrollbar_policy) { case GTK_POLICY_NEVER: min_width = child_min_width; break; case GTK_POLICY_ALWAYS: case GTK_POLICY_AUTOMATIC: /* Should theoretically use the min width of the hscrollbar, * but that's not cleanly defined at the moment */ min_width = 0; break; } switch (priv->vscrollbar_policy) { case GTK_POLICY_NEVER: account_for_vscrollbar = FALSE; break; case GTK_POLICY_ALWAYS: account_for_vscrollbar = !priv->overlay_scrollbars; break; case GTK_POLICY_AUTOMATIC: /* For automatic scrollbars, we always request space for the vertical * scrollbar; we won't know whether we actually need one until our * height is assigned in allocate(). */ account_for_vscrollbar = !priv->overlay_scrollbars; break; } if (account_for_vscrollbar) { float sb_width = get_scrollbar_width (ST_SCROLL_VIEW (actor), for_height); min_width += sb_width; natural_width += sb_width; } if (min_width_p) *min_width_p = min_width; if (natural_width_p) *natural_width_p = natural_width; st_theme_node_adjust_preferred_width (theme_node, min_width_p, natural_width_p); }