Ejemplo n.º 1
0
static void
make_ui (ClutterActor *stage)
{
  gint             i             = 0;
  ClutterActor    *editable      = NULL;
  ClutterActor    *rectangle     = NULL;
  ClutterActor    *label         = NULL;
  ClutterColor     color_stage   = { 0x00, 0x00, 0x00, 0xff };
  ClutterColor     color_text    = { 0xff, 0x00, 0x00, 0xff };
  ClutterColor     color_sel     = { 0x00, 0xff, 0x00, 0x55 };
  ClutterColor     color_label   = { 0x00, 0xff, 0x55, 0xff };
  ClutterColor     color_rect    = { 0x00, 0xff, 0xff, 0x55 };
  ClutterGeometry  label_geom    = {0, 50, -1, -1};
  ClutterGeometry  editable_geom = {150, 50, 500, 75};


  clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
  clutter_actor_set_size (stage, WIDTH, HEIGHT);

  for (i = 0; i < NUM_ENTRIES; i++)
    {
      /* label */
      label = clutter_text_new_full ("Sans Bold 32px",
                                     "Entry",
                                     &color_label);
      clutter_actor_set_geometry (label, &label_geom);

      /* editable */
      editable = clutter_text_new_full ("Sans Bold 32px",
                                        "ddd",
                                        &color_text);
      clutter_actor_set_geometry (editable, &editable_geom);
      clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
      clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
      clutter_text_set_selection_color (CLUTTER_TEXT (editable),
                                        &color_sel);
      clutter_actor_grab_key_focus (editable);
      clutter_actor_set_reactive (editable, TRUE);

      /* rectangle: to create a entry "feeling" */
      rectangle = clutter_rectangle_new_with_color (&color_rect);
      clutter_actor_set_geometry (rectangle, &editable_geom);

      clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), editable);
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle);

      label_geom.y += HEIGHT_STEP;
      editable_geom.y += HEIGHT_STEP;
    }
}
Ejemplo n.º 2
0
static void
set_foreign_window_callback (ClutterActor *actor,
                             void         *data)
{
    ForeignWindowData *fwd = data;

    CLUTTER_NOTE (BACKEND, "Setting foreign window (0x%x)",
                  (guint) fwd->hwnd);

    if (fwd->destroy_old_hwnd && fwd->stage_win32->hwnd != NULL)
    {
        CLUTTER_NOTE (BACKEND, "Destroying previous window (0x%x)",
                      (guint) fwd->stage_win32->hwnd);
        DestroyWindow (fwd->stage_win32->hwnd);
    }

    fwd->stage_win32->hwnd = fwd->hwnd;
    fwd->stage_win32->is_foreign_win = TRUE;

    fwd->stage_win32->win_width = fwd->geom.width;
    fwd->stage_win32->win_height = fwd->geom.height;

    clutter_actor_set_geometry (actor, &fwd->geom);

    /* calling this with the stage unrealized will unset the stage
     * from the GL context; once the stage is realized the GL context
     * will be set again
     */
    clutter_stage_ensure_current (CLUTTER_STAGE (actor));
}
Ejemplo n.º 3
0
static void
make_ui (ClutterActor *stage)
{
  ClutterActor    *editable      = NULL;
  ClutterActor    *rectangle     = NULL;
  ClutterActor    *label         = NULL;
  ClutterColor     color_stage   = { 0x00, 0x00, 0x00, 0xff };
  ClutterColor     color_text    = { 0xff, 0x00, 0x00, 0xff };
  ClutterColor     color_sel     = { 0x00, 0xff, 0x00, 0x55 };
  ClutterColor     color_label   = { 0x00, 0xff, 0x55, 0xff };
  ClutterColor     color_rect    = { 0x00, 0xff, 0xff, 0x55 };
  ClutterGeometry  editable_geom = {150, 50, 100, 75};
  ClutterActor    *full_entry    = NULL;
  ClutterActor    *cloned_entry  = NULL;


  clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
  clutter_actor_set_size (stage, WIDTH, HEIGHT);

  label = clutter_text_new_full ("Sans Bold 32px",
                                 "Entry",
                                 &color_label);
  clutter_actor_set_position (label, 0, 50);

  /* editable */
  editable = clutter_text_new_full ("Sans Bold 32px",
                                    "ddd",
                                    &color_text);
  clutter_actor_set_position (editable, 150, 50);
  clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
  clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
  clutter_text_set_selection_color (CLUTTER_TEXT (editable),
                                    &color_sel);
  clutter_actor_grab_key_focus (editable);
  clutter_actor_set_reactive (editable, TRUE);

  /* rectangle: to create a entry "feeling" */
  rectangle = clutter_rectangle_new_with_color (&color_rect);
  clutter_actor_set_geometry (rectangle, &editable_geom);

  full_entry = clutter_group_new ();
  clutter_actor_set_position (full_entry, 0, 50);
  clutter_actor_set_size (full_entry, 100, 75);
  clutter_group_add (CLUTTER_GROUP (full_entry), label);
  clutter_group_add (CLUTTER_GROUP (full_entry), editable);
  clutter_group_add (CLUTTER_GROUP (full_entry), rectangle);
  clutter_actor_show_all (full_entry);
  clutter_actor_set_scale (full_entry, 2, 1);
  clutter_group_add (CLUTTER_GROUP (stage), full_entry);

  /* Cloning! */
  cloned_entry = clutter_clone_new (full_entry);
  clutter_actor_set_position (cloned_entry, 50, 200);
  clutter_actor_set_scale (cloned_entry, 1, 2);
  clutter_actor_show_all (cloned_entry);
  clutter_actor_set_reactive (cloned_entry, TRUE);

  clutter_group_add (CLUTTER_GROUP (stage), cloned_entry);
}
Ejemplo n.º 4
0
IO_METHOD(IoClutterActor, setGeometry) {
  ClutterGeometry geometry = { 0, 0, 0, 0, };
  geometry.x       = IoMessage_locals_intArgAt_(m, locals, 0);
  geometry.y       = IoMessage_locals_intArgAt_(m, locals, 1);
  geometry.width   = IoMessage_locals_intArgAt_(m, locals, 2);
  geometry.height  = IoMessage_locals_intArgAt_(m, locals, 3);

  clutter_actor_set_geometry(IOCACTOR(self), &geometry);
  return self;
}
Ejemplo n.º 5
0
/**
 * clutter_win32_set_stage_foreign:
 * @stage: a #ClutterStage
 * @hwnd: an existing window handle
 *
 * Target the #ClutterStage to use an existing external window handle.
 *
 * Return value: %TRUE if foreign window is valid
 *
 * Since: 0.8
 */
gboolean
clutter_win32_set_stage_foreign (ClutterStage *stage,
				 HWND          hwnd)
{
  ClutterStageWin32 *stage_win32;
  ClutterStageWindow *impl;
  ClutterActor *actor;
  RECT client_rect;
  POINT window_pos;
  ClutterGeometry geom;

  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
  g_return_val_if_fail (hwnd != NULL, FALSE);

  actor = CLUTTER_ACTOR (stage);

  impl = _clutter_stage_get_window (stage);
  stage_win32 = CLUTTER_STAGE_WIN32 (impl);

  /* FIXME this needs updating to use _clutter_actor_rerealize(),
   * see the analogous code in x11 backend. Probably best if
   * win32 maintainer does it so they can be sure it compiles
   * and works.
   */

  clutter_actor_unrealize (actor);

  if (!GetClientRect (hwnd, &client_rect))
    {
      g_warning ("Unable to retrieve the new window geometry");
      return FALSE;
    }
  window_pos.x = client_rect.left;
  window_pos.y = client_rect.right;
  ClientToScreen (hwnd, &window_pos);

  CLUTTER_NOTE (BACKEND, "Setting foreign window (0x%x)", (int) hwnd);

  stage_win32->hwnd = hwnd;
  stage_win32->is_foreign_win = TRUE;

  geom.x = 0;
  geom.y = 0;
  geom.width = client_rect.right - client_rect.left;
  geom.height = client_rect.bottom - client_rect.top;

  clutter_actor_set_geometry (actor, &geom);
  clutter_actor_realize (actor);

  return TRUE;
}
Ejemplo n.º 6
0
void
test_pick (TestConformSimpleFixture *fixture,
	   gconstpointer data)
{
  int y, x;
  State state;
  
  state.pass = TRUE;

  state.stage = clutter_stage_get_default ();

  clutter_actor_set_size (state.stage, STAGE_WIDTH, STAGE_HEIGHT);
  state.actor_width = STAGE_WIDTH / ACTORS_X;
  state.actor_height = STAGE_HEIGHT / ACTORS_Y;

  for (y = 0; y < ACTORS_Y; y++)
    for (x = 0; x < ACTORS_X; x++)
      {
	ClutterColor color = { x * 255 / (ACTORS_X - 1),
			       y * 255 / (ACTORS_Y - 1),
			       128, 255 };
	ClutterGeometry geom = { x * state.actor_width, y * state.actor_height,
				 state.actor_width, state.actor_height };
	ClutterActor *rect = clutter_rectangle_new_with_color (&color);

	clutter_actor_set_geometry (rect, &geom);

	clutter_container_add (CLUTTER_CONTAINER (state.stage), rect, NULL);

	state.gids[y * ACTORS_X + x] = clutter_actor_get_gid (rect);
      }

  clutter_actor_show (state.stage);

  g_timeout_add (250, (GSourceFunc) on_timeout, &state);

  clutter_main ();


  if (g_test_verbose ())
    g_print ("end result: %s\n", state.pass ? "pass" : "FAIL");

  g_assert (state.pass);
}
Ejemplo n.º 7
0
static void
opt_show_update_position_label (OptShow *show)
{
  OptShowPrivate *priv = show->priv;
  ClutterActor *stage;
  ClutterGeometry stage_geom;
  ClutterGeometry rect_geom;
  gint label_width, label_height;
  gchar *pos;
  
  if (!priv->position_label)
    return;

  stage = clutter_stage_get_default ();
  clutter_actor_get_geometry (stage, &stage_geom);
  
  pos = g_strdup_printf ("%d/%d",
		         priv->current_slide_num + 1,
			 priv->num_slides);

  clutter_text_set_text (CLUTTER_TEXT (priv->position_label), pos);
  clutter_texture_get_base_size (CLUTTER_TEXTURE (priv->position_label),
		                 &label_width,
				 &label_height);

  rect_geom.width = label_width + 50;
  rect_geom.height = label_height + 20;
  rect_geom.x = (stage_geom.width / 2) - (rect_geom.width / 2);
  rect_geom.y = stage_geom.height - rect_geom.height - 10;
  
  clutter_actor_set_geometry (priv->position_rect, &rect_geom);
  clutter_actor_set_position (priv->position_label,
		              rect_geom.x + 25,
			      rect_geom.y + 10);
  
  g_free (pos);
}
Ejemplo n.º 8
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage = NULL;
  ClutterColor  color = { 0x00, 0x00, 0x00, 0xff };
  ClutterActor *button1 = NULL;
  ClutterActor *button2 = NULL;
  ClutterActor *button3 = NULL;
  ClutterActor *button4 = NULL;
  ClutterActor *group[4];
  ClutterGeometry geom = {0, 0, SIZE, SIZE};
  gint i = 0;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  cally_util_a11y_init (&argc, &argv);

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage), &color);
  clutter_actor_set_size (stage, WIDTH, HEIGHT);

  button1 = clutter_rectangle_new_with_color (&color1);
  clutter_actor_set_geometry (button1, &geom);

  button2 = clutter_rectangle_new_with_color (&color2);
  geom.x = 2*SIZE;
  geom.y = 0;
  clutter_actor_set_geometry (button2, &geom);

  geom.x = 0;
  geom.y = 2*SIZE;
  button3 = clutter_rectangle_new_with_color (&color3);
  clutter_actor_set_geometry (button3, &geom);
  clutter_actor_set_depth( button3, DEPTH);

  /* a nested hierarchy, to check that the relative positions are
     computed properly */
  geom.x = SIZE/2;
  geom.y = SIZE/2;
  button4 = clutter_rectangle_new_with_color (&color4);
  clutter_actor_set_geometry (button4, &geom);
  clutter_actor_show (button4);

  for (i = 0; i < 4; i++) {
    group[i] = clutter_group_new ();
    clutter_actor_set_geometry (group[i], &geom);

    if (i > 0)
      clutter_group_add (CLUTTER_GROUP (group[i]), group [i - 1]);

    clutter_actor_show_all (group[i]);
  }

  clutter_group_add (CLUTTER_GROUP (stage), button1);
  clutter_group_add (CLUTTER_GROUP (stage), button2);
  clutter_group_add (CLUTTER_GROUP (stage), button3);
  clutter_group_add (CLUTTER_GROUP (stage), group[3]);
  clutter_group_add (CLUTTER_GROUP (group[0]), button4);

  clutter_actor_show_all (stage);

  clutter_main ();

  return 0;
}
Ejemplo n.º 9
0
void
opt_show_toggle_position (OptShow *show)
{
  OptShowPrivate *priv;
  ClutterActor *stage;
  ClutterGeometry stage_geom;
  
  g_return_if_fail (OPT_IS_SHOW (show));

  priv = show->priv;

  stage = clutter_stage_get_default ();
  clutter_actor_get_geometry (stage, &stage_geom);

  if (!priv->position_label)
    {
      ClutterActor *rect;
      ClutterActor *label;
      ClutterColor rect_color = { 0x00, 0x00, 0x00, 0x33 };
      ClutterColor label_color = { 0xff, 0xff, 0xff, 0xee };
      ClutterGeometry rect_geom;

      rect = clutter_rectangle_new ();
      clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect),
		                   &rect_color);

      rect_geom.width = 102;
      rect_geom.height = 77;
      rect_geom.x = stage_geom.width / 2 - rect_geom.width / 2;
      rect_geom.y = stage_geom.height - rect_geom.height - 20;

      clutter_actor_set_geometry (rect, &rect_geom);

      label = clutter_text_new_with_text ("Sans Bold 20", "0/0");
      clutter_text_set_color (CLUTTER_TEXT (label),
                              &label_color);
      clutter_actor_set_position (label, rect_geom.x + 10, rect_geom.y + 10);

      clutter_group_add_many (CLUTTER_GROUP (stage),
		              rect,
			      label,
			      NULL);
      
      priv->position_label = label;
      priv->position_rect = rect;
      priv->position_label_visible = FALSE;
    }

  if (!priv->position_label_visible)
    {
      priv->position_label_visible = TRUE;

      opt_show_update_position_label (show);
      
      clutter_actor_show (priv->position_rect);
      clutter_actor_show (priv->position_label);
    }
  else
    {
      clutter_actor_hide (priv->position_label);
      clutter_actor_hide (priv->position_rect);

      priv->position_label_visible = FALSE;
    }
}