forked from enlightenment/efl
[slider] show/hide slider popup
Summary: elementary_test->slider Reviewers: singh.amitesh, seoz, raster Differential Revision: https://phab.enlightenment.org/D347
This commit is contained in:
parent
c2c1b87f6f
commit
d64230de9f
|
@ -113,6 +113,20 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
||||||
elm_box_pack_end(bx, sl);
|
elm_box_pack_end(bx, sl);
|
||||||
evas_object_show(sl);
|
evas_object_show(sl);
|
||||||
|
|
||||||
|
sl = elm_slider_add(bx);
|
||||||
|
elm_slider_unit_format_set(sl, "%1.0f units");
|
||||||
|
elm_slider_indicator_format_set(sl, "%1.0f");
|
||||||
|
elm_slider_span_size_set(sl, 120);
|
||||||
|
elm_slider_min_max_set(sl, 0, 100);
|
||||||
|
elm_object_text_set(sl, "Always show : ");
|
||||||
|
step = _step_size_calculate(0, 9);
|
||||||
|
elm_slider_step_set(sl, step);
|
||||||
|
elm_slider_indicator_show_on_focus_set(sl, EINA_TRUE);
|
||||||
|
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
|
||||||
|
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
|
||||||
|
elm_box_pack_end(bx, sl);
|
||||||
|
evas_object_show(sl);
|
||||||
|
|
||||||
// normal horizontal slider
|
// normal horizontal slider
|
||||||
ic = elm_icon_add(bx);
|
ic = elm_icon_add(bx);
|
||||||
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
|
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
|
||||||
|
|
|
@ -316,6 +316,8 @@ _popup_hide(void *data,
|
||||||
if (sd->popup)
|
if (sd->popup)
|
||||||
{
|
{
|
||||||
if (!sd->popup_hiding)
|
if (!sd->popup_hiding)
|
||||||
|
{
|
||||||
|
if (!(elm_widget_focus_get(data) && sd->always_popup_show))
|
||||||
{
|
{
|
||||||
edje_object_signal_emit(sd->popup, "popup,hide", "elm"); // XXX: for compat
|
edje_object_signal_emit(sd->popup, "popup,hide", "elm"); // XXX: for compat
|
||||||
edje_object_signal_emit(sd->popup, "elm,popup,hide", "elm");
|
edje_object_signal_emit(sd->popup, "elm,popup,hide", "elm");
|
||||||
|
@ -323,6 +325,7 @@ _popup_hide(void *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_popup_hide_done(void *data,
|
_popup_hide_done(void *data,
|
||||||
|
@ -334,12 +337,15 @@ _popup_hide_done(void *data,
|
||||||
if (sd->popup)
|
if (sd->popup)
|
||||||
{
|
{
|
||||||
if (sd->popup_hiding)
|
if (sd->popup_hiding)
|
||||||
|
{
|
||||||
|
if (!(elm_widget_focus_get(data) && sd->always_popup_show))
|
||||||
{
|
{
|
||||||
evas_object_hide(sd->popup);
|
evas_object_hide(sd->popup);
|
||||||
sd->popup_hiding = EINA_FALSE;
|
sd->popup_hiding = EINA_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_popup_emit(void *data,
|
_popup_emit(void *data,
|
||||||
|
@ -1383,6 +1389,44 @@ _elm_slider_step_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
|
||||||
*ret = sd->step;
|
*ret = sd->step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
elm_slider_indicator_show_on_focus_set(Evas_Object *obj, Eina_Bool flag)
|
||||||
|
{
|
||||||
|
ELM_SLIDER_CHECK(obj);
|
||||||
|
eo_do(obj, elm_obj_slider_indicator_show_on_focus_set(flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_elm_slider_indicator_show_on_focus_set(Eo *obj, void *_pd, va_list *list)
|
||||||
|
{
|
||||||
|
Eina_Bool flag = va_arg(*list, int);
|
||||||
|
Elm_Slider_Smart_Data *sd = _pd;
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
sd->always_popup_show = EINA_TRUE;
|
||||||
|
else
|
||||||
|
sd->always_popup_show = EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
elm_slider_indicator_show_on_focus_get(const Evas_Object *obj)
|
||||||
|
{
|
||||||
|
ELM_SLIDER_CHECK(obj) EINA_FALSE;
|
||||||
|
Eina_Bool ret;
|
||||||
|
|
||||||
|
eo_do((Eo *) obj, elm_obj_slider_indicator_show_on_focus_get(&ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_elm_slider_indicator_show_on_focus_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
|
||||||
|
{
|
||||||
|
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
|
||||||
|
Elm_Slider_Smart_Data *sd = _pd;
|
||||||
|
*ret = sd->always_popup_show;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_elm_slider_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
|
_elm_slider_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
|
||||||
{
|
{
|
||||||
|
@ -1397,6 +1441,20 @@ _elm_slider_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA
|
||||||
*ret = EINA_FALSE;
|
*ret = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_elm_slider_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
||||||
|
{
|
||||||
|
Eina_Bool int_ret;
|
||||||
|
Elm_Slider_Smart_Data *sd = _pd;
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, elm_wdg_on_focus(&int_ret));
|
||||||
|
|
||||||
|
if (sd->always_popup_show && elm_widget_focus_get(obj))
|
||||||
|
_popup_show(obj, NULL, NULL, NULL);
|
||||||
|
else
|
||||||
|
_popup_hide(obj, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_class_constructor(Eo_Class *klass)
|
_class_constructor(Eo_Class *klass)
|
||||||
{
|
{
|
||||||
|
@ -1412,6 +1470,7 @@ _class_constructor(Eo_Class *klass)
|
||||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ACTIVATE), _elm_slider_smart_activate),
|
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ACTIVATE), _elm_slider_smart_activate),
|
||||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT_MANAGER_IS), _elm_slider_smart_focus_next_manager_is),
|
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT_MANAGER_IS), _elm_slider_smart_focus_next_manager_is),
|
||||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_slider_smart_focus_direction_manager_is),
|
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_slider_smart_focus_direction_manager_is),
|
||||||
|
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ON_FOCUS), _elm_slider_smart_on_focus),
|
||||||
|
|
||||||
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_slider_smart_sizing_eval),
|
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_slider_smart_sizing_eval),
|
||||||
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_TEXT_ALIASES_GET), _elm_slider_smart_text_aliases_get),
|
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_TEXT_ALIASES_GET), _elm_slider_smart_text_aliases_get),
|
||||||
|
@ -1437,6 +1496,8 @@ _class_constructor(Eo_Class *klass)
|
||||||
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET), _elm_slider_indicator_show_get),
|
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET), _elm_slider_indicator_show_get),
|
||||||
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_SET), _elm_slider_step_set),
|
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_SET), _elm_slider_step_set),
|
||||||
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_GET), _elm_slider_step_get),
|
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_GET), _elm_slider_step_get),
|
||||||
|
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_SET), _elm_slider_indicator_show_on_focus_set),
|
||||||
|
EO_OP_FUNC(ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_GET), _elm_slider_indicator_show_on_focus_get),
|
||||||
EO_OP_FUNC_SENTINEL
|
EO_OP_FUNC_SENTINEL
|
||||||
};
|
};
|
||||||
eo_class_funcs_set(klass, func_desc);
|
eo_class_funcs_set(klass, func_desc);
|
||||||
|
@ -1465,6 +1526,8 @@ static const Eo_Op_Description op_desc[] = {
|
||||||
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET, "Get whether a given slider widget's enlarging indicator or not."),
|
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET, "Get whether a given slider widget's enlarging indicator or not."),
|
||||||
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_STEP_SET, "Set the draggable's step size."),
|
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_STEP_SET, "Set the draggable's step size."),
|
||||||
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_STEP_GET, "Get the draggable's step size."),
|
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_STEP_GET, "Get the draggable's step size."),
|
||||||
|
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_SET, "Set the visiblity of slider indicator."),
|
||||||
|
EO_OP_DESCRIPTION(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_GET, "Get the visiblity of slider indicator."),
|
||||||
EO_OP_DESCRIPTION_SENTINEL
|
EO_OP_DESCRIPTION_SENTINEL
|
||||||
};
|
};
|
||||||
static const Eo_Class_Description class_desc = {
|
static const Eo_Class_Description class_desc = {
|
||||||
|
|
|
@ -29,6 +29,8 @@ enum
|
||||||
ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET,
|
ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_GET,
|
||||||
ELM_OBJ_SLIDER_SUB_ID_STEP_SET,
|
ELM_OBJ_SLIDER_SUB_ID_STEP_SET,
|
||||||
ELM_OBJ_SLIDER_SUB_ID_STEP_GET,
|
ELM_OBJ_SLIDER_SUB_ID_STEP_GET,
|
||||||
|
ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_SET,
|
||||||
|
ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_GET,
|
||||||
ELM_OBJ_SLIDER_SUB_ID_LAST
|
ELM_OBJ_SLIDER_SUB_ID_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -266,7 +268,7 @@ enum
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def elm_obj_slider_indicator_show_set
|
* @def elm_obj_slider_indicator_show_set
|
||||||
* @since 1.8
|
* @since 1.9
|
||||||
*
|
*
|
||||||
* Set whether to enlarge slider indicator (augmented knob) or not.
|
* Set whether to enlarge slider indicator (augmented knob) or not.
|
||||||
*
|
*
|
||||||
|
@ -326,3 +328,31 @@ enum
|
||||||
* @ingroup Slider
|
* @ingroup Slider
|
||||||
*/
|
*/
|
||||||
#define elm_obj_slider_step_get(ret) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_GET), EO_TYPECHECK(double *, ret)
|
#define elm_obj_slider_step_get(ret) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_STEP_GET), EO_TYPECHECK(double *, ret)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def elm_slider_indicator_show_on_focus_set
|
||||||
|
* @since 1.9
|
||||||
|
*
|
||||||
|
* show indicator of slider on focus
|
||||||
|
*
|
||||||
|
* @param[in] flag
|
||||||
|
*
|
||||||
|
* @see elm_slider_indicator_show_on_focus_set
|
||||||
|
*
|
||||||
|
* @ingroup Slider
|
||||||
|
*/
|
||||||
|
#define elm_obj_slider_indicator_show_on_focus_set(flag) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_SET), EO_TYPECHECK(Eina_Bool, flag)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def elm_slider_indicator_show_on_focus_get
|
||||||
|
* @since 1.9
|
||||||
|
*
|
||||||
|
* Get whether the indicator of the slider is set or not
|
||||||
|
*
|
||||||
|
* @param[out] ret
|
||||||
|
*
|
||||||
|
* @see elm_slider_indicator_show_on_focus_get
|
||||||
|
*
|
||||||
|
* @ingroup Slider
|
||||||
|
*/
|
||||||
|
#define elm_obj_slider_indicator_show_on_focus_get(ret) ELM_OBJ_SLIDER_ID(ELM_OBJ_SLIDER_SUB_ID_INDICATOR_SHOW_ON_FOCUS_GET), EO_TYPECHECK(Eina_Bool*, ret)
|
||||||
|
|
|
@ -357,3 +357,24 @@ EAPI void elm_slider_step_set(Evas_Object *obj, double s
|
||||||
* @ingroup Slider
|
* @ingroup Slider
|
||||||
*/
|
*/
|
||||||
EAPI double elm_slider_step_get(const Evas_Object *obj);
|
EAPI double elm_slider_step_get(const Evas_Object *obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the indicator of slider on focus
|
||||||
|
*
|
||||||
|
* @param obj The slider object.
|
||||||
|
* @param flag @ EINA_TRUE sets the indicator visible
|
||||||
|
*
|
||||||
|
* @ingroup Slider
|
||||||
|
*/
|
||||||
|
EAPI void elm_slider_indicator_show_on_focus_set(Evas_Object *obj, Eina_Bool flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether the indicator of the slider is set or not
|
||||||
|
*
|
||||||
|
* @param obj The slider object.
|
||||||
|
* @return @c EINA_TRUE, if indicator is set
|
||||||
|
* @c EINA_FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @ingroup Slider
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool elm_slider_indicator_show_on_focus_get(const Evas_Object *obj);
|
||||||
|
|
|
@ -43,6 +43,9 @@ struct _Elm_Slider_Smart_Data
|
||||||
Eina_Bool frozen : 1;
|
Eina_Bool frozen : 1;
|
||||||
Eina_Bool popup_hiding : 1;
|
Eina_Bool popup_hiding : 1;
|
||||||
Eina_Bool units_show : 1;
|
Eina_Bool units_show : 1;
|
||||||
|
Eina_Bool always_popup_show : 1; /*this flag is to set the visiblity of slider indicator
|
||||||
|
* if this flag is set then the indicator always show
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue