Compare commits

...

1 Commits

3 changed files with 37 additions and 2 deletions

View File

@ -58,6 +58,12 @@ typedef struct _Size_Params
#define PAGE_NUM 3
static void
page_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
printf("Button Page is clicked!\n");
}
static Eo *
view_add(View_Type p, Eo *parent)
{
@ -95,6 +101,7 @@ view_add(View_Type p, Eo *parent)
case BUTTON:
page = efl_add(EFL_UI_BUTTON_CLASS, parent,
efl_text_set(efl_added, "Button Page"));
efl_event_callback_add(page, EFL_UI_EVENT_CLICKED, page_clicked_cb, NULL);
efl_gfx_hint_fill_set(page, EINA_TRUE, EINA_TRUE);
break;

View File

@ -20,6 +20,7 @@ typedef struct {
Eina_Bool active;
int from;
Eina_Position2D mouse_start;
Eina_Bool moved;
} mouse_move;
Eina_Bool animation;
} Efl_Ui_Active_View_View_Manager_Scroll_Data;
@ -105,6 +106,7 @@ _mouse_down_cb(void *data,
pd->mouse_move.active = EINA_TRUE;
pd->mouse_move.from = efl_ui_active_view_active_index_get(pd->container);
pd->mouse_move.mouse_start = efl_input_pointer_position_get(ev);
pd->mouse_move.moved = EINA_FALSE;
}
static void
@ -123,6 +125,11 @@ _mouse_move_cb(void *data,
pos = efl_input_pointer_position_get(ev);
pos_y_diff = pd->mouse_move.mouse_start.x - pos.x;
pd->mouse_move.moved = EINA_TRUE;
//Set input processed not to cause clicked event to content button.
if (!efl_input_processed_get(ev))
efl_input_processed_set(ev, EINA_TRUE);
pd->transition.active = EINA_TRUE;
pd->transition.from = pd->mouse_move.from;
pd->transition.progress = (double)pos_y_diff / (double)pd->page_size.w;
@ -144,6 +151,12 @@ _mouse_up_cb(void *data,
if (efl_input_event_flags_get(ev) & EFL_INPUT_FLAGS_PROCESSED) return;
if (!pd->mouse_move.active) return;
//Set input processed not to cause clicked event to content button.
if (pd->mouse_move.moved && efl_input_processed_get(ev))
efl_input_processed_set(ev, EINA_FALSE);
pd->mouse_move.moved = EINA_FALSE;
double absolut_current_position = (double)pd->transition.from + pd->transition.progress;
int result = round(absolut_current_position);

View File

@ -38,9 +38,24 @@ _on_mouse_out(void *data,
efl_ui_clickable_button_state_reset(data, 1);
}
static void
_theme_move_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
Efl_Input_Pointer *pointer = ev->info;
if (efl_input_processed_get(pointer))
efl_ui_clickable_button_state_reset(data, 1);
}
EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks,
{EFL_EVENT_POINTER_MOVE, _theme_move_cb},
)
EOLIAN static void
_efl_ui_clickable_util_bind_to_theme(Efl_Canvas_Layout *object, Efl_Ui_Clickable *clickable)
{
efl_event_callback_array_add(object, bind_to_theme_callbacks(), clickable);
efl_layout_signal_callback_add(object, "efl,action,press", "*", clickable, _on_press_cb, NULL);
efl_layout_signal_callback_add(object, "efl,action,unpress", "*", clickable, _on_unpress_cb, NULL);
efl_layout_signal_callback_add(object, "efl,action,mouse_out", "*", clickable, _on_mouse_out, NULL);
@ -84,7 +99,7 @@ _unpress_cb(void *data, const Efl_Event *ev EINA_UNUSED)
}
}
EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks,
EFL_CALLBACKS_ARRAY_DEFINE(bind_to_object_callbacks,
{EFL_EVENT_POINTER_DOWN, _press_cb},
{EFL_EVENT_POINTER_UP, _unpress_cb},
)
@ -92,7 +107,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(bind_to_theme_callbacks,
EOLIAN static void
_efl_ui_clickable_util_bind_to_object(Efl_Input_Interface *object, Efl_Ui_Clickable *clickable)
{
efl_event_callback_array_add(object, bind_to_theme_callbacks(), clickable);
efl_event_callback_array_add(object, bind_to_object_callbacks(), clickable);
}