elemenatry/colorselector - finally first implementation going on

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



SVN revision: 69100
This commit is contained in:
ChunEon Park 2012-03-09 13:04:00 +00:00
parent d25bfa1266
commit d951cb6136
16 changed files with 1684 additions and 91 deletions

View File

@ -59,4 +59,160 @@ group "Elm_Config" struct {
value "week_start" int: 1; value "week_start" int: 1;
value "weekend_start" int: 6; value "weekend_start" int: 6;
value "weekend_len" int: 2; 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;
}
}
}
}
} }

View File

@ -59,4 +59,160 @@ group "Elm_Config" struct {
value "week_start" int: 1; value "week_start" int: 1;
value "weekend_start" int: 6; value "weekend_start" int: 6;
value "weekend_len" int: 2; 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;
}
}
}
}
} }

View File

@ -59,4 +59,160 @@ group "Elm_Config" struct {
value "week_start" int: 1; value "week_start" int: 1;
value "weekend_start" int: 6; value "weekend_start" int: 6;
value "weekend_len" int: 2; 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;
}
}
}
}
} }

View File

@ -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"; group { name: "elm/colorselector/bg/default";
parts { parts {
part { name: "elm.colorbar_0"; part { name: "elm.colorbar_0";
@ -165,8 +228,7 @@ group { name: "elm/colorselector/base/default";
type: SWALLOW; type: SWALLOW;
mouse_events: 1; mouse_events: 1;
scale: 1; scale: 1;
description { description { state: "default" 0.0;
state: "default" 0.0;
min: 24 24; min: 24 24;
fixed: 1 1; fixed: 1 1;
rel1 { 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;
}
}
}
}

View File

@ -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;
}
}
}

View File

@ -24,7 +24,7 @@ WGT_PREVIEW = \
bubble:preview-00.png:widget_preview_bubble1:160:50 \ bubble:preview-00.png:widget_preview_bubble1:160:50 \
bubble:preview-01.png:widget_preview_bubble2:160:50 \ bubble:preview-01.png:widget_preview_bubble2:160:50 \
bubble:preview-02.png:widget_preview_bubble3: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 \ layout:preview-00.png:widget_preview_layout:200:160 \
conformant:preview-00.png:widget_preview_conformant:200:400 \ conformant:preview-00.png:widget_preview_conformant:200:400 \
list:preview-00.png:widget_preview_list:200:200 \ list:preview-00.png:widget_preview_list:200:200 \

View File

@ -5485,16 +5485,29 @@
* @until show(rect) * @until show(rect)
* *
* Now that we have a window with background and a rectangle we can create * 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: * our color_selector
* @until show * @until elm_colorselector_add
* *
* Next we tell ask to be notified whenever the color changes: * Now colors can be loaded to color selector's palette by setting the palette name
* @until show(cs)
*
* Next we ask to be notified whenever the color changes on selector:
* @until changed * @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() * @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 } * @until }
* *
* This example will look like this: * This example will look like this:

View File

@ -1,8 +1,14 @@
#include "widget_preview_tmpl_head.c" #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 *o = elm_colorselector_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 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); evas_object_show(o);
#include "widget_preview_tmpl_foot.c" #include "widget_preview_tmpl_foot.c"

View File

@ -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_spinner(void *data, Evas_Object *obj, void *event_info);
void test_index(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_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_photocam(void *data, Evas_Object *obj, void *event_info);
void test_photo(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); 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", test_index);
ADD_TEST(NULL, "Selectors", "Index 2", test_index2); 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", test_fileselector);
ADD_TEST(NULL, "Selectors", "File Selector Entry", test_fileselector_entry); ADD_TEST(NULL, "Selectors", "File Selector Entry", test_fileselector_entry);
ADD_TEST(NULL, "Selectors", "File Selector Button", test_fileselector_button); ADD_TEST(NULL, "Selectors", "File Selector Button", test_fileselector_button);

View File

@ -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); 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 void
test_colorselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 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]; char buf[PATH_MAX];
int r, g, b, a; 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); elm_box_pack_end(bx, fr);
evas_object_show(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; a = 180;
r = 255; r = 255;
g = 160; g = 160;
b = 132; b = 132;
elm_colorselector_color_set(cp, r, g, b, a); elm_colorselector_color_set(cs, r, g, b, a);
evas_object_size_hint_weight_set(cp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(cs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cp, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_align_set(cs, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(fr, cp); elm_object_content_set(fr, cs);
evas_object_show(cp); evas_object_show(cs);
evas_object_smart_callback_add(cp, "changed", _colorselector_clicked_cb, re); 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 */ /* Fix Alpha pre multiplication by edje */
r = (r * a) / 255; r = (r * a) / 255;
g = (g * a) / 255; g = (g * a) / 255;

View File

@ -18,6 +18,18 @@ struct _api_data
}; };
typedef struct _api_data 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 enum _api_state
{ {
INDEX_LEVEL_SET, INDEX_LEVEL_SET,
@ -394,4 +406,167 @@ test_index2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_show(win); 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 #endif

View File

@ -7,12 +7,13 @@
#endif #endif
static void _change_color(void *data, Evas_Object *obj, void *event_info); 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 EAPI_MAIN int
elm_main(int argc, char **argv) elm_main(int argc, char **argv)
{ {
Evas_Object *win, *bg, *cs, *frame, *rect; Evas_Object *win, *bg, *cs, *rect, *bx, *fr;
char buf[256];
win = elm_win_add(NULL, "color selector", ELM_WIN_BASIC); win = elm_win_add(NULL, "color selector", ELM_WIN_BASIC);
elm_win_title_set(win, "Color selector"); 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); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
bg = elm_bg_add(win); 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); elm_win_resize_object_add(win, bg);
evas_object_show(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)); rect = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_resize(rect, 50, 50); elm_object_content_set(fr, rect);
evas_object_move(rect, 125, 325); evas_object_color_set(rect, 255, 90, 18, 255);
evas_object_color_set(rect, 0, 0, 255, 255);
evas_object_show(rect); 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); cs = elm_colorselector_add(win);
elm_colorselector_color_set(cs, 0, 0, 255, 255); elm_colorselector_palette_name_set(cs, "painting");
evas_object_resize(cs, 300, 300); 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_show(cs);
evas_object_smart_callback_add(cs, "changed", _change_color, rect); 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); evas_object_show(win);
elm_run(); elm_run();
evas_object_del(rect);
return 0; 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); elm_colorselector_color_get(obj, &r, &g, &b, &a);
evas_object_color_set(data, 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);
}

View File

@ -6,6 +6,8 @@
#define SAT_STEP 128.0 #define SAT_STEP 128.0
#define LIG_STEP 256.0 #define LIG_STEP 256.0
#define ALP_STEP 256.0 #define ALP_STEP 256.0
#define DEFAULT_HOR_PAD 10
#define DEFAULT_VER_PAD 10
typedef enum _Color_Type typedef enum _Color_Type
{ {
@ -30,16 +32,32 @@ struct _Colorselector_Data
}; };
typedef struct _Widget_Data Widget_Data; typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Color_Item Elm_Color_Item;
struct _Widget_Data struct _Widget_Data
{ {
Evas_Object *sel;
Evas_Object *base; Evas_Object *base;
Evas_Object *box;
Eina_List *items;
Colorselector_Data *cp[4]; Colorselector_Data *cp[4];
Ecore_Timer *longpress_timer;
const char *palette_name;
Evas_Coord _x, _y, _w, _h; Evas_Coord _x, _y, _w, _h;
int r, g, b, a; int r, g, b, a;
int er, eg, eb; int er, eg, eb;
int sr, sg, sb; int sr, sg, sb;
int lr, lg, lb; int lr, lg, lb;
double h, s, l; 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; static const char *widtype = NULL;
@ -47,6 +65,7 @@ static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj); static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj);
static void _sizing_eval(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 _rgb_to_hsl(void *data);
static void _hsl_to_rgb(void *data); static void _hsl_to_rgb(void *data);
static void _color_with_saturation(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); void *event_info);
static void _add_colorbar(Evas_Object *obj); static void _add_colorbar(Evas_Object *obj);
static void _set_color(Evas_Object *obj, int r, int g, int b, int a); 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_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[] = static const Evas_Smart_Cb_Description _signals[] =
{ {
{SIG_CHANGED, ""}, {SIG_COLOR_ITEM_SELECTED, ""},
{NULL, NULL} {SIG_COLOR_ITEM_LONGPRESSED, ""},
{SIG_CHANGED, ""},
{NULL, NULL}
}; };
static void static void
@ -82,6 +114,9 @@ _del_hook(Evas_Object *obj)
int i = 0; int i = 0;
if (!wd) return; 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]); for (i = 0; i < 4; i++) free(wd->cp[i]);
free(wd); free(wd);
} }
@ -90,13 +125,21 @@ static void
_theme_hook(Evas_Object *obj) _theme_hook(Evas_Object *obj)
{ {
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *elist;
Elm_Color_Item *item;
int i; 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_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++) for (i = 0; i < 4; i++)
{ {
evas_object_del(wd->cp[i]->colorbar); evas_object_del(wd->cp[i]->colorbar);
@ -136,10 +179,52 @@ _colorselector_set_size_hints(Evas_Object *obj, int timesw, int timesh)
} }
static void 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); Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1; Evas_Coord minw = -1, minh = -1;
Evas_Coord w = 0, h = 0;
int i; int i;
if (!wd) return; if (!wd) return;
@ -156,9 +241,211 @@ _sizing_eval(Evas_Object *obj)
} }
elm_coords_finger_size_adjust(4, &minw, 4, &minh); 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_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, -1, -1); 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->cp[i]->bg_rect, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->bar, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->rbt, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->lbt, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->colorbar, 4, 1);
}
elm_coords_finger_size_adjust(4, &minw, 4, &minh);
edje_object_size_min_restricted_calc(wd->sel, &minw, &minh, minw, minh);
evas_object_size_hint_min_get(wd->box, &bw, &bh);
evas_object_size_hint_min_set(obj, minw, minh+bh);
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+bh)) h = (minh+bh);
evas_object_resize(obj, w, h);
}
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
switch (wd->mode)
{
case ELM_COLORSELECTOR_PALETTE:
_sizing_eval_palette(obj);
break;
case ELM_COLORSELECTOR_COMPONENTS:
_sizing_eval_selector(obj);
break;
case ELM_COLORSELECTOR_BOTH:
_sizing_eval_palette_selector(obj);
break;
default:
break;
}
}
static Eina_Bool
_long_press(void *data)
{
Elm_Color_Item *item = (Elm_Color_Item *) data;
Widget_Data *wd = elm_widget_data_get(WIDGET(item));
if (!wd) return ECORE_CALLBACK_CANCEL;
wd->longpress_timer = NULL;
wd->longpressed = EINA_TRUE;
evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, item);
return ECORE_CALLBACK_CANCEL;
}
static void
_item_highlight(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Elm_Color_Item *item = (Elm_Color_Item *) data;
Evas_Event_Mouse_Down *ev = event_info;
if (!item) return;
Widget_Data *wd = elm_widget_data_get(WIDGET(item));
if (!wd) return;
if (ev->button != 1) return;
elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
wd->longpressed = EINA_FALSE;
if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
wd->longpress_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
}
static void
_item_unhighlight(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Elm_Color_Item *item = (Elm_Color_Item *) data;
Evas_Event_Mouse_Down *ev = event_info;
if (!item) return;
Widget_Data *wd = elm_widget_data_get(WIDGET(item));
if (!wd) return;
if (ev->button != 1) return;
if (wd->longpress_timer)
{
ecore_timer_del(wd->longpress_timer);
wd->longpress_timer = NULL;
}
elm_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
if (!wd->longpressed)
{
evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_SELECTED, item);
elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g, item->color->b, item->color->a);
}
}
static void
_remove_items(Widget_Data *wd)
{
Elm_Color_Item *item;
if (!wd->items) return;
EINA_LIST_FREE(wd->items, item)
{
free(item->color);
elm_widget_item_free(item);
}
wd->items = NULL;
}
static Elm_Color_Item*
_item_new(Evas_Object *obj)
{
Elm_Color_Item *item;
Widget_Data *wd;
wd = elm_widget_data_get(obj);
if (!wd) return NULL;
item = elm_widget_item_new(obj, Elm_Color_Item);
if (!item) return NULL;
VIEW(item) = elm_layout_add(obj);
elm_layout_theme_set(VIEW(item), "colorselector", "item", elm_widget_style_get(obj));
evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
item->color_obj = edje_object_add(evas_object_evas_get(obj));
_elm_theme_object_set(obj, item->color_obj, "colorselector", "item/color", elm_widget_style_get(obj));
evas_object_size_hint_weight_set(item->color_obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(item->color_obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_event_callback_add(item->color_obj, EVAS_CALLBACK_MOUSE_DOWN, _item_highlight, item);
evas_object_event_callback_add(item->color_obj, EVAS_CALLBACK_MOUSE_UP, _item_unhighlight, item);
elm_object_part_content_set(VIEW(item), "color_obj", item->color_obj);
_item_sizing_eval(item);
evas_object_show(VIEW(item));
return item;
}
static void
_colors_remove(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
_remove_items(wd);
_elm_config_colors_free(wd->palette_name);
}
static void _colors_save(Evas_Object *obj)
{
Eina_List *elist;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Color_Item *item;
_elm_config_colors_free(wd->palette_name);
EINA_LIST_FOREACH(wd->items, elist, item)
{
_elm_config_color_set(wd->palette_name, item->color->r, item->color->g,
item->color->b, item->color->a);
}
}
static void
_colors_load_apply(Evas_Object *obj)
{
Elm_Color_RGBA *color;
Eina_List *elist;
Eina_List *color_list;
Elm_Color_Item *item;
Widget_Data *wd = elm_widget_data_get(obj);
color_list = _elm_config_color_list_get(wd->palette_name);
if (!color_list) return;
EINA_LIST_FOREACH(color_list, elist, color)
{
item = _item_new(obj);
if (!item) return;
item->color = ELM_NEW(Elm_Color_RGBA);
if (!item->color) return;
item->color->r = color->r;
item->color->g = color->g;
item->color->b = color->b;
item->color->a = color->a;
elm_box_pack_end(wd->box, VIEW(item));
evas_object_color_set(item->color_obj, item->color->r, item->color->g,
item->color->b, item->color->a);
wd->items = eina_list_append(wd->items, item);
_sizing_eval_palette(obj);
}
wd->config_load = EINA_TRUE;
} }
static void static void
@ -604,7 +891,7 @@ _add_colorbar(Evas_Object *obj)
snprintf(colorbar_s, sizeof(colorbar_s), "elm.colorbar_%d", i); snprintf(colorbar_s, sizeof(colorbar_s), "elm.colorbar_%d", i);
edje_object_signal_callback_add(wd->cp[i]->colorbar, "drag", "*", edje_object_signal_callback_add(wd->cp[i]->colorbar, "drag", "*",
_arrow_cb, wd->cp[i]); _arrow_cb, wd->cp[i]);
edje_object_part_swallow(wd->base, colorbar_s, wd->cp[i]->colorbar); edje_object_part_swallow(wd->sel, colorbar_s, wd->cp[i]->colorbar);
elm_widget_sub_object_add(obj, wd->cp[i]->colorbar); elm_widget_sub_object_add(obj, wd->cp[i]->colorbar);
/* load colorbar image */ /* load colorbar image */
@ -741,6 +1028,9 @@ elm_colorselector_add(Evas_Object *parent)
Evas_Object *obj = NULL; Evas_Object *obj = NULL;
Widget_Data *wd = NULL; Widget_Data *wd = NULL;
Evas *e; Evas *e;
const char *hpadstr, *vpadstr;
unsigned int h_pad = DEFAULT_HOR_PAD;
unsigned int v_pad = DEFAULT_VER_PAD;
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
@ -750,11 +1040,40 @@ elm_colorselector_add(Evas_Object *parent)
elm_widget_data_set(obj, wd); elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook); elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_theme_hook_set(obj, _theme_hook);
evas_object_smart_callbacks_descriptions_set(obj, _signals);
/* load background edj */ /* load background edj */
wd->base = edje_object_add(e); wd->base = edje_object_add(e);
_elm_theme_object_set(obj, wd->base, "colorselector", "bg", "default"); _elm_theme_object_set(obj, wd->base, "colorselector", "palette", "default");
elm_widget_resize_object_set(obj, wd->base); elm_widget_resize_object_set(obj, wd->base);
evas_object_event_callback_add(wd->base, EVAS_CALLBACK_RESIZE,
_resize_cb, obj);
wd->box = elm_box_add(obj);
elm_box_layout_set(wd->box, evas_object_box_layout_flow_horizontal,
NULL, NULL);
elm_box_horizontal_set(wd->box, EINA_TRUE);
evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
0);
evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0);
elm_box_homogeneous_set(wd->box, EINA_TRUE);
hpadstr = edje_object_data_get(wd->sel, "horizontal_pad");
if (hpadstr) h_pad = atoi(hpadstr);
vpadstr = edje_object_data_get(wd->sel, "vertical_pad");
if (vpadstr) v_pad = atoi(vpadstr);
elm_box_padding_set(wd->box, h_pad, v_pad);
elm_box_align_set(wd->box, 0.5, 0.5);
elm_widget_sub_object_add(obj, wd->box);
evas_object_show(wd->box);
edje_object_part_swallow(wd->base, "palette", wd->box);
wd->palette_name = eina_stringshare_add("default");
_colors_load_apply(obj);
/* load background edj */
wd->sel = edje_object_add(e);
_elm_theme_object_set(obj, wd->sel, "colorselector", "bg", "default");
edje_object_part_swallow(wd->base, "selector", wd->sel);
wd->mode = ELM_COLORSELECTOR_BOTH;
wd->er = 255; wd->er = 255;
wd->eg = 0; wd->eg = 0;
@ -768,7 +1087,6 @@ elm_colorselector_add(Evas_Object *parent)
_add_colorbar(obj); _add_colorbar(obj);
_sizing_eval(obj); _sizing_eval(obj);
evas_object_smart_callbacks_descriptions_set(obj, _signals);
return obj; return obj;
} }
@ -782,8 +1100,8 @@ elm_colorselector_color_set(Evas_Object *obj, int r, int g, int b, int a)
EAPI void EAPI void
elm_colorselector_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a) elm_colorselector_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
{ {
Widget_Data *wd = elm_widget_data_get(obj);
ELM_CHECK_WIDTYPE(obj, widtype); ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (r) *r = wd->r; if (r) *r = wd->r;
if (g) *g = wd->g; if (g) *g = wd->g;
@ -792,60 +1110,154 @@ elm_colorselector_color_get(const Evas_Object *obj, int *r, int *g, int *b, int
} }
EAPI void EAPI void
elm_colorselector_mode_set(Evas_Object *obj, Elm_Colorselector_Mode mode __UNUSED__) elm_colorselector_mode_set(Evas_Object *obj, Elm_Colorselector_Mode mode)
{ {
ELM_CHECK_WIDTYPE(obj, widtype); ELM_CHECK_WIDTYPE(obj, widtype);
//TODO: Implement! Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->mode == mode) return;
wd->mode = mode;
switch (wd->mode)
{
case ELM_COLORSELECTOR_PALETTE:
if (edje_object_part_swallow_get(wd->base, "selector"))
{
edje_object_part_unswallow(wd->base, wd->sel);
evas_object_hide(wd->sel);
}
if (!edje_object_part_swallow_get(wd->base, "palette"))
{
edje_object_part_swallow(wd->base, "palette", wd->box);
evas_object_show(wd->box);
}
break;
case ELM_COLORSELECTOR_COMPONENTS:
if (edje_object_part_swallow_get(wd->base, "palette"))
{
edje_object_part_unswallow(wd->base, wd->box);
evas_object_hide(wd->box);
}
if (!edje_object_part_swallow_get(wd->base, "selector"))
{
edje_object_part_swallow(wd->base, "selector", wd->sel);
evas_object_show(wd->sel);
}
break;
case ELM_COLORSELECTOR_BOTH:
if (!edje_object_part_swallow_get(wd->base, "palette"))
{
edje_object_part_swallow(wd->base, "palette", wd->box);
evas_object_show(wd->box);
}
if (!edje_object_part_swallow_get(wd->base, "selector"))
{
edje_object_part_swallow(wd->base, "selector", wd->sel);
evas_object_show(wd->sel);
}
break;
default:
return;
}
_sizing_eval(obj);
} }
EAPI Elm_Colorselector_Mode EAPI Elm_Colorselector_Mode
elm_colorselector_mode_get(const Evas_Object *obj) elm_colorselector_mode_get(const Evas_Object *obj)
{ {
ELM_CHECK_WIDTYPE(obj, widtype) ELM_COLORSELECTOR_PALETTE; ELM_CHECK_WIDTYPE(obj, widtype) ELM_COLORSELECTOR_BOTH;
//TODO: Implement! Widget_Data *wd = elm_widget_data_get(obj);
return ELM_COLORSELECTOR_PALETTE; if (!wd) return ELM_COLORSELECTOR_BOTH;
return wd->mode;
} }
EAPI void EAPI void
elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, int *r __UNUSED__, int *g __UNUSED__, int *b __UNUSED__, int*a __UNUSED__) elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, int *r __UNUSED__, int *g __UNUSED__, int *b __UNUSED__, int*a __UNUSED__)
{ {
ELM_OBJ_ITEM_CHECK_OR_RETURN(it); ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
//TODO: Implement! Elm_Color_Item *item;
item = (Elm_Color_Item *) it;
if (item)
{
if(r) *r = item->color->r;
if(g) *g = item->color->g;
if(b) *b = item->color->b;
if(a) *a = item->color->a;
}
} }
EAPI void EAPI void
elm_colorselector_palette_item_color_set(Elm_Object_Item *it, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__) elm_colorselector_palette_item_color_set(Elm_Object_Item *it, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__)
{ {
ELM_OBJ_ITEM_CHECK_OR_RETURN(it); ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
//TODO: Implement! Elm_Color_Item *item;
item = (Elm_Color_Item *) it;
item->color->r = r;
item->color->g = g;
item->color->b = b;
item->color->a = a;
evas_object_color_set(item->color_obj, item->color->r, item->color->g, item->color->b, item->color->a);
_colors_save(WIDGET(it));
} }
EAPI Elm_Object_Item * EAPI Elm_Object_Item *
elm_colorselector_palette_color_add(Evas_Object *obj, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__) elm_colorselector_palette_color_add(Evas_Object *obj, int r, int g, int b, int a)
{ {
Elm_Color_Item *item;
ELM_CHECK_WIDTYPE(obj, widtype) NULL; ELM_CHECK_WIDTYPE(obj, widtype) NULL;
//TODO: Implement! Widget_Data *wd = elm_widget_data_get(obj);
return NULL; if (!wd) return NULL;
if (wd->config_load)
{
_colors_remove(obj);
wd->config_load = EINA_FALSE;
}
item = _item_new(obj);
if (!item) return NULL;
item->color = ELM_NEW(Elm_Color_RGBA);
if (!item->color) return NULL;
item->color->r = r;
item->color->g = g;
item->color->b = b;
item->color->a = a;
_elm_config_color_set(wd->palette_name, item->color->r, item->color->g,
item->color->b, item->color->a);
elm_box_pack_end(wd->box, VIEW(item));
evas_object_color_set(item->color_obj, item->color->r, item->color->g,
item->color->b, item->color->a);
wd->items = eina_list_append(wd->items, item);
_sizing_eval(obj);
return (Elm_Object_Item *) item;
} }
EAPI void EAPI void
elm_colorselector_palette_clear(Evas_Object *obj) elm_colorselector_palette_clear(Evas_Object *obj)
{ {
ELM_CHECK_WIDTYPE(obj, widtype); ELM_CHECK_WIDTYPE(obj, widtype);
//TODO: Implement! Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
_colors_remove(obj);
} }
EAPI void EAPI void
elm_colorselector_palette_name_set(Evas_Object *obj, const char *palette_name __UNUSED__) elm_colorselector_palette_name_set(Evas_Object *obj, const char *palette_name)
{ {
ELM_CHECK_WIDTYPE(obj, widtype); ELM_CHECK_WIDTYPE(obj, widtype);
//TODO: Implement! Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (!strcmp(wd->palette_name, palette_name)) return;
if (palette_name)
{
_colors_remove(obj);
eina_stringshare_replace(&wd->palette_name, palette_name);
_colors_load_apply(obj);
}
} }
EAPI const char* EAPI const char*
elm_colorselector_palette_name_get(const Evas_Object *obj) elm_colorselector_palette_name_get(const Evas_Object *obj)
{ {
ELM_CHECK_WIDTYPE(obj, widtype) NULL; ELM_CHECK_WIDTYPE(obj, widtype) NULL;
//TODO: Implement! Widget_Data *wd = elm_widget_data_get(obj);
return NULL; if (!wd) return NULL;
return wd->palette_name;
} }

View File

@ -1,24 +1,56 @@
/** /**
* @defgroup Colorselector Colorselector * @defgroup Colorselector Colorselector
* * @ingroup Elementary
* @{
* *
* @image html img/widget/colorselector/preview-00.png * @image html img/widget/colorselector/preview-00.png
* @image latex img/widget/colorselector/preview-00.eps * @image latex img/widget/colorselector/preview-00.eps
* *
* @brief Widget for user to select a color. * A ColorSelector is a color selection widget. It allows application to set a
* series of colors.It also allows to load/save colors from/to config with a
* unique identifier, by default, the colors are loaded/saved from/to config
* using "default" identifier.
* The colors can be picked by user from the color set by clicking on individual color
* item on the palette or by selecting it from selector.
* *
* Signals that you can add callbacks for are: * Signals that you can add callbacks for are:
* "changed" - When the color value changes(event_info is NULL). * - "changed" - When the color value changes on selector(event_info is NULL).
* - "color,item,selected" - When user clicks on color item. The event_info parameter
* of the callback will be the selected color item.
* - "color,item,longpressed" - When user long presses on color item. The event info
* parameter of the callback contains selected color item.
* *
* See @ref tutorial_colorselector. * See @ref tutorial_colorselector.
* @{
*/ */
typedef struct _Elm_Color_RGBA
{
unsigned int r;
unsigned int g;
unsigned int b;
unsigned int a;
} Elm_Color_RGBA;
typedef struct _Elm_Custom_Palette
{
const char *palette_name;
Eina_List *color_list;
} Elm_Custom_Palette;
/**
* @enum _Elm_Colorselector_Mode
* @typedef Elm_Colorselector_Mode
*
* Different modes supported by Colorselector
*
* @see elm_colorselector_mode_set()
* @see elm_colorselector_mode_get()
*/
typedef enum typedef enum
{ {
ELM_COLORSELECTOR_PALETTE = 0, ELM_COLORSELECTOR_PALETTE = 0, /**< only color palette is displayed */
ELM_COLORSELECTOR_COMPONENTS, ELM_COLORSELECTOR_COMPONENTS, /**< only color selector is displayed */
ELM_COLORSELECTOR_BOTH ELM_COLORSELECTOR_BOTH /**< Both Palette and selector is displayed, default */
} Elm_Colorselector_Mode; } Elm_Colorselector_Mode;
/** /**
@ -32,60 +64,55 @@ typedef enum
EAPI Evas_Object *elm_colorselector_add(Evas_Object *parent); EAPI Evas_Object *elm_colorselector_add(Evas_Object *parent);
/** /**
* Set a color for the colorselector * Set color to colorselector
* *
* @param obj Colorselector object * @param obj Colorselector object
* @param r r-value of color * @param r r-value of color
* @param g g-value of color * @param g g-value of color
* @param b b-value of color * @param b b-value of color
* @param a a-value of color * @param a a-value of color
* *
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI void elm_colorselector_color_set(Evas_Object *obj, int r, int g, int b, int a); EAPI void elm_colorselector_color_set(Evas_Object *obj, int r, int g, int b, int a);
/** /**
* Get a color from the colorselector * Get current color from colorselector
* *
* @param obj Colorselector object * @param obj Colorselector object
* @param r integer pointer for r-value of color * @param r integer pointer for r-value of color
* @param g integer pointer for g-value of color * @param g integer pointer for g-value of color
* @param b integer pointer for b-value of color * @param b integer pointer for b-value of color
* @param a integer pointer for a-value of color * @param a integer pointer for a-value of color
* *
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI void elm_colorselector_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a); EAPI void elm_colorselector_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a);
/** /**
* Set a Colorselector mode. * Set Colorselector's mode.
* Colorselector
* *
* @param obj Colorselector object * @param obj Colorselector object
* @param mode * @param mode Elm_Colorselector_Mode
* @param g G color value to be returned
* @param b B color value to be returned
* @param a A color value to be returned
* *
* Colorselector supports three modes palette only, selector only and both.
*
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI void elm_colorselector_mode_set(Evas_Object *obj, Elm_Colorselector_Mode mode); EAPI void elm_colorselector_mode_set(Evas_Object *obj, Elm_Colorselector_Mode mode);
/** /**
* Get a Colorselector mode. * Get Colorselector's mode.
* *
* @param item The color palette item. * @param obj Colorselector object
* @param r R color value to be returned * @return mode The current mode of colorselector
* @param g G color value to be returned
* @param b B color value to be returned
* @param a A color value to be returned
* *
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI Elm_Colorselector_Mode elm_colorselector_mode_get(const Evas_Object *obj); EAPI Elm_Colorselector_Mode elm_colorselector_mode_get(const Evas_Object *obj);
/** /**
* Get a palette item's color. * Get Palette item's color.
* *
* @param item The color palette item. * @param item The color palette item.
* @param r integer pointer for r-value of color * @param r integer pointer for r-value of color
@ -98,7 +125,7 @@ EAPI Elm_Colorselector_Mode elm_colorselector_mode_get(const Evas_Object *obj);
EAPI void elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, int *r, int *g, int *b, int *a); EAPI void elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, int *r, int *g, int *b, int *a);
/** /**
* Set the palette item's color. * Set palette item's color.
* *
* @param item The color palette item. * @param item The color palette item.
* @param r r-value of color * @param r r-value of color
@ -129,9 +156,6 @@ EAPI Elm_Object_Item *elm_colorselector_palette_color_add(Evas_Object *obj, int
* *
* @param obj The Colorselector object * @param obj The Colorselector object
* *
* @note This API will be available when ELM_COLORSELECTOR_PALETTE or
* ELM_COLORSELECTOR_BOTH mode is set.
*
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI void elm_colorselector_palette_clear(Evas_Object *obj); EAPI void elm_colorselector_palette_clear(Evas_Object *obj);
@ -148,7 +172,7 @@ EAPI void elm_colorselector_palette_clear(Evas_Object *obj);
* *
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI void elm_colorselector_palette_name_set(Evas_Object *obj, const char *palette_name); EAPI void elm_colorselector_palette_name_set(Evas_Object *obj, const char *palette_name);
/** /**
* Get current palette's name * Get current palette's name
@ -161,7 +185,7 @@ EAPI void elm_colorselector_palette_name_set(Evas_Object *obj
* *
* @ingroup Colorselector * @ingroup Colorselector
*/ */
EAPI const char *elm_colorselector_palette_name_get(const Evas_Object *obj); EAPI const char *elm_colorselector_palette_name_get(const Evas_Object *obj);
/** /**
* @} * @}

View File

@ -15,6 +15,8 @@ Elm_Config *_elm_config = NULL;
char *_elm_profile = NULL; char *_elm_profile = NULL;
static Eet_Data_Descriptor *_config_edd = NULL; static Eet_Data_Descriptor *_config_edd = NULL;
static Eet_Data_Descriptor *_config_font_overlay_edd = NULL; static Eet_Data_Descriptor *_config_font_overlay_edd = NULL;
static Eet_Data_Descriptor *_config_color_edd = NULL;
static Eet_Data_Descriptor *_config_color_palette_edd = NULL;
const char *_elm_preferred_engine = NULL; const char *_elm_preferred_engine = NULL;
static Ecore_Poller *_elm_cache_flush_poller = NULL; static Ecore_Poller *_elm_cache_flush_poller = NULL;
@ -259,6 +261,33 @@ _desc_init(void)
eet_data_descriptor_free(_config_edd); eet_data_descriptor_free(_config_edd);
return; return;
} }
memset(&eddc, 0, sizeof(eddc)); /* just in case... */
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Color_RGBA);
eddc.func.str_direct_alloc = NULL;
eddc.func.str_direct_free = NULL;
_config_color_edd = eet_data_descriptor_stream_new(&eddc);
if (!_config_color_edd)
{
printf("EEEK! eet_data_descriptor_stream_new() failed\n");
eet_data_descriptor_free(_config_edd);
return;
}
memset(&eddc, 0, sizeof(eddc)); /* just in case... */
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Custom_Palette);
eddc.func.str_direct_alloc = NULL;
eddc.func.str_direct_free = NULL;
_config_color_palette_edd = eet_data_descriptor_stream_new(&eddc);
if (!_config_color_palette_edd)
{
printf("EEEK! eet_data_descriptor_stream_new() failed\n");
eet_data_descriptor_free(_config_edd);
return;
}
#define T_INT EET_T_INT #define T_INT EET_T_INT
#define T_DOUBLE EET_T_DOUBLE #define T_DOUBLE EET_T_DOUBLE
#define T_STRING EET_T_STRING #define T_STRING EET_T_STRING
@ -272,6 +301,22 @@ _desc_init(void)
#undef T #undef T
#undef D #undef D
#define T Elm_Color_RGBA
#define D _config_color_edd
ELM_CONFIG_VAL(D, T, r, EET_T_UINT);
ELM_CONFIG_VAL(D, T, g, EET_T_UINT);
ELM_CONFIG_VAL(D, T, b, EET_T_UINT);
ELM_CONFIG_VAL(D, T, a, EET_T_UINT);
#undef T
#undef D
#define T Elm_Custom_Palette
#define D _config_color_palette_edd
ELM_CONFIG_VAL(D, T, palette_name, EET_T_STRING);
ELM_CONFIG_LIST(D, T, color_list, _config_color_edd);
#undef T
#undef D
#define T Elm_Config #define T Elm_Config
#define D _config_edd #define D _config_edd
ELM_CONFIG_VAL(D, T, config_version, T_INT); ELM_CONFIG_VAL(D, T, config_version, T_INT);
@ -337,6 +382,7 @@ _desc_init(void)
ELM_CONFIG_VAL(D, T, week_start, T_INT); ELM_CONFIG_VAL(D, T, week_start, T_INT);
ELM_CONFIG_VAL(D, T, weekend_start, T_INT); ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
ELM_CONFIG_VAL(D, T, weekend_len, T_INT); ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
#undef T #undef T
#undef D #undef D
#undef T_INT #undef T_INT
@ -359,6 +405,18 @@ _desc_shutdown(void)
eet_data_descriptor_free(_config_font_overlay_edd); eet_data_descriptor_free(_config_font_overlay_edd);
_config_font_overlay_edd = NULL; _config_font_overlay_edd = NULL;
} }
if (_config_color_edd)
{
eet_data_descriptor_free(_config_color_edd);
_config_color_edd = NULL;
}
if (_config_color_palette_edd)
{
eet_data_descriptor_free(_config_color_palette_edd);
_config_color_palette_edd = NULL;
}
} }
static int static int
@ -560,6 +618,63 @@ _elm_config_text_classes_free(Eina_List *l)
free(tc); free(tc);
} }
Eina_List *
_elm_config_color_list_get(const char *palette_name)
{
Eina_List *plist;
Elm_Custom_Palette *cpalette;
EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
{
if (strcmp(cpalette->palette_name, palette_name))
continue;
return cpalette->color_list;
}
return NULL;
}
void
_elm_config_color_set(const char *palette_name,
int r,
int g,
int b,
int a)
{
Eina_List *plist;
Elm_Custom_Palette *cpalette;
Elm_Color_RGBA *color;
EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
{
if (strcmp(cpalette->palette_name, palette_name))
continue;
color = calloc(1, sizeof(Elm_Color_RGBA));
color->r = r;
color->g = g;
color->b = b;
color->a = a;
cpalette->color_list = eina_list_prepend(cpalette->color_list,
color);
}
}
void
_elm_config_colors_free(const char *palette_name)
{
Eina_List *plist;
Elm_Custom_Palette *cpalette;
Elm_Color_RGBA *color;
EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
{
if (strcmp(cpalette->palette_name, palette_name))
continue;
EINA_LIST_FREE(cpalette->color_list, color)
{
free(color);
}
}
}
Eina_List * Eina_List *
_elm_config_profiles_list(void) _elm_config_profiles_list(void)
{ {
@ -708,6 +823,8 @@ _config_free(void)
{ {
Elm_Font_Overlay *fo; Elm_Font_Overlay *fo;
const char *fontdir; const char *fontdir;
Elm_Custom_Palette *palette;
Elm_Color_RGBA *color;
if (!_elm_config) return; if (!_elm_config) return;
EINA_LIST_FREE(_elm_config->font_dirs, fontdir) EINA_LIST_FREE(_elm_config->font_dirs, fontdir)
@ -721,6 +838,12 @@ _config_free(void)
if (fo->font) eina_stringshare_del(fo->font); if (fo->font) eina_stringshare_del(fo->font);
free(fo); free(fo);
} }
EINA_LIST_FREE(_elm_config->color_palette, palette)
{
if (palette->palette_name) eina_stringshare_del(palette->palette_name);
EINA_LIST_FREE(palette->color_list, color) free(color);
free(palette);
}
if (_elm_config->theme) eina_stringshare_del(_elm_config->theme); if (_elm_config->theme) eina_stringshare_del(_elm_config->theme);
if (_elm_config->modules) eina_stringshare_del(_elm_config->modules); if (_elm_config->modules) eina_stringshare_del(_elm_config->modules);
free(_elm_config); free(_elm_config);
@ -911,6 +1034,7 @@ _config_load(void)
_elm_config->week_start = 1; /* monday */ _elm_config->week_start = 1; /* monday */
_elm_config->weekend_start = 6; /* saturday */ _elm_config->weekend_start = 6; /* saturday */
_elm_config->weekend_len = 2; _elm_config->weekend_len = 2;
_elm_config->color_palette = NULL;
} }
static const char * static const char *

View File

@ -168,6 +168,7 @@ struct _Elm_Config
int week_start; int week_start;
int weekend_start; int weekend_start;
int weekend_len; int weekend_len;
Eina_List *color_palette;
/* Not part of the EET file */ /* Not part of the EET file */
Eina_Bool is_mirrored : 1; Eina_Bool is_mirrored : 1;
@ -277,6 +278,10 @@ char *_elm_util_text_to_mkup(const char *text);
Eina_Bool _elm_video_check(Evas_Object *video); Eina_Bool _elm_video_check(Evas_Object *video);
Eina_List *_elm_config_color_list_get(const char *palette_name);
void _elm_config_color_set(const char *palette_name, int r, int g, int b, int a);
void _elm_config_colors_free(const char *palette_name);
extern char *_elm_appname; extern char *_elm_appname;
extern Elm_Config *_elm_config; extern Elm_Config *_elm_config;
extern const char *_elm_data_dir; extern const char *_elm_data_dir;