summaryrefslogtreecommitdiff
path: root/legacy/edje/src
diff options
context:
space:
mode:
authorrbdpngn <rbdpngn>2003-11-04 06:15:19 +0000
committerrbdpngn <rbdpngn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2003-11-04 06:15:19 +0000
commit17678212d6418b13a8654087213d09eecb973ff1 (patch)
tree9b14e3b82ee224373dae5a94cc6c5d03f043997c /legacy/edje/src
parent9a54b4ad5a75775d538a7cf006e2f3d8cd7ab537 (diff)
Global text and color class manipulation. Settings on individual edje's will
override the global values. SVN revision: 7795
Diffstat (limited to 'legacy/edje/src')
-rw-r--r--legacy/edje/src/bin/edje_main.c15
-rw-r--r--legacy/edje/src/lib/Edje.h3
-rw-r--r--legacy/edje/src/lib/edje_calc.c7
-rw-r--r--legacy/edje/src/lib/edje_load.c12
-rw-r--r--legacy/edje/src/lib/edje_private.h5
-rw-r--r--legacy/edje/src/lib/edje_text.c34
-rw-r--r--legacy/edje/src/lib/edje_util.c214
7 files changed, 276 insertions, 14 deletions
diff --git a/legacy/edje/src/bin/edje_main.c b/legacy/edje/src/bin/edje_main.c
index 20973eb..d2a4158 100644
--- a/legacy/edje/src/bin/edje_main.c
+++ b/legacy/edje/src/bin/edje_main.c
@@ -232,10 +232,17 @@ bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_info)
232 else if (!strcmp(ev->keyname, "Right")) 232 else if (!strcmp(ev->keyname, "Right"))
233 edje_object_part_text_set(de->edje, "text", "You pressed \"U\". Nice one stenchie!"); 233 edje_object_part_text_set(de->edje, "text", "You pressed \"U\". Nice one stenchie!");
234 else if (!strcmp(ev->keyname, "F1")) 234 else if (!strcmp(ev->keyname, "F1"))
235 edje_object_color_class_set(de->edje, "bg", 235 {
236 255, 255, 255, 255, 236 edje_object_color_class_set(de->edje, "bg",
237 0, 0, 0, 0, 237 255, 255, 255, 255,
238 0, 0, 0, 0); 238 0, 0, 0, 0,
239 0, 0, 0, 0);
240 edje_color_class_set("fg",
241 0, 0, 0, 255,
242 0, 0, 0, 0,
243 0, 0, 0, 0);
244 edje_text_class_set("plainjane", "Vera", 10);
245 }
239 else if (!strcmp(ev->keyname, "F2")) 246 else if (!strcmp(ev->keyname, "F2"))
240 edje_object_color_class_set(de->edje, "bg", 247 edje_object_color_class_set(de->edje, "bg",
241 255, 200, 120, 255, 248 255, 200, 120, 255,
diff --git a/legacy/edje/src/lib/Edje.h b/legacy/edje/src/lib/Edje.h
index 475427a..fb11c11 100644
--- a/legacy/edje/src/lib/Edje.h
+++ b/legacy/edje/src/lib/Edje.h
@@ -29,6 +29,9 @@ extern "C" {
29 Evas_List *edje_file_collection_list (const char *file); 29 Evas_List *edje_file_collection_list (const char *file);
30 void edje_file_collection_list_free (Evas_List *lst); 30 void edje_file_collection_list_free (Evas_List *lst);
31 char *edje_file_data_get (const char *file, const char *key); 31 char *edje_file_data_get (const char *file, const char *key);
32
33 void edje_color_class_set(const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3);
34 void edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size);
32 35
33 void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); 36 void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh);
34 void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh); 37 void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh);
diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c
index e9ab408..be8101c 100644
--- a/legacy/edje/src/lib/edje_calc.c
+++ b/legacy/edje/src/lib/edje_calc.c
@@ -418,8 +418,11 @@ _edje_part_recalc_single(Edje *ed,
418 Edje_Text_Class *tc; 418 Edje_Text_Class *tc;
419 419
420 tc = _edje_text_class_find(ed, chosen_desc->text.text_class); 420 tc = _edje_text_class_find(ed, chosen_desc->text.text_class);
421 if (tc->font) font = tc->font; 421 if (tc)
422 if (tc->size > 0) size = tc->size; 422 {
423 if (tc->font) font = tc->font;
424 if (tc->size > 0) size = tc->size;
425 }
423 } 426 }
424 427
425 if (ep->text.text) text = ep->text.text; 428 if (ep->text.text) text = ep->text.text;
diff --git a/legacy/edje/src/lib/edje_load.c b/legacy/edje/src/lib/edje_load.c
index 48ea221..0b36148 100644
--- a/legacy/edje/src/lib/edje_load.c
+++ b/legacy/edje/src/lib/edje_load.c
@@ -40,8 +40,17 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
40 { 40 {
41 Edje_Part *ep; 41 Edje_Part *ep;
42 Evas_List *hist = NULL; 42 Evas_List *hist = NULL;
43 43
44 /* Register any color classes in this parts descriptions. */
44 ep = l->data; 45 ep = l->data;
46 if ((ep->default_desc) && (ep->default_desc->color_class)) _edje_color_class_member_add(ed, ep->default_desc->color_class);
47 for (hist = ep->other_desc; hist; hist = hist->next)
48 {
49 Edje_Part_Description *desc;
50
51 desc = hist->data;
52 if (desc->color_class) _edje_color_class_member_add(ed, desc->color_class);
53 }
45 hist = evas_list_append(hist, ep); 54 hist = evas_list_append(hist, ep);
46 while (ep->dragable.confine_id >= 0) 55 while (ep->dragable.confine_id >= 0)
47 { 56 {
@@ -459,6 +468,7 @@ _edje_file_del(Edje *ed)
459 EVAS_CALLBACK_MOUSE_WHEEL, 468 EVAS_CALLBACK_MOUSE_WHEEL,
460 _edje_mouse_wheel_cb); 469 _edje_mouse_wheel_cb);
461 _edje_text_part_on_del(ed, rp); 470 _edje_text_part_on_del(ed, rp);
471 _edje_color_class_on_del(ed, rp);
462 evas_object_del(rp->object); 472 evas_object_del(rp->object);
463 if (rp->swallowed_object) 473 if (rp->swallowed_object)
464 { 474 {
diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h
index 781854e..848e7b4 100644
--- a/legacy/edje/src/lib/edje_private.h
+++ b/legacy/edje/src/lib/edje_private.h
@@ -586,7 +586,12 @@ void _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *pa
586 586
587Edje_Real_Part *_edje_real_part_get(Edje *ed, char *part); 587Edje_Real_Part *_edje_real_part_get(Edje *ed, char *part);
588Edje_Color_Class *_edje_color_class_find(Edje *ed, char *color_class); 588Edje_Color_Class *_edje_color_class_find(Edje *ed, char *color_class);
589void _edje_color_class_member_add(Edje *ed, char *color_class);
590void _edje_color_class_member_del(Edje *ed, char *color_class);
591void _edje_color_class_on_del(Edje *ed, Edje_Real_Part *rp);
589Edje_Text_Class *_edje_text_class_find(Edje *ed, char *text_class); 592Edje_Text_Class *_edje_text_class_find(Edje *ed, char *text_class);
593void _edje_text_class_member_add(Edje *ed, char *text_class);
594void _edje_text_class_member_del(Edje *ed, char *text_class);
590Edje *_edje_fetch(Evas_Object *obj); 595Edje *_edje_fetch(Evas_Object *obj);
591int _edje_glob_match(char *str, char *glob); 596int _edje_glob_match(char *str, char *glob);
592int _edje_freeze(Edje *ed); 597int _edje_freeze(Edje *ed);
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c
index 7f18a78..43acb54 100644
--- a/legacy/edje/src/lib/edje_text.c
+++ b/legacy/edje/src/lib/edje_text.c
@@ -1,6 +1,8 @@
1#include "Edje.h" 1#include "Edje.h"
2#include "edje_private.h" 2#include "edje_private.h"
3 3
4static Evas_Hash *_edje_text_class_hash = NULL;
5
4Edje_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST]; 6Edje_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST];
5 7
6void 8void
@@ -175,6 +177,8 @@ void
175_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep) 177_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep)
176{ 178{
177 int i; 179 int i;
180 Evas_List *tmp;
181 Edje_Part *pt = ep->part;
178 182
179 if (ep->part->type != EDJE_PART_TYPE_TEXT) return; 183 if (ep->part->type != EDJE_PART_TYPE_TEXT) return;
180 if (ep->part->effect >= EDJE_TEXT_EFFECT_LAST) return; 184 if (ep->part->effect >= EDJE_TEXT_EFFECT_LAST) return;
@@ -188,6 +192,16 @@ _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep)
188 evas_object_clip_set(o, ed->clipper); 192 evas_object_clip_set(o, ed->clipper);
189 evas_object_show(o); 193 evas_object_show(o);
190 ep->extra_objects = evas_list_append(ep->extra_objects, o); 194 ep->extra_objects = evas_list_append(ep->extra_objects, o);
195
196 }
197
198 if ((pt->default_desc) && (pt->default_desc->text.text_class)) _edje_text_class_member_add(ed, pt->default_desc->text.text_class);
199 for (tmp = pt->other_desc; tmp; tmp = tmp->next)
200 {
201 Edje_Part_Description *desc;
202
203 desc = tmp->data;
204 if ((desc) && (desc->text.text_class)) _edje_text_class_member_add(ed, desc->text.text_class);
191 } 205 }
192} 206}
193 207
@@ -217,6 +231,9 @@ _edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep)
217void 231void
218_edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep) 232_edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep)
219{ 233{
234 Evas_List *tmp;
235 Edje_Part *pt = ep->part;
236
220 while (ep->extra_objects) 237 while (ep->extra_objects)
221 { 238 {
222 Evas_Object *o; 239 Evas_Object *o;
@@ -225,8 +242,16 @@ _edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep)
225 ep->extra_objects = evas_list_remove(ep->extra_objects, o); 242 ep->extra_objects = evas_list_remove(ep->extra_objects, o);
226 evas_object_del(o); 243 evas_object_del(o);
227 } 244 }
245
246 if ((pt->default_desc) && (pt->default_desc->text.text_class)) _edje_text_class_member_del(ed, pt->default_desc->text.text_class);
247 for (tmp = pt->other_desc; tmp; tmp = tmp->next)
248 {
249 Edje_Part_Description *desc;
250
251 desc = tmp->data;
252 if (desc->text.text_class) _edje_text_class_member_del(ed, desc->text.text_class);
253 }
228 return; 254 return;
229 ed = NULL;
230} 255}
231 256
232void 257void
@@ -250,8 +275,11 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
250 Edje_Text_Class *tc; 275 Edje_Text_Class *tc;
251 276
252 tc = _edje_text_class_find(ed, chosen_desc->text.text_class); 277 tc = _edje_text_class_find(ed, chosen_desc->text.text_class);
253 if (tc->font) font = tc->font; 278 if (tc)
254 if (tc->size > 0) size = tc->size; 279 {
280 if (tc->font) font = tc->font;
281 if (tc->size > 0) size = tc->size;
282 }
255 } 283 }
256 284
257 if (ep->text.text) text = ep->text.text; 285 if (ep->text.text) text = ep->text.text;
diff --git a/legacy/edje/src/lib/edje_util.c b/legacy/edje/src/lib/edje_util.c
index 02f8141..df1c1e3 100644
--- a/legacy/edje/src/lib/edje_util.c
+++ b/legacy/edje/src/lib/edje_util.c
@@ -1,6 +1,12 @@
1#include "Edje.h" 1#include "Edje.h"
2#include "edje_private.h" 2#include "edje_private.h"
3 3
4Evas_Hash *_edje_color_class_hash = NULL;
5Evas_Hash *_edje_color_class_member_hash = NULL;
6
7Evas_Hash *_edje_text_class_hash = NULL;
8Evas_Hash *_edje_text_class_member_hash = NULL;
9
4void 10void
5edje_freeze(void) 11edje_freeze(void)
6{ 12{
@@ -60,6 +66,75 @@ edje_object_thaw(Evas_Object *obj)
60} 66}
61 67
62void 68void
69edje_color_class_set(const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3)
70{
71 Evas_List *members;
72 Edje_Color_Class *cc;
73
74 if (!color_class) return;
75
76 cc = evas_hash_find(_edje_color_class_hash, color_class);
77 if (!cc)
78 {
79 cc = malloc(sizeof(Edje_Color_Class));
80 if (!cc) return;
81 cc->name = strdup(color_class);
82 if (!cc->name)
83 {
84 free(cc);
85 return;
86 }
87 _edje_color_class_hash = evas_hash_add(_edje_color_class_hash, color_class, cc);
88 if (evas_hash_alloc_error())
89 {
90 free(cc->name);
91 free(cc);
92 return;
93 }
94
95 }
96
97 if (r < 0) r = 0;
98 if (r > 255) r = 255;
99 if (g < 0) g = 0;
100 if (g > 255) g = 255;
101 if (b < 0) b = 0;
102 if (b > 255) b = 255;
103 if (a < 0) a = 0;
104 if (a > 255) a = 255;
105 if ((cc->r == r) && (cc->g == g) &&
106 (cc->b == b) && (cc->a == a) &&
107 (cc->r2 == r2) && (cc->g2 == g2) &&
108 (cc->b2 == b2) && (cc->a2 == a2) &&
109 (cc->r3 == r3) && (cc->g3 == g3) &&
110 (cc->b3 == b3) && (cc->a3 == a3))
111 return;
112 cc->r = r;
113 cc->g = g;
114 cc->b = b;
115 cc->a = a;
116 cc->r2 = r2;
117 cc->g2 = g2;
118 cc->b2 = b2;
119 cc->a2 = a2;
120 cc->r3 = r3;
121 cc->g3 = g3;
122 cc->b3 = b3;
123 cc->a3 = a3;
124
125 members = evas_hash_find(_edje_color_class_member_hash, color_class);
126 while (members)
127 {
128 Edje *ed;
129
130 ed = members->data;
131 ed->dirty = 1;
132 _edje_recalc(ed);
133 members = members->next;
134 }
135}
136
137void
63edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3) 138edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3)
64{ 139{
65 Edje *ed; 140 Edje *ed;
@@ -106,6 +181,7 @@ edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, in
106 } 181 }
107 } 182 }
108 cc = malloc(sizeof(Edje_Color_Class)); 183 cc = malloc(sizeof(Edje_Color_Class));
184 if (!cc) return;
109 cc->name = strdup(color_class); 185 cc->name = strdup(color_class);
110 if (!cc->name) 186 if (!cc->name)
111 { 187 {
@@ -130,6 +206,65 @@ edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, in
130} 206}
131 207
132void 208void
209edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size)
210{
211 Evas_List *members;
212 Edje_Text_Class *tc;
213
214 if (!text_class) return;
215
216 if (size < 0) size = 0;
217 if (!font) font = "";
218
219 tc = evas_hash_find(_edje_text_class_hash, text_class);
220 if (!tc)
221 {
222 tc = calloc(1, sizeof(Edje_Text_Class));
223 if (!tc) return;
224 tc->name = strdup(text_class);
225 if (!tc->name)
226 {
227 free(tc);
228 return;
229 }
230 _edje_text_class_hash = evas_hash_add(_edje_text_class_hash, text_class, tc);
231 if (evas_hash_alloc_error())
232 {
233 free(tc->name);
234 free(tc);
235 return;
236 }
237
238 tc->font = strdup(font);
239 tc->size = size;
240 return;
241 }
242
243 if ((tc->size == size) && (!strcmp(tc->font, font)))
244 return;
245 free(tc->font);
246 tc->font = strdup(font);
247 if (!tc->font)
248 {
249 _edje_text_class_hash = evas_hash_del(_edje_text_class_hash, text_class, tc);
250 free(tc);
251 return;
252 }
253 tc->size = size;
254
255 members = evas_hash_find(_edje_text_class_member_hash, text_class);
256 while (members)
257 {
258 Edje *ed;
259
260 ed = members->data;
261 ed->dirty = 1;
262 _edje_recalc(ed);
263 members = members->next;
264 }
265}
266
267void
133edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size) 268edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size)
134{ 269{
135 Edje *ed; 270 Edje *ed;
@@ -161,6 +296,7 @@ edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char
161 } 296 }
162 } 297 }
163 tc = malloc(sizeof(Edje_Text_Class)); 298 tc = malloc(sizeof(Edje_Text_Class));
299 if (!tc) return;
164 tc->name = strdup(text_class); 300 tc->name = strdup(text_class);
165 if (!tc->name) 301 if (!tc->name)
166 { 302 {
@@ -876,7 +1012,7 @@ _edje_color_class_find(Edje *ed, char *color_class)
876{ 1012{
877 Evas_List *l; 1013 Evas_List *l;
878 1014
879 if (!color_class) return NULL; 1015 if ((!ed) || (!color_class)) return;
880 for (l = ed->color_classes; l; l = l->next) 1016 for (l = ed->color_classes; l; l = l->next)
881 { 1017 {
882 Edje_Color_Class *cc; 1018 Edje_Color_Class *cc;
@@ -884,7 +1020,50 @@ _edje_color_class_find(Edje *ed, char *color_class)
884 cc = l->data; 1020 cc = l->data;
885 if (!strcmp(color_class, cc->name)) return cc; 1021 if (!strcmp(color_class, cc->name)) return cc;
886 } 1022 }
887 return NULL; 1023 return evas_hash_find(_edje_color_class_hash, color_class);
1024}
1025
1026void
1027_edje_color_class_member_add(Edje *ed, char *color_class)
1028{
1029 Evas_List *members;
1030
1031 if ((!ed) || (!color_class)) return;
1032 members = evas_hash_find(_edje_color_class_member_hash, color_class);
1033 if (members) _edje_color_class_member_hash = evas_hash_del(_edje_color_class_member_hash, color_class, members);
1034
1035 members = evas_list_prepend(members, ed);
1036 _edje_color_class_member_hash = evas_hash_add(_edje_color_class_member_hash, color_class, members);
1037}
1038
1039void
1040_edje_color_class_member_del(Edje *ed, char *color_class)
1041{
1042 Evas_List *members, *tmp = NULL;
1043
1044 if ((!ed) || (!color_class)) return;
1045 members = evas_hash_find(_edje_color_class_member_hash, color_class);
1046 if (!members) return;
1047
1048 _edje_color_class_member_hash = evas_hash_del(_edje_color_class_member_hash, color_class, members);
1049 members = evas_list_remove(members, ed);
1050 if (members) _edje_color_class_member_hash = evas_hash_add(_edje_color_class_member_hash, color_class, members);
1051}
1052
1053void
1054_edje_color_class_on_del(Edje *ed, Edje_Real_Part *rp)
1055{
1056 Evas_List *tmp;
1057 Edje_Part *ep = rp->part;
1058
1059 if ((ep->default_desc) && (ep->default_desc->color_class)) _edje_color_class_member_del(ed, ep->default_desc->color_class);
1060 for (tmp = ep->other_desc; tmp; tmp = tmp->next)
1061 {
1062 Edje_Part_Description *desc;
1063
1064 desc = tmp->data;
1065 if (desc->color_class) _edje_color_class_member_del(ed, desc->color_class);
1066 }
888} 1067}
889 1068
890Edje_Text_Class * 1069Edje_Text_Class *
@@ -892,7 +1071,7 @@ _edje_text_class_find(Edje *ed, char *text_class)
892{ 1071{
893 Evas_List *l; 1072 Evas_List *l;
894 1073
895 if (!text_class) return NULL; 1074 if ((!ed) || (!text_class)) return;
896 for (l = ed->text_classes; l; l = l->next) 1075 for (l = ed->text_classes; l; l = l->next)
897 { 1076 {
898 Edje_Text_Class *tc; 1077 Edje_Text_Class *tc;
@@ -900,7 +1079,34 @@ _edje_text_class_find(Edje *ed, char *text_class)
900 tc = l->data; 1079 tc = l->data;
901 if (!strcmp(text_class, tc->name)) return tc; 1080 if (!strcmp(text_class, tc->name)) return tc;
902 } 1081 }
903 return NULL; 1082 return evas_hash_find(_edje_text_class_hash, text_class);
1083}
1084
1085void
1086_edje_text_class_member_add(Edje *ed, char *text_class)
1087{
1088 Evas_List *members;
1089
1090 if ((!ed) || (!text_class)) return;
1091 members = evas_hash_find(_edje_text_class_member_hash, text_class);
1092 if (members) _edje_text_class_member_hash = evas_hash_del(_edje_text_class_member_hash, text_class, members);
1093
1094 members = evas_list_prepend(members, ed);
1095 _edje_text_class_member_hash = evas_hash_add(_edje_text_class_member_hash, text_class, members);
1096}
1097
1098void
1099_edje_text_class_member_del(Edje *ed, char *text_class)
1100{
1101 Evas_List *members, *tmp = NULL;
1102
1103 if ((!ed) || (!text_class)) return;
1104 members = evas_hash_find(_edje_text_class_member_hash, text_class);
1105 if (!members) return;
1106
1107 _edje_text_class_member_hash = evas_hash_del(_edje_text_class_member_hash, text_class, members);
1108 members = evas_list_remove(members, ed);
1109 if (members) _edje_text_class_member_hash = evas_hash_add(_edje_text_class_member_hash, text_class, members);
904} 1110}
905 1111
906Edje * 1112Edje *