summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeber <beber>2005-08-23 09:17:10 +0000
committerbeber <beber>2005-08-23 09:17:10 +0000
commit9d04c809b391d8163c68ec8830bb33a0dd4a2090 (patch)
treec5f8e436030ccc76fe335eb1024d7e861eda4252
Add epresent to svn
Thanks raster
-rw-r--r--epresent.tgzbin0 -> 1888132 bytes
-rw-r--r--pres/Makefile41
-rw-r--r--pres/anx_compat.h76
-rw-r--r--pres/anx_core.h58
-rw-r--r--pres/anx_list.c253
-rw-r--r--pres/anx_list.h175
-rw-r--r--pres/bg.edc369
-rw-r--r--pres/data/fonts/.cvsignore2
-rw-r--r--pres/data/fonts/Vera.COPYING47
-rw-r--r--pres/data/fonts/Vera.ttfbin0 -> 65932 bytes
-rw-r--r--pres/data/fonts/VeraBI.ttfbin0 -> 63208 bytes
-rw-r--r--pres/data/fonts/VeraBd.ttfbin0 -> 58716 bytes
-rw-r--r--pres/data/fonts/VeraIt.ttfbin0 -> 63684 bytes
-rw-r--r--pres/data/fonts/VeraMoBI.ttfbin0 -> 55032 bytes
-rw-r--r--pres/data/fonts/VeraMoBd.ttfbin0 -> 49052 bytes
-rw-r--r--pres/data/fonts/VeraMoIt.ttfbin0 -> 54508 bytes
-rw-r--r--pres/data/fonts/VeraMono.ttfbin0 -> 49224 bytes
-rw-r--r--pres/data/fonts/VeraSe.ttfbin0 -> 60280 bytes
-rw-r--r--pres/data/fonts/VeraSeBd.ttfbin0 -> 58736 bytes
-rw-r--r--pres/data/fonts/fonts.alias11
-rw-r--r--pres/data/fonts/fonts.dir51
-rw-r--r--pres/data/images/brushed.pngbin0 -> 43875 bytes
-rw-r--r--pres/data/images/next1.pngbin0 -> 13146 bytes
-rw-r--r--pres/data/images/next2.pngbin0 -> 12150 bytes
-rw-r--r--pres/data/images/prev.xcf.gzbin0 -> 20043 bytes
-rw-r--r--pres/data/images/prev1.pngbin0 -> 13089 bytes
-rw-r--r--pres/data/images/prev2.pngbin0 -> 12089 bytes
-rw-r--r--pres/data/images/reflection_overlay.pngbin0 -> 376638 bytes
-rw-r--r--pres/data/images/shadow.pngbin0 -> 58557 bytes
-rw-r--r--pres/main.c155
-rw-r--r--pres/main.h35
-rw-r--r--pres/pres_core.c332
-rw-r--r--pres/slide.c571
-rw-r--r--pres/slide.h12
-rw-r--r--pres/test/e.pngbin0 -> 74944 bytes
-rw-r--r--pres/test/pres.xml229
-rw-r--r--pres/test/sky.edjbin0 -> 130975 bytes
-rw-r--r--pres/test/sky/bg.pngbin0 -> 59412 bytes
-rw-r--r--pres/test/sky/build.sh2
-rw-r--r--pres/test/sky/c1.pngbin0 -> 172983 bytes
-rw-r--r--pres/test/sky/c2.pngbin0 -> 85067 bytes
-rw-r--r--pres/test/sky/c3.pngbin0 -> 97280 bytes
-rw-r--r--pres/test/sky/c4.pngbin0 -> 141508 bytes
-rw-r--r--pres/test/sky/icon.pngbin0 -> 16849 bytes
-rw-r--r--pres/test/sky/main_edje_source.edc625
-rw-r--r--pres/test/sky/s0.pngbin0 -> 48604 bytes
-rw-r--r--pres/test/sky/s1.pngbin0 -> 31506 bytes
-rw-r--r--pres/test/sky/s2.pngbin0 -> 47676 bytes
-rw-r--r--pres/test/sky/sky.edjbin0 -> 130975 bytes
-rw-r--r--pres/xtag.c829
-rw-r--r--pres/xtag.h135
51 files changed, 4008 insertions, 0 deletions
diff --git a/epresent.tgz b/epresent.tgz
new file mode 100644
index 0000000..a20dc63
--- /dev/null
+++ b/epresent.tgz
Binary files differ
diff --git a/pres/Makefile b/pres/Makefile
new file mode 100644
index 0000000..c156ed2
--- /dev/null
+++ b/pres/Makefile
@@ -0,0 +1,41 @@
1SRCS = \
2main.c \
3pres_core.c \
4slide.c \
5xtag.c \
6anx_list.c
7
8ifdef CONFIG_BIN
9 CFBIN = $(CONFIG_BIN)/
10else
11 CFBIN =
12endif
13
14FLGS = \
15`$(CFBIN)evas-config --cflags` \
16`$(CFBIN)ecore-config --cflags` \
17`$(CFBIN)edje-config --cflags` \
18`$(CFBIN)emotion-config --cflags`
19
20LIBS = \
21`$(CFBIN)evas-config --libs` \
22`$(CFBIN)ecore-config --libs` \
23`$(CFBIN)edje-config --libs` \
24`$(CFBIN)emotion-config --libs` \
25-lm
26
27####################
28OBJS = $(SRCS:.c=.o)
29
30ddc_2005: $(OBJS) bg.edj
31 $(RM) $@
32 $(CC) -o $@ $(OBJS) $(LIBS)
33
34.c.o:
35 $(CC) $(FLGS) $(CFLAGS) -c $< -o $@
36
37bg.edj: Makefile
38 edje_cc -fd ./data/fonts -id ./data/images -v bg.edc bg.edj
39
40clean::
41 rm -rf ddc_2005 *.o *~ "#"* bg.edj
diff --git a/pres/anx_compat.h b/pres/anx_compat.h
new file mode 100644
index 0000000..c763023
--- /dev/null
+++ b/pres/anx_compat.h
@@ -0,0 +1,76 @@
1/*
2 Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3 Organisation (CSIRO) Australia
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 - Neither the name of CSIRO Australia nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33
34#ifndef __ANX_COMPAT_H__
35#define __ANX_COMPAT_H__
36
37#ifndef __GNUC__
38
39# ifdef _WIN32
40# define __inline__ __inline
41# else
42# define __inline__
43# endif
44
45#endif
46
47
48#ifdef HAVE_UNISTD_H
49#include <unistd.h>
50#else
51
52#ifdef WIN32
53#include <io.h>
54#include <process.h>
55#endif
56
57#endif
58
59
60#ifdef WIN32
61#define lseek _lseek
62#define strcasecmp _stricmp
63#define strncasecmp _strnicmp
64#define snprintf _snprintf
65#define random rand
66#define srandom srand
67#define lstat stat
68#define getpid _getpid
69
70#include <stdarg.h>
71#include <stdlib.h>
72int vsnprintf(char * str, size_t n, const char * fmt, va_list ap);
73
74#endif
75
76#endif /* __ANX_COMPAT_H__ */
diff --git a/pres/anx_core.h b/pres/anx_core.h
new file mode 100644
index 0000000..60a58f0
--- /dev/null
+++ b/pres/anx_core.h
@@ -0,0 +1,58 @@
1/*
2 Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3 Organisation (CSIRO) Australia
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 - Neither the name of CSIRO Australia nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33#ifndef __ANX_CORE__
34#define __ANX_CORE__
35
36/** \file
37 * Core datatypes etc.
38 */
39
40#include <stdlib.h>
41
42/** malloc() wrapper to allow easy overriding */
43#define anx_malloc(n) calloc(1,(n))
44
45/** free() wrapper to allow easy overriding */
46#define anx_free(x) free((void *)(x))
47
48/**
49 * Signature of a cloning function.
50 */
51typedef void * (*AnxCloneFunc) (void * data);
52
53/**
54 * Signature of a freeing function.
55 */
56typedef void * (*AnxFreeFunc) (void * data);
57
58#endif /* __ANX_CORE__ */
diff --git a/pres/anx_list.c b/pres/anx_list.c
new file mode 100644
index 0000000..13d2ec2
--- /dev/null
+++ b/pres/anx_list.c
@@ -0,0 +1,253 @@
1/*
2 Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3 Organisation (CSIRO) Australia
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 - Neither the name of CSIRO Australia nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33#if HAVE_CONFIG
34#include "config.h"
35#endif
36
37#include "anx_compat.h"
38
39#include "anx_list.h"
40
41static AnxList *
42anx_list_node_new (void * data)
43{
44 AnxList * l;
45
46 l = (AnxList *) anx_malloc (sizeof (AnxList));
47 l->prev = l->next = NULL;
48 l->data = data;
49
50 return l;
51}
52
53AnxList *
54anx_list_new (void)
55{
56 return NULL;
57}
58
59AnxList *
60anx_list_clone (AnxList * list)
61{
62 AnxList * l, * new_list;
63
64 if (list == NULL) return NULL;
65 new_list = anx_list_new ();
66
67 for (l = list; l; l = l->next) {
68 new_list = anx_list_append (new_list, l->data);
69 }
70
71 return new_list;
72}
73
74AnxList *
75anx_list_clone_with (AnxList * list, AnxCloneFunc clone)
76{
77 AnxList * l, * new_list;
78 void * new_data;
79
80 if (list == NULL) return NULL;
81 if (clone == NULL) return anx_list_clone (list);
82
83 new_list = anx_list_new ();
84
85 for (l = list; l; l = l->next) {
86 new_data = clone (l->data);
87 new_list = anx_list_append (new_list, new_data);
88 }
89
90 return new_list;
91}
92
93
94AnxList *
95anx_list_tail (AnxList * list)
96{
97 AnxList * l;
98 for (l = list; l; l = l->next)
99 if (l->next == NULL) return l;
100 return NULL;
101}
102
103AnxList *
104anx_list_prepend (AnxList * list, void * data)
105{
106 AnxList * l = anx_list_node_new (data);
107
108 if (list == NULL) return l;
109
110 l->next = list;
111 list->prev = l;
112
113 return l;
114}
115
116AnxList *
117anx_list_append (AnxList * list, void * data)
118{
119 AnxList * l = anx_list_node_new (data);
120 AnxList * last;
121
122 if (list == NULL) return l;
123
124 last = anx_list_tail (list);
125 if (last) last->next = l;
126 l->prev = last;
127 return list;
128}
129
130AnxList *
131anx_list_add_before (AnxList * list, void * data, AnxList * node)
132{
133 AnxList * l, * p;
134
135 if (list == NULL) return anx_list_node_new (data);
136 if (node == NULL) return anx_list_append (list, data);
137 if (node == list) return anx_list_prepend (list, data);
138
139 l = anx_list_node_new (data);
140 p = node->prev;
141
142 l->prev = p;
143 l->next = node;
144 if (p) p->next = l;
145 node->prev = l;
146
147 return list;
148}
149
150AnxList *
151anx_list_add_after (AnxList * list, void * data, AnxList * node)
152{
153 AnxList * l, * n;
154
155 if (node == NULL) return anx_list_prepend (list, data);
156
157 l = anx_list_node_new (data);
158 n = node->next;
159
160 l->prev = node;
161 l->next = n;
162 if (n) n->prev = l;
163 node->next = l;
164
165 return list;
166}
167
168AnxList *
169anx_list_find (AnxList * list, void * data)
170{
171 AnxList * l;
172
173 for (l = list; l; l = l->next)
174 if (l->data == data) return l;
175
176 return NULL;
177}
178
179AnxList *
180anx_list_remove (AnxList * list, AnxList * node)
181{
182 if (node == NULL) return list;
183
184 if (node->prev) node->prev->next = node->next;
185 if (node->next) node->next->prev = node->prev;
186
187 if (node == list) return list->next;
188 else return list;
189}
190
191int
192anx_list_length (AnxList * list)
193{
194 AnxList * l;
195 int c = 0;
196
197 for (l = list; l; l = l->next)
198 c++;
199
200 return c;
201}
202
203int
204anx_list_is_empty (AnxList * list)
205{
206 return (list == NULL);
207}
208
209int
210anx_list_is_singleton (AnxList * list)
211{
212 if (list == NULL) return 0;
213 if (list->next == NULL) return 1;
214 else return 0;
215}
216
217/*
218 * anx_list_free_with (list, free_func)
219 *
220 * Step through list 'list', freeing each node using free_func(), and
221 * also free the list structure itself.
222 */
223AnxList *
224anx_list_free_with (AnxList * list, AnxFreeFunc free_func)
225{
226 AnxList * l, * ln;
227
228 for (l = list; l; l = ln) {
229 ln = l->next;
230 free_func (l->data);
231 anx_free (l);
232 }
233
234 return NULL;
235}
236
237/*
238 * anx_list_free (list)
239 *
240 * Free the list structure 'list', but not its nodes.
241 */
242AnxList *
243anx_list_free (AnxList * list)
244{
245 AnxList * l, * ln;
246
247 for (l = list; l; l = ln) {
248 ln = l->next;
249 anx_free (l);
250 }
251
252 return NULL;
253}
diff --git a/pres/anx_list.h b/pres/anx_list.h
new file mode 100644
index 0000000..899c640
--- /dev/null
+++ b/pres/anx_list.h
@@ -0,0 +1,175 @@
1/*
2 Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3 Organisation (CSIRO) Australia
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 - Neither the name of CSIRO Australia nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33#ifndef __ANX_LIST_H__
34#define __ANX_LIST_H__
35
36/** \file
37 * A doubly linked list
38 */
39
40#include "anx_core.h"
41
42/**
43 * A doubly linked list
44 */
45typedef struct _AnxList AnxList;
46
47struct _AnxList {
48 AnxList * prev;
49 AnxList * next;
50 void * data;
51};
52
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58/** Create a new list
59 * \return a new list
60 */
61AnxList * anx_list_new (void);
62
63/**
64 * Clone a list using the default clone function
65 * \param list the list to clone
66 * \returns a newly cloned list
67 */
68AnxList * anx_list_clone (AnxList * list);
69
70/**
71 * Clone a list using a custom clone function
72 * \param list the list to clone
73 * \param clone the function to use to clone a list item
74 * \returns a newly cloned list
75 */
76AnxList * anx_list_clone_with (AnxList * list, AnxCloneFunc clone);
77
78/**
79 * Return the tail element of a list
80 * \param list the list
81 * \returns the tail element
82 */
83AnxList * anx_list_tail (AnxList * list);
84
85/**
86 * Prepend a new node to a list containing given data
87 * \param list the list
88 * \param data the data element of the newly created node
89 * \returns the new list head
90 */
91AnxList * anx_list_prepend (AnxList * list, void * data);
92
93/**
94 * Append a new node to a list containing given data
95 * \param list the list
96 * \param data the data element of the newly created node
97 * \returns the head of the list
98 */
99AnxList * anx_list_append (AnxList * list, void * data);
100
101/**
102 * Add a new node containing given data before a given node
103 * \param list the list
104 * \param data the data element of the newly created node
105 * \param node the node before which to add the newly created node
106 * \returns the head of the list (which may have changed)
107 */
108AnxList * anx_list_add_before (AnxList * list, void * data, AnxList * node);
109
110/**
111 * Add a new node containing given data after a given node
112 * \param list the list
113 * \param data the data element of the newly created node
114 * \param node the node after which to add the newly created node
115 * \returns the head of the list
116 */
117AnxList * anx_list_add_after (AnxList * list, void * data, AnxList * node);
118
119/**
120 * Find the first node containing given data in a list
121 * \param list the list
122 * \param data the data element to find
123 * \returns the first node containing given data, or NULL if it is not found
124 */
125AnxList * anx_list_find (AnxList * list, void * data);
126
127/**
128 * Remove a node from a list
129 * \param list the list
130 * \param node the node to remove
131 * \returns the head of the list (which may have changed)
132 */
133AnxList * anx_list_remove (AnxList * list, AnxList * node);
134
135/**
136 * Query the number of items in a list
137 * \param list the list
138 * \returns the number of nodes in the list
139 */
140int anx_list_length (AnxList * list);
141
142/**
143 * Query if a list is empty, ie. contains no items
144 * \param list the list
145 * \returns 1 if the list is empty, 0 otherwise
146 */
147int anx_list_is_empty (AnxList * list);
148
149/**
150 * Query if the list is singleton, ie. contains exactly one item
151 * \param list the list
152 * \returns 1 if the list is singleton, 0 otherwise
153 */
154int anx_list_is_singleton (AnxList * list);
155
156/**
157 * Free a list, using a given function to free each data element
158 * \param list the list
159 * \param free_func a function to free each data element
160 * \returns NULL on success
161 */
162AnxList * anx_list_free_with (AnxList * list, AnxFreeFunc free_func);
163
164/**
165 * Free a list, using anx_free() to free each data element
166 * \param list the list
167 * \returns NULL on success
168 */
169AnxList * anx_list_free (AnxList * list);
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif /* __ANX_LIST_H__ */
diff --git a/pres/bg.edc b/pres/bg.edc
new file mode 100644
index 0000000..a07fd81
--- /dev/null
+++ b/pres/bg.edc
@@ -0,0 +1,369 @@
1fonts {
2 font: "Vera.ttf" "Edje Vera";
3 font: "VeraBd.ttf" "Edje Vera Bold";
4}
5
6images {
7 image: "brushed.png" COMP;
8 image: "shadow.png" LOSSY 70;
9 image: "reflection_overlay.png" LOSSY 70;
10 image: "next1.png" LOSSY 98;
11 image: "next2.png" LOSSY 98;
12 image: "prev1.png" LOSSY 98;
13 image: "prev2.png" LOSSY 98;
14}
15
16collections {
17 group {
18 name: "presentation/template";
19 parts {
20 part {
21 name: "background_image";
22 mouse_events: 0;
23 description {
24 state: "default" 0.0;
25 image {
26 normal: "brushed.png";
27 }
28 fill {
29 size {
30 relative: 0 0;
31 offset: 400 300;
32 }
33 }
34 }
35 }
36 part {
37 name: "reflection_overlay";
38 mouse_events: 0;
39 description {
40 state: "default" 0.0;
41 image {
42 normal: "reflection_overlay.png";
43 }
44 }
45 }
46 part {
47 name: "old_clip";
48 type: RECT;
49 mouse_events: 0;
50 description {
51 state: "default" 0.0;
52 color: 255 255 255 255;
53 }
54 description {
55 state: "hidden" 0.0;
56 color: 255 255 255 0;
57 }
58 }
59 part {
60 name: "OLD_SLIDE";
61 type: SWALLOW;
62 mouse_events: 0;
63 clip_to: "old_clip";
64 description {
65 state: "default" 0.0;
66 rel1 {
67 relative: 0.1 0.1;
68 }
69 rel2 {
70 relative: 0.9 0.9;
71 }
72 }
73 description {
74 state: "hidden" 0.0;
75 rel1 {
76 relative: -0.9 0.1;
77 }
78 rel2 {
79 relative: -0.1 0.9;
80 }
81 }
82 }
83 part {
84 name: "clip";
85 type: RECT;
86 mouse_events: 0;
87 description {
88 state: "default" 0.0;
89 color: 255 255 255 0;
90 }
91 description {
92 state: "visible" 0.0;
93 color: 255 255 255 255;
94 }
95 }
96 part {
97 name: "SLIDE";
98 type: SWALLOW;
99 mouse_events: 0;
100 clip_to: "clip";
101 description {
102 state: "default" 0.0;
103 rel1 {
104 relative: 0.1 0.1;
105 }
106 rel2 {
107 relative: 0.9 0.9;
108 }
109 }
110 }
111 part {
112 name: "shadow";
113 mouse_events: 0;
114 description {
115 state: "default" 0.0;
116 image {
117 normal: "shadow.png";
118 }
119 }
120 }
121 part {
122 name: "nextbg";
123 type: RECT;
124 description {
125 state: "default" 0.0;
126 visible: 0;
127 aspect: 1.6 1.6;
128 min: 80 50;
129 max: 160 100;
130 align: 1.0 1.0;
131 rel1 {
132 relative: 0.8 0.8;
133 offset: 0 0;
134 }
135 rel2 {
136 relative: 1.0 1.0;
137 offset: -1 -1;
138 }
139 }
140 }
141 part {
142 name: "prevbg";
143 type: RECT;
144 description {
145 state: "default" 0.0;
146 visible: 0;
147 aspect: 1.6 1.6;
148 aspect_preference: VERTICAL;
149 min: 80 50;
150 max: 160 100;
151 align: 1.0 1.0;
152 rel1 {
153 to: "nextbg";
154 relative: 0.0 0.0;
155 offset: -1 0;
156 }
157 rel2 {
158 to: "nextbg";
159 relative: 0.0 1.0;
160 offset: -1 -1;
161 }
162 }
163 }
164 part {
165 name: "nextclip";
166 type: RECT;
167 description {
168 state: "default" 0.0;
169 visible: 1;
170 rel1 {
171 to: "nextbg";
172 }
173 rel2 {
174 to: "nextbg";
175 }
176 color: 255 255 255 255;
177 }
178 description {
179 state: "hidden" 0.0;
180 inherit: "default" 0.0;
181 visible: 0;
182 color: 255 255 255 0;
183 }
184 }
185 part {
186 name: "prevclip";
187 type: RECT;
188 description {
189 state: "default" 0.0;
190 visible: 1;
191 rel1 {
192 to: "prevbg";
193 }
194 rel2 {
195 to: "prevbg";
196 }
197 color: 255 255 255 255;
198 }
199 description {
200 state: "hidden" 0.0;
201 inherit: "default" 0.0;
202 visible: 0;
203 color: 255 255 255 0;
204 }
205 }
206 part {
207 name: "next";
208 clip_to: "nextclip";
209 description {
210 state: "default" 0.0;
211 rel1 {
212 to: "nextbg";
213 }
214 rel2 {
215 to: "nextbg";
216 }
217 image {
218 normal: "next1.png";
219 }
220 }
221 description {
222 state: "down" 0.0;
223 inherit: "default" 0.0;
224 rel1 {
225 offset: 1 1;
226 }
227 rel2 {
228 offset: -2 -2;
229 }
230 image {
231 normal: "next2.png";
232 }
233 }
234 }
235 part {
236 name: "prev";
237 clip_to: "prevbg";
238 clip_to: "prevclip";
239 description {
240 state: "default" 0.0;
241 rel1 {
242 to: "prevbg";
243 }
244 rel2 {
245 to: "prevbg";
246 }
247 image {
248 normal: "prev1.png";
249 }
250 }
251 description {
252 state: "down" 0.0;
253 inherit: "default" 0.0;
254 rel1 {
255 offset: 1 1;
256 }
257 rel2 {
258 offset: -2 -2;
259 }
260 image {
261 normal: "prev2.png";
262 }
263 }
264 }
265 }
266 programs {
267 program {
268 name: "next1";
269 signal: "mouse,down,1";
270 source: "next";
271 action: STATE_SET "down" 0.0;
272 target: "next";
273 }
274 program {
275 name: "next2";
276 signal: "mouse,up,1";
277 source: "next";
278 action: STATE_SET "default" 0.0;
279 target: "next";
280 }
281 program {
282 name: "next3";
283 signal: "mouse,up,1";
284 source: "next";
285 action: SIGNAL_EMIT "CONTROL" "next";
286 }
287 program {
288 name: "prev1";
289 signal: "mouse,down,1";
290 source: "prev";
291 action: STATE_SET "down" 0.0;
292 target: "prev";
293 }
294 program {
295 name: "prev2";
296 signal: "mouse,up,1";
297 source: "prev";
298 action: STATE_SET "default" 0.0;
299 target: "prev";
300 }
301 program {
302 name: "prev3";
303 signal: "mouse,up,1";
304 source: "prev";
305 action: SIGNAL_EMIT "CONTROL" "prev";
306 }
307 program {
308 name: "new_slide0";
309 signal: "EVENT";
310 source: "new_slide";
311 action: STATE_SET "default" 0.0;
312 target: "OLD_SLIDE";
313 target: "old_clip";
314 after: "new_slide1";
315 }
316 program {
317 name: "new_slide1";
318 action: STATE_SET "hidden" 0.0;
319 transition: ACCELERATE 2.0;
320 target: "OLD_SLIDE";
321 target: "old_clip";
322 after: "new_slide2";
323 }
324 program {
325 name: "new_slide2";
326 action: SIGNAL_EMIT "CONTROL" "old_slide_done";
327 }
328 program {
329 name: "new_slide3";
330 signal: "EVENT";
331 source: "new_slide";
332 action: STATE_SET "default" 0.0;
333 target: "clip";
334 after: "new_slide4";
335 }
336 program {
337 name: "new_slide4";
338 action: STATE_SET "visible" 0.0;
339 transition: SINUSOIDAL 1.0;
340 target: "clip";
341 }
342 program {
343 name: "new_slide5";
344 signal: "EVENT";
345 source: "new_slide";
346 action: STATE_SET "default" 0.0;
347 transition: SINUSOIDAL 1.0;
348 target: "nextclip";
349 target: "prevclip";
350 }
351 program {
352 name: "first_slide";
353 signal: "EVENT";
354 source: "first_slide";
355 action: STATE_SET "hidden" 0.0;
356 transition: SINUSOIDAL 1.0;
357 target: "prevclip";
358 }
359 program {
360 name: "last_slide";
361 signal: "EVENT";
362 source: "last_slide";
363 action: STATE_SET "hidden" 0.0;
364 transition: SINUSOIDAL 1.0;
365 target: "nextclip";
366 }
367 }
368 }
369}
diff --git a/pres/data/fonts/.cvsignore b/pres/data/fonts/.cvsignore
new file mode 100644
index 0000000..282522d
--- /dev/null
+++ b/pres/data/fonts/.cvsignore
@@ -0,0 +1,2 @@
1Makefile
2Makefile.in
diff --git a/pres/data/fonts/Vera.COPYING b/pres/data/fonts/Vera.COPYING
new file mode 100644
index 0000000..20385c8
--- /dev/null
+++ b/pres/data/fonts/Vera.COPYING
@@ -0,0 +1,47 @@
1Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.
2Bitstream Vera is a trademark of Bitstream, Inc.
3
4Permission is hereby granted, free of charge, to any person
5obtaining a copy of the fonts accompanying this license (“Fonts”)
6and associated documentation files (the “Font Software”), to
7reproduce and distribute the Font Software, including without
8limitation the rights to use, copy, merge, publish, distribute,
9and/or sell copies of the Font Software, and to permit persons to
10whom the Font Software is furnished to do so, subject to the
11following conditions:
12
13The above copyright and trademark notices and this permission
14notice shall be included in all copies of one or more of the Font
15Software typefaces.
16
17The Font Software may be modified, altered, or added to, and in
18particular the designs of glyphs or characters in the Fonts may
19be modified and additional glyphs or characters may be added to
20the Fonts, only if the fonts are renamed to names not containing
21either the words “Bitstream” or the word “Vera”.
22
23This License becomes null and void to the extent applicable to
24Fonts or Font Software that has been modified and is distributed
25under the “Bitstream Vera” names.
26
27The Font Software may be sold as part of a larger software
28package but no copy of one or more of the Font Software typefaces
29may be sold by itself.
30
31THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
32KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
33WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
34AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER
35RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE
36LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY
37GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
38WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR
40FROM OTHER DEALINGS IN THE FONT SOFTWARE.
41
42Except as contained in this notice, the names of Gnome, the Gnome
43Foundation, and Bitstream Inc., shall not be used in advertising
44or otherwise to promote the sale, use or other dealings in this
45Font Software without prior written authorization from the Gnome
46Foundation or Bitstream Inc., respectively. For further
47information, contact: fonts at gnome dot org.
diff --git a/pres/data/fonts/Vera.ttf b/pres/data/fonts/Vera.ttf
new file mode 100644
index 0000000..58cd6b5
--- /dev/null
+++ b/pres/data/fonts/Vera.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraBI.ttf b/pres/data/fonts/VeraBI.ttf
new file mode 100644
index 0000000..b55eee3
--- /dev/null
+++ b/pres/data/fonts/VeraBI.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraBd.ttf b/pres/data/fonts/VeraBd.ttf
new file mode 100644
index 0000000..51d6111
--- /dev/null
+++ b/pres/data/fonts/VeraBd.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraIt.ttf b/pres/data/fonts/VeraIt.ttf
new file mode 100644
index 0000000..cc23c9e
--- /dev/null
+++ b/pres/data/fonts/VeraIt.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraMoBI.ttf b/pres/data/fonts/VeraMoBI.ttf
new file mode 100644
index 0000000..8624542
--- /dev/null
+++ b/pres/data/fonts/VeraMoBI.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraMoBd.ttf b/pres/data/fonts/VeraMoBd.ttf
new file mode 100644
index 0000000..9be6547
--- /dev/null
+++ b/pres/data/fonts/VeraMoBd.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraMoIt.ttf b/pres/data/fonts/VeraMoIt.ttf
new file mode 100644
index 0000000..2404924
--- /dev/null
+++ b/pres/data/fonts/VeraMoIt.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraMono.ttf b/pres/data/fonts/VeraMono.ttf
new file mode 100644
index 0000000..139f0b4
--- /dev/null
+++ b/pres/data/fonts/VeraMono.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraSe.ttf b/pres/data/fonts/VeraSe.ttf
new file mode 100644
index 0000000..4b4ecc6
--- /dev/null
+++ b/pres/data/fonts/VeraSe.ttf
Binary files differ
diff --git a/pres/data/fonts/VeraSeBd.ttf b/pres/data/fonts/VeraSeBd.ttf
new file mode 100644
index 0000000..672bf76
--- /dev/null
+++ b/pres/data/fonts/VeraSeBd.ttf
Binary files differ
diff --git a/pres/data/fonts/fonts.alias b/pres/data/fonts/fonts.alias
new file mode 100644
index 0000000..50cde29
--- /dev/null
+++ b/pres/data/fonts/fonts.alias
@@ -0,0 +1,11 @@
1Vera-Bold-Italic -Bitstream-Bitstream Vera Sans-bold-i-normal--0-0-0-0-p-0-ascii-0
2Vera-Normal -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-ascii-0
3Vera-Bold -Bitstream-Bitstream Vera Sans-bold-r-normal--0-0-0-0-p-0-ascii-0
4Vera-Italic -Bitstream-Bitstream Vera Sans-medium-i-normal--0-0-0-0-p-0-ascii-0
5Vera-Mono-Bold-Italic -Bitstream-Bitstream Vera Sans Mono-bold-i-normal--0-0-0-0-m-0-ascii-0
6Vera-Mono-Bold -Bitstream-Bitstream Vera Sans Mono-bold-r-normal--0-0-0-0-m-0-ascii-0
7Vera-Mono-Italic -Bitstream-Bitstream Vera Sans Mono-medium-i-normal--0-0-0-0-m-0-ascii-0
8Vera-Mono -Bitstream-Bitstream Vera Sans Mono-medium-r-normal--0-0-0-0-m-0-ascii-0
9Vera-Serif -Bitstream-Bitstream Vera Serif-medium-r-normal--0-0-0-0-p-0-ascii-0
10Vera-Serif-Bold -Bitstream-Bitstream Vera Serif-bold-r-normal--0-0-0-0-p-0-ascii-0
11Vera -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-ascii-0
diff --git a/pres/data/fonts/fonts.dir b/pres/data/fonts/fonts.dir
new file mode 100644
index 0000000..2dab016
--- /dev/null
+++ b/pres/data/fonts/fonts.dir
@@ -0,0 +1,51 @@
150
2VeraBI.ttf -Bitstream-Bitstream Vera Sans-bold-i-normal--0-0-0-0-p-0-ascii-0
3VeraBI.ttf -Bitstream-Bitstream Vera Sans-bold-i-normal--0-0-0-0-p-0-fcd8859-15
4VeraBI.ttf -Bitstream-Bitstream Vera Sans-bold-i-normal--0-0-0-0-p-0-iso8859-1
5VeraBI.ttf -Bitstream-Bitstream Vera Sans-bold-i-normal--0-0-0-0-p-0-iso8859-15
6VeraBI.ttf -Bitstream-Bitstream Vera Sans-bold-i-normal--0-0-0-0-p-0-iso8859-9
7Vera.ttf -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-ascii-0
8Vera.ttf -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-fcd8859-15
9Vera.ttf -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-iso8859-1
10Vera.ttf -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-iso8859-15
11Vera.ttf -Bitstream-Bitstream Vera Sans-medium-r-normal--0-0-0-0-p-0-iso8859-9
12VeraBd.ttf -Bitstream-Bitstream Vera Sans-bold-r-normal--0-0-0-0-p-0-ascii-0
13VeraBd.ttf -Bitstream-Bitstream Vera Sans-bold-r-normal--0-0-0-0-p-0-fcd8859-15
14VeraBd.ttf -Bitstream-Bitstream Vera Sans-bold-r-normal--0-0-0-0-p-0-iso8859-1
15VeraBd.ttf -Bitstream-Bitstream Vera Sans-bold-r-normal--0-0-0-0-p-0-iso8859-15
16VeraBd.ttf -Bitstream-Bitstream Vera Sans-bold-r-normal--0-0-0-0-p-0-iso8859-9
17VeraIt.ttf -Bitstream-Bitstream Vera Sans-medium-i-normal--0-0-0-0-p-0-ascii-0
18VeraIt.ttf -Bitstream-Bitstream Vera Sans-medium-i-normal--0-0-0-0-p-0-fcd8859-15
19VeraIt.ttf -Bitstream-Bitstream Vera Sans-medium-i-normal--0-0-0-0-p-0-iso8859-1
20VeraIt.ttf -Bitstream-Bitstream Vera Sans-medium-i-normal--0-0-0-0-p-0-iso8859-15
21VeraIt.ttf -Bitstream-Bitstream Vera Sans-medium-i-normal--0-0-0-0-p-0-iso8859-9
22VeraMoBI.ttf -Bitstream-Bitstream Vera Sans Mono-bold-i-normal--0-0-0-0-m-0-ascii-0
23VeraMoBI.ttf -Bitstream-Bitstream Vera Sans Mono-bold-i-normal--0-0-0-0-m-0-fcd8859-15
24VeraMoBI.ttf -Bitstream-Bitstream Vera Sans Mono-bold-i-normal--0-0-0-0-m-0-iso8859-1
25VeraMoBI.ttf -Bitstream-Bitstream Vera Sans Mono-bold-i-normal--0-0-0-0-m-0-iso8859-15
26VeraMoBI.ttf -Bitstream-Bitstream Vera Sans Mono-bold-i-normal--0-0-0-0-m-0-iso8859-9
27VeraMoBd.ttf -Bitstream-Bitstream Vera Sans Mono-bold-r-normal--0-0-0-0-m-0-ascii-0
28VeraMoBd.ttf -Bitstream-Bitstream Vera Sans Mono-bold-r-normal--0-0-0-0-m-0-fcd8859-15
29VeraMoBd.ttf -Bitstream-Bitstream Vera Sans Mono-bold-r-normal--0-0-0-0-m-0-iso8859-1
30VeraMoBd.ttf -Bitstream-Bitstream Vera Sans Mono-bold-r-normal--0-0-0-0-m-0-iso8859-15
31VeraMoBd.ttf -Bitstream-Bitstream Vera Sans Mono-bold-r-normal--0-0-0-0-m-0-iso8859-9
32VeraMoIt.ttf -Bitstream-Bitstream Vera Sans Mono-medium-i-normal--0-0-0-0-m-0-ascii-0
33VeraMoIt.ttf -Bitstream-Bitstream Vera Sans Mono-medium-i-normal--0-0-0-0-m-0-fcd8859-15
34VeraMoIt.ttf -Bitstream-Bitstream Vera Sans Mono-medium-i-normal--0-0-0-0-m-0-iso8859-1
35VeraMoIt.ttf -Bitstream-Bitstream Vera Sans Mono-medium-i-normal--0-0-0-0-m-0-iso8859-15
36VeraMoIt.ttf -Bitstream-Bitstream Vera Sans Mono-medium-i-normal--0-0-0-0-m-0-iso8859-9
37VeraMono.ttf -Bitstream-Bitstream Vera Sans Mono-medium-r-normal--0-0-0-0-m-0-ascii-0
38VeraMono.ttf -Bitstream-Bitstream Vera Sans Mono-medium-r-normal--0-0-0-0-m-0-fcd8859-15
39VeraMono.ttf -Bitstream-Bitstream Vera Sans Mono-medium-r-normal--0-0-0-0-m-0-iso8859-1
40VeraMono.ttf -Bitstream-Bitstream Vera Sans Mono-medium-r-normal--0-0-0-0-m-0-iso8859-15
41VeraMono.ttf -Bitstream-Bitstream Vera Sans Mono-medium-r-normal--0-0-0-0-m-0-iso8859-9
42VeraSe.ttf -Bitstream-Bitstream Vera Serif-medium-r-normal--0-0-0-0-p-0-ascii-0
43VeraSe.ttf -Bitstream-Bitstream Vera Serif-medium-r-normal--0-0-0-0-p-0-fcd8859-15
44VeraSe.ttf -Bitstream-Bitstream Vera Serif-medium-r-normal--0-0-0-0-p-0-iso8859-1
45VeraSe.ttf -Bitstream-Bitstream Vera Serif-medium-r-normal--0-0-0-0-p-0-iso8859-15
46VeraSe.ttf -Bitstream-Bitstream Vera Serif-medium-r-normal--0-0-0-0-p-0-iso8859-9
47VeraSeBd.ttf -Bitstream-Bitstream Vera Serif-bold-r-normal--0-0-0-0-p-0-ascii-0
48VeraSeBd.ttf -Bitstream-Bitstream Vera Serif-bold-r-normal--0-0-0-0-p-0-fcd8859-15
49VeraSeBd.ttf -Bitstream-Bitstream Vera Serif-bold-r-normal--0-0-0-0-p-0-iso8859-1
50VeraSeBd.ttf -Bitstream-Bitstream Vera Serif-bold-r-normal--0-0-0-0-p-0-iso8859-15
51VeraSeBd.ttf -Bitstream-Bitstream Vera Serif-bold-r-normal--0-0-0-0-p-0-iso8859-9
diff --git a/pres/data/images/brushed.png b/pres/data/images/brushed.png
new file mode 100644
index 0000000..dafe13c
--- /dev/null
+++ b/pres/data/images/brushed.png
Binary files differ
diff --git a/pres/data/images/next1.png b/pres/data/images/next1.png
new file mode 100644
index 0000000..25b2662
--- /dev/null
+++ b/pres/data/images/next1.png
Binary files differ
diff --git a/pres/data/images/next2.png b/pres/data/images/next2.png
new file mode 100644
index 0000000..de99f8b
--- /dev/null
+++ b/pres/data/images/next2.png
Binary files differ
diff --git a/pres/data/images/prev.xcf.gz b/pres/data/images/prev.xcf.gz
new file mode 100644
index 0000000..b8dbfc2
--- /dev/null
+++ b/pres/data/images/prev.xcf.gz
Binary files differ
diff --git a/pres/data/images/prev1.png b/pres/data/images/prev1.png
new file mode 100644
index 0000000..b1c95f7
--- /dev/null
+++ b/pres/data/images/prev1.png
Binary files differ
diff --git a/pres/data/images/prev2.png b/pres/data/images/prev2.png
new file mode 100644
index 0000000..e171bea
--- /dev/null
+++ b/pres/data/images/prev2.png
Binary files differ
diff --git a/pres/data/images/reflection_overlay.png b/pres/data/images/reflection_overlay.png
new file mode 100644
index 0000000..98d3d38
--- /dev/null
+++ b/pres/data/images/reflection_overlay.png
Binary files differ
diff --git a/pres/data/images/shadow.png b/pres/data/images/shadow.png
new file mode 100644
index 0000000..e862459
--- /dev/null
+++ b/pres/data/images/shadow.png
Binary files differ
diff --git a/pres/main.c b/pres/main.c
new file mode 100644
index 0000000..ec63b49
--- /dev/null
+++ b/pres/main.c
@@ -0,0 +1,155 @@
1#include "main.h"
2
3#define SOFT_X 0
4#define GL_X 1
5
6Ecore_Evas *ee = NULL;
7Evas *evas = NULL;
8int win_w = 640;
9int win_h = 480;
10
11static int im_cache = 4096 * 1024;
12static int fn_cache = 512 * 1024;
13static int engine = SOFT_X;
14static double fps = 60.0;
15static const char *pres_file = "./test/pres.xml";
16
17
18static void
19cb_delete_request(Ecore_Evas *ee)
20{
21 ecore_main_loop_quit();
22}
23
24static void
25cb_resize(Ecore_Evas *ee)
26{
27 Evas_Coord w, h;
28
29 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
30 win_w = w;
31 win_h = h;
32 pres_core_resize();
33}
34
35int
36main(int argc, const char **argv)
37{
38 int i;
39
40 for (i = 1; i < argc; i++)
41 {
42 if ((!strcmp(argv[i], "-x11"))) engine = SOFT_X;
43 else if ((!strcmp(argv[i], "-gl"))) engine = GL_X;
44 else if ((!strcmp(argv[i], "-g")) && (i < (argc - 1)))
45 {
46 char b1[32], b2[32];
47
48 i++;
49 b1[0] = 0;
50 b2[0] = 0;
51 sscanf(argv[i], "%30[^x]x%30s", b1, b2);
52 win_w = atoi(b1);
53 win_h = atoi(b2);
54 if (((win_w < 1) || (win_w > 8000)) ||
55 ((win_h < 1) || (win_h > 8000)))
56 {
57 printf("Error parsing options to -g option.\n"
58 "Please see -h help output for syntax.\n");
59 return 0;
60 }
61 }
62 else if ((!strcmp(argv[i], "-ic")) && (i < (argc - 1)))
63 {
64 i++;
65 im_cache = atoi(argv[i]);
66 if ((im_cache < 0) || (im_cache > 65536 * 1024))
67 {
68 printf("Invalid image cache value. use between 0 and 65536\n");
69 return 0;
70 }
71 }
72 else if ((!strcmp(argv[i], "-fc")) && (i < (argc - 1)))
73 {
74 i++;
75 fn_cache = atoi(argv[i]);
76 if ((fn_cache < 0) || (fn_cache > 65536 * 1024))
77 {
78 printf("Invalid font cache value. use between 0 and 65536\n");
79 return 0;
80 }
81 }
82 else if ((!strcmp(argv[i], "-fr")) && (i < (argc - 1)))
83 {
84 i++;
85 fps = atof(argv[i]);
86 if (fps <= 0.0)
87 {
88 printf("Invalid fps value. must be greater than 0.0\n");
89 return 0;
90 }
91 }
92 else if ((!strcmp(argv[i], "-h")))
93 {
94 printf("%s [OPTIONS] presentation_file\n"
95 "\tWhere OPTIONS is 0 or more of the following:\n"
96 "\n"
97 "-x11 Display using software X11 (default)\n"
98 "-gl Display using OpenGL in X11\n"
99 "-g WxH Set display size to W x H pixels (default: %ix%i)\n"
100 "-ic Kb Set image cache in Kb (default %iKb)\n"
101 "-fc Kb Set font cache in Kb (default %iKb)\n"
102 "-fr fps Set attempted framerate in frames per second (default %3.1ffps)\n"
103 "-h Display this help\n",
104 argv[0],
105 win_w, win_h, im_cache / 1024, fn_cache / 1024, fps);
106 return 0;
107 }
108 else
109 pres_file = argv[i];
110 }
111 ecore_init();
112 ecore_app_args_set(argc, argv);
113 ecore_evas_init();
114
115 if (engine == SOFT_X)
116 ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, win_w, win_h);
117 else if (engine == GL_X)
118 ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, win_w, win_h);
119 if (!ee)
120 {
121 printf("ERROR: cannot create canvas.\n");
122 return -1;
123 }
124
125 ecore_evas_callback_delete_request_set(ee, cb_delete_request);
126 ecore_evas_callback_resize_set(ee, cb_resize);
127 ecore_evas_title_set(ee, "Desktopcon 2005 - Ottawa");
128 ecore_evas_name_class_set(ee, "ddc", "Ddc");
129 ecore_evas_avoid_damage_set(ee, 1);
130 ecore_evas_show(ee);
131
132 evas = ecore_evas_get(ee);
133 evas_image_cache_set(evas, im_cache);
134 evas_font_cache_set(evas, fn_cache);
135 evas_font_path_append(evas, "./data/fonts");
136
137 edje_init();
138 edje_frametime_set(1.0 / fps);
139
140 pres_core_init();
141 if (!pres_core_slide_load(pres_file))
142 {
143 printf("ERROR: cannot load presentation \"%s\"\n", pres_file);
144 return -1;
145 }
146 pres_core_slide_set(0);
147
148 ecore_main_loop_begin();
149
150 ecore_evas_free(ee);
151 edje_shutdown();
152 ecore_evas_shutdown();
153 ecore_shutdown();
154 return 0;
155}
diff --git a/pres/main.h b/pres/main.h
new file mode 100644
index 0000000..4baf57b
--- /dev/null
+++ b/pres/main.h
@@ -0,0 +1,35 @@
1#ifndef MAIN_H
2#define MAIN_H
3
4#include <Ecore.h>
5#include <Evas.h>
6#include <Ecore_Evas.h>
7#include <Edje.h>
8#include <Emotion.h>
9
10#include <stdio.h>
11#include <unistd.h>
12#include <stdlib.h>
13#include <math.h>
14#include <sys/types.h>
15#include <sys/stat.h>
16#include <sys/types.h>
17
18#include "xtag.h"
19#include "slide.h"
20
21extern Ecore_Evas *ee;
22extern Evas *evas;
23extern int win_w;
24extern int win_h;
25
26void pres_core_init(void);
27void pres_core_resize(void);
28void pres_core_next(void);
29void pres_core_prev(void);
30int pres_core_slide_get(void);
31int pres_core_slide_count_get(void);
32void pres_core_slide_set(int slide);
33int pres_core_slide_load(const char *file);
34
35#endif
diff --git a/pres/pres_core.c b/pres/pres_core.c
new file mode 100644
index 0000000..341e70e
--- /dev/null
+++ b/pres/pres_core.c
@@ -0,0 +1,332 @@
1#include "main.h"
2
3typedef struct _Slide Slide;
4
5struct _Slide
6{
7 XTag *tag;
8};
9
10static Evas_Object *o_bg = NULL;
11static Evas_Object *o_old_slide = NULL;
12static Evas_Object *o_slide = NULL;
13static int slide_num = 0;
14static int slide_count = 0;
15static Evas_List *slides = NULL;
16static char *slides_dir = "./";
17
18static void
19cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
20{
21 Evas_Event_Key_Down *ev;
22
23 ev = event_info;
24 if ((!strcmp(ev->keyname, "Escape")) ||
25 (!strcmp(ev->keyname, "q")))
26 ecore_main_loop_quit();
27 else if ((!strcmp(ev->keyname, "Return")) ||
28 (!strcmp(ev->keyname, "space")) ||
29 (!strcmp(ev->keyname, "Right")) ||
30 (!strcmp(ev->keyname, "Down")))
31 pres_core_next();
32 else if ((!strcmp(ev->keyname, "BackSpace")) ||
33 (!strcmp(ev->keyname, "Delete")) ||
34 (!strcmp(ev->keyname, "Left")) ||
35 (!strcmp(ev->keyname, "Up")))
36 pres_core_prev();
37 else if ((!strcmp(ev->keyname, "f")))
38 ecore_evas_fullscreen_set(ee, !ecore_evas_fullscreen_get(ee));
39}
40
41static void
42cb_singal(void *data, Evas_Object *o, const char *emission, const char *source)
43{
44 if (!strcmp(source, "next"))
45 pres_core_next();
46 else if (!strcmp(source, "prev"))
47 pres_core_prev();
48 else if (!strcmp(source, "old_slide_done"))
49 {
50 if (o_old_slide)
51 {
52 evas_object_del(o_old_slide);
53 o_old_slide = NULL;
54 }
55 }
56}
57
58static char *
59strip_whitespace(char *str)
60{
61 char *news = NULL, *p, *pp;
62 int len = 0;
63 int pblank = 0;
64
65 p = str;
66 while (*p)
67 {
68 if (isspace(*p) || iscntrl(*p) || !(isprint(*p)))
69 {
70 if (!pblank)
71 {
72 len++;
73 pblank = 1;
74 }
75 }
76 else
77 {
78 len++;
79 pblank = 0;
80 }
81 p++;
82 }
83 news = malloc(len + 1);
84 p = str;
85 pp = news;
86 while (*p)
87 {
88 if (isspace(*p) || iscntrl(*p) || !(isprint(*p)))
89 {
90 if (!pblank)
91 {
92 *pp = ' ';
93 pp++;
94 pblank = 1;
95 }
96 }
97 else
98 {
99 *pp = *p;
100 pp++;
101 pblank = 0;
102 }
103 p++;
104 }
105 *pp = 0;
106 return news;
107}
108
109static Evas_Object *
110slide_new(int slide)
111{
112 Slide *s;
113 Evas_Object *o;
114 XTag *tag, *ctag;
115
116 s = evas_list_nth(slides, slide);
117 if (!s) return NULL;
118
119 o = slide_add(evas);
120
121 tag = s->tag;
122 ctag = xtag_first_child(tag, NULL);
123 while (ctag)
124 {
125 char *name, *pcd, *str;
126
127 name = xtag_get_name(ctag);
128 pcd = xtag_get_pcdata(ctag);
129 if ((name) && (pcd))
130 {
131 if (!strcmp(name, "title"))
132 {
133 str = strip_whitespace(pcd);
134 slide_title_add(o, str);
135 free(str);
136 }
137 else if (!strcmp(name, "text"))
138 {
139 str = strip_whitespace(pcd);
140 slide_text_add(o, str);
141 free(str);
142 }
143 else if (!strcmp(name, "list"))
144 {
145 XTag *itag;
146
147 itag = xtag_first_child(ctag, NULL);
148 while (itag)
149 {
150 name = xtag_get_name(itag);
151 pcd = xtag_get_pcdata(itag);
152 if ((name) && (pcd))
153 {
154 str = strip_whitespace(pcd);
155 slide_item_add(o, str);
156 free(str);
157 }
158 itag = xtag_next_child(ctag, NULL);
159 }
160 }
161 else if (!strcmp(name, "image"))
162 {
163 char *ex;
164 char buf[4096];
165
166 ex = strrchr(pcd, '.');
167 snprintf(buf, sizeof(buf), "%s/%s", slides_dir, pcd);
168 if ((ex) && (!strcmp(ex, ".edj")))
169 slide_edje_add(o, buf,
170 xtag_get_attribute(ctag, "size"),
171 xtag_get_attribute(ctag, "dimensions"));
172 else
173 slide_image_add(o, buf,
174 xtag_get_attribute(ctag, "size"));
175 }
176 else if (!strcmp(name, "video"))
177 {
178 char buf[4096];
179
180 snprintf(buf, sizeof(buf), "%s/%s", slides_dir, pcd);
181 slide_video_add(o, buf,
182 xtag_get_attribute(ctag, "size"),
183 xtag_get_attribute(ctag, "pos"),
184 xtag_get_attribute(ctag, "alpha")
185 );
186 }
187 }
188 ctag = xtag_next_child(tag, NULL);
189 }
190 return o;
191}
192
193void
194pres_core_init(void)
195{
196 o_bg = edje_object_add(evas);
197 edje_object_signal_callback_add(o_bg, "CONTROL", "*", cb_singal, NULL);
198 edje_object_file_set(o_bg, "bg.edj", "presentation/template");
199 evas_object_show(o_bg);
200 evas_object_event_callback_add(o_bg, EVAS_CALLBACK_KEY_DOWN, cb_key_down, NULL);
201 evas_object_focus_set(o_bg, 1);
202
203 pres_core_resize();
204}
205
206void
207pres_core_resize(void)
208{
209 evas_object_move(o_bg, 0, 0);
210 evas_object_resize(o_bg, win_w, win_h);
211}
212
213void
214pres_core_next(void)
215{
216 pres_core_slide_set(pres_core_slide_get() + 1);
217}
218
219void
220pres_core_prev(void)
221{
222 pres_core_slide_set(pres_core_slide_get() - 1);
223}
224
225int
226pres_core_slide_get(void)
227{
228 return slide_num;
229}
230
231int
232pres_core_slide_count_get(void)
233{
234 return slide_count;
235}
236
237void
238pres_core_slide_set(int slide)
239{
240 if (slide < 0)
241 return;
242 else if (slide >= slide_count)
243 return;
244
245 slide_num = slide;
246
247 if (o_old_slide)
248 evas_object_del(o_old_slide);
249 o_old_slide = o_slide;
250 {
251 if (o_old_slide)
252 {
253 edje_object_part_unswallow(o_bg, o_old_slide);
254 edje_object_part_swallow(o_bg, "OLD_SLIDE", o_old_slide);
255 evas_object_show(o_old_slide);
256 }
257 }
258 o_slide = slide_new(slide_num);
259 if (o_slide)
260 {
261 evas_object_show(o_slide);
262 edje_object_part_swallow(o_bg, "SLIDE", o_slide);
263 }
264
265 edje_object_signal_emit(o_bg, "EVENT", "new_slide");
266 if (slide_num == 0)
267 edje_object_signal_emit(o_bg, "EVENT", "first_slide");
268 if (slide_num == (slide_count - 1))
269 edje_object_signal_emit(o_bg, "EVENT", "last_slide");
270}
271
272int
273pres_core_slide_load(const char *file)
274{
275 FILE *f;
276 int len;
277 char *data = NULL;
278 Slide *s = NULL;
279 char *str, *p;
280 XTag *tag, *tag2, *tag3;
281
282 f = fopen(file, "r");
283 if (!f) return 0;
284 fseek(f, 0, SEEK_END);
285 len = ftell(f);
286 data = malloc(len + 1);
287 if (!data)
288 {
289 printf("ERROR: Cannot allocate ram for file data\n");
290 exit(-1);
291 }
292 rewind(f);
293 if (fread(data, 1, len, f) != len)
294 {
295 printf("ERROR: Cannot read all data form file\n");
296 exit(-1);
297 }
298 data[len] = 0;
299 tag = xtag_new_parse(data, len);
300 if (!strcmp(xtag_get_name(tag), "presentation"))
301 {
302 tag2 = xtag_next_child(tag, NULL);
303 while (tag2)
304 {
305 str = xtag_get_name(tag2);
306 if ((str) && (!strcmp(str, "slide")))
307 {
308 tag3 = xtag_next_child(tag2, NULL);
309 if (tag3)
310 {
311 s = calloc(1, sizeof(Slide));
312 if (!s)
313 {
314 printf("ERROR: cannot alloc ram for slide struct\n");
315 exit(-1);
316 }
317 s->tag = tag2;
318 slides = evas_list_append(slides, s);
319 }
320 }
321 tag2 = xtag_next_child(tag, NULL);
322 }
323 }
324 /* FIXME: rememebr tag so we can free it */
325 free(data);
326 fclose(f);
327 slide_count = evas_list_count(slides);
328 slides_dir = strdup(file);
329 p = strrchr(slides_dir, '/');
330 if (p) *p = 0;
331 return 1;
332}
diff --git a/pres/slide.c b/pres/slide.c
new file mode 100644
index 0000000..1c88d04
--- /dev/null
+++ b/pres/slide.c
@@ -0,0 +1,571 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include "main.h"
5
6#define SMART_NAME "slide"
7#define API_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd)
8#define INTERNAL_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
9#define WALK_ITEMS_BEGIN \
10{ Evas_List *l; Smart_Item *si; \
11for (l = sd->items; l; l = l->next) { \
12 si = l->data;
13#define WALK_ITEMS_END \
14} }
15
16typedef struct _Smart_Data Smart_Data;
17typedef struct _Smart_Item Smart_Item;
18
19struct _Smart_Data
20{
21 Evas *evas;
22 Evas_Object *smart_object;
23 Evas_Object *marker_object;
24 Evas_Coord x, y, w, h;
25 Evas_List *items;
26};
27
28#define TITLE 0
29#define TEXT 1
30#define IMAGE 2
31#define EDJE 3
32#define ITEM 4
33#define VIDEO 5
34
35struct _Smart_Item
36{
37 int type;
38 Evas_Coord x, y, w, h;
39 double align_x, align_y;
40 double size_w, size_h;
41 int dim_w, dim_h;
42 int pos_x, pos_y;
43 int alpha;
44 Evas_Object *obj;
45 char *text;
46};
47
48/* local subsystem functions */
49static Smart_Item *_smart_item_text_next(Smart_Data *sd);
50static Smart_Item *_smart_item_image_next(Smart_Data *sd);
51static Smart_Item *_smart_item_edje_next(Smart_Data *sd);
52static Smart_Item *_smart_item_video_next(Smart_Data *sd);
53static void _smart_reconfigure(Smart_Data *sd);
54static void _smart_add(Evas_Object *obj);
55static void _smart_del(Evas_Object *obj);
56static void _smart_layer_set(Evas_Object *obj, int layer);
57static void _smart_raise(Evas_Object *obj);
58static void _smart_lower(Evas_Object *obj);
59static void _smart_stack_above(Evas_Object *obj, Evas_Object *above);
60static void _smart_stack_below(Evas_Object *obj, Evas_Object *below);
61static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
62static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
63static void _smart_show(Evas_Object *obj);
64static void _smart_hide(Evas_Object *obj);
65static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
66static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip);
67static void _smart_clip_unset(Evas_Object *obj);
68static void _smart_init(void);
69
70/* local subsystem globals */
71static Evas_Smart *_smart = NULL;
72
73/* externally accessible functions */
74Evas_Object *
75slide_add(Evas *evas)
76{
77 _smart_init();
78 return evas_object_smart_add(evas, _smart);
79}
80
81void
82slide_title_add(Evas_Object *obj, const char *str)
83{
84 Smart_Item *si;
85
86 API_ENTRY return;
87 si = _smart_item_text_next(sd);
88 si->type = TITLE;
89 si->text = strdup(str);
90 _smart_reconfigure(sd);
91}
92
93void
94slide_text_add(Evas_Object *obj, const char *str)
95{
96 Smart_Item *si;
97
98 API_ENTRY return;
99 si = _smart_item_text_next(sd);
100 si->type = TEXT;
101 si->text = strdup(str);
102 _smart_reconfigure(sd);
103}
104
105void
106slide_image_add(Evas_Object *obj, const char *str, const char *size)
107{
108 Smart_Item *si;
109
110 API_ENTRY return;
111 si = _smart_item_image_next(sd);
112 si->type = IMAGE;
113 si->size_w = -1;
114 if (size) si->size_h = (double)atoi(size) / 100.0;
115 else si->size_h = 0.25;
116 si->text = strdup(str);
117 _smart_reconfigure(sd);
118}
119
120void
121slide_edje_add(Evas_Object *obj, const char *str, const char *size, const char *dimensions)
122{
123 Smart_Item *si;
124
125 API_ENTRY return;
126 si = _smart_item_edje_next(sd);
127 si->type = EDJE;
128 si->size_w = -1;
129 if (size) si->size_h = (double)atoi(size) / 100.0;
130 else si->size_h = 0.25;
131 if (dimensions)
132 sscanf(dimensions, "%ix%i", &si->dim_w, &si->dim_h);
133 si->text = strdup(str);
134 _smart_reconfigure(sd);
135}
136
137void
138slide_item_add(Evas_Object *obj, const char *str)
139{
140 Smart_Item *si;
141
142 API_ENTRY return;
143 si = _smart_item_text_next(sd);
144 si->type = ITEM;
145 si->text = strdup(str);
146 _smart_reconfigure(sd);
147}
148
149void
150slide_video_add(Evas_Object *obj, const char *str, const char *size, const char *pos, const char *alpha)
151{
152 Smart_Item *si;
153
154 API_ENTRY return;
155 si = _smart_item_video_next(sd);
156 si->type = VIDEO;
157 si->text = strdup(str);
158 si->size_w = -1;
159 if (size) si->size_h = (double)atoi(size) / 100.0;
160 else si->size_h = 0.25;
161 if (pos) sscanf(pos, "%i+%i", &si->pos_x, &si->pos_y);
162 if (alpha) si->alpha = atoi(alpha);
163 si->text = strdup(str);
164 _smart_reconfigure(sd);
165}
166
167/* local subsystem functions */
168static Smart_Item *
169_smart_item_text_next(Smart_Data *sd)
170{
171 Smart_Item *si;
172
173 si = calloc(1, sizeof(Smart_Item));
174 si->obj = evas_object_textblock_add(sd->evas);
175 evas_object_smart_member_add(si->obj, sd->smart_object);
176 sd->items = evas_list_append(sd->items, si);
177 return si;
178}
179
180static Smart_Item *
181_smart_item_image_next(Smart_Data *sd)
182{
183 Smart_Item *si;
184
185 si = calloc(1, sizeof(Smart_Item));
186 si->obj = evas_object_image_add(sd->evas);
187 si->align_x = 0.5;
188 si->align_y = 0.0;
189 si->size_w = -1.0;
190 si->size_h = 0.25;
191 evas_object_smart_member_add(si->obj, sd->smart_object);
192 sd->items = evas_list_append(sd->items, si);
193 return si;
194}
195
196static Smart_Item *
197_smart_item_edje_next(Smart_Data *sd)
198{
199 Smart_Item *si;
200
201 si = calloc(1, sizeof(Smart_Item));
202 si->obj = edje_object_add(sd->evas);
203 si->align_x = 0.5;
204 si->align_y = 0.0;
205 si->size_w = -1.0;
206 si->size_h = 0.25;
207 si->dim_w = 320;
208 si->dim_h = 240;
209 evas_object_smart_member_add(si->obj, sd->smart_object);
210 sd->items = evas_list_append(sd->items, si);
211 return si;
212}
213
214static Smart_Item *
215_smart_item_video_next(Smart_Data *sd)
216{
217 Smart_Item *si;
218
219 si = calloc(1, sizeof(Smart_Item));
220 si->obj = emotion_object_add(sd->evas);
221 si->align_x = 0.5;
222 si->align_y = 0.0;
223 si->size_w = -1.0;
224 si->size_h = 0.25;
225 si->pos_x = -1;
226 si->pos_y = -1;
227 si->alpha = 100;
228 evas_object_smart_member_add(si->obj, sd->smart_object);
229 sd->items = evas_list_append(sd->items, si);
230 return si;
231}
232
233static void
234_smart_reconfigure(Smart_Data *sd)
235{
236 Evas_Coord x, y, w, h;
237 char buf[512];
238 int padjust = 0;
239 int special_pos = 0;
240 int sx, sy;
241
242 x = 0;
243 y = 0;
244 WALK_ITEMS_BEGIN;
245 special_pos = 0;
246 y += padjust;
247 if (si->type == TITLE)
248 {
249 snprintf(buf, sizeof(buf),
250 "font=%s size=%i wrap=word align=center color=#ffffffff "
251 "outer_glow_color=#00000010 glow_color=#00000020 style=glow"
252 ,
253 "Vera-Bold",
254 (int)sd->h / 16);
255 evas_object_textblock_clear(si->obj);
256 evas_object_textblock_format_insert(si->obj, buf);
257 evas_object_textblock_text_insert(si->obj, si->text);
258 evas_object_resize(si->obj, sd->w, 1);
259 evas_object_textblock_format_size_get(si->obj, &w, &h);
260 w = sd->w;
261 padjust = 0;
262 }
263 else if (si->type == TEXT)
264 {
265 snprintf(buf, sizeof(buf),
266 "font=%s size=%i wrap=word align=left color=#ffffffff "
267 "outer_glow_color=#00000010 glow_color=#00000020 style=glow"
268 ,
269 "Vera",
270 (int)sd->h / 24);
271 evas_object_textblock_clear(si->obj);
272 evas_object_textblock_format_insert(si->obj, buf);
273 evas_object_textblock_text_insert(si->obj, si->text);
274 evas_object_resize(si->obj, sd->w, 1);
275 evas_object_textblock_format_size_get(si->obj, &w, &h);
276 w = sd->w;
277 padjust = 0;
278 }
279 else if (si->type == IMAGE)
280 {
281 int iw, ih;
282
283 evas_object_image_file_set(si->obj, si->text, NULL);
284 evas_object_image_size_get(si->obj, &iw, &ih);
285 if ((si->size_w < 0) && (si->size_h < 0))
286 {
287 w = iw;
288 h = ih;
289 }
290 else if (si->size_h < 0)
291 {
292 w = sd->w * si->size_w;
293 if (iw > 0) h = (w * ih) / iw;
294 else h = 0;
295 }
296 else if (si->size_w < 0)
297 {
298 h = sd->h * si->size_h;
299 if (ih > 0) w = (h * iw) / ih;
300 else w = 0;
301 }
302 else
303 {
304 w = sd->w * si->size_w;
305 h = sd->h * si->size_h;
306 }
307 evas_object_image_fill_set(si->obj, 0, 0, w, h);
308 padjust = 0;
309 }
310 else if (si->type == EDJE)
311 {
312 int iw, ih;
313
314 edje_object_file_set(si->obj, si->text, "desktop/background");
315 iw = si->dim_w;
316 ih = si->dim_h;
317 if ((si->size_w < 0) && (si->size_h < 0))
318 {
319 w = iw;
320 h = ih;
321 }
322 else if (si->size_h < 0)
323 {
324 w = sd->w * si->size_w;
325 if (iw > 0) h = (w * ih) / iw;
326 else h = 0;
327 }
328 else if (si->size_w < 0)
329 {
330 h = sd->h * si->size_h;
331 if (ih > 0) w = (h * iw) / ih;
332 else w = 0;
333 }
334 else
335 {
336 w = sd->w * si->size_w;
337 h = sd->h * si->size_h;
338 }
339 padjust = 0;
340 }
341 else if (si->type == ITEM)
342 {
343 snprintf(buf, sizeof(buf),
344 "font=%s size=%i wrap=word align=left color=#ffffffff "
345 "outer_glow_color=#00000010 glow_color=#00000020 style=glow left_tab_stop=20%"
346 ,
347 "Vera",
348 (int)sd->h / 24);
349 evas_object_textblock_clear(si->obj);
350 evas_object_textblock_format_insert(si->obj, buf);
351 evas_object_textblock_format_insert(si->obj, "\t");
352 evas_object_textblock_text_insert(si->obj, "* ");
353 evas_object_textblock_text_insert(si->obj, si->text);
354 evas_object_resize(si->obj, sd->w, 1);
355 evas_object_textblock_format_size_get(si->obj, &w, &h);
356 w = sd->w;
357 padjust = -(sd->h / 40);
358 }
359 else if (si->type == VIDEO)
360 {
361 int iw, ih;
362
363 emotion_object_file_set(si->obj, si->text);
364 emotion_object_play_set(si->obj, 1);
365 emotion_object_smooth_scale_set(si->obj, 1);
366 emotion_object_size_get(si->obj, &iw, &ih);
367 evas_object_color_set(si->obj, 255, 255, 255, (si->alpha * 255) / 100);
368 if ((si->size_w < 0) && (si->size_h < 0))
369 {
370 w = iw;
371 h = ih;
372 }
373 else if (si->size_h < 0)
374 {
375 w = sd->w * si->size_w;
376 if (iw > 0) h = (w * ih) / iw;
377 else h = 0;
378 }
379 else if (si->size_w < 0)
380 {
381 h = sd->h * si->size_h;
382 if (ih > 0) w = (h * iw) / ih;
383 else w = 0;
384 }
385 else
386 {
387 w = sd->w * si->size_w;
388 h = sd->h * si->size_h;
389 }
390 special_pos = 1;
391 sx = (si->pos_x * (sd->w - w)) / 100;
392 sy = (si->pos_y * (sd->h - h)) / 100;
393 padjust = (-h) - (sd->h / 40);
394 }
395 if (special_pos)
396 {
397 si->x = sx;
398 si->y = sy;
399 }
400 else
401 {
402 si->x = x + ((double)(sd->w - w) * si->align_x);
403 si->y = y;
404 }
405 si->w = w;
406 si->h = h;
407 y += h + (sd->h / 40);
408 evas_object_move(si->obj, sd->x + si->x, sd->y + si->y);
409 evas_object_resize(si->obj, si->w, si->h);
410 WALK_ITEMS_END;
411}
412
413static void
414_smart_add(Evas_Object *obj)
415{
416 Smart_Data *sd;
417
418 sd = calloc(1, sizeof(Smart_Data));
419 if (!sd) return;
420 sd->x = 0;
421 sd->y = 0;
422 sd->w = 0;
423 sd->h = 0;
424 sd->smart_object = obj;
425 sd->evas = evas_object_evas_get(obj);
426 sd->marker_object = evas_object_rectangle_add(sd->evas);
427 evas_object_smart_member_add(sd->marker_object, sd->smart_object);
428 evas_object_smart_data_set(obj, sd);
429}
430
431static void
432_smart_del(Evas_Object *obj)
433{
434 INTERNAL_ENTRY;
435 WALK_ITEMS_BEGIN;
436 evas_object_del(si->obj);
437 if (si->text) free(si->text);
438 free(si);
439 WALK_ITEMS_END;
440 evas_object_del(sd->marker_object);
441 evas_list_free(sd->items);
442 free(sd);
443}
444
445static void
446_smart_layer_set(Evas_Object *obj, int layer)
447{
448 INTERNAL_ENTRY;
449 WALK_ITEMS_BEGIN;
450 evas_object_layer_set(si->obj, layer);
451 WALK_ITEMS_END;
452 evas_object_layer_set(sd->marker_object, layer);
453}
454
455static void
456_smart_raise(Evas_Object *obj)
457{
458 INTERNAL_ENTRY;
459 WALK_ITEMS_BEGIN;
460 evas_object_raise(si->obj);
461 WALK_ITEMS_END;
462 evas_object_raise(sd->marker_object);
463}
464
465static void
466_smart_lower(Evas_Object *obj)
467{
468 INTERNAL_ENTRY;
469 evas_object_lower(sd->marker_object);
470 WALK_ITEMS_BEGIN;
471 evas_object_lower(si->obj);
472 WALK_ITEMS_END;
473}
474
475static void
476_smart_stack_above(Evas_Object *obj, Evas_Object *above)
477{
478 INTERNAL_ENTRY;
479 evas_object_stack_above(sd->marker_object, above);
480 WALK_ITEMS_BEGIN;
481 evas_object_stack_below(si->obj, sd->marker_object);
482 WALK_ITEMS_END;
483}
484
485static void
486_smart_stack_below(Evas_Object *obj, Evas_Object *below)
487{
488 INTERNAL_ENTRY;
489 evas_object_stack_below(sd->marker_object, below);
490 WALK_ITEMS_BEGIN;
491 evas_object_stack_below(si->obj, sd->marker_object);
492 WALK_ITEMS_END;
493}
494
495static void
496_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
497{
498 INTERNAL_ENTRY;
499 sd->x = x;
500 sd->y = y;
501 _smart_reconfigure(sd);
502}
503
504static void
505_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
506{
507 INTERNAL_ENTRY;
508 sd->w = w;
509 sd->h = h;
510 _smart_reconfigure(sd);
511}
512
513static void
514_smart_show(Evas_Object *obj)
515{
516 INTERNAL_ENTRY;
517 WALK_ITEMS_BEGIN;
518 evas_object_show(si->obj);
519 WALK_ITEMS_END;
520}
521
522static void
523_smart_hide(Evas_Object *obj)
524{
525 INTERNAL_ENTRY;
526 WALK_ITEMS_BEGIN;
527 evas_object_hide(si->obj);
528 WALK_ITEMS_END;
529}
530
531static void
532_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
533{
534 INTERNAL_ENTRY;
535 WALK_ITEMS_BEGIN;
536 evas_object_color_set(si->obj, r, g, b, a);
537 WALK_ITEMS_END;
538}
539
540static void
541_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
542{
543 INTERNAL_ENTRY;
544 WALK_ITEMS_BEGIN;
545 evas_object_clip_set(si->obj, clip);
546 WALK_ITEMS_END;
547}
548
549static void
550_smart_clip_unset(Evas_Object *obj)
551{
552 INTERNAL_ENTRY;
553 WALK_ITEMS_BEGIN;
554 evas_object_clip_unset(si->obj);
555 WALK_ITEMS_END;
556}
557
558/* never need to touch this */
559
560static void
561_smart_init(void)
562{
563 if (_smart) return;
564 _smart = evas_smart_new
565 (SMART_NAME, _smart_add, _smart_del, _smart_layer_set,
566 _smart_raise, _smart_lower, _smart_stack_above,
567 _smart_stack_below, _smart_move, _smart_resize,
568 _smart_show, _smart_hide, _smart_color_set,
569 _smart_clip_set, _smart_clip_unset, NULL);
570}
571
diff --git a/pres/slide.h b/pres/slide.h
new file mode 100644
index 0000000..9929ae2
--- /dev/null
+++ b/pres/slide.h
@@ -0,0 +1,12 @@
1#ifndef SLIDE_H
2#define SLIDE_H
3
4Evas_Object *slide_add(Evas *evas);
5void slide_title_add(Evas_Object *o, const char *str);
6void slide_text_add(Evas_Object *o, const char *str);
7void slide_image_add(Evas_Object *o, const char *str, const char *size);
8void slide_edje_add(Evas_Object *o, const char *str, const char *size, const char *dimensions);
9void slide_item_add(Evas_Object *o, const char *str);
10void slide_video_add(Evas_Object *o, const char *str, const char *size, const char *pos, const char *alpha);
11
12#endif
diff --git a/pres/test/e.png b/pres/test/e.png
new file mode 100644
index 0000000..47597a8
--- /dev/null
+++ b/pres/test/e.png
Binary files differ
diff --git a/pres/test/pres.xml b/pres/test/pres.xml
new file mode 100644
index 0000000..42076dc
--- /dev/null
+++ b/pres/test/pres.xml
@@ -0,0 +1,229 @@
1<presentation>
2 <slide>
3 </slide>
4 <slide>
5 <title>BLING BLING!</title>
6 <image size="25">e.png</image>
7 <title>
8 Desktop Developers Conference, Ottawa, 2005
9 </title>
10 <text>
11 The power of structural objects for building widget sets, applications
12 in a way that allows powerful theme manipulation, smart display pipeline
13 optimization that scales from hand-held device all the way to the
14 high-end desktop.
15 </text>
16 <text>
17 Carsten Haitzler (Rasterman) - raster@rasterman.com
18 </text>
19 </slide>
20 <slide>
21 <title>Enlightenment is just a Window Manager... Right?</title>
22 <text>
23 Once upon a time in a galaxy far far away... Enlightenment was mostly a
24 Window Manager for X. As part of development for 0.17 It has become much
25 more.
26 </text>
27 <text>
28 The work for E17 has created an imaging toolkit, canvas library,
29 shareable theme engine, virtual machine and much more, targeted not just
30 at the WM but all the way down to embedded devices.
31 </text>
32 <text>
33 It all began when trying to write a better file manager - EFM, where it
34 turned out an immediate display system was much harder to use to build
35 such a GUI, as the program ended up creating a structured GUI on top
36 anyway.
37 </text>
38 </slide>
39 <slide>
40 <title>The nature of GUI's</title>
41 <text>
42 Despite the API X and other display systems provide at its core, the
43 nature of display is invariably object based. You display a set of
44 objects (icons, buttons, labels etc.) and need to retain that structure
45 and manipulate it. Generally this task is left up to the application
46 itself, or a widget set. Often you don't want a widget set, but need
47 some half-way house where you can arrange lower-level primitives, but
48 not need to worry how to draw them all the time.
49 </text>
50 <text>
51 Here comes the canvas...
52 </text>
53 </slide>
54 <slide>
55 <title>Back to file managers</title>
56 <text>
57 In a modern world a GUI with bitmapped fonts, jagged icons with a few
58 minimal colors just doesn't cut it. People want smooth icons, colorful
59 displays and smooth anti-aliased text. All of this revolves around
60 alpha blending image data one way or another, and handling scaling of
61 image data in addition to the old stalwart rendering algorithms.
62 </text>
63 <text>
64 To do this on any reasonable sized display needs a very fast CPU, or
65 hardware acceleration, but let's be honest - the hardware acceleration
66 support under X is patchy for this level of rendering. There is need for
67 a way to do this without HAVING to rely on hardware acceleration. This
68 also makes way for scaling DOWN to small embedded systems that often only
69 have very dumb framebuffers AS WELL AS supporting cards with no driver
70 support and a stable development platform for drivers to be improved.
71 </text>
72 </slide>
73 <slide>
74 <title>Evas engines and fast software</title>
75 <text>
76 Evas is built on the premise that the rendering back-end may change
77 over time and that there may even be multiple rendering engines supported
78 at any one time, BUT there must always be a reliable software engine
79 that works fast enough for real use as the target may not have hardware
80 accelerated support, or such acceleration may place limits on the
81 rendering that the application cannot allow.
82 </text>
83 <text>
84 Currently Evas supports rendering to X via software rendering, Linux
85 framebuffer, Memory ARGB buffer, OpenGL/)X, DirectFB, Qtopia via software
86 and even Cairo (not that useful). It works on a tile update system that
87 limits redraws to only what changed, but even this currently has limits.
88 </text>
89 </slide>
90 <slide>
91 <title>Building more powerful layers on top</title>
92 <video size="33" pos="20+10" alpha="40">vid1.mpg</video>
93 <video size="60" pos="50+60" alpha="50">vid3.mpg</video>
94 <text>
95 Being not just a rendering engine and abstraction layer, but a structural
96 drawing system, Evas does require building layers on top to make it do
97 more. Evas provides a way to extend its objects with your own. One
98 example of this is Emotion, a video object library that glues modular
99 video decoders to canvas objects, letting them play video on their own
100 and be just another native part of the canvas.
101 </text>
102 </slide>
103 <slide>
104 <title>Edje</title>
105 <text>
106 Another layer like this is Edje. This is a hybrid layout engine with
107 event, scripting, and general look and feel rolled in. This information
108 is compiled into small, compact portable files that do not need to be
109 "installed" to be used. They can be used as-is as they are accessed on
110 a on-demand basis. They can react to events (signals) and transition
111 states and even execute scripts. The scripts are entirely sand-boxed and
112 cannot take over a program or cause any security problems. By
113 transitioning states you can also generate animation as transitions can
114 happen over time and Edje will insert or drop frames as needed to meet
115 a target framerate.
116 </text>
117 <text>
118 The Edje file is compiled from a text source (that looks not much
119 different from a C struct), and produces the compressed output that can
120 be directly used by an application. These files are even de-compilable
121 so you can extract the original source from the compiled output.
122 </text>
123 </slide>
124 <slide>
125 <title>Defining GUI layout with a structure and procedure</title>
126 <text>
127 Edje takes a layout system that looks more like layers found in GIMP
128 or Photoshop, but generally has many more layers that move, resize,
129 get recolored or have their contents changed. These layers are known as
130 Parts in Edje and have their geometry defined relative to the Edje object
131 as a whole or to other Edje parts, as well as allowing padding, offsets,
132 and many other limiting and augmenting parameters (aspect ratio, min/max
133 size, alignment etc.). This allows for a wide range of layout abilities,
134 but does fall short of a widget set's multi-item containering such as
135 h/vbox, tables, lists etc. Edje was intended to be something that could
136 be used to augment a widget set at a lower level, or be used as part of
137 building one, allowing your "button" or "scrollbar" to be much more
138 visually flexible than existing widget theme systems allow. It saves
139 having to interpret lots of script code as the layout engine is compiled
140 but it just accepts many parameters.
141 </text>
142 </slide>
143 <slide>
144 <title>Events</title>
145 <text>
146 Edje can allow for things to happen on events or signals. These events
147 either come from the user (the mouse fore example) or from the running
148 program that is using the Edje (it can emit signals) as well as from
149 well structured message queues. Edje has a set of "programs" that "run"
150 when a certain signal happens. They may simply change the state of a
151 part from normal to selected, or may emit more signals, transition parts
152 over periods of time for animation and even run an entire virtual
153 machine and scripting engine (known as embryo) to perform work to react
154 to the program or the user.
155 </text>
156 <text>
157 When simple signals are not enough the program and the Edje object can
158 communicate via structured message queues that allow a set of Edje
159 object-side callbacks in Embryo and application message handling
160 callbacks to talk. This allows a fairly sophisticated way of
161 communicating with a fairly opaque GUI object.
162 </text>
163 </slide>
164 <slide>
165 <title>Encapsulation for ease of use</title>
166 <image size="50" dimensions="640x480">sky.edj</image>
167 <text>
168 Compiling the source files into a single output file allows for easy
169 distribution and use. The above example is a single Edje object that
170 can animate and behave on its own, all encapsulated in a single file.
171 </text>
172 </slide>
173 <slide>
174 <title>Problems</title>
175 <list>
176 <item>Still fairly limited in abilities</item>
177 <item>No GUI editing tools yet</item>
178 <item>Complex to get a hold on</item>
179 <item>Limited primitive support</item>
180 <item>Limited API available to scripts</item>
181 <item>Not easily ported away from Evas</item>
182 <item>No multi-item layout primitives (h/vbox etc.)</item>
183 </list>
184 </slide>
185 <slide>
186 <title>Application in other areas</title>
187 <text>
188 Widget set theme engines should allow the theme to REACT to events such
189 as signals, mouse and focus events etc. and thus possibly animate to
190 help draw attention to something or simply be more flexible.
191 </text>
192 <text>
193 Custom interfaces where widgets sets are just too "standard" such as
194 set top boxes, mobile phone GUI's, kiosks and any other
195 "specific purpose"
196 </text>
197 <text>
198 Window Managers, anything with skinnable GUI's such as XMMS etc.
199 </text>
200 <text>
201 Anythng you feel needs to be funky and/or heavily user "re-skinnable"
202 </text>
203 </slide>
204 <slide>
205 <title>The problems facing us</title>
206 <text>
207 One of the problems facing Edje is object explosion. Since each Edje
208 object in turn is composed of multiple sub-objects it is very easy to
209 get a massive object count very quickly. The real problem is Evas'
210 flat object heirachy. I hope to fix this in the future with better
211 recursive canvas support.
212 </text>
213 <text>
214 Another big problem is hardware accelerated rendering support and
215 decent software fallbacks for it when needed within such a layer.
216 Currently decent software rendering support is an all or nothing deal
217 with the client side doing it all or hoping that the server-side doesn't
218 ever hit a software fallback, as when it does the whole thing falls
219 apart. OpenGL is an option but is still unstable, not supported
220 everywhere and is not the most appropriate API for 2D rendering.
221 </text>
222 </slide>
223 <slide>
224 <title>Hardware acceleration</title>
225 <text>
226 /* FIXME: This needs fixing. */
227 </text>
228 </slide>
229</presentation>
diff --git a/pres/test/sky.edj b/pres/test/sky.edj
new file mode 100644
index 0000000..142b15d
--- /dev/null
+++ b/pres/test/sky.edj
Binary files differ
diff --git a/pres/test/sky/bg.png b/pres/test/sky/bg.png
new file mode 100644
index 0000000..39a2f9b
--- /dev/null
+++ b/pres/test/sky/bg.png
Binary files differ
diff --git a/pres/test/sky/build.sh b/pres/test/sky/build.sh
new file mode 100644
index 0000000..16f318b
--- /dev/null
+++ b/pres/test/sky/build.sh
@@ -0,0 +1,2 @@
1#!/bin/sh
2edje_cc $@ --image_dir . --font_dir . main_edje_source.edc -o sky.edj
diff --git a/pres/test/sky/c1.png b/pres/test/sky/c1.png
new file mode 100644
index 0000000..6d66a56
--- /dev/null
+++ b/pres/test/sky/c1.png
Binary files differ
diff --git a/pres/test/sky/c2.png b/pres/test/sky/c2.png
new file mode 100644
index 0000000..e4374b8
--- /dev/null
+++ b/pres/test/sky/c2.png
Binary files differ
diff --git a/pres/test/sky/c3.png b/pres/test/sky/c3.png
new file mode 100644
index 0000000..488e756
--- /dev/null
+++ b/pres/test/sky/c3.png
Binary files differ
diff --git a/pres/test/sky/c4.png b/pres/test/sky/c4.png
new file mode 100644
index 0000000..1f6de86
--- /dev/null
+++ b/pres/test/sky/c4.png
Binary files differ
diff --git a/pres/test/sky/icon.png b/pres/test/sky/icon.png
new file mode 100644
index 0000000..d68aad1
--- /dev/null
+++ b/pres/test/sky/icon.png
Binary files differ
diff --git a/pres/test/sky/main_edje_source.edc b/pres/test/sky/main_edje_source.edc
new file mode 100644
index 0000000..2aaaa9b
--- /dev/null
+++ b/pres/test/sky/main_edje_source.edc
@@ -0,0 +1,625 @@
1images {
2 // image "filename.png" STORAGE_MEOTHD [option to storage method];
3 // STORAGE_METHOD can be:
4 // COMP = compressed, no loss
5 // RAW = uncompressed, no loss
6 // LOSSY = compressed with quality loss, next param is quality level (0-100)
7 image, "bg.png" LOSSY 80;
8 image, "icon.png" LOSSY 60;
9 image, "c1.png" LOSSY 60;
10 image, "c2.png" LOSSY 60;
11 image, "c3.png" LOSSY 60;
12 image, "c4.png" LOSSY 60;
13 image, "s0.png" LOSSY 60;
14 image, "s1.png" LOSSY 60;
15 image, "s2.png" LOSSY 60;
16}
17
18collections {
19 group {
20 name, "desktop/background";
21// min, 720, 480;
22// min, 180, 120;
23 parts {
24 /* BACKGROUND */
25 part {
26 name, "background";
27 mouse_events, 1;
28 description {
29 state, "default" 0.0;
30// aspect, 1.5 1.5;
31 rel1 {
32 relative, 0.0 0.0;
33 offset, 0 0;
34 }
35 rel2 {
36 relative, 1.0 1.0;
37 offset, -1 -1;
38 }
39 image {
40 normal, "bg.png";
41 }
42 fill {
43 smooth, 0;
44 }
45 }
46 }
47/*
48 part {
49 name, "icon";
50 mouse_events, 0;
51 description {
52 min, 253 176;
53 state, "default" 0.0;
54 align, 1.0 0.0;
55 rel1 {
56 relative, 0.0 1.0;
57 offset, 0 0;
58 }
59 rel2 {
60 relative, 0.0 1.0;
61 offset, 0 0;
62 }
63 image {
64 normal, "icon.png";
65 }
66 color, 255 255 255 50;
67 }
68 }
69 part {
70 name, "text";
71 type, TEXT;
72 effect, SOFT_SHADOW;
73 description {
74 state, "default" 0.0;
75 rel1 {
76 relative, 0.0 0.0;
77 offset, 48 36;
78 }
79 rel2 {
80 relative, 1.0, 1.0;
81 offset, -49, -37;
82 }
83 color, 255 255 255 255;
84 // color2, 0 0 255 255;
85 color3, 0 0 0 50;
86 text {
87 text, "Photos";
88 font, "Vera";
89 size, 48;
90 //fit, 0 1;
91 //min, 1 1;
92 align, 1.0 0.0;
93 }
94 }
95 }
96 */
97 /* LAND LAYER 0 */
98 part {
99 name, "land_0";
100 mouse_events, 0;
101 description {
102 state, "default" 0.0;
103// aspect, 1.5 1.5;
104 rel1 {
105 relative, 0.0 0.0;
106 offset, 0 0;
107 }
108 rel2 {
109 relative, 1.0 1.0;
110 offset, -1 -1;
111 }
112 fill {
113 smooth, 0;
114 origin {
115 relative, 0.0 0.0;
116 offset, 0 0;
117 }
118 size {
119 relative, 3.55556 1.0;
120 offset, 0 0;
121 }
122 }
123 color, 150 130 110 200;
124 image {
125 normal, "s0.png";
126 }
127 }
128 description {
129 state, "drift" 0.0;
130// aspect, 1.5 1.5;
131 rel1 {
132 relative, 0.0 0.0;
133 offset, 0 0;
134 }
135 rel2 {
136 relative, 1.0 1.0;
137 offset, -1 -1;
138 }
139 fill {
140 smooth, 0;
141 origin {
142 relative, 3.55556 0.0;
143 offset, 0 0;
144 }
145 size {
146 relative, 3.55556 1.0;
147 offset, 0 0;
148 }
149 }
150 color, 150 130 110 200;
151 image {
152 normal, "s0.png";
153 }
154 }
155 }
156 /* CLOUD LAYER 1 */
157 part {
158 name, "cloud_1";
159 mouse_events, 0;
160 description {
161 state, "default" 0.0;
162// aspect, 1.5 1.5;
163 rel1 {
164 relative, 0.0 0.0;
165 offset, 0 0;
166 }
167 rel2 {
168 relative, 1.0 1.0;
169 offset, -1 -1;
170 }
171 fill {
172 smooth, 0;
173 origin {
174 relative, 0.0 0.0;
175 offset, 0 0;
176 }
177 size {
178 relative, 3.55556 1.0;
179 offset, 0 0;
180 }
181 }
182 image {
183 normal, "c1.png";
184 }
185 }
186 description {
187 state, "drift" 0.0;
188// aspect, 1.5 1.5;
189 rel1 {
190 relative, 0.0 0.0;
191 offset, 0 0;
192 }
193 rel2 {
194 relative, 1.0 1.0;
195 offset, -1 -1;
196 }
197 fill {
198 smooth, 0;
199 origin {
200 relative, 3.55556 0.0;
201 offset, 0 0;
202 }
203 size {
204 relative, 3.55556 1.0;
205 offset, 0 0;
206 }
207 }
208 image {
209 normal, "c1.png";
210 }
211 }
212 }
213 /* LAND LAYER 1 */
214 part {
215 name, "land_1";
216 mouse_events, 0;
217 description {
218 state, "default" 0.0;
219// aspect, 1.5 1.5;
220 rel1 {
221 relative, 0.0 0.0;
222 offset, 0 0;
223 }
224 rel2 {
225 relative, 1.0 1.0;
226 offset, -1 -1;
227 }
228 fill {
229 smooth, 0;
230 origin {
231 relative, 0.0 0.0;
232 offset, 0 0;
233 }
234 size {
235 relative, 3.55556 1.0;
236 offset, 0 0;
237 }
238 }
239 color, 100 80 60 220;
240 image {
241 normal, "s1.png";
242 }
243 }
244 description {
245 state, "drift" 0.0;
246// aspect, 1.5 1.5;
247 rel1 {
248 relative, 0.0 0.0;
249 offset, 0 0;
250 }
251 rel2 {
252 relative, 1.0 1.0;
253 offset, -1 -1;
254 }
255 fill {
256 smooth, 0;
257 origin {
258 relative, 3.55556 0.0;
259 offset, 0 0;
260 }
261 size {
262 relative, 3.55556 1.0;
263 offset, 0 0;
264 }
265 }
266 color, 100 80 60 220;
267 image {
268 normal, "s1.png";
269 }
270 }
271 }
272 /* CLOUD LAYER 2 */
273 part {
274 name, "cloud_2";
275 mouse_events, 0;
276 description {
277 state, "default" 0.0;
278// aspect, 1.5 1.5;
279 rel1 {
280 relative, 0.0 0.0;
281 offset, 0 0;
282 }
283 rel2 {
284 relative, 1.0 1.0;
285 offset, -1 -1;
286 }
287 fill {
288 smooth, 0;
289 origin {
290 relative, 0.0 0.0;
291 offset, 0 0;
292 }
293 size {
294 relative, 1.47083 1.0;
295 offset, 0 0;
296 }
297 }
298 image {
299 normal, "c2.png";
300 }
301 }
302 description {
303 state, "drift" 0.0;
304// aspect, 1.5 1.5;
305 rel1 {
306 relative, 0.0 0.0;
307 offset, 0 0;
308 }
309 rel2 {
310 relative, 1.0 1.0;
311 offset, -1 -1;
312 }
313 fill {
314 smooth, 0;
315 origin {
316 relative, 1.47083 0.0;
317 offset, 0 0;
318 }
319 size {
320 relative, 1.47083 1.0;
321 offset, 0 0;
322 }
323 }
324 image {
325 normal, "c2.png";
326 }
327 }
328 }
329 /* LAND LAYER 2 */
330 part {
331 name, "land_2";
332 mouse_events, 0;
333 description {
334 state, "default" 0.0;
335// aspect, 1.5 1.5;
336 rel1 {
337 relative, 0.0 0.0;
338 offset, 0 0;
339 }
340 rel2 {
341 relative, 1.0 1.0;
342 offset, -1 -1;
343 }
344 fill {
345 smooth, 0;
346 origin {
347 relative, 0.0 0.0;
348 offset, 0 0;
349 }
350 size {
351 relative, 1.77778 1.0;
352 offset, 0 0;
353 }
354 }
355 color, 90 70 50 230;
356 image {
357 normal, "s2.png";
358 }
359 }
360 description {
361 state, "drift" 0.0;
362// aspect, 1.5 1.5;
363 rel1 {
364 relative, 0.0 0.0;
365 offset, 0 0;
366 }
367 rel2 {
368 relative, 1.0 1.0;
369 offset, -1 -1;
370 }
371 fill {
372 smooth, 0;
373 origin {
374 relative, 1.77778 0.0;
375 offset, 0 0;
376 }
377 size {
378 relative, 1.77778 1.0;
379 offset, 0 0;
380 }
381 }
382 color, 90 70 50 230;
383 image {
384 normal, "s2.png";
385 }
386 }
387 }
388 /* CLOUD LAYER 3 */
389 part {
390 name, "cloud_3";
391 mouse_events, 0;
392 description {
393 state, "default" 0.0;
394// aspect, 1.5 1.5;
395 rel1 {
396 relative, 0.0 0.0;
397 offset, 0 0;
398 }
399 rel2 {
400 relative, 1.0 1.0;
401 offset, -1 -1;
402 }
403 fill {
404 smooth, 0;
405 origin {
406 relative, 0.0 0.0;
407 offset, 0 0;
408 }
409 size {
410 relative, 1.86667 1.0;
411 offset, 0 0;
412 }
413 }
414 image {
415 normal, "c3.png";
416 }
417 }
418 description {
419 state, "drift" 0.0;
420// aspect, 1.5 1.5;
421 rel1 {
422 relative, 0.0 0.0;
423 offset, 0 0;
424 }
425 rel2 {
426 relative, 1.0 1.0;
427 offset, -1 -1;
428 }
429 fill {
430 smooth, 0;
431 origin {
432 relative, 1.86667 0.0;
433 offset, 0 0;
434 }
435 size {
436 relative, 1.86667 1.0;
437 offset, 0 0;
438 }
439 }
440 image {
441 normal, "c3.png";
442 }
443 }
444 }
445 /* CLOUD LAYER 4 */
446 part {
447 name, "cloud_4";
448 mouse_events, 0;
449 description {
450 state, "default" 0.0;
451// aspect, 1.5 1.5;
452 rel1 {
453 relative, 0.0 0.0;
454 offset, 0 0;
455 }
456 rel2 {
457 relative, 1.0 1.0;
458 offset, -1 -1;
459 }
460 fill {
461 smooth, 0;
462 origin {
463 relative, 0.0 0.0;
464 offset, 0 0;
465 }
466 size {
467 relative, 1.84722 1.0;
468 offset, 0 0;
469 }
470 }
471 image {
472 normal, "c4.png";
473 }
474 }
475 description {
476 state, "drift" 0.0;
477// aspect, 1.5 1.5;
478 rel1 {
479 relative, 0.0 0.0;
480 offset, 0 0;
481 }
482 rel2 {
483 relative, 1.0 1.0;
484 offset, -1 -1;
485 }
486 fill {
487 smooth, 0;
488 origin {
489 relative, 1.84722 0.0;
490 offset, 0 0;
491 }
492 size {
493 relative, 1.84722 1.0;
494 offset, 0 0;
495 }
496 }
497 image {
498 normal, "c4.png";
499 }
500 }
501 }
502 }
503 programs {
504 program {
505 name, "anim_1_land_0";
506 signal, "show";
507 source, "";
508 action, STATE_SET "drift" 0.0;
509 transition, LINEAR 855.0;
510 target, "land_0";
511 after, "anim_2_land_0";
512 }
513 program {
514 name, "anim_2_land_0";
515 signal, "NONE";
516 source, "NONE";
517 action, STATE_SET "default" 0.0;
518 target, "land_0";
519 after, "anim_1_land_0";
520 }
521 program {
522 name, "anim_1_cloud_1";
523 signal, "show";
524 source, "";
525 action, STATE_SET "drift" 0.0;
526 transition, LINEAR 485.0;
527 target, "cloud_1";
528 after, "anim_2_cloud_1";
529 }
530 program {
531 name, "anim_2_cloud_1";
532 signal, "NONE";
533 source, "NONE";
534 action, STATE_SET "default" 0.0;
535 target, "cloud_1";
536 after, "anim_1_cloud_1";
537 }
538 program {
539 name, "anim_1_land_1";
540 signal, "show";
541 source, "";
542 action, STATE_SET "drift" 0.0;
543 transition, LINEAR 425.0;
544 target, "land_1";
545 after, "anim_2_land_1";
546 }
547 program {
548 name, "anim_2_land_1";
549 signal, "NONE";
550 source, "NONE";
551 action, STATE_SET "default" 0.0;
552 target, "land_1";
553 after, "anim_1_land_1";
554 }
555 program {
556 name, "anim_1_cloud_2";
557 signal, "show";
558 source, "";
559 action, STATE_SET "drift" 0.0;
560 transition, LINEAR 65.0;
561 target, "cloud_2";
562 after, "anim_2_cloud_2";
563 }
564 program {
565 name, "anim_2_cloud_2";
566 signal, "NONE";
567 source, "NONE";
568 action, STATE_SET "default" 0.0;
569 target, "cloud_2";
570 after, "anim_1_cloud_2";
571 }
572 program {
573 name, "anim_1_land_2";
574 signal, "show";
575 source, "";
576 action, STATE_SET "drift" 0.0;
577 transition, LINEAR 70.0;
578 target, "land_2";
579 after, "anim_2_land_2";
580 }
581 program {
582 name, "anim_2_land_2";
583 signal, "NONE";
584 source, "NONE";
585 action, STATE_SET "default" 0.0;
586 target, "land_2";
587 after, "anim_1_land_2";
588 }
589 program {
590 name, "anim_1_cloud_3";
591 signal, "show";
592 source, "";
593 action, STATE_SET "drift" 0.0;
594 transition, LINEAR 55.0;
595 target, "cloud_3";
596 after, "anim_2_cloud_3";
597 }
598 program {
599 name, "anim_2_cloud_3";
600 signal, "";
601 source, "";
602 action, STATE_SET "default" 0.0;
603 target, "cloud_3";
604 after, "anim_1_cloud_3";
605 }
606 program {
607 name, "anim_1_cloud_4";
608 signal, "show";
609 source, "";
610 action, STATE_SET "drift" 0.0;
611 transition, LINEAR 25.0;
612 target, "cloud_4";
613 after, "anim_2_cloud_4";
614 }
615 program {
616 name, "anim_2_cloud_4";
617 signal, "";
618 source, "";
619 action, STATE_SET "default" 0.0;
620 target, "cloud_4";
621 after, "anim_1_cloud_4";
622 }
623 }
624 }
625}
diff --git a/pres/test/sky/s0.png b/pres/test/sky/s0.png
new file mode 100644
index 0000000..0f15972
--- /dev/null
+++ b/pres/test/sky/s0.png
Binary files differ
diff --git a/pres/test/sky/s1.png b/pres/test/sky/s1.png
new file mode 100644
index 0000000..e1f1bc7
--- /dev/null
+++ b/pres/test/sky/s1.png
Binary files differ
diff --git a/pres/test/sky/s2.png b/pres/test/sky/s2.png
new file mode 100644
index 0000000..af81024
--- /dev/null
+++ b/pres/test/sky/s2.png
Binary files differ
diff --git a/pres/test/sky/sky.edj b/pres/test/sky/sky.edj
new file mode 100644
index 0000000..142b15d
--- /dev/null
+++ b/pres/test/sky/sky.edj
Binary files differ
diff --git a/pres/xtag.c b/pres/xtag.c
new file mode 100644
index 0000000..cf32c38
--- /dev/null
+++ b/pres/xtag.c
@@ -0,0 +1,829 @@
1/*
2 Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3 Organisation (CSIRO) Australia
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 - Neither the name of CSIRO Australia nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33/**
34 * \file xtag.c
35 *
36 * XTag: A trivial parser for xml-like tags.
37 *
38 * API Version: 1.0
39 * Author: Conrad Parker, 2003
40 */
41
42#include "anx_compat.h"
43
44#include <ctype.h>
45#include <string.h>
46#include <stdarg.h>
47
48#include "anx_list.h"
49
50/*#define DEBUG*/
51
52#ifdef DEBUG
53#include <stdio.h>
54#endif
55
56#undef FALSE
57#undef TRUE
58
59#define FALSE (0)
60#define TRUE (!FALSE)
61
62#undef MIN
63#define MIN(a,b) ((a)<(b)?(a):(b))
64
65#undef MAX
66#define MAX(a,b) ((a)>(b)?(a):(b))
67
68typedef struct _XTag XTag;
69typedef struct _XAttribute XAttribute;
70typedef struct _XTagParser XTagParser;
71
72/*
73 * struct _XTag is kind of a union ... it normally represents a whole
74 * tag (and its children), but it could alternatively represent some
75 * PCDATA. Basically, if tag->pcdata is non-NULL, interpret only it and
76 * ignore the name, attributes and inner_tags.
77 */
78struct _XTag {
79 char * name;
80 char * pcdata;
81 XTag * parent;
82 AnxList * attributes;
83 AnxList * children;
84 AnxList * current_child;
85};
86
87struct _XAttribute {
88 char * name;
89 char * value;
90};
91
92struct _XTagParser {
93 int valid; /* boolean */
94 XTag * current_tag;
95 char * start;
96 char * end;
97};
98
99/* Character classes */
100#define X_NONE 0
101#define X_WHITESPACE 1<<0
102#define X_OPENTAG 1<<1
103#define X_CLOSETAG 1<<2
104#define X_DQUOTE 1<<3
105#define X_SQUOTE 1<<4
106#define X_EQUAL 1<<5
107#define X_SLASH 1<<6
108#define X_DASH 1<<7
109#define X_QUESTION 1<<8
110
111static int
112xtag_cin (char c, int char_class)
113{
114 if (char_class & X_WHITESPACE)
115 if (isspace(c)) return TRUE;
116
117 if (char_class & X_OPENTAG)
118 if (c == '<') return TRUE;
119
120 if (char_class & X_CLOSETAG)
121 if (c == '>') return TRUE;
122
123 if (char_class & X_DQUOTE)
124 if (c == '"') return TRUE;
125
126 if (char_class & X_SQUOTE)
127 if (c == '\'') return TRUE;
128
129 if (char_class & X_EQUAL)
130 if (c == '=') return TRUE;
131
132 if (char_class & X_SLASH)
133 if (c == '/') return TRUE;
134
135 if (char_class & X_DASH)
136 if (c == '-') return TRUE;
137
138 if (char_class & X_QUESTION)
139 if (c == '?') return TRUE;
140
141 return FALSE;
142}
143
144static int
145xtag_index (XTagParser * parser, int char_class)
146{
147 char * s;
148 int i;
149
150 if (!parser->valid) return -1;
151
152 for (i = 0, s = parser->start; s != parser->end && *s; i++, s++) {
153 if (xtag_cin(*s, char_class)) return i;
154 }
155
156 return -1;
157}
158
159static void
160xtag_skip_over (XTagParser * parser, int char_class)
161{
162 char * s;
163 int i;
164
165 if (!parser->valid) return;
166
167 for (i = 0, s = parser->start; s != parser->end && *s; i++, s++) {
168 if (!xtag_cin(*s, char_class)) {
169 parser->start = s;
170 return;
171 }
172 }
173
174 return;
175}
176
177static void
178xtag_skip_whitespace (XTagParser * parser)
179{
180 xtag_skip_over (parser, X_WHITESPACE);
181}
182
183static int
184xtag_skip_to (XTagParser * parser, int char_class)
185{
186 char * s;
187 int i;
188
189 if (!parser->valid) return FALSE;
190
191 for (i = 0, s = parser->start; s != parser->end && *s; i++, s++) {
192 if (xtag_cin(*s, char_class)) {
193 parser->start = s;
194 return TRUE;
195 }
196#ifdef DEBUG
197 else printf ("xtag: skipping '%c'\n", s[i]);
198#endif
199 }
200
201 return FALSE;
202}
203
204static char *
205xtag_slurp_to (XTagParser * parser, int good_end, int bad_end)
206{
207 char * s, * ret;
208 int xi;
209
210 if (!parser->valid) return NULL;
211
212 s = parser->start;
213
214 xi = xtag_index (parser, good_end | bad_end);
215
216 if (xi > 0 && xtag_cin (s[xi], good_end)) {
217 ret = anx_malloc ((xi+1) * sizeof(char));
218 strncpy (ret, s, xi);
219 ret[xi] = '\0';
220 parser->start = &s[xi];
221 return ret;
222 }
223
224 return NULL;
225}
226
227static int
228xtag_pass (XTagParser * parser, int char_class, int assert)
229{
230 char * s;
231
232 if (!parser->valid) return FALSE;
233
234 s = parser->start;
235
236 if (!xtag_cin (s[0], char_class)) {
237 if (assert) parser->valid = FALSE;
238 return FALSE;
239 }
240
241 parser->start = &s[1];
242
243 return TRUE;
244}
245
246static int
247xtag_check_and_pass (XTagParser * parser, int char_class)
248{
249 return xtag_pass (parser, char_class, FALSE);
250}
251
252static int
253xtag_assert_and_pass (XTagParser * parser, int char_class)
254{
255 return xtag_pass (parser, char_class, TRUE);
256}
257
258static char *
259xtag_slurp_quoted (XTagParser * parser)
260{
261 char * s, * prev = NULL, * ret;
262 int quote = X_DQUOTE; /* quote char to match on */
263 int i;
264
265 if (!parser->valid) return NULL;
266
267 xtag_skip_whitespace (parser);
268
269 s = parser->start;
270
271 if (xtag_cin (s[0], X_SQUOTE)) quote = X_SQUOTE;
272
273 if (!xtag_assert_and_pass (parser, quote)) return NULL;
274
275 s = parser->start;
276
277 for (i = 0, s = parser->start; s != parser->end && *s; i++, s++) {
278 if (xtag_cin (*s, quote)) {
279 if (!(i > 1 && *prev == '\\')) break;
280 }
281 prev = s;
282 }
283
284 s = parser->start;
285
286 ret = anx_malloc ((i+1) * sizeof(char));
287 strncpy (ret, s, i);
288 ret[i] = '\0';
289 parser->start = &s[i];
290
291 if (!xtag_assert_and_pass (parser, quote)) {
292 anx_free (ret);
293 return NULL;
294 }
295
296 return ret;
297}
298
299static XAttribute *
300xtag_parse_attribute (XTagParser * parser)
301{
302 XAttribute * attr;
303 char * name, * value;
304 char * s;
305
306 if (!parser->valid) return NULL;
307
308 xtag_skip_whitespace (parser);
309
310 name = xtag_slurp_to (parser, X_WHITESPACE | X_EQUAL, X_SLASH | X_CLOSETAG);
311
312 if (name == NULL) return NULL;
313
314 xtag_skip_whitespace (parser);
315 s = parser->start;
316
317 if (!xtag_assert_and_pass (parser, X_EQUAL)) {
318#ifdef DEBUG
319 printf ("xtag: attr failed EQUAL on <%s>\n", name);
320#endif
321 goto err_free_name;
322 }
323
324 xtag_skip_whitespace (parser);
325
326 value = xtag_slurp_quoted (parser);
327
328 if (value == NULL) {
329#ifdef DEBUG
330 printf ("Got NULL quoted attribute value\n");
331#endif
332 goto err_free_name;
333 }
334
335 attr = anx_malloc (sizeof (*attr));
336 attr->name = name;
337 attr->value = value;
338
339 return attr;
340
341 err_free_name:
342 anx_free (name);
343
344 parser->valid = FALSE;
345
346 return NULL;
347}
348
349static XTag *
350xtag_parse_pcdata (XTagParser * parser)
351{
352 XTag * tag;
353 char * pcdata;
354
355 if (!parser->valid) return NULL;
356
357 pcdata = xtag_slurp_to (parser, X_OPENTAG, X_NONE);
358 if (pcdata == NULL) return NULL;
359
360 tag = anx_malloc (sizeof (*tag));
361 tag->name = NULL;
362 tag->pcdata = pcdata;
363 tag->parent = parser->current_tag;
364 tag->attributes = NULL;
365 tag->children = NULL;
366 tag->current_child = NULL;
367
368 return tag;
369}
370
371static char *
372xtag_parse_name (XTagParser * parser)
373{
374 char * name;
375
376 if (!xtag_assert_and_pass (parser, X_OPENTAG)) return NULL;
377
378 name = xtag_slurp_to (parser, X_WHITESPACE | X_SLASH | X_CLOSETAG, X_NONE);
379
380 return name;
381}
382
383/* Forward declaration for tail-recursive skipping functions */
384static XTag * xtag_parse_tag (XTagParser * parser);
385
386static XTag *
387xtag_parse_directive (XTagParser * parser)
388{
389#ifdef DEBUG
390 printf ("xtag: processing directive\n");
391#endif
392 while (parser->start < parser->end &&
393 xtag_skip_to (parser, X_QUESTION)) {
394 if (xtag_check_and_pass (parser, X_QUESTION) &&
395 xtag_check_and_pass (parser, X_CLOSETAG))
396 return xtag_parse_tag (parser);
397 }
398 /* Unterminated processing directive */
399 return NULL;
400}
401
402static XTag *
403xtag_parse_comment (XTagParser * parser)
404{
405#ifdef DEBUG
406 printf ("xtag: comment\n");
407#endif
408 while (parser->start < parser->end &&
409 xtag_skip_to (parser, X_DASH)) {
410 if (xtag_check_and_pass (parser, X_DASH) &&
411 xtag_check_and_pass (parser, X_DASH) &&
412 xtag_check_and_pass (parser, X_CLOSETAG))
413 return xtag_parse_tag (parser);
414 }
415 /* Unterminated comment */
416 return NULL;
417}
418
419static XTag *
420xtag_parse_declaration (XTagParser * parser)
421{
422#ifdef DEBUG
423 printf ("xtag: non-comment declaration\n");
424#endif
425 while (parser->start < parser->end &&
426 xtag_skip_to (parser, X_CLOSETAG)) {
427 if (xtag_check_and_pass (parser, X_CLOSETAG))
428 return xtag_parse_tag (parser);
429 }
430 /* Unterminated declaration */
431 return NULL;
432}
433
434static XTag *
435xtag_parse_tag (XTagParser * parser)
436{
437 XTag * tag, * inner;
438 XAttribute * attr;
439 char * name;
440 char * s;
441
442 if (!parser->valid) return NULL;
443
444 tag = xtag_parse_pcdata (parser);
445 if (tag != NULL) return tag;
446
447 s = parser->start;
448
449 /* Return to the parent if we're at the end of input */
450 if (s == parser->end) return NULL;
451
452 /* if this starts a close tag, return NULL and let the parent take it */
453 if (xtag_cin (s[0], X_OPENTAG) && xtag_cin (s[1], X_SLASH))
454 return NULL;
455
456 name = xtag_parse_name (parser);
457 if (name == NULL) return NULL;
458
459#ifdef DEBUG
460 printf ("<%s ...\n", name);
461#endif
462
463 /* Skip processing directives */
464 if (name[0] == '?') {
465 anx_free (name);
466 return xtag_parse_directive (parser);
467 } else if (!strcmp (name, "!--")) {
468 anx_free (name);
469 return xtag_parse_comment (parser);
470 } else if (name[0] == '!') {
471 anx_free (name);
472 return xtag_parse_declaration (parser);
473 }
474
475 tag = anx_malloc (sizeof (*tag));
476 tag->name = name;
477 tag->pcdata = NULL;
478 tag->parent = parser->current_tag;
479 tag->attributes = NULL;
480 tag->children = NULL;
481 tag->current_child = NULL;
482
483 s = parser->start;
484
485 if (xtag_cin (s[0], X_WHITESPACE)) {
486 while ((attr = xtag_parse_attribute (parser)) != NULL) {
487 tag->attributes = anx_list_append (tag->attributes, attr);
488 }
489 }
490
491 xtag_skip_whitespace (parser);
492
493 s = parser->start;
494
495 if (xtag_cin (s[0], X_CLOSETAG)) {
496 parser->current_tag = tag;
497
498 xtag_assert_and_pass (parser, X_CLOSETAG);
499
500 while ((inner = xtag_parse_tag (parser)) != NULL) {
501 tag->children = anx_list_append (tag->children, inner);
502 }
503
504 xtag_skip_whitespace (parser);
505
506 xtag_assert_and_pass (parser, X_OPENTAG);
507 xtag_assert_and_pass (parser, X_SLASH);
508 name = xtag_slurp_to (parser, X_WHITESPACE | X_CLOSETAG, X_NONE);
509 if (name == NULL) {
510#ifdef DEBUG
511 printf ("tag %s not closed\n", tag->name);
512#endif
513 parser->valid = FALSE;
514 } else {
515 if (tag->name && strcmp (name, tag->name)) {
516#ifdef DEBUG
517 printf ("got %s expected %s\n", name, tag->name);
518#endif
519 parser->valid = FALSE;
520 }
521 anx_free (name);
522 }
523
524 xtag_skip_whitespace (parser);
525 xtag_assert_and_pass (parser, X_CLOSETAG);
526
527 } else {
528 xtag_assert_and_pass (parser, X_SLASH);
529 xtag_assert_and_pass (parser, X_CLOSETAG);
530 }
531
532 return tag;
533}
534
535XTag *
536xtag_free (XTag * xtag)
537{
538 AnxList * l;
539 XAttribute * attr;
540 XTag * child;
541
542 if (xtag == NULL) return NULL;
543
544 if (xtag->name) anx_free (xtag->name);
545 if (xtag->pcdata) anx_free (xtag->pcdata);
546
547 for (l = xtag->attributes; l; l = l->next) {
548 if ((attr = (XAttribute *)l->data) != NULL) {
549 if (attr->name) anx_free (attr->name);
550 if (attr->value) anx_free (attr->value);
551 anx_free (attr);
552 }
553 }
554 anx_list_free (xtag->attributes);
555
556 for (l = xtag->children; l; l = l->next) {
557 child = (XTag *)l->data;
558 xtag_free (child);
559 }
560 anx_list_free (xtag->children);
561
562 anx_free (xtag);
563
564 return NULL;
565}
566
567XTag *
568xtag_new_parse (const char * s, int n)
569{
570 XTagParser parser;
571 XTag * tag, * ttag, * wrapper;
572
573 parser.valid = TRUE;
574 parser.current_tag = NULL;
575 parser.start = (char *)s;
576
577 if (n == -1)
578 parser.end = NULL;
579 else if (n == 0)
580 return NULL;
581 else
582 parser.end = (char *)&s[n];
583
584 tag = xtag_parse_tag (&parser);
585
586 if (!parser.valid) {
587#ifdef DEBUG
588 printf ("xtag_new_parse(): parser invalid\n");
589#endif
590 xtag_free (tag);
591 return NULL;
592 }
593
594 if ((ttag = xtag_parse_tag (&parser)) != NULL) {
595
596 if (!parser.valid) {
597 xtag_free (ttag);
598 return tag;
599 }
600
601 wrapper = anx_malloc (sizeof (XTag));
602 wrapper->name = NULL;
603 wrapper->pcdata = NULL;
604 wrapper->parent = NULL;
605 wrapper->attributes = NULL;
606 wrapper->children = NULL;
607 wrapper->current_child = NULL;
608
609 wrapper->children = anx_list_append (wrapper->children, tag);
610 wrapper->children = anx_list_append (wrapper->children, ttag);
611
612 while ((ttag = xtag_parse_tag (&parser)) != NULL) {
613
614 if (!parser.valid) {
615 xtag_free (ttag);
616 return wrapper;
617 }
618
619 wrapper->children = anx_list_append (wrapper->children, ttag);
620 }
621 return wrapper;
622 }
623
624 return tag;
625}
626
627const char *
628xtag_get_name (XTag * xtag)
629{
630 return xtag ? xtag->name : NULL;
631}
632
633const char *
634xtag_get_pcdata (XTag * xtag)
635{
636 AnxList * l;
637 XTag * child;
638
639 if (xtag == NULL) return NULL;
640
641 for (l = xtag->children; l; l = l->next) {
642 child = (XTag *)l->data;
643 if (child->pcdata != NULL) {
644 return child->pcdata;
645 }
646 }
647
648 return NULL;
649}
650
651const char *
652xtag_get_attribute (XTag * xtag, const char * attribute)
653{
654 AnxList * l;
655 XAttribute * attr;
656
657 if (xtag == NULL) return NULL;
658
659 for (l = xtag->attributes; l; l = l->next) {
660 if ((attr = (XAttribute *)l->data) != NULL) {
661 if (attr->name && attribute && !strcmp (attr->name, attribute))
662 return attr->value;
663 }
664 }
665
666 return NULL;
667}
668
669XTag *
670xtag_first_child (XTag * xtag, const char * name)
671{
672 AnxList * l;
673 XTag * child;
674
675 if (xtag == NULL) return NULL;
676
677 if ((l = xtag->children) == NULL) return NULL;
678
679 if (name == NULL) {
680 xtag->current_child = l;
681 return (XTag *)l->data;
682 }
683
684 for (; l; l = l->next) {
685 child = (XTag *)l->data;
686
687 if (child->name && name && !strcmp(child->name, name)) {
688 xtag->current_child = l;
689 return child;
690 }
691 }
692
693 xtag->current_child = NULL;
694
695 return NULL;
696}
697
698XTag *
699xtag_next_child (XTag * xtag, const char * name)
700{
701 AnxList * l;
702 XTag * child;
703
704 if (xtag == NULL) return NULL;
705
706 if ((l = xtag->current_child) == NULL)
707 return xtag_first_child (xtag, name);
708
709 if ((l = l->next) == NULL)
710 return NULL;
711
712 if (name == NULL) {
713 xtag->current_child = l;
714 return (XTag *)l->data;
715 }
716
717 for (; l; l = l->next) {
718 child = (XTag *)l->data;
719
720 if (child->name && name && !strcmp(child->name, name)) {
721 xtag->current_child = l;
722 return child;
723 }
724 }
725
726 xtag->current_child = NULL;
727
728 return NULL;
729}
730
731/*
732 * This snprints function takes a variable list of char *, the last of
733 * which must be NULL, and prints each in turn to buf.
734 * Returns C99-style total length that would have been written, even if
735 * this is larger than n.
736 */
737static int
738xtag_snprints (char * buf, int n, ...)
739{
740 va_list ap;
741 char * s;
742 int len, to_copy, total = 0;
743
744 va_start (ap, n);
745
746 for (s = va_arg (ap, char *); s; s = va_arg (ap, char *)) {
747 len = (int) strlen (s);
748
749 if ((to_copy = MIN (n, len)) > 0) {
750 if (buf) {
751 memcpy (buf, s, to_copy);
752 buf += to_copy;
753 }
754 n -= to_copy;
755 }
756
757 total += len;
758 }
759
760 va_end (ap);
761
762 return total;
763}
764
765int
766xtag_snprint (char * buf, int n, XTag * xtag)
767{
768 int nn, written = 0;
769 AnxList * l;
770 XAttribute * attr;
771 XTag * child;
772
773#define FORWARD(N) \
774 if (buf) buf += MIN (n, N); \
775 n = MAX (n-N, 0); \
776 written += N;
777
778 /* If a NULL buffer is passed in, ensure it is not written to */
779 if (buf == NULL) n = 0;
780
781 if (xtag == NULL) {
782 if (n > 0) buf[0] = '\0';
783 return 0;
784 }
785
786 if (xtag->pcdata) {
787 nn = xtag_snprints (buf, n, xtag->pcdata, NULL);
788 FORWARD(nn);
789
790 return written;
791 }
792
793 if (xtag->name) {
794 nn = xtag_snprints (buf, n, "<", xtag->name, NULL);
795 FORWARD(nn);
796
797 for (l = xtag->attributes; l; l = l->next) {
798 attr = (XAttribute *)l->data;
799
800 nn = xtag_snprints (buf, n, " ", attr->name, "=\"", attr->value, "\"",
801 NULL);
802 FORWARD(nn);
803 }
804
805 if (xtag->children == NULL) {
806 nn = xtag_snprints (buf, n, "/>", NULL);
807 FORWARD(nn);
808
809 return written;
810 }
811
812 nn = xtag_snprints (buf, n, ">", NULL);
813 FORWARD(nn);
814 }
815
816 for (l = xtag->children; l; l = l->next) {
817 child = (XTag *)l->data;
818
819 nn = xtag_snprint (buf, n, child);
820 FORWARD(nn);
821 }
822
823 if (xtag->name) {
824 nn = xtag_snprints (buf, n, "</", xtag->name, ">", NULL);
825 FORWARD(nn);
826 }
827
828 return written;
829}
diff --git a/pres/xtag.h b/pres/xtag.h
new file mode 100644
index 0000000..fec5157
--- /dev/null
+++ b/pres/xtag.h
@@ -0,0 +1,135 @@
1/*
2 Copyright (C) 2003 Commonwealth Scientific and Industrial Research
3 Organisation (CSIRO) Australia
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15
16 - Neither the name of CSIRO Australia nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33/**
34 * \file xtag.h
35 *
36 * XTag: A trivial parser for xml-like tags.
37 *
38 * API Version: 1.0
39 * Author: Conrad Parker, 2003
40 */
41
42#ifndef __XTAG_H__