forked from enlightenment/efl
efl: Use Eina.Position2D for input events
This commit is contained in:
parent
b19ee757e5
commit
e28aba0542
|
@ -119,9 +119,9 @@ _clicked_button2(void *data, const Efl_Event *ev EINA_UNUSED)
|
|||
|
||||
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);
|
||||
|
|
|
@ -209,43 +209,33 @@ _efl_input_pointer_button_pressed_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Dat
|
|||
}
|
||||
|
||||
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;
|
||||
pd->prev.x = (double) pos.x;
|
||||
pd->prev.y = (double) pos.y;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_input_pointer_previous_position_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int *x, int *y)
|
||||
EOLIAN static Eina_Position2D
|
||||
_efl_input_pointer_previous_position_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd)
|
||||
{
|
||||
if (x) *x = (int) pd->prev.x;
|
||||
if (y) *y = (int) pd->prev.y;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_input_pointer_delta_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int *dx, int *dy)
|
||||
{
|
||||
// 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
|
||||
|
|
|
@ -76,8 +76,7 @@ class Efl.Input.Pointer (Efl.Object, Efl.Input.Event, Efl.Input.State)
|
|||
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 {
|
||||
|
@ -91,22 +90,7 @@ class Efl.Input.Pointer (Efl.Object, Efl.Input.Event, Efl.Input.State)
|
|||
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 {
|
||||
|
|
|
@ -197,12 +197,7 @@ END_TEST
|
|||
/* 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 },
|
||||
|
@ -228,7 +223,7 @@ _inputs_timer1_cb(void *data)
|
|||
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);
|
||||
|
||||
|
@ -239,7 +234,7 @@ _inputs_timer1_cb(void *data)
|
|||
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);
|
||||
}
|
||||
|
@ -295,7 +290,7 @@ _inputs_timer2_cb(void *data)
|
|||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue