2007-12-05 14:54:15 +00:00
|
|
|
#include <clutter/clutter.h>
|
2007-12-21 15:25:00 +00:00
|
|
|
|
2007-12-05 14:54:15 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2007-12-21 15:25:00 +00:00
|
|
|
#include <string.h>
|
2008-11-07 19:32:28 +00:00
|
|
|
#include <gmodule.h>
|
2007-12-05 14:54:15 +00:00
|
|
|
|
|
|
|
#define RECT_L 200
|
|
|
|
#define RECT_T 150
|
|
|
|
#define RECT_W 320
|
|
|
|
#define RECT_H 240
|
|
|
|
|
2008-12-19 13:03:53 +00:00
|
|
|
static ClutterActor *test_rectangle = NULL;
|
|
|
|
static ClutterActor *label = NULL;
|
|
|
|
|
|
|
|
|
2008-11-07 19:32:28 +00:00
|
|
|
static gboolean
|
2007-12-05 14:54:15 +00:00
|
|
|
on_event (ClutterStage *stage,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
{
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
ClutterActor *actor;
|
|
|
|
gfloat xu2, yu2;
|
|
|
|
gfloat x, y;
|
2007-12-05 14:54:15 +00:00
|
|
|
|
|
|
|
clutter_event_get_coords (event, &x, &y);
|
|
|
|
|
2009-04-24 14:05:02 +00:00
|
|
|
actor = clutter_stage_get_actor_at_pos (stage,
|
|
|
|
CLUTTER_PICK_ALL,
|
|
|
|
x, y);
|
2007-12-05 14:54:15 +00:00
|
|
|
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
if (clutter_actor_transform_stage_point (actor, x, y, &xu2, &yu2))
|
2007-12-05 14:54:15 +00:00
|
|
|
{
|
|
|
|
gchar *txt;
|
|
|
|
|
2008-12-19 13:03:53 +00:00
|
|
|
if (actor == test_rectangle)
|
2007-12-05 14:54:15 +00:00
|
|
|
txt = g_strdup_printf ("Click on rectangle\n"
|
|
|
|
"Screen coords: [%d, %d]\n"
|
|
|
|
"Local coords : [%d, %d]",
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
(int) x, (int) y,
|
|
|
|
(int) xu2, (int) yu2);
|
2007-12-05 14:54:15 +00:00
|
|
|
else
|
|
|
|
txt = g_strdup_printf ("Click on stage\n"
|
|
|
|
"Screen coords: [%d, %d]\n"
|
|
|
|
"Local coords : [%d, %d]",
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
(int) x, (int) y,
|
|
|
|
(int) xu2, (int) yu2);
|
2007-12-05 14:54:15 +00:00
|
|
|
|
2008-12-11 13:48:01 +00:00
|
|
|
clutter_text_set_text (CLUTTER_TEXT (label), txt);
|
2007-12-05 14:54:15 +00:00
|
|
|
g_free (txt);
|
|
|
|
}
|
|
|
|
else
|
2008-12-11 13:48:01 +00:00
|
|
|
clutter_text_set_text (CLUTTER_TEXT (label), "Unprojection failed.");
|
2007-12-05 14:54:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-09-22 13:33:19 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2007-12-05 14:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-07 19:32:28 +00:00
|
|
|
G_MODULE_EXPORT int
|
|
|
|
test_unproject_main (int argc, char *argv[])
|
2007-12-05 14:54:15 +00:00
|
|
|
{
|
|
|
|
gchar *txt;
|
|
|
|
ClutterActor *rect, *stage, *label0;
|
|
|
|
int i, rotate_x = 0, rotate_y = 60, rotate_z = 0;
|
2008-12-11 13:48:01 +00:00
|
|
|
ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff },
|
2007-12-05 14:54:15 +00:00
|
|
|
white = { 0xff, 0xff, 0xff, 0xff },
|
2008-12-11 13:48:01 +00:00
|
|
|
blue = { 0x0, 0xff, 0xff, 0xff };
|
2007-12-05 14:54:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < argc; ++i)
|
|
|
|
{
|
|
|
|
if (!strncmp (argv[i], "--rotate-x", 10))
|
|
|
|
{
|
|
|
|
rotate_x = atoi (argv[i] + 11);
|
|
|
|
}
|
|
|
|
else if (!strncmp (argv[i], "--rotate-y", 10))
|
|
|
|
{
|
|
|
|
rotate_y = atoi (argv[i] + 11);
|
|
|
|
}
|
|
|
|
else if (!strncmp (argv[i], "--rotate-z", 10))
|
|
|
|
{
|
|
|
|
rotate_z = atoi (argv[i] + 11);
|
|
|
|
}
|
|
|
|
else if (!strncmp (argv[i], "--help", 6))
|
|
|
|
{
|
2008-12-11 13:48:01 +00:00
|
|
|
g_print ("%s [--rotage-x=degrees] "
|
|
|
|
"[--rotage-y=degrees] "
|
|
|
|
"[--rotage-z=degrees]\n",
|
|
|
|
argv[0]);
|
2007-12-05 14:54:15 +00:00
|
|
|
|
2008-12-11 13:48:01 +00:00
|
|
|
return EXIT_FAILURE;
|
2007-12-05 14:54:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
|
|
|
|
stage = clutter_stage_get_default ();
|
|
|
|
|
|
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr);
|
|
|
|
clutter_actor_set_size (stage, 640, 480);
|
|
|
|
|
|
|
|
rect = clutter_rectangle_new_with_color (&white);
|
|
|
|
clutter_actor_set_size (rect, RECT_W, RECT_H);
|
|
|
|
clutter_actor_set_position (rect, RECT_L, RECT_T);
|
|
|
|
clutter_actor_set_rotation (rect, CLUTTER_X_AXIS, rotate_x, 0, 0, 0);
|
|
|
|
clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, rotate_y, 0, 0, 0);
|
|
|
|
clutter_actor_set_rotation (rect, CLUTTER_Z_AXIS, rotate_z, 0, 0, 0);
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), rect);
|
2008-12-19 13:03:53 +00:00
|
|
|
test_rectangle = rect;
|
2007-12-05 14:54:15 +00:00
|
|
|
|
|
|
|
txt = g_strdup_printf ("Rectangle: L %d, R %d, T %d, B %d\n"
|
|
|
|
"Rotation : x %d, y %d, z %d",
|
|
|
|
RECT_L, RECT_L + RECT_W,
|
|
|
|
RECT_T, RECT_T + RECT_H,
|
|
|
|
rotate_x, rotate_y, rotate_z);
|
|
|
|
|
2008-12-11 13:48:01 +00:00
|
|
|
label0 = clutter_text_new_with_text ("Mono 8pt", txt);
|
|
|
|
clutter_text_set_color (CLUTTER_TEXT (label0), &white);
|
2007-12-05 14:54:15 +00:00
|
|
|
|
|
|
|
clutter_actor_set_position (label0, 10, 10);
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), label0);
|
|
|
|
|
|
|
|
g_free (txt);
|
|
|
|
|
|
|
|
label =
|
2008-12-11 13:48:01 +00:00
|
|
|
clutter_text_new_with_text ("Mono 8pt", "Click around!");
|
2007-12-05 14:54:15 +00:00
|
|
|
|
2008-12-11 13:48:01 +00:00
|
|
|
clutter_text_set_color (CLUTTER_TEXT (label), &blue);
|
2007-12-05 14:54:15 +00:00
|
|
|
|
|
|
|
clutter_actor_set_position (label, 10, 50);
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), label);
|
|
|
|
|
|
|
|
clutter_actor_show_all (stage);
|
|
|
|
|
|
|
|
g_signal_connect (stage, "event", G_CALLBACK (on_event), NULL);
|
|
|
|
|
|
|
|
clutter_main();
|
|
|
|
|
2008-12-19 13:03:53 +00:00
|
|
|
test_rectangle = NULL;
|
|
|
|
label = NULL;
|
|
|
|
|
2007-12-05 14:54:15 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|