Ejemplo n.º 1
0
static void
mex_column_expand_children (MexColumn    *column,
                            ClutterActor *start_at)
{
  MexColumnPrivate *priv = column->priv;
  guint offset, increment;
  GList *c;
  gchar **markers;
  gint i;
  gboolean start;

  if (priv->n_items < 1)
    return;

  /* Open/close boxes as appropriate */
  offset = 0;
  increment = 150;

  clutter_timeline_set_duration (priv->expand_timeline,
                                 priv->n_items * increment);

  clutter_timeline_set_delay (priv->expand_timeline, 350);

  /* remove the previous markers */
  markers = clutter_timeline_list_markers (priv->expand_timeline, -1, NULL);
  if (markers)
    {
      for (i = 0; markers[i]; i++)
        {
          clutter_timeline_remove_marker (priv->expand_timeline,
                                          markers[i]);
        }
    }
  g_strfreev (markers);

  /* start is TRUE if start_at is NULL, otherwise it is set to TRUE when the
   * start_at item is found */
  start = (start_at == NULL);

  for (c = priv->children; c; c = g_list_next (c))
    {
      gchar signal_name[32+16];
      ClutterActor *child = c->data;

      if (!MEX_IS_CONTENT_BOX (child))
        continue;

      mex_content_box_set_important (MEX_CONTENT_BOX (child), TRUE);
      mex_column_expand_child (child);

      /* continue until the start item has been found */
      if (child == start_at)
        start = TRUE;

      if (!start)
        continue;

      /* Note, 'marker-reached::' is 16 characters long */
      g_snprintf (signal_name, G_N_ELEMENTS (signal_name),
                  "marker-reached::%p", child);

      /* stagger opening */
      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_child),
                                child);

      offset += increment;

    }

    clutter_timeline_start (priv->expand_timeline);
}
Ejemplo n.º 2
0
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);
}