/** * st_adjustment_get_values: * @adjustment: an #StAdjustment * @value: (out): the current value * @lower: (out): the lower bound * @upper: (out): the upper bound * @step_increment: (out): the step increment * @page_increment: (out): the page increment * @page_size: (out): the page size * * Gets all of @adjustment's values at once. */ void st_adjustment_get_values (StAdjustment *adjustment, gdouble *value, gdouble *lower, gdouble *upper, gdouble *step_increment, gdouble *page_increment, gdouble *page_size) { StAdjustmentPrivate *priv; g_return_if_fail (ST_IS_ADJUSTMENT (adjustment)); priv = st_adjustment_get_instance_private (adjustment); if (lower) *lower = priv->lower; if (upper) *upper = priv->upper; if (value) *value = st_adjustment_get_value (adjustment); if (step_increment) *step_increment = priv->step_increment; if (page_increment) *page_increment = priv->page_increment; if (page_size) *page_size = priv->page_size; }
void st_adjustment_clamp_page (StAdjustment *adjustment, gdouble lower, gdouble upper) { StAdjustmentPrivate *priv; gboolean changed; g_return_if_fail (ST_IS_ADJUSTMENT (adjustment)); priv = st_adjustment_get_instance_private (adjustment); lower = CLAMP (lower, priv->lower, priv->upper - priv->page_size); upper = CLAMP (upper, priv->lower + priv->page_size, priv->upper); changed = FALSE; if (priv->value + priv->page_size > upper) { priv->value = upper - priv->page_size; changed = TRUE; } if (priv->value < lower) { priv->value = lower; changed = TRUE; } if (changed) g_object_notify (G_OBJECT (adjustment), "value"); }
void st_adjustment_set_value (StAdjustment *adjustment, gdouble value) { StAdjustmentPrivate *priv; g_return_if_fail (ST_IS_ADJUSTMENT (adjustment)); priv = st_adjustment_get_instance_private (adjustment); /* Defer clamp until after construction. */ if (!priv->is_constructing) { value = CLAMP (value, priv->lower, MAX (priv->lower, priv->upper - priv->page_size)); } if (priv->value != value) { priv->value = value; g_object_notify (G_OBJECT (adjustment), "value"); } }
gdouble st_adjustment_get_value (StAdjustment *adjustment) { g_return_val_if_fail (ST_IS_ADJUSTMENT (adjustment), 0); return ((StAdjustmentPrivate *)st_adjustment_get_instance_private (adjustment))->value; }
gdouble st_adjustment_get_value (StAdjustment *adjustment) { StAdjustmentPrivate *priv; g_return_val_if_fail (ST_IS_ADJUSTMENT (adjustment), 0); priv = adjustment->priv; return priv->value; }
/** * st_adjustment_adjust_for_scroll_event: * @adjustment: An #StAdjustment * @delta: A delta, retrieved directly from clutter_event_get_scroll_delta() * or similar. * * Adjusts the adjustment using delta values from a scroll event. * You should use this instead of using st_adjustment_set_value() * as this method will tweak the values directly using the same * math as GTK+, to ensure that scrolling is consistent across * the environment. */ void st_adjustment_adjust_for_scroll_event (StAdjustment *adjustment, gdouble delta) { StAdjustmentPrivate *priv; gdouble new_value, scroll_unit; g_return_if_fail (ST_IS_ADJUSTMENT (adjustment)); priv = st_adjustment_get_instance_private (adjustment); scroll_unit = pow (priv->page_size, 2.0 / 3.0); new_value = priv->value + delta * scroll_unit; st_adjustment_set_value (adjustment, new_value); }
void st_adjustment_set_values (StAdjustment *adjustment, gdouble value, gdouble lower, gdouble upper, gdouble step_increment, gdouble page_increment, gdouble page_size) { StAdjustmentPrivate *priv; gboolean emit_changed = FALSE; g_return_if_fail (ST_IS_ADJUSTMENT (adjustment)); g_return_if_fail (page_size >= 0 && page_size <= G_MAXDOUBLE); g_return_if_fail (step_increment >= 0 && step_increment <= G_MAXDOUBLE); g_return_if_fail (page_increment >= 0 && page_increment <= G_MAXDOUBLE); priv = st_adjustment_get_instance_private (adjustment); emit_changed = FALSE; g_object_freeze_notify (G_OBJECT (adjustment)); emit_changed |= st_adjustment_set_lower (adjustment, lower); emit_changed |= st_adjustment_set_upper (adjustment, upper); emit_changed |= st_adjustment_set_step_increment (adjustment, step_increment); emit_changed |= st_adjustment_set_page_increment (adjustment, page_increment); emit_changed |= st_adjustment_set_page_size (adjustment, page_size); if (value != priv->value) { st_adjustment_set_value (adjustment, value); emit_changed = TRUE; } if (emit_changed) g_signal_emit (G_OBJECT (adjustment), signals[CHANGED], 0); g_object_thaw_notify (G_OBJECT (adjustment)); }