Exemplo n.º 1
0
static void
container_real_lower (ClutterContainer *container,
                      ClutterActor     *child,
                      ClutterActor     *sibling)
{
  ClutterActor *self = CLUTTER_ACTOR (container);

  clutter_actor_set_child_below_sibling (self, child, sibling);
}
Exemplo n.º 2
0
Arquivo: mx-button.c Projeto: danni/mx
static void
mx_button_update_contents (MxButton *self)
{
  MxButtonPrivate *priv = self->priv;
  ClutterActor *child;
  gboolean icon_visible, label_visible;
  const gchar *text;

  /* If the icon doesn't have a name set, treat it as
   * not-visible.
   */
  if (priv->icon_visible && mx_icon_get_icon_name (MX_ICON (priv->icon)))
    icon_visible = TRUE;
  else
    icon_visible = FALSE;

  text = clutter_text_get_text (CLUTTER_TEXT (priv->label));

  if (priv->label_visible && text && (strcmp (text, "") != 0))
    label_visible = TRUE;
  else
    label_visible = FALSE;

  /* replace any custom content */
  child = mx_bin_get_child (MX_BIN (self));

  if (child != priv->hbox)
    mx_bin_set_child (MX_BIN (self), priv->hbox);

  /* Handle the simple cases first */
  if (!icon_visible && !label_visible)
    {
      clutter_actor_hide (priv->hbox);
      return;
    }

  /* ensure the hbox is visible */
  clutter_actor_show (priv->hbox);

  if (icon_visible && !label_visible)
    {
      clutter_actor_show (priv->icon);
      clutter_actor_hide (priv->label);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);
      return;
    }

  if (!icon_visible && label_visible)
    {
      clutter_actor_hide (priv->icon);
      clutter_actor_show (priv->label);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->label, NULL);
      return;
    }

  /* Both the icon and text are visible, handle this case */
  clutter_actor_show (priv->icon);
  clutter_actor_show (priv->label);

  switch (priv->icon_position)
    {
    case MX_POSITION_TOP:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_VERTICAL);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_END, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_START, NULL);
      break;

    case MX_POSITION_RIGHT:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_HORIZONTAL);
      clutter_actor_set_child_above_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_START,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_END,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      break;

    case MX_POSITION_BOTTOM:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_VERTICAL);
      clutter_actor_set_child_above_sibling (priv->hbox, priv->icon, NULL);

      mx_box_layout_child_set_x_align (MX_BOX_LAYOUT (priv->hbox),
                                       priv->label, MX_ALIGN_MIDDLE);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_START, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_END, NULL);
      break;

    case MX_POSITION_LEFT:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_HORIZONTAL);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_END,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_START,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      break;
    }
}
Exemplo n.º 3
0
static void
sync_actor_stacking (MetaCompositor *compositor)
{
  GList *children;
  GList *expected_window_node;
  GList *tmp;
  GList *old;
  GList *backgrounds;
  gboolean has_windows;
  gboolean reordered;

  /* NB: The first entries in the lists are stacked the lowest */

  /* Restacking will trigger full screen redraws, so it's worth a
   * little effort to make sure we actually need to restack before
   * we go ahead and do it */

  children = clutter_actor_get_children (compositor->window_group);
  has_windows = FALSE;
  reordered = FALSE;

  /* We allow for actors in the window group other than the actors we
   * know about, but it's up to a plugin to try and keep them stacked correctly
   * (we really need extra API to make that reliable.)
   */

  /* First we collect a list of all backgrounds, and check if they're at the
   * bottom. Then we check if the window actors are in the correct sequence */
  backgrounds = NULL;
  expected_window_node = compositor->windows;
  for (old = children; old != NULL; old = old->next)
    {
      ClutterActor *actor = old->data;

      if (META_IS_BACKGROUND_GROUP (actor) ||
          META_IS_BACKGROUND_ACTOR (actor))
        {
          backgrounds = g_list_prepend (backgrounds, actor);

          if (has_windows)
            reordered = TRUE;
        }
      else if (META_IS_WINDOW_ACTOR (actor) && !reordered)
        {
          has_windows = TRUE;

          if (expected_window_node != NULL && actor == expected_window_node->data)
            expected_window_node = expected_window_node->next;
          else
            reordered = TRUE;
        }
    }

  g_list_free (children);

  if (!reordered)
    {
      g_list_free (backgrounds);
      return;
    }

  /* reorder the actors by lowering them in turn to the bottom of the stack.
   * windows first, then background.
   *
   * We reorder the actors even if they're not parented to the window group,
   * to allow stacking to work with intermediate actors (eg during effects)
   */
  for (tmp = g_list_last (compositor->windows); tmp != NULL; tmp = tmp->prev)
    {
      ClutterActor *actor = tmp->data, *parent;

      parent = clutter_actor_get_parent (actor);
      clutter_actor_set_child_below_sibling (parent, actor, NULL);
    }

  /* we prepended the backgrounds above so the last actor in the list
   * should get lowered to the bottom last.
   */
  for (tmp = backgrounds; tmp != NULL; tmp = tmp->next)
    {
      ClutterActor *actor = tmp->data, *parent;

      parent = clutter_actor_get_parent (actor);
      clutter_actor_set_child_below_sibling (parent, actor, NULL);
    }
  g_list_free (backgrounds);
}