forked from enlightenment/efl
config: Add support for some enums
This commit is contained in:
parent
575c704b02
commit
8b8430214a
|
@ -4264,8 +4264,16 @@ typedef const char * cstring;
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
_eina_value_to_int(const Eina_Value *val, int *i)
|
_eina_value_to_int(const Eina_Value *val, int *i)
|
||||||
{
|
{
|
||||||
Eina_Value *ival = eina_value_new(EINA_VALUE_TYPE_INT);
|
Eina_Value *ival;
|
||||||
Eina_Bool ret = EINA_TRUE;
|
Eina_Bool ret;
|
||||||
|
|
||||||
|
if (eina_value_type_get(val) == EINA_VALUE_TYPE_INT)
|
||||||
|
{
|
||||||
|
eina_value_get(val, i);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ival = eina_value_new(EINA_VALUE_TYPE_INT);
|
||||||
if (!eina_value_convert(val, ival))
|
if (!eina_value_convert(val, ival))
|
||||||
ret = EINA_FALSE;
|
ret = EINA_FALSE;
|
||||||
else
|
else
|
||||||
|
@ -4287,6 +4295,43 @@ _eina_value_to_cstring(const Eina_Value *val, cstring *s)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
Efl_Ui_Focus_Autoscroll_Mode val;
|
||||||
|
const char *str;
|
||||||
|
} _enum_map_focus_autoscroll_mode[] = {
|
||||||
|
{ EFL_UI_FOCUS_AUTOSCROLL_MODE_SHOW, "show" },
|
||||||
|
{ EFL_UI_FOCUS_AUTOSCROLL_MODE_NONE, "none" },
|
||||||
|
{ EFL_UI_FOCUS_AUTOSCROLL_MODE_BRING_IN, "bring_in" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
Efl_Ui_Softcursor_Mode val;
|
||||||
|
const char *str;
|
||||||
|
} _enum_map_softcursor_mode[] = {
|
||||||
|
{ EFL_UI_SOFTCURSOR_MODE_AUTO, "auto" },
|
||||||
|
{ EFL_UI_SOFTCURSOR_MODE_ON, "on" },
|
||||||
|
{ EFL_UI_SOFTCURSOR_MODE_OFF, "off" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
Efl_Ui_Slider_Indicator_Visible_Mode val;
|
||||||
|
const char *str;
|
||||||
|
} _enum_map_slider_indicator_visible_mode[] = {
|
||||||
|
{ EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_DEFAULT, "default" },
|
||||||
|
{ EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS, "always" },
|
||||||
|
{ EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS, "on_focus" },
|
||||||
|
{ EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_NONE, "none" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
Efl_Ui_Focus_Move_Policy val;
|
||||||
|
const char *str;
|
||||||
|
} _enum_map_focus_move_policy[] = {
|
||||||
|
{ EFL_UI_FOCUS_MOVE_POLICY_CLICK, "click" },
|
||||||
|
{ EFL_UI_FOCUS_MOVE_POLICY_IN, "in" },
|
||||||
|
{ EFL_UI_FOCUS_MOVE_POLICY_KEY_ONLY, "key_only" }
|
||||||
|
};
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
|
_efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
|
||||||
const char *name, const Eina_Value *val)
|
const char *name, const Eina_Value *val)
|
||||||
|
@ -4326,6 +4371,35 @@ _efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_U
|
||||||
#define CONFIG_SETD(opt) CONFIG_SET(opt, double, DOUBLE, int)
|
#define CONFIG_SETD(opt) CONFIG_SET(opt, double, DOUBLE, int)
|
||||||
#define CONFIG_SETS(opt) CONFIG_SET(opt, const char *, STRING, cstring)
|
#define CONFIG_SETS(opt) CONFIG_SET(opt, const char *, STRING, cstring)
|
||||||
|
|
||||||
|
#define CONFIG_SETE(opt) do { \
|
||||||
|
if (!strcmp(name, #opt)) \
|
||||||
|
{ \
|
||||||
|
int v = -1; \
|
||||||
|
if (eina_value_type_get(val) == EINA_VALUE_TYPE_STRING) \
|
||||||
|
{ \
|
||||||
|
const char *str; \
|
||||||
|
eina_value_get(val, &str); \
|
||||||
|
for (unsigned i = 0; i < (sizeof(_enum_map_ ## opt) / sizeof(_enum_map_ ## opt[0])); i++) \
|
||||||
|
{ \
|
||||||
|
if (eina_streq(_enum_map_ ## opt[i].str, str)) { v = _enum_map_ ## opt[i].val; break; } \
|
||||||
|
} \
|
||||||
|
if (v == -1) \
|
||||||
|
{ \
|
||||||
|
ERR("Invalid value for config '%s' (got '%s')", #opt, str); \
|
||||||
|
return EINA_FALSE; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
else if (!_eina_value_to_int(val, &v)) \
|
||||||
|
{ \
|
||||||
|
ERR("Invalid value type for config '%s' (got %s wanted int or string)", \
|
||||||
|
name, eina_value_type_name_get(eina_value_type_get(val))); \
|
||||||
|
return EINA_FALSE; \
|
||||||
|
} \
|
||||||
|
elm_config_ ## opt ## _set(v); \
|
||||||
|
return EINA_TRUE; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
CONFIG_SETB(scroll_bounce_enabled);
|
CONFIG_SETB(scroll_bounce_enabled);
|
||||||
CONFIG_SETD(scroll_bounce_friction);
|
CONFIG_SETD(scroll_bounce_friction);
|
||||||
CONFIG_SETD(scroll_page_scroll_friction);
|
CONFIG_SETD(scroll_page_scroll_friction);
|
||||||
|
@ -4350,10 +4424,10 @@ _efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_U
|
||||||
CONFIG_SETD(scroll_thumbscroll_acceleration_threshold);
|
CONFIG_SETD(scroll_thumbscroll_acceleration_threshold);
|
||||||
CONFIG_SETD(scroll_thumbscroll_acceleration_time_limit);
|
CONFIG_SETD(scroll_thumbscroll_acceleration_time_limit);
|
||||||
CONFIG_SETD(scroll_thumbscroll_acceleration_weight);
|
CONFIG_SETD(scroll_thumbscroll_acceleration_weight);
|
||||||
//focus_autoscroll_mode Elm_Focus_Autoscroll_Mode mode);
|
CONFIG_SETE(focus_autoscroll_mode);
|
||||||
//slider_indicator_visible_mode Elm_Slider_Indicator_Visible_Mode mode);
|
CONFIG_SETE(slider_indicator_visible_mode);
|
||||||
CONFIG_SETD(longpress_timeout);
|
CONFIG_SETD(longpress_timeout);
|
||||||
//softcursor_mode Elm_Softcursor_Mode mode);
|
CONFIG_SETE(softcursor_mode);
|
||||||
CONFIG_SETD(tooltip_delay);
|
CONFIG_SETD(tooltip_delay);
|
||||||
CONFIG_SETB(cursor_engine_only);
|
CONFIG_SETB(cursor_engine_only);
|
||||||
CONFIG_SETD(scale);
|
CONFIG_SETD(scale);
|
||||||
|
@ -4379,7 +4453,7 @@ _efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_U
|
||||||
CONFIG_SETB(focus_highlight_enabled);
|
CONFIG_SETB(focus_highlight_enabled);
|
||||||
CONFIG_SETB(focus_highlight_animate);
|
CONFIG_SETB(focus_highlight_animate);
|
||||||
CONFIG_SETB(focus_highlight_clip_disabled);
|
CONFIG_SETB(focus_highlight_clip_disabled);
|
||||||
//focus_move_policy Elm_Focus_Move_Policy policy);
|
CONFIG_SETE(focus_move_policy);
|
||||||
CONFIG_SETB(item_select_on_focus_disabled);
|
CONFIG_SETB(item_select_on_focus_disabled);
|
||||||
CONFIG_SETB(first_item_focus_on_first_focusin);
|
CONFIG_SETB(first_item_focus_on_first_focusin);
|
||||||
CONFIG_SETB(mirrored);
|
CONFIG_SETB(mirrored);
|
||||||
|
@ -4427,6 +4501,18 @@ _efl_config_internal_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd
|
||||||
#define CONFIG_GETD(opt) CONFIG_GET(opt, double, DOUBLE)
|
#define CONFIG_GETD(opt) CONFIG_GET(opt, double, DOUBLE)
|
||||||
#define CONFIG_GETS(opt) CONFIG_GET(opt, const char *, STRING)
|
#define CONFIG_GETS(opt) CONFIG_GET(opt, const char *, STRING)
|
||||||
|
|
||||||
|
#define CONFIG_GETE(opt) do { \
|
||||||
|
if (!strcmp(name, #opt)) \
|
||||||
|
{ \
|
||||||
|
int v = elm_config_ ## opt ## _get(); \
|
||||||
|
if ((v < 0) || (v > (int)(sizeof(_enum_map_ ## opt) / sizeof(_enum_map_ ## opt[0])))) \
|
||||||
|
v = 0; \
|
||||||
|
val = eina_value_new(EINA_VALUE_TYPE_STRING); \
|
||||||
|
eina_value_set(val, _enum_map_ ## opt[v].str); \
|
||||||
|
return val; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
CONFIG_GETB(scroll_bounce_enabled);
|
CONFIG_GETB(scroll_bounce_enabled);
|
||||||
CONFIG_GETD(scroll_bounce_friction);
|
CONFIG_GETD(scroll_bounce_friction);
|
||||||
CONFIG_GETD(scroll_page_scroll_friction);
|
CONFIG_GETD(scroll_page_scroll_friction);
|
||||||
|
@ -4451,10 +4537,10 @@ _efl_config_internal_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd
|
||||||
CONFIG_GETD(scroll_thumbscroll_acceleration_threshold);
|
CONFIG_GETD(scroll_thumbscroll_acceleration_threshold);
|
||||||
CONFIG_GETD(scroll_thumbscroll_acceleration_time_limit);
|
CONFIG_GETD(scroll_thumbscroll_acceleration_time_limit);
|
||||||
CONFIG_GETD(scroll_thumbscroll_acceleration_weight);
|
CONFIG_GETD(scroll_thumbscroll_acceleration_weight);
|
||||||
//focus_autoscroll_mode
|
CONFIG_GETE(focus_autoscroll_mode);
|
||||||
//slider_indicator_visible_mode
|
CONFIG_GETE(slider_indicator_visible_mode);
|
||||||
CONFIG_GETD(longpress_timeout);
|
CONFIG_GETD(longpress_timeout);
|
||||||
//softcursor_mode
|
CONFIG_GETE(softcursor_mode);
|
||||||
CONFIG_GETD(tooltip_delay);
|
CONFIG_GETD(tooltip_delay);
|
||||||
CONFIG_GETB(cursor_engine_only);
|
CONFIG_GETB(cursor_engine_only);
|
||||||
CONFIG_GETD(scale);
|
CONFIG_GETD(scale);
|
||||||
|
@ -4480,7 +4566,7 @@ _efl_config_internal_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd
|
||||||
CONFIG_GETB(focus_highlight_enabled);
|
CONFIG_GETB(focus_highlight_enabled);
|
||||||
CONFIG_GETB(focus_highlight_animate);
|
CONFIG_GETB(focus_highlight_animate);
|
||||||
CONFIG_GETB(focus_highlight_clip_disabled);
|
CONFIG_GETB(focus_highlight_clip_disabled);
|
||||||
//focus_move_policy
|
CONFIG_GETE(focus_move_policy);
|
||||||
CONFIG_GETB(item_select_on_focus_disabled);
|
CONFIG_GETB(item_select_on_focus_disabled);
|
||||||
CONFIG_GETB(first_item_focus_on_first_focusin);
|
CONFIG_GETB(first_item_focus_on_first_focusin);
|
||||||
CONFIG_GETB(mirrored);
|
CONFIG_GETB(mirrored);
|
||||||
|
|
|
@ -815,7 +815,7 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible, Elm.Inter
|
||||||
[[Returns the widget's focus move policy.]]
|
[[Returns the widget's focus move policy.]]
|
||||||
}
|
}
|
||||||
values {
|
values {
|
||||||
policy: Elm.Focus.Move_Policy; [[Object's focus move policy.]]
|
policy: Efl.Ui.Focus.Move_Policy; [[Object's focus move policy.]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@property focus_move_policy_automatic {
|
@property focus_move_policy_automatic {
|
||||||
|
|
|
@ -38,6 +38,13 @@ START_TEST (elm_config_eoapi)
|
||||||
fail_if(!eina_streq(efl_config_string_get(cfg, #opt), val)); \
|
fail_if(!eina_streq(efl_config_string_get(cfg, #opt), val)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define CONFIG_CHKE(opt, ival, sval) do { \
|
||||||
|
elm_config_ ## opt ## _set(ival); \
|
||||||
|
fail_if(!eina_streq(efl_config_string_get(cfg, #opt), sval)); \
|
||||||
|
fail_if(!efl_config_string_set(cfg, #opt, sval)); \
|
||||||
|
fail_if(!eina_streq(efl_config_string_get(cfg, #opt), sval)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
CONFIG_CHKB(scroll_bounce_enabled, !old);
|
CONFIG_CHKB(scroll_bounce_enabled, !old);
|
||||||
CONFIG_CHKD(scroll_bounce_friction, 0);
|
CONFIG_CHKD(scroll_bounce_friction, 0);
|
||||||
CONFIG_CHKD(scroll_page_scroll_friction, 0);
|
CONFIG_CHKD(scroll_page_scroll_friction, 0);
|
||||||
|
@ -62,10 +69,10 @@ START_TEST (elm_config_eoapi)
|
||||||
CONFIG_CHKD(scroll_thumbscroll_acceleration_threshold, 0);
|
CONFIG_CHKD(scroll_thumbscroll_acceleration_threshold, 0);
|
||||||
CONFIG_CHKD(scroll_thumbscroll_acceleration_time_limit, 0);
|
CONFIG_CHKD(scroll_thumbscroll_acceleration_time_limit, 0);
|
||||||
CONFIG_CHKD(scroll_thumbscroll_acceleration_weight, 0);
|
CONFIG_CHKD(scroll_thumbscroll_acceleration_weight, 0);
|
||||||
//focus_autoscroll_mode
|
CONFIG_CHKE(focus_autoscroll_mode, EFL_UI_FOCUS_AUTOSCROLL_MODE_NONE, "none");
|
||||||
//slider_indicator_visible_mode
|
CONFIG_CHKE(slider_indicator_visible_mode, EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS, "always");
|
||||||
CONFIG_CHKD(longpress_timeout, 0);
|
CONFIG_CHKD(longpress_timeout, 0);
|
||||||
//softcursor_mode
|
CONFIG_CHKE(softcursor_mode, EFL_UI_SOFTCURSOR_MODE_ON, "on");
|
||||||
CONFIG_CHKD(tooltip_delay, 0);
|
CONFIG_CHKD(tooltip_delay, 0);
|
||||||
CONFIG_CHKB(cursor_engine_only, 0);
|
CONFIG_CHKB(cursor_engine_only, 0);
|
||||||
CONFIG_CHKD(scale, 0);
|
CONFIG_CHKD(scale, 0);
|
||||||
|
@ -91,7 +98,7 @@ START_TEST (elm_config_eoapi)
|
||||||
CONFIG_CHKB(focus_highlight_enabled, !old);
|
CONFIG_CHKB(focus_highlight_enabled, !old);
|
||||||
CONFIG_CHKB(focus_highlight_animate, 0);
|
CONFIG_CHKB(focus_highlight_animate, 0);
|
||||||
CONFIG_CHKB(focus_highlight_clip_disabled, !old);
|
CONFIG_CHKB(focus_highlight_clip_disabled, !old);
|
||||||
//focus_move_policy
|
CONFIG_CHKE(focus_move_policy, EFL_UI_FOCUS_MOVE_POLICY_IN, "in");
|
||||||
CONFIG_CHKB(item_select_on_focus_disabled, !old);
|
CONFIG_CHKB(item_select_on_focus_disabled, !old);
|
||||||
CONFIG_CHKB(first_item_focus_on_first_focusin, 0);
|
CONFIG_CHKB(first_item_focus_on_first_focusin, 0);
|
||||||
CONFIG_CHKB(mirrored, 0);
|
CONFIG_CHKB(mirrored, 0);
|
||||||
|
|
Loading…
Reference in New Issue