elemenatry/colorselector - finally first implementation going on

Signed-Off-By: ShilpaOnkar Singh(shilpa.singh@samsung.com)



SVN revision: 69100
devs/felipealmeida/promises
ChunEon Park 11 years ago
parent d25bfa1266
commit d951cb6136
  1. 156
      legacy/elementary/config/default/base.src
  2. 156
      legacy/elementary/config/illume/base.src
  3. 156
      legacy/elementary/config/standard/base.src
  4. 131
      legacy/elementary/data/themes/widgets/colorselector.edc
  5. 162
      legacy/elementary/data/themes/widgets/index.edc
  6. 2
      legacy/elementary/doc/Makefile.am
  7. 23
      legacy/elementary/doc/examples.dox
  8. 8
      legacy/elementary/doc/widgets/widget_preview_colorselector.c
  9. 2
      legacy/elementary/src/bin/test.c
  10. 50
      legacy/elementary/src/bin/test_colorselector.c
  11. 175
      legacy/elementary/src/bin/test_index.c
  12. 61
      legacy/elementary/src/examples/colorselector_example_01.c
  13. 464
      legacy/elementary/src/lib/elm_colorselector.c
  14. 100
      legacy/elementary/src/lib/elm_colorselector.h
  15. 124
      legacy/elementary/src/lib/elm_config.c
  16. 5
      legacy/elementary/src/lib/elm_priv.h

@ -59,4 +59,160 @@ group "Elm_Config" struct {
value "week_start" int: 1;
value "weekend_start" int: 6;
value "weekend_len" int: 2;
group "color_palette" list {
group "Elm_Custom_Palette" struct {
value "palette_name" string: "default";
group "color_list" list {
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 0;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 255;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 0;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 255;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 255;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 0;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 90;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 180;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 92;
value "g" uint: 142;
value "b" uint: 151;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 41;
value "g" uint: 68;
value "b" uint: 59;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 41;
value "g" uint: 46;
value "b" uint: 68;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 68;
value "g" uint: 40;
value "b" uint: 55;
value "a" uint: 255;
}
}
}
group "Elm_Custom_Palette" struct {
value "palette_name" string: "painting";
group "color_list" list {
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 90;
value "b" uint: 18;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 213;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 146;
value "g" uint: 255;
value "b" uint: 11;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 9;
value "g" uint: 186;
value "b" uint: 10;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 86;
value "g" uint: 201;
value "b" uint: 242;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 18;
value "g" uint: 83;
value "b" uint: 128;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 140;
value "g" uint: 53;
value "b" uint: 238;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 145;
value "b" uint: 145;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 59;
value "b" uint: 119;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 133;
value "g" uint: 100;
value "b" uint: 69;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 255;
value "b" uint: 119;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 133;
value "g" uint: 100;
value "b" uint: 255;
value "a" uint: 255;
}
}
}
}
}

@ -59,4 +59,160 @@ group "Elm_Config" struct {
value "week_start" int: 1;
value "weekend_start" int: 6;
value "weekend_len" int: 2;
group "color_palette" list {
group "Elm_Custom_Palette" struct {
value "palette_name" string: "default";
group "color_list" list {
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 0;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 255;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 0;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 255;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 255;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 0;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 90;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 180;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 92;
value "g" uint: 142;
value "b" uint: 151;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 41;
value "g" uint: 68;
value "b" uint: 59;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 41;
value "g" uint: 46;
value "b" uint: 68;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 68;
value "g" uint: 40;
value "b" uint: 55;
value "a" uint: 255;
}
}
}
group "Elm_Custom_Palette" struct {
value "palette_name" string: "painting";
group "color_list" list {
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 90;
value "b" uint: 18;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 213;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 146;
value "g" uint: 255;
value "b" uint: 11;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 9;
value "g" uint: 186;
value "b" uint: 10;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 86;
value "g" uint: 201;
value "b" uint: 242;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 18;
value "g" uint: 83;
value "b" uint: 128;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 140;
value "g" uint: 53;
value "b" uint: 238;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 145;
value "b" uint: 145;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 59;
value "b" uint: 119;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 133;
value "g" uint: 100;
value "b" uint: 69;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 255;
value "b" uint: 119;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 133;
value "g" uint: 100;
value "b" uint: 255;
value "a" uint: 255;
}
}
}
}
}

@ -59,4 +59,160 @@ group "Elm_Config" struct {
value "week_start" int: 1;
value "weekend_start" int: 6;
value "weekend_len" int: 2;
group "color_palette" list {
group "Elm_Custom_Palette" struct {
value "palette_name" string: "default";
group "color_list" list {
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 0;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 255;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 0;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 255;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 0;
value "g" uint: 255;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 0;
value "b" uint: 255;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 90;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 180;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 92;
value "g" uint: 142;
value "b" uint: 151;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 41;
value "g" uint: 68;
value "b" uint: 59;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 41;
value "g" uint: 46;
value "b" uint: 68;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 68;
value "g" uint: 40;
value "b" uint: 55;
value "a" uint: 255;
}
}
}
group "Elm_Custom_Palette" struct {
value "palette_name" string: "painting";
group "color_list" list {
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 90;
value "b" uint: 18;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 213;
value "b" uint: 0;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 146;
value "g" uint: 255;
value "b" uint: 11;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 9;
value "g" uint: 186;
value "b" uint: 10;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 86;
value "g" uint: 201;
value "b" uint: 242;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 18;
value "g" uint: 83;
value "b" uint: 128;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 140;
value "g" uint: 53;
value "b" uint: 238;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 145;
value "b" uint: 145;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 59;
value "b" uint: 119;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 133;
value "g" uint: 100;
value "b" uint: 69;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 255;
value "g" uint: 255;
value "b" uint: 119;
value "a" uint: 255;
}
group "Elm_Color_RGBA" struct {
value "r" uint: 133;
value "g" uint: 100;
value "b" uint: 255;
value "a" uint: 255;
}
}
}
}
}

@ -1,3 +1,66 @@
///////////////////////////////////////////////////////////////////////////////
group {
name: "elm/colorselector/palette/default";
data.item: "horizontal_pad" "10";
data.item: "vertical_pad" "10";
parts {
part { name: "base";
type: RECT;
scale: 1;
mouse_events: 1;
description { state: "default" 0.0;
visible: 0;
align: 0.0 0.0;
}
}
part { name: "palette";
type: SWALLOW;
scale: 1;
mouse_events: 1;
description { state: "default" 0.0;
align: 0.0 0.0;
rel1 {
relative: 0.0 0.0;
to: "base";
}
rel2 {
relative: 1.0 0.0;
to: "base";
}
}
}
part{ name: "bottom_padding";
type: RECT;
scale: 1;
description { state: "default" 0.0;
visible: 0;
min: 0 20;
fixed: 0 1;
rel1.relative: 0.0 1.0;
rel1.to: "palette";
rel2.to: "palette";
align: 0.0 0.0;
}
}
part { name: "selector";
type: SWALLOW;
scale: 1;
mouse_events: 1;
description { state: "default" 0.0;
align: 0.0 1.0;
rel1 {
relative: 0.0 1.0;
to: "bottom_padding";
}
rel2 {
relative: 1.0 1.0;
to: "base";
}
}
}
}
}
group { name: "elm/colorselector/bg/default";
parts {
part { name: "elm.colorbar_0";
@ -165,8 +228,7 @@ group { name: "elm/colorselector/base/default";
type: SWALLOW;
mouse_events: 1;
scale: 1;
description {
state: "default" 0.0;
description { state: "default" 0.0;
min: 24 24;
fixed: 1 1;
rel1 {
@ -284,3 +346,68 @@ group { name: "elm/colorselector/arrow/default";
}
}
}
group { name: "elm/colorselector/item/default";
parts {
part { name: "color_bg";
type: RECT;
mouse_events: 1;
scale: 1;
description { state: "default" 0.0;
min: 40 40;
}
}
part { name: "color_obj";
type: SWALLOW;
mouse_events: 1;
scale: 1;
description { state: "default" 0.0;
rel1.to: "color_bg";
rel2.to: "color_bg";
}
}
part { name: "focus_color";
mouse_events:1;
scale: 1;
type: RECT;
description { state: "default" 0.0;
visible: 0;
min: 38 38;
rel1.to: "color_bg";
rel2.to: "color_bg";
color: 255 255 255 80;
}
description { state: "focused" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
}
programs {
program { name: "item_focus";
source: "elm";
signal: "elm,state,selected";
action: STATE_SET "focused" 0.0;
target: "focus_color";
}
program { name: "item_unfocus";
source: "elm";
signal: "elm,state,unselected";
action: STATE_SET "default" 0.0;
target: "focus_color";
}
}
}
group { name: "elm/colorselector/item/color/default";
parts {
part { name: "color_rect";
type: RECT;
mouse_events: 1;
scale: 1;
description{ state: "default" 0.0;
}
}
}
}

@ -807,3 +807,165 @@ group { name: "elm/index/item_odd/horizontal/default";
}
}
group {
name: "elm/index/base/vertical/pagecontrol";
alias: "elm/index/base/horizontal/pagecontrol";
parts {
part { name: "clip";
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
}
description { state: "active" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part {
name: "elm.swallow.index.0";
type: SWALLOW;
scale: 1;
clip_to: "clip";
description {
state: "default" 0.0;
align: 0.5 0;
rel1.relative: 0 0;
rel2.relative: 1 1;
}
}
part { name: "elm.swallow.event.0";
type: SWALLOW;
description { state: "default" 0.0;
align: 0.5 0;
fixed: 1 1;
rel1 {
relative: 0 0.0;
offset: 0 0;
}
rel2 {
relative: 1 0.0;
offset: -1 -1;
}
}
}
}
programs {
program { name: "active";
signal: "elm,state,active";
source: "elm";
action: STATE_SET "active" 0.0;
transition: DECELERATE 0.5;
target: "clip";
}
program { name: "inactive";
signal: "elm,state,inactive";
source: "elm";
action: STATE_SET "default" 0.0;
transition: DECELERATE 0.5;
target: "clip";
}
}
}
group {
name: "elm/index/item/vertical/pagecontrol";
alias: "elm/index/item_odd/vertical/pagecontrol";
alias: "elm/index/item/horizontal/pagecontrol";
alias: "elm/index/item_odd/horizontal/pagecontrol";
images {
image: "00_mainmenu_page_bar_001.png" COMP;
image: "00_mainmenu_page_bar_002.png" COMP;
}
parts {
part {
name:"bg";
type : RECT;
scale: 1;
description {
state: "default" 0.0;
min: 40 40;
max: 40 40;
align:0.5 0;
visible: 0;
}
}
part {
name: "indicator";
type: IMAGE;
mouse_events: 0;
scale: 1;
description {
state: "default" 0.0;
min: 20 20;
max: 20 20;
fixed: 1 1;
rel1 { to: "bg"; }
rel2 { to: "bg"; }
image {
normal: "00_mainmenu_page_bar_001.png";
}
}
description {
state: "active" 0.0;
inherit: "default" 0.0;
min: 40 40;
max: 40 40;
image {
normal: "00_mainmenu_page_bar_002.png";
}
}
}
part {
name: "elm.text";
type: TEXT;
mouse_events: 0;
scale: 1;
description {
state: "default" 0.0;
min: 40 40;
max: 40 40;
fixed: 1 1;
color: 170 170 170 0;
text {
font: "Sans,Edje-Vera";
size: 10;
min: 0 1;
align: 0.5 0.5;
}
rel1 { to: "bg"; }
rel2 { to: "bg"; }
}
description {
state: "active" 0.0;
inherit: "default" 0.0;
color: 170 170 170 255;
min: 40 40;
max: 40 40;
text {
font: "Sans,Edje-Vera";
size: 10;
min: 0 1;
}
}
}
}
programs {
program { name: "active";
signal: "elm,state,active";
source: "elm";
action: STATE_SET "active" 0.0;
target: "indicator";
target: "elm.text";
transition: LINEAR 0.2;
}
program { name: "inactive";
signal: "elm,state,inactive";
source: "elm";
action: STATE_SET "default" 0.0;
target: "indicator";
target: "elm.text";
transition: LINEAR 0.2;
}
}
}

@ -24,7 +24,7 @@ WGT_PREVIEW = \
bubble:preview-00.png:widget_preview_bubble1:160:50 \
bubble:preview-01.png:widget_preview_bubble2:160:50 \
bubble:preview-02.png:widget_preview_bubble3:160:50 \
colorselector:preview-00.png:widget_preview_colorselector:160:200 \
colorselector:preview-00.png:widget_preview_colorselector:320:300 \
layout:preview-00.png:widget_preview_layout:200:160 \
conformant:preview-00.png:widget_preview_conformant:200:400 \
list:preview-00.png:widget_preview_list:200:200 \

@ -5485,16 +5485,29 @@
* @until show(rect)
*
* Now that we have a window with background and a rectangle we can create
* our color_selector and set it's initial color to fully opaque blue:
* @until show
* our color_selector
* @until elm_colorselector_add
*
* Now colors can be loaded to color selector's palette by setting the palette name
* @until show(cs)
*
* Next we tell ask to be notified whenever the color changes:
* Next we ask to be notified whenever the color changes on selector:
* @until changed
*
* We follow that we some more run of the mill setup code:
* Next we ask to be notified whenever the color item is selected and longpressed:
* @until color,item,longpressed
*
* We add some more code to the usual setup code:
* @until ELM_MAIN()
*
* And now get to the callback that sets the color of the rectangle:
* now get to the "changed" callback that sets the color of the rectangle:
* @until }
*
* And now get to the "color,item,selected" callback that sets the color of the rectangle:
* @until }
*
* And now get to the "color,item,longpressed" callback that gets and displays
* the color of the rectangle:
* @until }
*
* This example will look like this:

@ -1,8 +1,14 @@
#include "widget_preview_tmpl_head.c"
Evas_Object *bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
Evas_Object *o = elm_colorselector_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, o);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);;
elm_box_pack_end(bx, o);
evas_object_show(o);
#include "widget_preview_tmpl_foot.c"

@ -112,6 +112,7 @@ void test_scroller2(void *data, Evas_Object *obj, void *event_info);
void test_spinner(void *data, Evas_Object *obj, void *event_info);
void test_index(void *data, Evas_Object *obj, void *event_info);
void test_index2(void *data, Evas_Object *obj, void *event_info);
void test_index3(void *data, Evas_Object *obj, void *event_info);
void test_photocam(void *data, Evas_Object *obj, void *event_info);
void test_photo(void *data, Evas_Object *obj, void *event_info);
void test_thumb(void *data, Evas_Object *obj, void *event_info);
@ -470,6 +471,7 @@ add_tests:
//------------------------------//
ADD_TEST(NULL, "Selectors", "Index", test_index);
ADD_TEST(NULL, "Selectors", "Index 2", test_index2);
ADD_TEST(NULL, "Selectors", "Index 3", test_index3);
ADD_TEST(NULL, "Selectors", "File Selector", test_fileselector);
ADD_TEST(NULL, "Selectors", "File Selector Entry", test_fileselector_entry);
ADD_TEST(NULL, "Selectors", "File Selector Button", test_fileselector_button);

@ -21,10 +21,28 @@ _colorselector_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSE
evas_object_color_set(re, r, g, b, a);
}
static void
_colorpalette_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
int r = 0, g = 0, b = 0 ,a = 0;
Elm_Object_Item *color_it = (Elm_Object_Item *) event_info;
elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
evas_object_color_set((Evas_Object *) data, r, g, b , a);
}
static void
_colorpalette_longpressed_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
int r = 0,g = 0,b = 0 ,a = 0;
Elm_Object_Item *color_it = (Elm_Object_Item *) event_info;
elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
printf("\ncolor = %d-%d-%d-%d\n", r, g, b, a);
}
void
test_colorselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bx, *cp, *fr, *ly, *re;
Evas_Object *win, *bg, *bx, *cs, *fr, *ly, *re;
char buf[PATH_MAX];
int r, g, b, a;
@ -69,21 +87,35 @@ test_colorselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *eve
elm_box_pack_end(bx, fr);
evas_object_show(fr);
cp = elm_colorselector_add(win);
cs = elm_colorselector_add(win);
elm_colorselector_palette_color_add(cs, 255, 90, 18, 255);
elm_colorselector_palette_color_add(cs, 255, 213, 0, 255);
elm_colorselector_palette_color_add(cs, 146, 255, 11, 255);
elm_colorselector_palette_color_add(cs, 9, 186, 10, 255);
elm_colorselector_palette_color_add(cs, 86, 201, 242, 255);
elm_colorselector_palette_color_add(cs, 18, 83, 128, 255);
elm_colorselector_palette_color_add(cs, 140, 53, 238, 255);
elm_colorselector_palette_color_add(cs, 255, 145, 145, 255);
elm_colorselector_palette_color_add(cs, 255, 59, 119, 255);
elm_colorselector_palette_color_add(cs, 133, 100, 69, 255);
elm_colorselector_palette_color_add(cs, 255, 255, 119, 255);
elm_colorselector_palette_color_add(cs, 133, 100, 255, 255);
a = 180;
r = 255;
g = 160;
b = 132;
elm_colorselector_color_set(cp, r, g, b, a);
evas_object_size_hint_weight_set(cp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cp, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(fr, cp);
evas_object_show(cp);
evas_object_smart_callback_add(cp, "changed", _colorselector_clicked_cb, re);
elm_colorselector_color_set(cs, r, g, b, a);
evas_object_size_hint_weight_set(cs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cs, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(fr, cs);
evas_object_show(cs);
evas_object_smart_callback_add(cs, "changed", _colorselector_clicked_cb, re);
evas_object_smart_callback_add(cs, "color,item,selected", _colorpalette_clicked_cb, re);
evas_object_smart_callback_add(cs, "color,item,longpressed", _colorpalette_longpressed_cb, re);
elm_colorselector_color_get(cp, &r, &g, &b, &a);
elm_colorselector_color_get(cs, &r, &g, &b, &a);
/* Fix Alpha pre multiplication by edje */
r = (r * a) / 255;
g = (g * a) / 255;

@ -18,6 +18,18 @@ struct _api_data
};
typedef struct _api_data api_data;
struct _pagectrl_data
{
Evas_Object *index;
Evas_Object *sc;
Evas_Coord recent_x;
Evas_Coord page_width;
int page_cnt;
Eina_Bool drag_started : 1;
Eina_Bool changed : 1;
};
typedef struct _pagectrl_data pagectrl_data;
enum _api_state
{
INDEX_LEVEL_SET,
@ -394,4 +406,167 @@ test_index2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_show(win);
}
static void
_drag_start(void *data , Evas_Object *obj, void *event_info __UNUSED__)
{
pagectrl_data *page_data = data;
Evas_Coord x, y, w, h;
elm_scroller_region_get(obj, &x, &y, &w, &h);
page_data->recent_x = x;
page_data->drag_started = EINA_TRUE;
}
static void
_drag_stop(void *data , Evas_Object *obj, void *event_info __UNUSED__)
{
pagectrl_data *page_data = data;
Evas_Coord x, y, w, h;
elm_scroller_region_get(obj, &x, &y, &w, &h);
if ((page_data->recent_x == x) && (x != 0))
elm_object_scroll_hold_push(obj);
}
static void
_anim_start(void *data , Evas_Object *obj, void *event_info __UNUSED__)
{
pagectrl_data *page_data = data;
Evas_Coord x, y, w, h;
Elm_Object_Item *it;
int idx;
int threshold;
Evas_Coord max_page_x;
if (page_data->changed)
{
page_data->changed = EINA_FALSE;
return;
}
if (!page_data->drag_started) return;
max_page_x = (page_data->page_cnt - 1) * page_data->page_width;
elm_scroller_region_get(obj, &x, &y, &w, &h);
it = elm_index_selected_item_get(page_data->index, 0);
if (!it) return;
idx = (int) elm_object_item_data_get(it);
if (x < 0) x = 0;
if (x > max_page_x) x = max_page_x;
threshold = page_data->page_width * 0.2;
if (abs(page_data->recent_x - x) > threshold)
{
if (x > page_data->recent_x) idx++;
else if ((x < page_data->recent_x) && (idx > 0)) idx--;
}
if (idx > page_data->page_cnt) idx = page_data->page_cnt;
page_data->drag_started = EINA_FALSE;
elm_scroller_region_bring_in(obj, page_data->page_width * idx, 0, w, h);
it = elm_index_item_find(page_data->index, (void *) idx);
elm_index_item_selected_set(it, EINA_TRUE);
}
static void
_anim_stop(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
elm_object_scroll_hold_pop(obj);
}
static void
_index3_selected_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
Evas_Coord x, y, w, h;
Elm_Object_Item *it = event_info;
int idx = (int) elm_object_item_data_get(it);
pagectrl_data *page_data = data;
evas_object_geometry_get(page_data->sc, &x, &y, &w, &h);
page_data->changed = EINA_TRUE;
elm_scroller_region_bring_in(page_data->sc, page_data->page_width * idx, 0,
w, h);
}
void
test_index3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *sc, *img, *id;
char buf[PATH_MAX];
api_data *api = calloc(1, sizeof(api_data));
pagectrl_data *page_data = calloc(1, sizeof(pagectrl_data));
Evas_Coord page_h;
int i;
Elm_Object_Item *it;
page_data->page_width = 480;
page_data->page_cnt = 3;
win = elm_win_add(NULL, "index", ELM_WIN_BASIC);
elm_win_title_set(win, "index - pagecontrol style");
elm_win_autodel_set(win, EINA_TRUE);
evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
img = elm_image_add(win);
snprintf(buf, sizeof(buf), "%s/images/horz_scrollbar.jpg", elm_app_data_dir_get());
elm_image_file_set(img, buf, NULL);
elm_image_resizable_set(img, EINA_TRUE, EINA_FALSE);
elm_image_object_size_get(img, NULL, &page_h);
evas_object_show(img);
page_data->sc = sc = elm_scroller_add(win);
evas_object_smart_callback_add(sc, "scroll,drag,start", _drag_start,
page_data);
evas_object_smart_callback_add(sc, "scroll,drag,stop", _drag_stop,
page_data);
evas_object_smart_callback_add(sc, "scroll,anim,start", _anim_start,
page_data);
evas_object_smart_callback_add(sc, "scroll,anim,stop", _anim_stop,
page_data);
elm_scroller_bounce_set(sc, EINA_FALSE, EINA_FALSE);
elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF,
ELM_SCROLLER_POLICY_OFF);
elm_scroller_page_size_set(sc, page_data->page_width, page_h);
elm_object_content_set(sc, img);
elm_object_scroll_lock_y_set(sc, EINA_TRUE);
elm_win_resize_object_add(win, sc);
evas_object_show(sc);
page_data->index = api->dt.id = id = elm_index_add(win);
elm_index_horizontal_set(id, EINA_TRUE);
elm_index_autohide_disabled_set(id, EINA_TRUE);
elm_object_style_set(id, "pagecontrol");
evas_object_smart_callback_add(id, "selected", _index3_selected_cb,
page_data);
evas_object_size_hint_weight_set(id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(id, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(id);
for(i = 0; i < page_data->page_cnt; i++)
{
snprintf(buf, sizeof(buf), "%c", '1' + i);
if (i == 0)
it = elm_index_item_append(id, buf, NULL, (void *) i);
else
elm_index_item_append(id, buf, NULL, (void *) i);
}
elm_index_level_go(id, 0);
elm_index_item_selected_set(it, EINA_TRUE);
elm_win_resize_object_add(win, id);
evas_object_resize(win, page_data->page_width, 585);
evas_object_show(win);
}
#endif

@ -7,12 +7,13 @@
#endif
static void _change_color(void *data, Evas_Object *obj, void *event_info);
static void _colorpalette_clicked_cb(void *data, Evas_Object *obj, void *event_info);
static void _colorpalette_longpressed_cb(void *data, Evas_Object *obj, void *event_info);
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Evas_Object *win, *bg, *cs, *frame, *rect;
char buf[256];
Evas_Object *win, *bg, *cs, *rect, *bx, *fr;
win = elm_win_add(NULL, "color selector", ELM_WIN_BASIC);
elm_win_title_set(win, "Color selector");
@ -20,26 +21,50 @@ elm_main(int argc, char **argv)
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
fr = elm_frame_add(win);
evas_object_size_hint_weight_set(fr, 1.0, 0.5);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(fr, "Color View");
elm_box_pack_end(bx, fr);
evas_object_show(fr);
rect = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_resize(rect, 50, 50);
evas_object_move(rect, 125, 325);
evas_object_color_set(rect, 0, 0, 255, 255);
elm_object_content_set(fr, rect);
evas_object_color_set(rect, 255, 90, 18, 255);
evas_object_show(rect);
fr = elm_frame_add(win);
evas_object_size_hint_weight_set(fr, 1.0, 0.5);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(fr, "Color Selector");
elm_box_pack_end(bx, fr);
evas_object_show(fr);
cs = elm_colorselector_add(win);
elm_colorselector_color_set(cs, 0, 0, 255, 255);
evas_object_resize(cs, 300, 300);
elm_colorselector_palette_name_set(cs, "painting");
evas_object_size_hint_weight_set(cs, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(cs, EVAS_HINT_FILL, 0.0);
elm_colorselector_color_set(cs, 255, 90, 18, 255);
evas_object_show(cs);
evas_object_smart_callback_add(cs, "changed", _change_color, rect);
evas_object_smart_callback_add(cs, "color,item,selected", _colorpalette_clicked_cb, rect);
evas_object_smart_callback_add(cs, "color,item,longpressed", _colorpalette_longpressed_cb, rect);
elm_object_content_set(fr, cs);
evas_object_resize(win, 300, 400);
evas_object_resize(win, 320, 480);
evas_object_show(win);
elm_run();
evas_object_del(rect);
return 0;
}
@ -52,3 +77,21 @@ _change_color(void *data, Evas_Object *obj, void *event_info)
elm_colorselector_color_get(obj, &r, &g, &b, &a);
evas_object_color_set(data, r, g, b, a);
}
static void
_colorpalette_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
int r = 0, g = 0, b = 0 ,a = 0;
Elm_Object_Item *color_it = (Elm_Object_Item *) event_info;
elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
evas_object_color_set(data, r, g, b, a);
}
static void
_colorpalette_longpressed_cb(void *data, Evas_Object *obj, void *event_info)
{
int r = 0,g = 0,b = 0 ,a = 0;
Elm_Object_Item *color_it = (Elm_Object_Item *) event_info;
elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
printf("\ncolor = %d-%d-%d-%d\n", r, g, b, a);
}

@ -6,6 +6,8 @@
#define SAT_STEP 128.0
#define LIG_STEP 256.0
#define ALP_STEP 256.0
#define DEFAULT_HOR_PAD 10
#define DEFAULT_VER_PAD 10
typedef enum _Color_Type
{
@ -30,16 +32,32 @@ struct _Colorselector_Data
};
typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Color_Item Elm_Color_Item;
struct _Widget_Data
{
Evas_Object *sel;
Evas_Object *base;
Evas_Object *box;
Eina_List *items;
Colorselector_Data *cp[4];
Ecore_Timer *longpress_timer;
const char *palette_name;
Evas_Coord _x, _y, _w, _h;
int r, g, b, a;
int er, eg, eb;
int sr, sg, sb;
int lr, lg, lb;
double h, s, l;
Elm_Colorselector_Mode mode;
Eina_Bool longpressed : 1;
Eina_Bool config_load: 1;
};
struct _Elm_Color_Item
{
ELM_WIDGET_ITEM;
Evas_Object *color_obj;
Elm_Color_RGBA *color;
};
static const char *widtype = NULL;
@ -47,6 +65,7 @@ static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _resize_cb(void *data, Evas *a, Evas_Object *obj, void *event_info);
static void _rgb_to_hsl(void *data);
static void _hsl_to_rgb(void *data);
static void _color_with_saturation(void *data);
@ -66,13 +85,26 @@ static void _right_button_repeat_cb(void *data, Evas_Object * obj,
void *event_info);
static void _add_colorbar(Evas_Object *obj);
static void _set_color(Evas_Object *obj, int r, int g, int b, int a);
static Elm_Color_Item *_item_new(Evas_Object *obj);
static void _item_sizing_eval(Elm_Color_Item *item);
static void _item_highlight(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _item_unhighlight(void *data, Evas *e, Evas_Object *obj, void *event_info);
static Eina_Bool _long_press(void *data);
static void _remove_items(Widget_Data *wd);
static void _colors_remove(Evas_Object *obj);
static void _colors_save(Evas_Object *obj);
static void _colors_load_apply(Evas_Object *obj);
static const char SIG_CHANGED[] = "changed";
static const char SIG_COLOR_ITEM_SELECTED[] = "color,item,selected";
static const char SIG_COLOR_ITEM_LONGPRESSED[] = "color,item,longpressed";
static const Evas_Smart_Cb_Description _signals[] =
{
{SIG_CHANGED, ""},
{NULL, NULL}
{SIG_COLOR_ITEM_SELECTED, ""},
{SIG_COLOR_ITEM_LONGPRESSED, ""},
{SIG_CHANGED, ""},
{NULL, NULL}
};
static void
@ -82,6 +114,9 @@ _del_hook(Evas_Object *obj)
int i = 0;
if (!wd) return;
if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
if (wd->palette_name) eina_stringshare_del(wd->palette_name);
_remove_items(wd);
for (i = 0; i < 4; i++) free(wd->cp[i]);
free(wd);
}
@ -90,13 +125,21 @@ static void
_theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *elist;
Elm_Color_Item *item;
int i;
if ((!wd) || (!wd->base)) return;
if ((!wd) || (!wd->sel)) return;
_elm_theme_object_set(obj, wd->base, "colorselector", "bg",
_elm_theme_object_set(obj, wd->base, "colorselector", "palette",
elm_widget_style_get(obj));
_elm_theme_object_set(obj, wd->sel, "colorselector", "bg",
elm_widget_style_get(obj));
EINA_LIST_FOREACH(wd->items, elist, item)
{
elm_layout_theme_set(VIEW(item), "colorselector", "item", elm_widget_style_get(obj));
_elm_theme_object_set(obj, item->color_obj, "colorselector", "item/color", elm_widget_style_get(obj));
}
for (i = 0; i < 4; i++)
{
evas_object_del(wd->cp[i]->colorbar);
@ -136,10 +179,52 @@ _colorselector_set_size_hints(Evas_Object *obj, int timesw, int timesh)
}
static void
_sizing_eval(Evas_Object *obj)
_item_sizing_eval(Elm_Color_Item *item)
{
Evas_Coord minw = -1, minh = -1;
if (!item) return;
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
edje_object_size_min_restricted_calc(VIEW(item), &minw, &minh, minw,
minh);
evas_object_size_hint_min_set(VIEW(item), minw, minh);
}
static void _resize_cb(void *data, Evas *a __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
_sizing_eval(data);
}
static void
_sizing_eval_palette(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *elist;
Elm_Color_Item *item;
Evas_Coord bw = 0, bh = 0;
Evas_Coord w = 0, h = 0;
if (!wd) return;
EINA_LIST_FOREACH(wd->items, elist, item)
{
_item_sizing_eval(item);
}
evas_object_size_hint_min_get(wd->box, &bw, &bh);
evas_object_size_hint_min_set(obj, bw, bh);
evas_object_size_hint_max_set(obj, -1, -1);
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
if (w < bw) w = bw;
if (h < bh) h = bh;
evas_object_resize(obj, w, h);
}
static void
_sizing_eval_selector(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1;
Evas_Coord w = 0, h = 0;
int i;
if (!wd) return;
@ -156,9 +241,211 @@ _sizing_eval(Evas_Object *obj)
}
elm_coords_finger_size_adjust(4, &minw, 4, &minh);
edje_object_size_min_restricted_calc(wd->base, &minw, &minh, minw, minh);
edje_object_size_min_restricted_calc(wd->sel, &minw, &minh, minw, minh);
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, -1, -1);
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
if (w < minw) w = minw;
if (h < minh) h = minh;
evas_object_resize(obj, w, h);
}
static void
_sizing_eval_palette_selector(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1;
Evas_Coord bw = 0, bh = 0;
Evas_Coord w = 0, h = 0;
int i;
if (!wd) return;
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
for (i = 0; i < 4; i++)
{
if (wd->cp[i]->bg_rect)
_colorselector_set_size_hints(wd-