Color indicator in Native API

Color indicator in Native API

BY 17 Jul 2018 Native Application Development
I need to allow selecting colors for a list’s items and therefore to show the selected colors in lists, details and dialogs. I looked for some color indicator component but did not find any (looks like it does not exist). What can I use for this?
 
The color indicator will be shown inside items of Genlist (in my app Genlist is used for lists, details and dialogs/forms). This can be just a square or circle (filled with the selected color). But, this can also be some more complicated component like a colored button without label. Is there anything like this?
 
I’m trying to implement such indicator using other components, but it does not work for some reason:
Colored square
Thus, I was trying to use Bg in elm.swallow.end of a Genlist item of the “default” item style:
static Evas_Object* gl_content_get_cb(void* data, Evas_Object* obj, const char* part) {
    if (!strcmp(part, "elm.swallow.end")) {
        Evas_Object* bg = elm_bg_add(obj);
    	elm_bg_color_set(bg, 66, 162, 206);
        return bg;
    }
}
But, this renders nothing. If I replace this with, e.g., a check, it is shown. What I’m missing?
Circle widget from ColorSelector
I was also trying to reuse the circle widget, which is used in ColorSelector, as follows:
static Evas_Object* gl_content_get_cb(void* data, Evas_Object* obj, const char* part) {
    if (!strcmp(part, "elm.swallow.end")) {
        Evas_Object* layout = elm_layout_add(obj);
        elm_layout_theme_set(layout, "colorselector", "item", "default");
        return layout;
    }
}
This renders a circle with white background (I can see shadows). But, I do not understand, how can I change the color of this widget.
 
The theme “elm/colorselector/item/default” can be checked here: https://git.enlightenment.org/core/efl.git/tree/data/elementary/themes/edc/elm/colorsel.edc
The source code of the ColorSelector can be found here: https://git.enlightenment.org/core/efl.git/tree/src/lib/elementary/elm_colorselector.c
 
Any of these options or any other new option will work for me. As I wrote, I just need some color indicator. Please help.
 
Thanks.
Andriy
Written by