diff --git a/legacy/elementary/data/edje_externals/Makefile.am b/legacy/elementary/data/edje_externals/Makefile.am index 4fd17a84e2..829e4fd5dd 100644 --- a/legacy/elementary/data/edje_externals/Makefile.am +++ b/legacy/elementary/data/edje_externals/Makefile.am @@ -14,6 +14,7 @@ ico_anchorview.png \ ico_bubble.png \ ico_button.png \ ico_check.png \ +ico_hoversel.png \ ico_notepad.png \ ico_radio.png \ ico_scrolled_entry.png \ diff --git a/legacy/elementary/data/edje_externals/ico_hoversel.png b/legacy/elementary/data/edje_externals/ico_hoversel.png new file mode 100644 index 0000000000..134d12db99 Binary files /dev/null and b/legacy/elementary/data/edje_externals/ico_hoversel.png differ diff --git a/legacy/elementary/data/edje_externals/icons.edc b/legacy/elementary/data/edje_externals/icons.edc index de19422fd8..45425fd736 100644 --- a/legacy/elementary/data/edje_externals/icons.edc +++ b/legacy/elementary/data/edje_externals/icons.edc @@ -15,6 +15,7 @@ ICON("anchorview") ICON("bubble") ICON("button") ICON("check") +ICON("hoversel") ICON("notepad") ICON("radio") ICON("scrolled_entry") diff --git a/legacy/elementary/src/edje_externals/Makefile.am b/legacy/elementary/src/edje_externals/Makefile.am index 067ec707b6..eed93555d0 100644 --- a/legacy/elementary/src/edje_externals/Makefile.am +++ b/legacy/elementary/src/edje_externals/Makefile.am @@ -31,6 +31,7 @@ elm_anchorview.c \ elm_bubble.c \ elm_button.c \ elm_check.c \ +elm_hoversel.c \ elm_notepad.c \ elm_radio.c \ elm_scrolled_entry.c \ diff --git a/legacy/elementary/src/edje_externals/elm_hoversel.c b/legacy/elementary/src/edje_externals/elm_hoversel.c new file mode 100644 index 0000000000..902a956eb2 --- /dev/null +++ b/legacy/elementary/src/edje_externals/elm_hoversel.c @@ -0,0 +1,140 @@ +#include "private.h" + +typedef struct _Elm_Params_Hoversel +{ + Elm_Params base; + Evas_Object *icon; + Eina_Bool horizontal:1; + Eina_Bool horizontal_exists:1; +} Elm_Params_Hoversel; + +static void +external_hoversel_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) +{ + const Elm_Params_Hoversel *p; + + if (to_params) p = to_params; + else if (from_params) p = from_params; + else return; + + if (p->base.label) + elm_hoversel_label_set(obj, p->base.label); + if (p->icon) + elm_hoversel_icon_set(obj, p->icon); + if (p->horizontal_exists) + elm_hoversel_horizontal_set(obj, p->horizontal); +} + +static Eina_Bool +external_hoversel_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) +{ + if (!strcmp(param->name, "label")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + elm_hoversel_label_set(obj, param->s); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "icon")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + Evas_Object *icon = external_common_param_icon_get(obj, param); + if (icon) + { + elm_hoversel_icon_set(obj, icon); + return EINA_TRUE; + } + } + } + else if (!strcmp(param->name, "horizontal")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + { + elm_hoversel_horizontal_set(obj, param->i); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static Eina_Bool +external_hoversel_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) +{ + if (!strcmp(param->name, "label")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + param->s = elm_hoversel_label_get(obj); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "icon")) + { + /* not easy to get icon name back from live object */ + return EINA_FALSE; + } + else if (!strcmp(param->name, "horizontal")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + { + param->i = elm_hoversel_horizontal_get(obj); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static void * +external_hoversel_params_parse(void *data, Evas_Object *obj, const Eina_List *params) +{ + Elm_Params_Hoversel *mem; + Edje_External_Param *param; + const Eina_List *l; + + mem = external_common_params_parse(Elm_Params_Hoversel, data, obj, params); + if (!mem) + return NULL; + + external_common_icon_param_parse(&mem->icon, obj, params); + + EINA_LIST_FOREACH(params, l, param) + { + if (!strcmp(param->name, "horizontal")) + { + mem->horizontal = !!param->i; + mem->horizontal_exists = EINA_TRUE; + } + } + + return mem; +} + + static void +external_hoversel_params_free(void *params) +{ + Elm_Params_Hoversel *mem = params; + + if (mem->icon) + evas_object_del(mem->icon); + external_common_params_free(params); +} + +static Edje_External_Param_Info external_hoversel_params[] = { + DEFINE_EXTERNAL_COMMON_PARAMS, + EDJE_EXTERNAL_PARAM_INFO_STRING("icon"), + EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"), + EDJE_EXTERNAL_PARAM_INFO_SENTINEL +}; + +DEFINE_EXTERNAL_ICON_ADD(hoversel, "hoversel"); +DEFINE_EXTERNAL_TYPE_SIMPLE(hoversel, "Hoversel"); diff --git a/legacy/elementary/src/edje_externals/modules.inc b/legacy/elementary/src/edje_externals/modules.inc index 6517ba10a4..8543d130ea 100644 --- a/legacy/elementary/src/edje_externals/modules.inc +++ b/legacy/elementary/src/edje_externals/modules.inc @@ -3,6 +3,7 @@ DEFINE_TYPE(anchorview) DEFINE_TYPE(bubble) DEFINE_TYPE(button) DEFINE_TYPE(check) +DEFINE_TYPE(hoversel) DEFINE_TYPE(notepad) DEFINE_TYPE(radio) DEFINE_TYPE(scrolled_entry) diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 6d1a602ba9..a680ca31d7 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -738,6 +738,7 @@ extern "C" { EAPI Evas_Object *elm_hoversel_add(Evas_Object *parent); EAPI void elm_hoversel_horizontal_set(Evas_Object *obj, Eina_Bool horizontal); + EAPI Eina_Bool elm_hoversel_horizontal_get(const Evas_Object *obj); EAPI void elm_hoversel_hover_parent_set(Evas_Object *obj, Evas_Object *parent); EAPI void elm_hoversel_label_set(Evas_Object *obj, const char *label); EAPI const char *elm_hoversel_label_get(const Evas_Object *obj); diff --git a/legacy/elementary/src/lib/elc_hoversel.c b/legacy/elementary/src/lib/elc_hoversel.c index 329516dfac..fc4a765b1b 100644 --- a/legacy/elementary/src/lib/elc_hoversel.c +++ b/legacy/elementary/src/lib/elc_hoversel.c @@ -318,6 +318,15 @@ elm_hoversel_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) wd->horizontal = !!horizontal; } +EAPI Eina_Bool +elm_hoversel_horizontal_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + return wd->horizontal; +} + /** * Get the hoversel button label *