summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2015-03-30 15:18:34 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2015-03-30 15:18:34 -0400
commit0a16af35171e4fa94a362e817f83de40b16ed0eb (patch)
treeceff60d0d3eb2745db34a6975132141bf442e5d2
parent41a5072d14c76c811c555d1b435c9876acf0c438 (diff)
-rw-r--r--src/lib/elm_color_class.c169
1 files changed, 169 insertions, 0 deletions
diff --git a/src/lib/elm_color_class.c b/src/lib/elm_color_class.c
new file mode 100644
index 000000000..fe94a3049
--- /dev/null
+++ b/src/lib/elm_color_class.c
@@ -0,0 +1,169 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7#include "elm_priv.h"
8
9int
10elm_color_class_init(void)
11{
12 const Eina_List *l;
13 const Elm_Color_Class *cc;
14
15 EINA_LIST_FOREACH(elm_color_classes, l, cc)
16 {
17 if (!cc) continue;
18
19 printf("INIT CC: %s, %d %d %d %d\n", cc->name, cc->r, cc->g, cc->b, cc->a);
20 edje_color_class_set(cc->name,
21 cc->r, cc->g, cc->b, cc->a,
22 cc->r2, cc->g2, cc->b2, cc->a2,
23 cc->r3, cc->g3, cc->b3, cc->a3);
24 }
25 return 1;
26}
27
28int
29elm_color_class_shutdown(void)
30{
31 return 1;
32}
33
34static Eina_List *
35elm_color_class_node_find_stringshared(const char *name)
36{
37 Eina_List *l;
38 Elm_Color_Class *cc;
39
40 EINA_LIST_FOREACH(elm_color_classes, l, cc)
41 if (cc && cc->name == name)
42 return l;
43 return NULL;
44}
45
46EAPI Elm_Color_Class *
47elm_color_class_find_stringshared(const char *name)
48{
49 Eina_List *l = elm_color_class_node_find_stringshared(name);
50 if (!l) return NULL;
51 return l->data;
52}
53
54EAPI Elm_Color_Class *
55elm_color_class_find(const char *name)
56{
57 Elm_Color_Class *cc;
58
59 name = eina_stringshare_add(name);
60 cc = elm_color_class_find_stringshared(name);
61 eina_stringshare_del(name);
62
63 return cc;
64}
65
66EAPI void
67elm_color_class_instance_set(Elm_Color_Class *cc, int r, int g, int b, int a, int r2, int b2, int g2, int a2, int r3, int g3, int b3, int a3)
68{
69 if (!cc) return;
70
71 if (r != -1) cc->r = E_CLAMP(r, 0, 255);
72 if (g != -1) cc->g = E_CLAMP(g, 0, 255);
73 if (b != -1) cc->b = E_CLAMP(b, 0, 255);
74 if (a != -1) cc->a = E_CLAMP(a, 0, 255);
75 if (r2 != -1) cc->r2 = E_CLAMP(r2, 0, 255);
76 if (g2 != -1) cc->g2 = E_CLAMP(g2, 0, 255);
77 if (b2 != -1) cc->b2 = E_CLAMP(b2, 0, 255);
78 if (a2 != -1) cc->a2 = E_CLAMP(a2, 0, 255);
79 if (r3 != -1) cc->r3 = E_CLAMP(r3, 0, 255);
80 if (g3 != -1) cc->g3 = E_CLAMP(g3, 0, 255);
81 if (b3 != -1) cc->b3 = E_CLAMP(b3, 0, 255);
82 if (a3 != -1) cc->a3 = E_CLAMP(a3, 0, 255);
83
84 edje_color_class_set(cc->name,
85 cc->r, cc->g, cc->b, cc->a,
86 cc->r2, cc->g2, cc->b2, cc->a2,
87 cc->r3, cc->g3, cc->b3, cc->a3);
88 e_config_save_queue();
89}
90
91EAPI Elm_Color_Class *
92elm_color_class_set_stringshared(const char *color_class, int r, int g, int b, int a, int r2, int b2, int g2, int a2, int r3, int g3, int b3, int a3)
93{
94 Elm_Color_Class *cc = elm_color_class_find_stringshared(color_class);
95 if (!cc)
96 {
97 cc = E_NEW(Elm_Color_Class, 1);
98 if (!cc) return NULL;
99 elm_color_classes = eina_list_append(elm_color_classes, cc);
100 cc->name = eina_stringshare_ref(color_class);
101 cc->r = cc->g = cc->b = cc->a = 255;
102 cc->r2 = cc->g2 = cc->b2 = cc->a2 = 255;
103 cc->r3 = cc->g3 = cc->b3 = cc->a3 = 255;
104 }
105
106 elm_color_class_instance_set(cc,
107 r, g, b, a,
108 r2, g2, b2, a2,
109 r3, g3, b3, a3);
110 return cc;
111}
112
113EAPI Elm_Color_Class *
114elm_color_class_set(const char *color_class, int r, int g, int b, int a, int r2, int b2, int g2, int a2, int r3, int g3, int b3, int a3)
115{
116 Elm_Color_Class *cc;
117
118 color_class = eina_stringshare_add(color_class);
119 cc = elm_color_class_set_stringshared(color_class,
120 r, g, b, a,
121 r2, g2, b2, a2,
122 r3, g3, b3, a3);
123 eina_stringshare_del(color_class);
124
125 return cc;
126}
127
128static void
129elm_color_class_node_del(Eina_List *n)
130{
131 Elm_Color_Class *cc = n->data;
132 edje_color_class_del(cc->name);
133 eina_stringshare_del(cc->name);
134 E_FREE(cc);
135
136 elm_color_classes = eina_list_remove_list(elm_color_classes, n);
137 e_config_save_queue();
138}
139
140EAPI void
141elm_color_class_instance_del(Elm_Color_Class *cc)
142{
143 Eina_List *n = eina_list_data_find_list(elm_color_classes, cc);
144 if (!n) return;
145 elm_color_class_node_del(n);
146}
147
148EAPI void
149elm_color_class_del_stringshared(const char *name)
150{
151 Eina_List *n = elm_color_class_node_find_stringshared(name);
152 if (!n) return;
153 elm_color_class_node_del(n);
154}
155
156EAPI void
157elm_color_class_del(const char *name)
158{
159 name = eina_stringshare_add(name);
160 elm_color_class_del_stringshared(name);
161 eina_stringshare_del(name);
162}
163
164EAPI Eina_List *
165elm_color_class_list(void)
166{
167 return elm_color_classes;
168}
169