언어 설정

Menu
Sites
Language
Color indicator in Native API
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
답변 바로가기

Responses

5 댓글
Andriy Lesyuk

Ok. If I specify the minimum size for the Bg, it is shown:

evas_object_size_hint_min_set(bg, 40, 40);

But, why do I have to specify it? I feel, that it's wrong to use explicit size here. Any other workaround?

K Johnson

Hi Andriy Lesyuk,

So far I could understand from your post, you're trying to make a color selector for your wearable circular device. In that case, according to the direction provided in this link, you may try using Rotary Selector.

Please go through this link to know more details about Rotary Selector. Use colors as items of the selector. After that, configure the items according to your requirements and implement selector events along with that.

 

Andriy Lesyuk

Hi, K!

No, I'm doing this for Mobile and I know, how to use ColorSelector.

See, after the ColorSelector returns the selected color, I need to show it on my item details page (e.g., along with the "Color" label). Something like (I'm not sure, how to paste images here):

 [Name___________________x]
----------------------------
 Color                  [#]
----------------------------

Here, [#] is something of the selected color (a box, a circle or whatever).

K Johnson

To get the color from colorselector you may use below function:

elm_colorselector_color_get ( const Elm_Colorselector * obj, int * r, int * g, int * b, int * a )

After that set the selected color on an UI component like a button. Here's a code snippet to create custom button style with changable color, you may follow this.

Mark as answer
Andriy Lesyuk

Thanks for the suggestion, but I would like to avoid creating custom components, where it's possible.

I managed to make Bg work with the following code:

Evas_Object* bg = elm_bg_add(obj);
elm_bg_color_set(bg, 66, 162, 206);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_min_set(bg, ELM_SCALE_SIZE(24), ELM_SCALE_SIZE(24));
evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
return bg;

So, that's what I'll use.