Allow passing the pick mode to get_actor_at_pos()

Bug 1513 - Allow passing in ClutterPickMode to
           clutter_stage_get_actor_at_pos()

At the moment, clutter_stage_get_actor_at_pos() uses CLUTTER_PICK_ALL
internally to find an actor. It would be useful to allow passing in
ClutterPickMode to clutter_stage_get_actor_at_pos(), so that the caller
can specify CLUTTER_PICK_REACTIVE as a criteria.
This commit is contained in:
Emmanuele Bassi 2009-04-24 15:05:02 +01:00
parent 6064572703
commit 08ba42a5ab
10 changed files with 43 additions and 16 deletions

View File

@ -65,12 +65,6 @@ typedef enum {
CLUTTER_TEXTURE_IN_CLONE_PAINT = 1 << 6 /* Used for safety in clones */
} ClutterPrivateFlags;
typedef enum {
CLUTTER_PICK_NONE = 0,
CLUTTER_PICK_REACTIVE,
CLUTTER_PICK_ALL
} ClutterPickMode;
struct _ClutterInputDevice
{
gint id;

View File

@ -1242,20 +1242,26 @@ clutter_stage_read_pixels (ClutterStage *stage,
/**
* clutter_stage_get_actor_at_pos:
* @stage: a #ClutterStage
* @pick_mode: how the scene graph should be painted
* @x: X coordinate to check
* @y: Y coordinate to check
*
* Checks the scene at the coordinates @x and @y and returns a pointer
* to the #ClutterActor at those coordinates.
*
* Return value: (transfer none): the actor at the specified coordinates, if any
* By using @pick_mode it is possible to control which actors will be
* painted and thus available.
*
* Return value: (transfer none): the actor at the specified coordinates,
* if any
*/
ClutterActor *
clutter_stage_get_actor_at_pos (ClutterStage *stage,
gint x,
gint y)
clutter_stage_get_actor_at_pos (ClutterStage *stage,
ClutterPickMode pick_mode,
gint x,
gint y)
{
return _clutter_do_pick (stage, x, y, CLUTTER_PICK_ALL);
return _clutter_do_pick (stage, x, y, pick_mode);
}
/**

View File

@ -79,6 +79,22 @@ G_BEGIN_DECLS
#define CLUTTER_STAGE_HEIGHT() \
(clutter_actor_get_height (clutter_stage_get_default ()))
/**
* ClutterPickMode:
* @CLUTTER_PICK_NONE: Do not paint any actor
* @CLUTTER_PICK_REACTIVE: Paint only the reactive actors
* @CLUTTER_PICK_ALL: Paint all actors
*
* Controls the paint cycle of the scene graph when in pick mode
*
* Since: 1.0
*/
typedef enum {
CLUTTER_PICK_NONE = 0,
CLUTTER_PICK_REACTIVE,
CLUTTER_PICK_ALL
} ClutterPickMode;
typedef struct _ClutterPerspective ClutterPerspective;
typedef struct _ClutterFog ClutterFog;
@ -192,6 +208,7 @@ void clutter_stage_show_cursor (ClutterStage *stage);
void clutter_stage_hide_cursor (ClutterStage *stage);
ClutterActor *clutter_stage_get_actor_at_pos (ClutterStage *stage,
ClutterPickMode pick_mode,
gint x,
gint y);
guchar * clutter_stage_read_pixels (ClutterStage *stage,

View File

@ -496,6 +496,7 @@ clutter_stage_fullscreen
clutter_stage_unfullscreen
clutter_stage_show_cursor
clutter_stage_hide_cursor
ClutterPickMode
clutter_stage_get_actor_at_pos
clutter_stage_ensure_current
clutter_stage_ensure_viewport

View File

@ -68,6 +68,7 @@ on_timeout (State *state)
guint32 gid;
ClutterActor *actor
= clutter_stage_get_actor_at_pos (CLUTTER_STAGE (state->stage),
CLUTTER_PICK_ALL,
x * state->actor_width
+ state->actor_width / 2,
y * state->actor_height

View File

@ -57,7 +57,9 @@ input_cb (ClutterActor *stage,
button_event->button,
x, y);
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), x, y);
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage),
CLUTTER_PICK_ALL,
x, y);
/* only allow hiding the clones */
if (e && CLUTTER_IS_CLONE (e))

View File

@ -57,7 +57,9 @@ input_cb (ClutterActor *stage,
button_event->button,
x, y);
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), x, y);
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage),
CLUTTER_PICK_ALL,
x, y);
/* only allow hiding the clones */
if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE (e)))

View File

@ -59,7 +59,7 @@ input_cb (ClutterStage *stage,
g_print ("*** button press event (button:%d) ***\n",
button_event->button);
e = clutter_stage_get_actor_at_pos (stage, x, y);
e = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y);
if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE (e)))
{

View File

@ -108,7 +108,9 @@ on_event (ClutterStage *stage,
clutter_event_get_coords (event, &x, &y);
actor = clutter_stage_get_actor_at_pos (stage, x, y);
actor = clutter_stage_get_actor_at_pos (stage,
CLUTTER_PICK_ALL,
x, y);
if (actor != CLUTTER_ACTOR (stage))
{

View File

@ -29,7 +29,9 @@ on_event (ClutterStage *stage,
clutter_event_get_coords (event, &x, &y);
actor = clutter_stage_get_actor_at_pos (stage, x, y);
actor = clutter_stage_get_actor_at_pos (stage,
CLUTTER_PICK_ALL,
x, y);
if (clutter_actor_transform_stage_point (actor,
CLUTTER_UNITS_FROM_DEVICE (x),