Exemplo n.º 1
0
static void
expander_box_open_notify (MexExpanderBox *box,
                          GParamSpec     *pspec,
                          MexColumn      *column)
{
  MexColumnPrivate *priv = MEX_COLUMN (column)->priv;
  GList *l;
  MexShadow *shadow;
  ClutterColor shadow_color = { 0, 0, 0, 128 };

  if (mex_expander_box_get_open (box))
    {
      for (l = priv->children; l; l = l->next)
        {
          if (l->data != box)
            clutter_actor_animate (l->data, CLUTTER_EASE_IN_OUT_QUAD, 200,
                                   "opacity", 56, NULL);
        }
      clutter_actor_animate (priv->header, CLUTTER_EASE_IN_OUT_QUAD, 200,
                             "opacity", 56, NULL);

      /* Restore the opened box to full opacity */
      clutter_actor_animate (CLUTTER_ACTOR (box), CLUTTER_EASE_IN_OUT_QUAD, 200,
                             "opacity", 255, NULL);

      shadow = mex_shadow_new (CLUTTER_ACTOR (box));
      mex_shadow_set_paint_flags (shadow,
                                  MEX_TEXTURE_FRAME_TOP | MEX_TEXTURE_FRAME_BOTTOM);
      mex_shadow_set_radius_y (shadow, 25);
      mex_shadow_set_color (shadow, &shadow_color);

      g_object_set_qdata (G_OBJECT (box), _item_shadow_quark (), shadow);

      priv->open_boxes ++;
    }
  else
    {
      priv->open_boxes --;
    }

  if (priv->open_boxes == 0)
    {
      /* restore all children to full opacity */
      for (l = priv->children; l; l = l->next)
        {
          clutter_actor_animate (l->data, CLUTTER_EASE_IN_OUT_QUAD, 200,
                                 "opacity", 255, NULL);
        }
      clutter_actor_animate (priv->header, CLUTTER_EASE_IN_OUT_QUAD, 200,
                             "opacity", 255, NULL);

      shadow = g_object_get_qdata (G_OBJECT (box), _item_shadow_quark ());
      if (shadow)
        {
          g_object_unref (shadow);
          g_object_set_qdata (G_OBJECT (box), _item_shadow_quark (), NULL);
        }
    }
}
Exemplo n.º 2
0
/**
 * mex_column_add_content:
 *
 * Add an item to the column for the specified content at the specified
 * position.
 */
static void
mex_column_add_content (MexColumn  *column,
                        MexContent *content,
                        guint       position)
{
  MexColumnPrivate *priv = column->priv;
  ClutterActor *box;
  MexShadow *shadow;
  ClutterColor shadow_color = { 0, 0, 0, 128 };
  GList *sibling;

  box = mex_content_box_new ();
  mex_content_view_set_content (MEX_CONTENT_VIEW (box), content);
  mex_content_view_set_context (MEX_CONTENT_VIEW (box), priv->model);

  sibling = g_list_nth (priv->children, position);
  priv->children = g_list_insert_before (priv->children, sibling, box);
  priv->n_items ++;

  /* add shadow */
  shadow = mex_shadow_new ();
  mex_shadow_set_paint_flags (shadow,
                              MEX_TEXTURE_FRAME_TOP
                              | MEX_TEXTURE_FRAME_BOTTOM);
  mex_shadow_set_radius_y (shadow, 25);
  mex_shadow_set_color (shadow, &shadow_color);
  clutter_actor_add_effect_with_name (CLUTTER_ACTOR (box), "shadow",
                                      CLUTTER_EFFECT (shadow));
  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (shadow), FALSE);

  g_signal_connect (box, "notify::open",
                    G_CALLBACK (content_box_open_notify), column);

  /* set important if the column has focus */
  mex_content_box_set_important (MEX_CONTENT_BOX (box), priv->has_focus);

  clutter_actor_set_parent (box, CLUTTER_ACTOR (column));
}