efl_ui_spin: Support value change using mouse wheel.

Summary:
Enable value change using wheel.

(Up, Down key value change will be supported after D4933 dicussing.)

Test Plan: elementary_test efl_ui_spin test sample.

Reviewers: Jaehyun_Cho, jpeg, woohyun

Reviewed By: Jaehyun_Cho

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5546
This commit is contained in:
Woochan Lee 2017-11-28 20:03:06 +09:00 committed by Jaehyun Cho
parent 434be7dbfa
commit e8238522be
3 changed files with 24 additions and 4 deletions

View File

@ -22,15 +22,13 @@ _spin_max_reached_cb(void *data EINA_UNUSED, const Efl_Event *ev)
static void
_inc_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
{
int val = (int)efl_ui_range_value_get(data);
efl_ui_range_value_set(data, ++val);
efl_ui_range_value_set(data, (efl_ui_range_value_get(data) + efl_ui_range_step_get(data)));
}
static void
_dec_clicked(void *data, const Efl_Event *ev EINA_UNUSED)
{
int val = (int)efl_ui_range_value_get(data);
efl_ui_range_value_set(data, --val);
efl_ui_range_value_set(data, (efl_ui_range_value_get(data) - efl_ui_range_step_get(data)));
}
void

View File

@ -163,6 +163,27 @@ _efl_ui_spin_elm_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Data *sd EINA_UNUSED)
return EFL_UI_THEME_APPLY_SUCCESS;
}
EOLIAN static Eina_Bool
_efl_ui_spin_elm_widget_widget_event(Eo *obj, Efl_Ui_Spin_Data *sd, const Efl_Event *eo_event, Evas_Object *src EINA_UNUSED)
{
Eo *ev = eo_event->info;
if (efl_input_processed_get(ev)) return EINA_FALSE;
if (eo_event->desc == EFL_EVENT_POINTER_WHEEL)
{
if (efl_input_pointer_wheel_delta_get(ev) < 0)
efl_ui_range_value_set(obj, (efl_ui_range_value_get(obj) + sd->step));
else
efl_ui_range_value_set(obj, (efl_ui_range_value_get(obj) - sd->step));
}
else
return EINA_FALSE;
efl_input_processed_set(ev, EINA_TRUE);
return EINA_TRUE;
}
EOLIAN static Eo *
_efl_ui_spin_efl_object_constructor(Eo *obj, Efl_Ui_Spin_Data *sd)
{

View File

@ -13,6 +13,7 @@ class Efl.Ui.Spin (Efl.Ui.Layout, Efl.Ui.Range, Efl.Ui.Format,
Efl.Object.finalize;
Efl.Object.destructor;
Elm.Widget.theme_apply;
Elm.Widget.widget_event;
Efl.Ui.Range.range_min_max { get; set; }
Efl.Ui.Range.range_step { get; set; }
Efl.Ui.Range.range_value { get; set; }