示例#1
0
static void
draw_marker (ChamplainMarker *marker)
{
  BixiMarkerPrivate *priv = BIXI_MARKER (marker)->priv;
  ClutterText *label;
  gfloat width = 0, height = 0;
  gint radius = 10 + priv->value / 3;

  g_free (priv->text);
  priv->text = g_strdup_printf ("%u", priv->value);

  if (priv->text_actor == NULL)
    {
      priv->text_actor = clutter_text_new_with_text ("Sans 11", priv->text);
      g_object_ref (priv->text_actor); }

  label = CLUTTER_TEXT (priv->text_actor); clutter_text_set_font_name (label,
      "Sans 11"); clutter_text_set_text (label, priv->text);
  clutter_actor_get_size (CLUTTER_ACTOR (label), &width, &height);
  clutter_actor_set_position (CLUTTER_ACTOR (label), radius - width / 2, radius
      - height / 2);

  clutter_text_set_color (CLUTTER_TEXT (priv->text_actor), &default_text_color);
  if (clutter_actor_get_parent (priv->text_actor) == NULL)
    clutter_container_add_actor (CLUTTER_CONTAINER (marker), priv->text_actor);

  draw_shadow (BIXI_MARKER (marker), radius); draw_background (BIXI_MARKER
      (marker), radius);

  clutter_actor_raise (priv->text_actor, priv->background);
  clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), radius, radius); }
示例#2
0
IO_METHOD(IoClutterActor, raise) {
  clutter_actor_raise(
    IOCACTOR(self),
    IOCACTOR(IoMessage_locals_clutterActorArgAt_(m, locals, 0))
  );

  return self;
}
示例#3
0
static void
gnibbles_board_load_level (GnibblesBoard *board)
{
  gint i,j;
  gint x_pos, y_pos;
  ClutterActor *tmp;
  gboolean is_wall = TRUE;

  if (board->level) {
    clutter_group_remove_all (CLUTTER_GROUP (board->level));
    clutter_container_remove_actor (CLUTTER_CONTAINER (stage), board->level);
  }

  board->level = clutter_group_new ();

  /* Load wall_pixmaps onto the surface*/
  for (i = 0; i < BOARDHEIGHT; i++) {
    y_pos = i * properties->tilesize;
    for (j = 0; j < BOARDWIDTH; j++) {
      is_wall = TRUE;
      switch (board->walls[j][i]) {
        case 'a': // empty space
          is_wall = FALSE;
          break; // break right away
        case 'b': // straight up
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[0]);
          break;
        case 'c': // straight side
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[1]);
          break;
        case 'd': // corner bottom left
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[2]);
          break;
        case 'e': // corner bottom right
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[3]);
          break;
          case 'f': // corner up left
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[4]);
          break;
        case 'g': // corner up right
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[5]);
          break;
        case 'h': // tee up
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[6]);
          break;
        case 'i': // tee right
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[7]);
          break;
        case 'j': // tee left
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[8]);
          break;
        case 'k': // tee down
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[9]);
          break;
        case 'l': // cross
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[10]);
          break;
        default:
          is_wall = FALSE;
          break;
      }

      if (is_wall) {
        x_pos = j * properties->tilesize;

        clutter_actor_set_size (CLUTTER_ACTOR(tmp),
                                properties->tilesize,
                                properties->tilesize);

        clutter_actor_set_position (CLUTTER_ACTOR (tmp), x_pos, y_pos);
        clutter_actor_show (CLUTTER_ACTOR (tmp));
        clutter_container_add_actor (CLUTTER_CONTAINER (board->level),
                                     CLUTTER_ACTOR (tmp));
      }
    }
  }

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), board->level);
  clutter_actor_raise (board->level, board->surface);

  clutter_actor_set_opacity (board->level, 0);
  clutter_actor_set_scale (CLUTTER_ACTOR (board->level), 0.2, 0.2);
  clutter_actor_animate (board->level, CLUTTER_EASE_OUT_BOUNCE, 1210,
                         "opacity", 0xff,
                         "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
                         "scale-x", 1.0,
                         "scale-y", 1.0,
                         NULL);
}
示例#4
0
G_MODULE_EXPORT int
test_bin_layout_main (int argc, char *argv[])
{
  ClutterActor *stage, *box, *rect;
  ClutterLayoutManager *layout;
  ClutterColor stage_color = { 0xe0, 0xf2, 0xfc, 0xff };
  ClutterColor bg_color = { 0xcc, 0xcc, 0xcc, 0x99 };
  ClutterColor *color;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test");
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 640, 480);

  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
                                   CLUTTER_BIN_ALIGNMENT_CENTER);

  box = clutter_box_new (layout);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
  clutter_actor_set_anchor_point_from_gravity (box, CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (box, 320, 240);
  clutter_actor_set_reactive (box, TRUE);
  clutter_actor_set_name (box, "box");

  rect = make_background (&bg_color, 200, 200);

  /* first method: use clutter_box_pack() */
  clutter_box_pack (CLUTTER_BOX (box), rect,
                    "x-align", CLUTTER_BIN_ALIGNMENT_FILL,
                    "y-align", CLUTTER_BIN_ALIGNMENT_FILL,
                    NULL);

  clutter_actor_lower_bottom (rect);
  clutter_actor_set_name (rect, "background");

  {
    ClutterActor *tex;
    GError *error;
    gchar *file;

    error = NULL;
    file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
    tex = clutter_texture_new_from_file (file, &error);
    if (error)
      g_error ("Unable to create texture: %s", error->message);

    clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (tex), TRUE);

    /* second method: use clutter_bin_layout_add() */
    clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), tex,
                            CLUTTER_BIN_ALIGNMENT_CENTER,
                            CLUTTER_BIN_ALIGNMENT_CENTER);

    clutter_actor_raise (tex, rect);
    clutter_actor_set_width (tex, 175);
    clutter_actor_set_name (tex, "texture");

    g_free (file);
  }

  color = clutter_color_new (g_random_int_range (0, 255),
                             g_random_int_range (0, 255),
                             g_random_int_range (0, 255),
                             224);

  rect = clutter_rectangle_new_with_color (color);

  /* third method: container_add() and set_alignment() */
  clutter_container_add_actor (CLUTTER_CONTAINER (box), rect);
  clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect,
                                    CLUTTER_BIN_ALIGNMENT_END,
                                    CLUTTER_BIN_ALIGNMENT_END);

  clutter_actor_set_size (rect, 50, 50);
  clutter_actor_set_opacity (rect, 0);
  clutter_actor_raise_top (rect);
  clutter_actor_set_name (rect, "emblem");


  g_signal_connect (box,
                    "enter-event", G_CALLBACK (on_box_enter),
                    rect);
  g_signal_connect (box,
                    "leave-event", G_CALLBACK (on_box_leave),
                    rect);

  clutter_actor_show_all (stage);

  clutter_main ();

  clutter_color_free (color);

  return EXIT_SUCCESS;
}
/*
 * This is the Metacity entry point for the effect.
 */
void
mnb_switch_zones_effect (MetaPlugin         *plugin,
                         gint                from,
                         gint                to,
                         MetaMotionDirection direction)
{
  GList *w;
  gint width, height;
  MetaScreen *screen;
  ClutterActor *window_group;

  if (running++)
    {
      /*
       * We have been called while the effect is already in progress; we need to
       * mutter know that we completed the previous run.
       */
      if (--running < 0)
        {
          g_warning (G_STRLOC ": error in running effect accounting!");
          running = 0;
        }

      meta_plugin_switch_workspace_completed (plugin);
    }

  if ((from == to) && !zones_preview)
    {
      if (--running < 0)
        {
          g_warning (G_STRLOC ": error in running effect accounting!");
          running = 0;
        }

      meta_plugin_switch_workspace_completed (plugin);

      return;
    }

  screen = meta_plugin_get_screen (plugin);

  if (!zones_preview)
    {
      ClutterActor *stage;

      /* Construct the zones preview actor */
      zones_preview = mnb_zones_preview_new ();
      g_object_set (G_OBJECT (zones_preview),
                    "workspace", (gdouble)from,
                    NULL);

      /* Add it to the stage */
      stage = meta_get_stage_for_screen (screen);
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), zones_preview);

      /* Attach to completed signal */
      g_signal_connect (zones_preview, "switch-completed",
                        G_CALLBACK (mnb_switch_zones_completed_cb), plugin);
    }

  meta_screen_get_size (screen, &width, &height);
  g_object_set (G_OBJECT (zones_preview),
                "workspace-width", (guint)width,
                "workspace-height", (guint)height,
                NULL);

  mnb_zones_preview_clear (MNB_ZONES_PREVIEW (zones_preview));
  mnb_zones_preview_set_n_workspaces (MNB_ZONES_PREVIEW (zones_preview),
                                      meta_screen_get_n_workspaces (screen));

  /* Add windows to zone preview actor */
  for (w = meta_get_window_actors (screen); w; w = w->next)
    {
      MetaWindowActor *window_actor = w->data;
      gint workspace = meta_window_actor_get_workspace (window_actor);
      MetaWindow *window = meta_window_actor_get_meta_window (window_actor);
      MetaWindowType type = meta_window_get_window_type (window);

      /*
       * Only show regular windows that are not sticky (getting stacking order
       * right for sticky windows would be really hard, and since they appear
       * on each workspace, they do not help in identifying which workspace
       * it is).
       */
      if ((workspace < 0) ||
          meta_window_actor_is_override_redirect (window_actor) ||
          (type != META_WINDOW_NORMAL))
        continue;

      mnb_zones_preview_add_window (MNB_ZONES_PREVIEW (zones_preview), window_actor);
    }

  /* Make sure it's on top */
  window_group = meta_get_window_group_for_screen (screen);
  clutter_actor_raise (zones_preview, window_group);

  /* Initiate animation */
  mnb_zones_preview_change_workspace (MNB_ZONES_PREVIEW (zones_preview), to);
}
示例#6
0
void 
gnibbles_board_load_level (GnibblesBoard *board, GnibblesLevel *level) 
{
  gint i,j;
  gint x_pos, y_pos;
  ClutterActor *tmp;  
  gboolean wall = TRUE;

  if (board->level)
    g_object_unref (board->level);

  board->level = clutter_group_new ();

  /* Load walls onto the surface*/
  for (i = 0; i < BOARDHEIGHT; i++) {
    y_pos = i * properties->tilesize;
    for (j = 0; j < BOARDWIDTH; j++) {
      wall = TRUE;
      switch (level->walls[j][i]) {
        case 'a': // empty space
          wall = FALSE;
          break; // break right away
        case 'b': // straight up
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[1]);
          break;
        case 'c': // straight side
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[2]);
          break;
        case 'd': // corner bottom left
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[3]);
          break;
        case 'e': // corner bottom right
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[4]);
          break;
        case 'f': // corner up left
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[5]);
          break;
        case 'g': // corner up right
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[6]);
          break;
        case 'h': // tee up
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[7]);
          break;
        case 'i': // tee right
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[8]);
          break;
        case 'j': // tee left
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[9]);
          break;
        case 'k': // tee down
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[10]);
          break;
        case 'l': // cross
          tmp = gtk_clutter_texture_new_from_pixbuf (wall_pixmaps[11]);
          break;
        default:
          wall = FALSE;
          break;
      }

      if (wall == TRUE) {
        x_pos = j * properties->tilesize;

        clutter_actor_set_size (CLUTTER_ACTOR(tmp),
                                 properties->tilesize,
                                 properties->tilesize);

        clutter_actor_set_position (CLUTTER_ACTOR (tmp), x_pos, y_pos);
        clutter_actor_show (CLUTTER_ACTOR (tmp));
        clutter_container_add_actor (CLUTTER_CONTAINER (board->level), tmp);
      }
    }
  }

  ClutterActor *stage = gnibbles_board_get_stage (board);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), board->level);
  //raise the level above the surface
  clutter_actor_raise (board->level,board->surface);
}