Пример #1
0
gboolean
on_event (ClutterStage *stage,
	  ClutterEvent *event,
	  gpointer      user_data)
{
  switch (event->type)
    {
    case CLUTTER_BUTTON_PRESS:
      {
	gint x, y;
	ClutterActor * actor;
	ClutterUnit xu2, yu2;

        clutter_event_get_coords (event, &x, &y);

	actor = clutter_stage_get_actor_at_pos (stage, x, y);


	if (clutter_actor_transform_stage_point (actor,
						CLUTTER_UNITS_FROM_DEVICE (x),
						CLUTTER_UNITS_FROM_DEVICE (y),
						&xu2, &yu2))
	  {
	    gchar *txt;

	    if (actor != CLUTTER_ACTOR (stage))
	      txt = g_strdup_printf ("Click on rectangle\n"
				     "Screen coords: [%d, %d]\n"
				     "Local coords : [%d, %d]",
				     x, y,
				     CLUTTER_UNITS_TO_DEVICE (xu2),
				     CLUTTER_UNITS_TO_DEVICE (yu2));
	    else
	      txt = g_strdup_printf ("Click on stage\n"
				     "Screen coords: [%d, %d]\n"
				     "Local coords : [%d, %d]",
				     x, y,
				     CLUTTER_UNITS_TO_DEVICE (xu2),
				     CLUTTER_UNITS_TO_DEVICE (yu2));

	    clutter_label_set_text (CLUTTER_LABEL (label), txt);
	    g_free (txt);
	  }
	else
	  clutter_label_set_text (CLUTTER_LABEL (label),
				  "Unprojection failed.");
      }
      break;

    default:
      break;
    }

  return FALSE;
}
Пример #2
0
static void
clutter_stage_egl_get_preferred_height (ClutterActor *self,
                                        gfloat        for_width,
                                        gfloat       *min_height_p,
                                        gfloat       *natural_height_p)
{
  ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self);

  if (min_height_p)
    *min_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_egl->surface_height);

  if (natural_height_p)
    *natural_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_egl->surface_height);
}
Пример #3
0
static void
aisleriot_card_get_preferred_height (ClutterActor *self,
                                     ClutterUnit   for_width,
                                     ClutterUnit  *min_height_p,
                                     ClutterUnit  *natural_height_p)
{
  AisleriotCard *card = AISLERIOT_CARD (self);
  AisleriotCardPrivate *priv = card->priv;
  CoglHandle tex;
  guint height;

  tex = games_card_textures_cache_get_card_texture (priv->cache,
                                                    priv->top_card);

  if (G_UNLIKELY (tex == COGL_INVALID_HANDLE))
    height = 0;
  else
    height = cogl_texture_get_height (tex);

  if (min_height_p)
    *min_height_p = 0;

  if (natural_height_p)
    *natural_height_p = CLUTTER_UNITS_FROM_DEVICE (height);
}
Пример #4
0
static void
tweet_overlay_query_coords (ClutterActor    *actor,
                            ClutterActorBox *box)
{
  TweetOverlayPrivate *priv = TWEET_OVERLAY (actor)->priv;
  gint width, height;

  if (!priv->base)
    {
      box->x2 = box->x1;
      box->y2 = box->y1;
      return;
    }

  /* we are as big as the base actor */
  width = height = 0;
  g_object_get (G_OBJECT (priv->base),
                "surface-width", &width,
                "surface-height", &height,
                NULL);

  box->x2 = box->x1 + CLUTTER_UNITS_FROM_DEVICE (width);
  box->y2 = box->y1 + CLUTTER_UNITS_FROM_DEVICE (height);
}