r.x = r.x + r.w / 2;
r.y = r.y + r.h / 2;
- efl_input_pointer_position_set(td->evmove, r.x, r.y);
- efl_input_pointer_position_set(td->evdown, r.x, r.y);
- efl_input_pointer_position_set(td->evup, r.x, r.y);
+ efl_input_pointer_position_set(td->evmove, r.pos);
+ efl_input_pointer_position_set(td->evdown, r.pos);
+ efl_input_pointer_position_set(td->evup, r.pos);
efl_event_callback_call(td->win, EFL_EVENT_POINTER_MOVE, td->evmove);
efl_event_callback_call(td->win, EFL_EVENT_POINTER_DOWN, td->evdown);
}
EOLIAN static void
-_efl_input_pointer_position_set(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int x, int y)
+_efl_input_pointer_position_set(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, Eina_Position2D pos)
{
_efl_input_value_mark(pd, EFL_INPUT_VALUE_X);
_efl_input_value_mark(pd, EFL_INPUT_VALUE_Y);
- pd->cur.x = (double) x;
- pd->cur.y = (double) y;
+ pd->cur.x = (double) pos.x;
+ pd->cur.y = (double) pos.y;
}
-EOLIAN static void
-_efl_input_pointer_position_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int *x, int *y)
+EOLIAN static Eina_Position2D
+_efl_input_pointer_position_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd)
{
- if (x) *x = (int) pd->cur.x;
- if (y) *y = (int) pd->cur.y;
+ return EINA_POSITION2D((int) pd->cur.x, (int) pd->cur.y);
}
EOLIAN static void
-_efl_input_pointer_previous_position_set(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int x, int y)
+_efl_input_pointer_previous_position_set(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, Eina_Position2D pos)
{
_efl_input_value_mark(pd, EFL_INPUT_VALUE_PREVIOUS_X);
_efl_input_value_mark(pd, EFL_INPUT_VALUE_PREVIOUS_Y);
- pd->prev.x = (double) x;
- pd->prev.y = (double) y;
-}
-
-EOLIAN static void
-_efl_input_pointer_previous_position_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int *x, int *y)
-{
- if (x) *x = (int) pd->prev.x;
- if (y) *y = (int) pd->prev.y;
+ pd->prev.x = (double) pos.x;
+ pd->prev.y = (double) pos.y;
}
-EOLIAN static void
-_efl_input_pointer_delta_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int *dx, int *dy)
+EOLIAN static Eina_Position2D
+_efl_input_pointer_previous_position_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd)
{
- // Using (int) twice to return the same as previous_position - position
- if (dx) *dx = (int) pd->prev.x - (int) pd->cur.x;
- if (dy) *dy = (int) pd->prev.y - (int) pd->cur.y;
+ return EINA_POSITION2D((int) pd->prev.x, (int) pd->prev.y);
}
EOLIAN static void
if you need precise coordinates.
]]
values {
- x: int; [[X coordinate of the event]]
- y: int; [[Y coordinate of the event]]
+ pos: Eina.Position2D; [[The position of the event, in pixels.]]
}
}
@property previous_position {
but prefer the generic interface if you need precise coordinates.
]]
values {
- x: int; [[X coordinate of the previous event]]
- y: int; [[Y coordinate of the previous event]]
- }
- }
- @property delta {
- [[Position delta, or movement, since the last event.
-
- This position, in integers, is an approximation of
- @.value.get($dx), @.value.get($dy). Use @.delta if you need
- simple pixel positions, but prefer the generic interface
- if you need precise coordinates.
- ]]
- get {}
- values {
- dx: int; [[X coordinate delta]]
- dy: int; [[Y coordinate delta]]
+ pos: Eina.Position2D; [[The position of the event, in pixels.]]
}
}
@property tool {
/* a very lax definition of == for doubles */
#define VALEQ(a, b) ((fabs((a) - (b))) <= 0.001)
-typedef struct
-{
- double x, y;
-} point_t;
-
-static point_t points[2][4] =
+static const Eina_Position2D points[2][4] =
{
{
{ 20, 20 },
for (size_t i = 0; i < 4; i++)
{
ptr = efl_add(EFL_INPUT_POINTER_CLASS, win);
- efl_input_pointer_position_set(ptr, points[0][i].x, points[0][i].y);
+ efl_input_pointer_position_set(ptr, points[0][i]);
efl_input_pointer_tool_set(ptr, i);
efl_input_pointer_button_set(ptr, 1);
efl_event_callback_call(win, EFL_EVENT_POINTER_IN, ptr);
/* move second */
- efl_input_pointer_position_set(ptr, points[0][i].x, points[0][i].y);
+ efl_input_pointer_position_set(ptr, points[0][i]);
efl_input_pointer_action_set(ptr, EFL_POINTER_ACTION_MOVE);
efl_event_callback_call(win, EFL_EVENT_POINTER_MOVE, ptr);
}
for (i = 0; i < 4; i++)
{
ptr = efl_add(EFL_INPUT_POINTER_CLASS, win);
- efl_input_pointer_position_set(ptr, points[1][i].x, points[1][i].y);
+ efl_input_pointer_position_set(ptr, points[1][i]);
efl_input_pointer_tool_set(ptr, i);
efl_input_pointer_button_set(ptr, 1);