Colorselector
This feature is supported in mobile applications only.
The colorselector component provides a color selection solution to the user. There are different modes available, each of them showing a different configuration of the colorselector component.
Currently only the Palette mode is available in Tizen.
- ELM_COLORSELECTOR_PALETTE
The Palette mode displays several color items that enable the user to choose a color in the items displayed. It is possible to add new items, or to update the color of the current item. The list of color items is called a palette, and it is associated with a unique identifier. This enables the developers to create new series of colors (a new palette) and save it under another identifier. By default, the color palette is using the default identifier.
This UI component inherits from the layout component, so all functions concerning the layout component can also be used on the colorselector component.
Figure: Colorselector component
Figure: Colorselector hierarchy
Adding a Colorselector Component
The following example shows how to create a colorselector object.
Evas_Object *colorsel, *parent; colorsel = elm_colorselector_add(parent);
Setting the Colorselector Modes
The following example shows how to set the mode of the colorselector to the palette mode.
elm_colorselector_mode_set(colorsel, ELM_COLORSELECTOR_PALETTE);
The following example shows how to create a new palette called mypalette. This new palette is saved by elementary config and you can to load it again later. You then add three colors in mypalette: red, green, and blue.
elm_colorselector_palette_name_set(colorsel, "mypalette"); elm_colorselector_palette_color_add(colorsel, 255, 0, 0, 255); elm_colorselector_palette_color_add(colorsel, 0, 255, 0, 255); elm_colorselector_palette_color_add(colorsel, 0, 0, 255, 255);
The default palette already contains 14 colors.
elm_colorselector_palette_name_set(colorsel, "default");
When the user clicks on the color elements, the element changes the color that is set to the colorselector component. You can use the following function to retrieve the current selected color.
int r, g, b, a; elm_colorselector_color_get(colorsel, &r, &g, &b, &a);
Using the Colorselector Callbacks
You can register callbacks on the following signals:
- changed - The color value changes on the selector. event_info is NULL.
- color,item,selected - The user clicks on a color item. The event_info parameter of the callback is the selected color item.
- color,item,longpressed - The user long presses on a color item. The event_info parameter of the callback contains the selected color item.
The following example shows how to register a callback on the changed signal.
{ evas_object_smart_callback_add(colorselector, "changed", changed_cb, data); } // Callback function for the "changed" signal // This callback is called when the colorselector value changes void changed_cb(void *data, Evas_Object *obj, void *event_info) { dlog_print(DLOG_INFO, LOG_TAG, "The color has changed\n"); }