/** * mx_adjustment_interpolate_relative: * @adjustment: A #MxAdjustment * @offset: A #gdouble * @duration: duration in milliseconds * @mode: A #ClutterAnimationMode * * Interpolate the value of #MxAdjustment:value to a new value calculated from * @offset. * */ void mx_adjustment_interpolate_relative (MxAdjustment *adjustment, gdouble offset, guint duration, gulong mode) { MxAdjustmentPrivate *priv = adjustment->priv; if (priv->interpolation) offset += priv->new_position; else offset += priv->value; mx_adjustment_interpolate (adjustment, offset, duration, mode); }
static void stepper_move_on (MxScrollBarPrivate *priv, gint mode) { double value, inc; g_object_get (priv->adjustment, "step-increment", &inc, "value", &value, NULL); if (priv->stepper_forward) value = value + inc; else value = value - inc; mx_adjustment_interpolate (priv->adjustment, value, PAGING_SUBSEQUENT_REPEAT_TIMEOUT, mode); }
static gboolean trough_paging_cb (MxScrollBar *self) { gfloat handle_pos, event_pos, tx, ty; gdouble value; gdouble page_increment; gboolean ret; gulong mode; if (self->priv->paging_event_no == 0) { /* Scroll on after initial timeout. */ mode = CLUTTER_EASE_OUT_CUBIC; ret = FALSE; self->priv->paging_event_no = 1; self->priv->paging_source_id = g_timeout_add ( PAGING_INITIAL_REPEAT_TIMEOUT, (GSourceFunc) trough_paging_cb, self); } else if (self->priv->paging_event_no == 1) { /* Scroll on after subsequent timeout. */ ret = FALSE; mode = CLUTTER_EASE_IN_CUBIC; self->priv->paging_event_no = 2; self->priv->paging_source_id = g_timeout_add ( PAGING_SUBSEQUENT_REPEAT_TIMEOUT, (GSourceFunc) trough_paging_cb, self); } else { /* Keep scrolling. */ ret = TRUE; mode = CLUTTER_LINEAR; self->priv->paging_event_no++; } /* Do the scrolling */ mx_adjustment_get_values (self->priv->adjustment, &value, NULL, NULL, NULL, &page_increment, NULL); if (self->priv->orientation == MX_ORIENTATION_VERTICAL) handle_pos = clutter_actor_get_y (self->priv->handle); else handle_pos = clutter_actor_get_x (self->priv->handle); clutter_actor_transform_stage_point (CLUTTER_ACTOR (self->priv->trough), self->priv->move_x, self->priv->move_y, &tx, &ty); if (self->priv->orientation == MX_ORIENTATION_VERTICAL) event_pos = ty; else event_pos = tx; if (event_pos > handle_pos) { if (self->priv->paging_direction == NONE) { /* Remember direction. */ self->priv->paging_direction = DOWN; } if (self->priv->paging_direction == UP) { /* Scrolled far enough. */ return FALSE; } value += page_increment; } else { if (self->priv->paging_direction == NONE) { /* Remember direction. */ self->priv->paging_direction = UP; } if (self->priv->paging_direction == DOWN) { /* Scrolled far enough. */ return FALSE; } value -= page_increment; } mx_adjustment_interpolate (self->priv->adjustment, value, 250, mode); return ret; }
static void mex_column_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexColumn *self) { GList *c; ClutterActor *focused, *focused_cell; gboolean cell_has_focus; MexColumnPrivate *priv = self->priv; focused = (ClutterActor *)mx_focus_manager_get_focused (manager); /* Check if we have focus, and what child is focused */ focused_cell = NULL; cell_has_focus = FALSE; if (focused) { ClutterActor *parent = clutter_actor_get_parent (focused); while (parent) { if (parent == (ClutterActor *)self) { focused_cell = focused; cell_has_focus = TRUE; /* Check whether focus has really moved */ if ((priv->current_focus == focused_cell) && !priv->has_focus_changed) return; priv->current_focus = focused_cell; break; } focused = parent; parent = clutter_actor_get_parent (focused); } } /* Scroll the adjustment to the top */ if (!cell_has_focus && priv->adjustment) mx_adjustment_interpolate (priv->adjustment, 0, 250, CLUTTER_EASE_OUT_CUBIC); if (cell_has_focus) { gboolean open; open = FALSE; for (c = priv->children; c; c = g_list_next (c)) { ClutterActor *child = c->data; if (priv->current_focus == child) open = TRUE; if (open) mex_column_expand_child (child); else mex_column_shrink_child (child); } } priv->has_focus_changed = FALSE; }
static void mex_column_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexColumn *self) { GList *c; guint offset, increment; ClutterActor *focused, *focused_cell; gboolean cell_has_focus, has_focus, open, set_tile_important; MexColumnPrivate *priv = self->priv; focused = (ClutterActor *)mx_focus_manager_get_focused (manager); /* Check if we have focus, and what child is focused */ focused_cell = NULL; set_tile_important = FALSE; cell_has_focus = has_focus = FALSE; if (focused) { gboolean contains_column = FALSE; ClutterActor *parent = clutter_actor_get_parent (focused); while (parent) { if (parent == (ClutterActor *)self) { has_focus = TRUE; if (!priv->has_focus) { set_tile_important = TRUE; priv->has_focus = TRUE; } if (focused != priv->header) { cell_has_focus = TRUE; focused_cell = focused; } break; } else if (MEX_IS_COLUMN (parent)) { contains_column = TRUE; } focused = parent; parent = clutter_actor_get_parent (focused); } if (!contains_column) has_focus = TRUE; } if (!has_focus && priv->has_focus) { priv->has_focus = FALSE; set_tile_important = TRUE; } /* Scroll the adjustment to the top */ if (!cell_has_focus && priv->adjustment) mx_adjustment_interpolate (priv->adjustment, 0, 250, CLUTTER_EASE_OUT_CUBIC); /* Open/close boxes as appropriate */ offset = 0; increment = 150; /* If we're changing the tile importance, initialise the state manager */ if (set_tile_important && priv->n_items > 0) { if (priv->expand_timeline) g_object_unref (priv->expand_timeline); priv->expand_timeline = clutter_timeline_new (priv->n_items * increment); clutter_timeline_set_delay (priv->expand_timeline, 350); } /* Loop through children and set the expander box important/unimportant * as necessary, and if necessary, do the same for the tile inside the * expander-box. */ open = has_focus && !cell_has_focus; for (c = priv->children; c; c = c->next) { gchar signal_name[32+16]; ClutterActor *child = c->data; if ((!priv->collapse && priv->has_focus) || (child == focused_cell)) open = TRUE; if (!MEX_IS_EXPANDER_BOX (child)) continue; /* Note, 'marker-reached::' is 16 characters long */ g_snprintf (signal_name, G_N_ELEMENTS (signal_name), "marker-reached::%p", child); if (MEX_IS_CONTENT_BOX (child)) { ClutterActor *tile = mex_content_box_get_tile (MEX_CONTENT_BOX (child)); mex_tile_set_important (MEX_TILE (tile), priv->has_focus); } if (!open) { if (priv->expand_timeline) { if (clutter_timeline_has_marker (priv->expand_timeline, signal_name + 16)) clutter_timeline_remove_marker (priv->expand_timeline, signal_name + 16); g_signal_handlers_disconnect_by_func (priv->expand_timeline, mex_column_expand_drawer_cb, child); } mex_expander_box_set_important (MEX_EXPANDER_BOX (child), FALSE); } else if (set_tile_important) { mex_expander_box_set_important (MEX_EXPANDER_BOX (child), FALSE); clutter_timeline_add_marker_at_time (priv->expand_timeline, signal_name + 16, offset); g_signal_connect_swapped (priv->expand_timeline, signal_name, G_CALLBACK (mex_column_expand_drawer_cb), child); offset += increment; } else mex_expander_box_set_important (MEX_EXPANDER_BOX (child), TRUE); } if (priv->expand_timeline && set_tile_important && (offset >= increment)) clutter_timeline_start (priv->expand_timeline); }