2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
8 _colorselector_clicked_cb(void *data, Evas_Object *obj,
9 void *event_info __UNUSED__)
11 Evas_Object *re = data;
14 elm_colorselector_color_get(obj, &r, &g, &b, &a);
15 printf("Current Color [r=%d g=%d b=%d a=%d]\n",r, g, b, a);
17 /* Fix Alpha pre multiplication by edje */
22 evas_object_color_set(re, r, g, b, a);
26 _colorpalette_clicked_cb(void *data, Evas_Object *obj __UNUSED__,
29 int r = 0, g = 0, b = 0 ,a = 0;
30 Elm_Object_Item *color_it = (Elm_Object_Item *) event_info;
31 elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
32 evas_object_color_set((Evas_Object *) data, r, g, b , a);
36 _colorpalette_longpressed_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
39 int r = 0,g = 0,b = 0 ,a = 0;
40 Elm_Object_Item *color_it = (Elm_Object_Item *) event_info;
41 elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
42 printf("\ncolor = %d-%d-%d-%d\n", r, g, b, a);
46 _palette_cb(void *data, Evas_Object *obj __UNUSED__,
47 void *event_info __UNUSED__)
49 Evas_Object *cs = data;
50 Evas_Object *win = evas_object_data_get(cs, "win");
51 elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_PALETTE);
52 evas_object_resize(win, 320, 300);
56 _components_cb(void *data, Evas_Object *obj __UNUSED__,
57 void *event_info __UNUSED__)
59 Evas_Object *cs = data;
60 Evas_Object *win = evas_object_data_get(cs, "win");
61 elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_COMPONENTS);
62 evas_object_resize(win, 320, 455);
66 _both_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
68 Evas_Object *cs = data;
69 Evas_Object *win = evas_object_data_get(cs, "win");
70 elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_BOTH);
71 evas_object_resize(win, 320, 535);
75 test_colorselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
76 void *event_info __UNUSED__)
78 Evas_Object *win, *bg, *bx, *bx2, *cs, *fr, *re, *bt;
81 win = elm_win_add(NULL, "colorselector", ELM_WIN_BASIC);
82 elm_win_title_set(win, "Color Selector");
83 elm_win_autodel_set(win, EINA_TRUE);
86 elm_win_resize_object_add(win, bg);
87 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
90 bx = elm_box_add(win);
91 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92 elm_win_resize_object_add(win, bx);
95 fr = elm_frame_add(bx);
96 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0);
97 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
98 elm_object_text_set(fr, "Color View");
99 elm_box_pack_end(bx, fr);
100 evas_object_show(fr);
102 re = evas_object_rectangle_add(evas_object_evas_get(win));
103 evas_object_size_hint_min_set(re, 1, 100);
104 evas_object_show(re);
105 elm_object_content_set(fr, re);
107 fr = elm_frame_add(bx);
108 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
109 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
110 elm_object_text_set(fr, "Color Selector");
111 elm_box_pack_end(bx, fr);
112 evas_object_show(fr);
114 cs = elm_colorselector_add(fr);
115 elm_colorselector_palette_color_add(cs, 255, 90, 18, 255);
116 elm_colorselector_palette_color_add(cs, 255, 213, 0, 255);
117 elm_colorselector_palette_color_add(cs, 146, 255, 11, 255);
118 elm_colorselector_palette_color_add(cs, 9, 186, 10, 255);
119 elm_colorselector_palette_color_add(cs, 86, 201, 242, 255);
120 elm_colorselector_palette_color_add(cs, 18, 83, 128, 255);
121 elm_colorselector_palette_color_add(cs, 140, 53, 238, 255);
122 elm_colorselector_palette_color_add(cs, 255, 145, 145, 255);
123 elm_colorselector_palette_color_add(cs, 255, 59, 119, 255);
124 elm_colorselector_palette_color_add(cs, 133, 100, 69, 255);
125 elm_colorselector_palette_color_add(cs, 255, 255, 119, 255);
126 elm_colorselector_palette_color_add(cs, 133, 100, 255, 255);
133 elm_colorselector_color_set(cs, r, g, b, a);
134 evas_object_size_hint_weight_set(cs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
135 evas_object_size_hint_align_set(cs, EVAS_HINT_FILL, EVAS_HINT_FILL);
136 elm_object_content_set(fr, cs);
137 evas_object_show(cs);
138 evas_object_smart_callback_add(cs, "changed", _colorselector_clicked_cb, re);
139 evas_object_smart_callback_add(cs, "color,item,selected",
140 _colorpalette_clicked_cb, re);
141 evas_object_smart_callback_add(cs, "color,item,longpressed",
142 _colorpalette_longpressed_cb, re);
143 evas_object_data_set(cs, "win", win);
145 elm_colorselector_color_get(cs, &r, &g, &b, &a);
146 /* Fix Alpha pre multiplication by edje */
150 evas_object_color_set(re, r, g, b, a);
152 bx2 = elm_box_add(bx);
153 elm_box_horizontal_set(bx2, EINA_TRUE);
154 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0);
155 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
156 evas_object_show(bx2);
157 elm_box_pack_end(bx, bx2);
159 bt = elm_button_add(bx2);
160 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
161 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
162 evas_object_smart_callback_add(bt, "clicked", _palette_cb, cs);
163 elm_object_text_set(bt, "Palette");
164 evas_object_show(bt);
165 elm_box_pack_end(bx2, bt);
167 bt = elm_button_add(bx2);
168 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
170 evas_object_smart_callback_add(bt, "clicked", _components_cb, cs);
171 elm_object_text_set(bt, "Components");
172 evas_object_show(bt);
173 elm_box_pack_end(bx2, bt);
175 bt = elm_button_add(bx2);
176 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
177 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
178 evas_object_smart_callback_add(bt, "clicked", _both_cb, cs);
179 elm_object_text_set(bt, "Both");
180 evas_object_show(bt);
181 elm_box_pack_end(bx2, bt);
183 evas_object_resize(win, 320, 500);
184 evas_object_show(win);