summaryrefslogtreecommitdiff
path: root/src/examples/edje
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-04 02:08:14 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-04 02:08:14 +0000
commit9ea2ce1041549c90f94062ce5ec145056e7fbdfa (patch)
tree3bcd3fb016bc498a72ff99c8d67c8b7ef2d91718 /src/examples/edje
parente2ce20e9a4dfd12bb383a1b60032f2ef7b507850 (diff)
efl: merge edje.
this is still in progress, mostly the multisense stuff is pending. it seems that when we merge ecore_audio in edje the libremix and similar are gone, at least from Edje, and will be in ecore_audio itself (or pulseaudio). Changes: * __UNUSED__ to EINA_UNUSED * binaries (epp, embryo_cc, edje_cc) now consider EFL_RUN_IN_TREE and will assume the binaries are still not installed, running from build tree location (needs more testing, maybe doesn't work with srcdir != builddir, still doesn't solve cross compile builds) SVN revision: 82139
Diffstat (limited to 'src/examples/edje')
-rw-r--r--src/examples/edje/Makefile.am198
-rw-r--r--src/examples/edje/Vera.ttfbin0 -> 65932 bytes
-rw-r--r--src/examples/edje/animations.edc93
-rw-r--r--src/examples/edje/animations2.c96
-rw-r--r--src/examples/edje/animations2.edc48
-rw-r--r--src/examples/edje/basic.edc39
-rw-r--r--src/examples/edje/basic2.edc24
-rw-r--r--src/examples/edje/box.edc142
-rw-r--r--src/examples/edje/bubble-blue.pngbin0 -> 4505 bytes
-rw-r--r--src/examples/edje/bubble.pngbin0 -> 4737 bytes
-rw-r--r--src/examples/edje/codegen.edc84
-rw-r--r--src/examples/edje/color-class.edc87
-rw-r--r--src/examples/edje/drag.edc89
-rw-r--r--src/examples/edje/duck.wavbin0 -> 22982 bytes
-rw-r--r--src/examples/edje/edje-animations.c227
-rw-r--r--src/examples/edje/edje-basic.c257
-rw-r--r--src/examples/edje/edje-basic2.c171
-rw-r--r--src/examples/edje/edje-box.c252
-rw-r--r--src/examples/edje/edje-box2.c247
-rw-r--r--src/examples/edje/edje-codegen-example.c202
-rw-r--r--src/examples/edje/edje-color-class.c295
-rw-r--r--src/examples/edje/edje-drag.c210
-rw-r--r--src/examples/edje/edje-multisense.c80
-rw-r--r--src/examples/edje/edje-nested.edc39
-rw-r--r--src/examples/edje/edje-perspective.c253
-rw-r--r--src/examples/edje/edje-signals-messages.c254
-rw-r--r--src/examples/edje/edje-swallow.c130
-rw-r--r--src/examples/edje/edje-swallow2.c135
-rw-r--r--src/examples/edje/edje-table.c210
-rw-r--r--src/examples/edje/edje-text.c121
-rw-r--r--src/examples/edje/edje_example.c81
-rw-r--r--src/examples/edje/edje_example.edc101
-rw-r--r--src/examples/edje/embryo_custom_state.edc184
-rw-r--r--src/examples/edje/embryo_pong.edc270
-rw-r--r--src/examples/edje/embryo_run_program.edc66
-rw-r--r--src/examples/edje/embryo_set_state.edc46
-rw-r--r--src/examples/edje/embryo_set_text.edc39
-rw-r--r--src/examples/edje/embryo_timer.edc90
-rw-r--r--src/examples/edje/external_elm_anchorblock.edc160
-rw-r--r--src/examples/edje/external_elm_button.edc270
-rw-r--r--src/examples/edje/external_elm_check.edc211
-rw-r--r--src/examples/edje/external_elm_panes.edc140
-rw-r--r--src/examples/edje/external_emotion_elm.edc239
-rw-r--r--src/examples/edje/lua_script.edc417
-rw-r--r--src/examples/edje/messages_echo.edc97
-rw-r--r--src/examples/edje/multisense.edc91
-rw-r--r--src/examples/edje/perspective.edc140
-rw-r--r--src/examples/edje/physics_3d.edc271
-rw-r--r--src/examples/edje/physics_actions.edc573
-rw-r--r--src/examples/edje/physics_backcull.edc228
-rw-r--r--src/examples/edje/physics_basic.edc86
-rw-r--r--src/examples/edje/physics_complex.edc142
-rw-r--r--src/examples/edje/physics_soft_bodies.edc197
-rw-r--r--src/examples/edje/red.pngbin0 -> 225 bytes
-rw-r--r--src/examples/edje/signals-messages.edc174
-rw-r--r--src/examples/edje/signals2.c134
-rw-r--r--src/examples/edje/signalsBubble.edc22
-rw-r--r--src/examples/edje/sigtest.c341
-rw-r--r--src/examples/edje/sigtest.edc303
-rw-r--r--src/examples/edje/swallow.edc21
-rw-r--r--src/examples/edje/table.edc19
-rw-r--r--src/examples/edje/test.pngbin0 -> 22869 bytes
-rw-r--r--src/examples/edje/text.edc68
-rw-r--r--src/examples/edje/toggle_using_filter.edc66
64 files changed, 9270 insertions, 0 deletions
diff --git a/src/examples/edje/Makefile.am b/src/examples/edje/Makefile.am
new file mode 100644
index 0000000000..d1f587668e
--- /dev/null
+++ b/src/examples/edje/Makefile.am
@@ -0,0 +1,198 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3EDJE_CC = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/edje/edje_cc
4EDJE_CC_FLAGS_VERBOSE_0 =
5EDJE_CC_FLAGS_VERBOSE_1 = -v
6EDJE_CC_FLAGS = $(EDJE_CC_FLAGS_VERBOSE_$(V)) -id $(srcdir) -fd $(srcdir)
7
8AM_V_EDJ = $(am__v_EDJ_$(V))
9am__v_EDJ_ = $(am__v_EDJ_$(AM_DEFAULT_VERBOSITY))
10am__v_EDJ_0 = @echo " EDJ " $@;
11
12EDJE_CODEGEN = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/edje/edje_codegen
13EDJE_CODEGEN_FLAGS = --prefix=codegen_example
14
15AM_V_GEN = $(am__v_GEN_$(V))
16am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
17am__v_GEN_0 = @echo " GEN " $@;
18
19examplesdir = $(datadir)/edje/examples
20
21if ENABLE_MULTISENSE
22SND_DIR = -sd $(srcdir)
23endif
24
25#put here all EDCs one needs to the examples
26EDCS = \
27animations2.edc \
28animations.edc \
29basic2.edc \
30basic.edc \
31box.edc \
32codegen.edc \
33color-class.edc \
34drag.edc \
35edje_example.edc \
36edje-nested.edc \
37embryo_custom_state.edc \
38embryo_pong.edc \
39embryo_run_program.edc \
40embryo_set_state.edc \
41embryo_set_text.edc \
42embryo_timer.edc \
43external_elm_anchorblock.edc \
44external_elm_button.edc \
45external_elm_check.edc \
46external_elm_panes.edc \
47external_emotion_elm.edc \
48lua_script.edc \
49messages_echo.edc \
50perspective.edc \
51signalsBubble.edc \
52signals-messages.edc \
53sigtest.edc \
54swallow.edc \
55table.edc \
56text.edc \
57toggle_using_filter.edc
58
59if ENABLE_MULTISENSE
60EDCS += multisense.edc
61endif
62
63if HAVE_EPHYSICS
64EDCS += \
65physics_3d.edc \
66physics_actions.edc \
67physics_backcull.edc \
68physics_basic.edc \
69physics_complex.edc \
70physics_soft_bodies.edc
71endif
72
73.edc.edj:
74 $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $(SND_DIR) $< $(builddir)/$(@F)
75
76
77EDJS = $(EDCS:%.edc=%.edj)
78
79filesdir = $(datadir)/edje/examples
80files_DATA = \
81$(EDCS) \
82bubble.png \
83bubble-blue.png \
84red.png \
85test.png \
86Vera.ttf \
87duck.wav \
88edje-codegen-example.c \
89edje_example.c \
90edje-basic.c \
91edje-swallow.c \
92edje-text.c \
93edje-table.c \
94edje-box.c \
95edje-box2.c \
96edje-drag.c \
97edje-signals-messages.c \
98edje-color-class.c \
99edje-perspective.c \
100edje-animations.c \
101sigtest.c \
102animations2.c \
103edje-basic2.c \
104signals2.c \
105edje-swallow2.c
106
107if ENABLE_MULTISENSE
108files_DATA += edje-multisense.c
109endif
110
111EXTRA_DIST = $(files_DATA)
112
113AM_CPPFLAGS = \
114-I. \
115-I$(top_srcdir)/src/lib/eina \
116-I$(top_builddir)/src/lib/eina \
117-I$(top_srcdir)/src/lib/eo \
118-I$(top_builddir)/src/lib/eo \
119-I$(top_srcdir)/src/lib/eet \
120-I$(top_builddir)/src/lib/eet \
121-I$(top_srcdir)/src/lib/evas \
122-I$(top_builddir)/src/lib/evas \
123-I$(top_srcdir)/src/lib/ecore \
124-I$(top_builddir)/src/lib/ecore \
125-I$(top_srcdir)/src/lib/ecore_evas \
126-I$(top_builddir)/src/lib/ecore_evas \
127-I$(top_srcdir)/src/lib/ecore_file \
128-I$(top_builddir)/src/lib/ecore_file \
129-I$(top_srcdir)/src/lib/ecore_input \
130-I$(top_builddir)/src/lib/ecore_input \
131-I$(top_srcdir)/src/lib/ecore_imf \
132-I$(top_builddir)/src/lib/ecore_imf \
133-I$(top_srcdir)/src/lib/embryo \
134-I$(top_builddir)/src/lib/embryo \
135-I$(top_srcdir)/src/lib/edje \
136-I$(top_srcdir)/src/lib/edje/include \
137-DPACKAGE_BIN_DIR=\"$(bindir)\" \
138-DPACKAGE_LIB_DIR=\"$(libdir)\" \
139-DPACKAGE_DATA_DIR=\"$(datadir)/edje\" \
140@EDJE_CFLAGS@
141
142codegen_example_generated.c codegen_example_generated.h: codegen.edj
143 $(AM_V_GEN)$(EDJE_CODEGEN) $(EDJE_CODEGEN_FLAGS) codegen.edj example_group $(builddir)/codegen_example_generated.c $(builddir)/codegen_example_generated.h
144
145BUILT_SOURCES = codegen_example_generated.c codegen_example_generated.h
146
147edje_codegen_example_SOURCES = \
148edje-codegen-example.c
149nodist_edje_codegen_example_SOURCES = \
150codegen_example_generated.c \
151codegen_example_generated.h
152
153files_DATA += $(EDJS)
154
155examples_PROGRAMS = \
156edje-animations \
157edje-basic \
158edje-box \
159edje-box2 \
160edje-codegen-example \
161edje-color-class \
162edje-drag\
163edje-perspective \
164edje-signals-messages \
165edje-swallow \
166edje-table \
167edje-text \
168sigtest \
169animations2 \
170edje-basic2 \
171signals2 \
172edje-swallow2
173
174if ENABLE_MULTISENSE
175examples_PROGRAMS += edje-multisense
176endif
177
178LDADD = \
179$(top_builddir)/src/lib/eina/libeina.la \
180$(top_builddir)/src/lib/eo/libeo.la \
181$(top_builddir)/src/lib/eet/libeet.la \
182$(top_builddir)/src/lib/evas/libevas.la \
183$(top_builddir)/src/lib/ecore/libecore.la \
184$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \
185$(top_builddir)/src/lib/ecore_file/libecore_file.la \
186$(top_builddir)/src/lib/ecore_input/libecore_input.la \
187$(top_builddir)/src/lib/ecore_imf/libecore_imf.la \
188$(top_builddir)/src/lib/ecore_imf/libecore_imf_evas.la \
189$(top_builddir)/src/lib/embryo/libembryo.la \
190$(top_builddir)/src/lib/edje/libedje.la \
191@EDJE_LDFLAGS@
192
193if HAVE_EPHYSICS
194LDADD += $(top_builddir)/src/lib/ephysics/libephysics.la
195endif
196
197clean-local:
198 rm -f *.edj
diff --git a/src/examples/edje/Vera.ttf b/src/examples/edje/Vera.ttf
new file mode 100644
index 0000000000..58cd6b5e61
--- /dev/null
+++ b/src/examples/edje/Vera.ttf
Binary files differ
diff --git a/src/examples/edje/animations.edc b/src/examples/edje/animations.edc
new file mode 100644
index 0000000000..f25296fdb2
--- /dev/null
+++ b/src/examples/edje/animations.edc
@@ -0,0 +1,93 @@
1collections {
2 group {
3 name: "animations_group";
4 min: 100 80;
5
6 parts {
7 part {
8 name: "part_one";
9 type: RECT;
10 scale: 1;
11 description {
12 min: 50 50;
13 state: "default" 0.0;
14 color: 0 0 0 255; /* black */
15 rel1.relative: 0.0 0.0;
16 rel2.relative: 0.33 1.0;
17 }
18 description {
19 state: "invert" 1.0;
20 inherit: "default" 0.0;
21 rel1.relative: 0.0 0.0;
22 rel2.relative: 1.0 0.33;
23 }
24 }
25
26 part {
27 name: "part_two";
28 type: RECT;
29 scale: 1;
30 description {
31 min: 50 50;
32 state: "default" 0.0;
33 color: 255 255 0 255; /* yellow */
34 rel1.relative: 0.33 0.0;
35 rel2.relative: 0.66 1.0;
36 }
37 description {
38 state: "invert" 1.0;
39 inherit: "default" 0.0;
40 rel1.relative: 0.0 0.66;
41 rel2.relative: 1.0 1.0;
42 }
43 }
44
45 part {
46 name: "part_three";
47 type: RECT;
48 description {
49 state: "default" 0.0;
50 color: 255 0 0 255; /* red */
51 rel1.relative: 0.66 0.0;
52 rel2.relative: 1.0 1.0;
53 }
54 description {
55 state: "invert" 1.0;
56 inherit: "default" 0.0;
57 rel1.relative: 0.0 0.33;
58 rel2.relative: 1.0 0.66;
59 }
60 }
61 }
62
63 program {
64 signal: "load";
65 source: "";
66 in: 2.0 0.0;
67 after: "animation,state1";
68 }
69 program {
70 name: "animation,state1";
71 signal: "animation,start";
72 source: "";
73 in: 1.0 0.0;
74 action: STATE_SET "invert" 1.0;
75 target: "part_one";
76 target: "part_two";
77 target: "part_three";
78 transition: LINEAR 0.6;
79 after: "animation,state2";
80 }
81 program {
82 name: "animation,state2";
83 signal: "animation,start";
84 source: "";
85 in: 1.0 0.0;
86 action: STATE_SET "default" 0.0;
87 target: "part_one";
88 target: "part_two";
89 target: "part_three";
90 transition: LINEAR 0.6;
91 after: "animation,state1";
92 }
93}
diff --git a/src/examples/edje/animations2.c b/src/examples/edje/animations2.c
new file mode 100644
index 0000000000..045c5cc0e5
--- /dev/null
+++ b/src/examples/edje/animations2.c
@@ -0,0 +1,96 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#else
4#define PACKAGE_EXAMPLES_DIR "."
5#define EINA_UNUSED
6#endif
7
8#include <Ecore.h>
9#include <Ecore_Evas.h>
10#include <Edje.h>
11#include <stdio.h>
12
13#define WIDTH (700)
14#define HEIGHT (700)
15
16static void
17_on_delete(Ecore_Evas *ee)
18{
19 ecore_main_loop_quit();
20}
21
22int
23main(int argc EINA_UNUSED, char **argv)
24{
25 char edje_file_path[PATH_MAX];
26 const char *edje_file = "animations2.edj";
27 Evas *evas;
28 Ecore_Evas *ee;
29 Eina_Prefix *pfx;
30 Evas_Object *edje_obj;
31 Evas_Object *bg;
32
33 if (!ecore_evas_init()) return EXIT_FAILURE;
34
35 if (!edje_init()) goto shutdown_ecore_evas;
36
37 pfx = eina_prefix_new(argv[0], main, "EDJE_EXAMPLES", "edje/examples",
38 edje_file, PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
39 PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
40
41 if (!pfx) goto shutdown_edje;
42
43 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
44
45 if (!ee) goto eina_prefix_free;
46
47 ecore_evas_callback_delete_request_set(ee, _on_delete);
48 ecore_evas_title_set(ee, "Animations");
49
50 evas = ecore_evas_get(ee);
51
52 bg = evas_object_rectangle_add(evas);
53 evas_object_color_set(bg, 255, 255, 255, 255);
54 evas_object_move(bg, 0, 0);
55 evas_object_resize(bg, WIDTH, HEIGHT);
56 evas_object_show(bg);
57
58 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
59 evas_object_focus_set(bg, EINA_TRUE);
60
61 edje_obj = edje_object_add(evas);
62
63 snprintf(edje_file_path, sizeof(edje_file_path), "%s/examples/%s",
64 eina_prefix_data_get(pfx), edje_file);
65
66 if (!edje_object_file_set(edje_obj, edje_file_path, "animation_group"))
67 {
68 int err = edje_object_load_error_get(edje_obj);
69 const char *errmsg = edje_load_error_str(err);
70 fprintf(stderr, "Could not load the edje file - reason:%s\n", errmsg);
71 goto eina_prefix_free;
72 }
73
74 evas_object_resize(edje_obj, 700, 700);
75 evas_object_move(edje_obj, 50, 50);
76 evas_object_show(edje_obj);
77
78 ecore_evas_show(ee);
79
80 ecore_main_loop_begin();
81
82 eina_prefix_free(pfx);
83 ecore_evas_free(ee);
84 edje_shutdown();
85 ecore_evas_shutdown();
86
87 return EXIT_SUCCESS;
88
89 eina_prefix_free: eina_prefix_free(pfx);
90
91 shutdown_edje: edje_shutdown();
92
93 shutdown_ecore_evas: ecore_evas_shutdown();
94
95 return EXIT_FAILURE;
96}
diff --git a/src/examples/edje/animations2.edc b/src/examples/edje/animations2.edc
new file mode 100644
index 0000000000..eb7e81c583
--- /dev/null
+++ b/src/examples/edje/animations2.edc
@@ -0,0 +1,48 @@
1collections {
2 group {
3 name: "animation_group";
4 max: 700 700;
5 min: 700 700;
6 images{
7 image: "bubble.png" COMP;
8 }
9 parts{
10 part{
11 name: "part_bubble";
12 type: IMAGE;
13 description{
14 state: "default" 0.0;
15 max: 63 63;
16 min: 63 63;
17 image{
18 normal: "bubble.png";
19 }
20 rel1.relative: 0.0 0.0;
21 rel2.relative: 0.0 0.0;
22 }
23 description {
24 state: "down-state" 1.0;
25 inherit: "default" 0.0;
26 rel1.relative: 0.0 1.0;
27 rel2.relative: 0.0 0.0;
28 }
29 }
30
31 }
32 programs{
33 program {
34 signal: "load";
35 source: "";
36 in: 0.5 0.0;
37 after: "animation,state1";
38 }
39 program {
40 name: "animation,state1";
41 source: "";
42 action: STATE_SET "down-state" 1.0;
43 target: "part_bubble";
44 transition: BOUNCE 2.5 0.0 5.0;
45 }
46 }
47 }
48}
diff --git a/src/examples/edje/basic.edc b/src/examples/edje/basic.edc
new file mode 100644
index 0000000000..a708b507f9
--- /dev/null
+++ b/src/examples/edje/basic.edc
@@ -0,0 +1,39 @@
1collections {
2 group {
3 name: "example_group";
4 max: 500 500;
5 min: 50 50;
6
7 data {
8 item: "example_data" "a string";
9 }
10
11 parts {
12 part {
13 name: "part_one";
14 type: RECT;
15 scale: 1;
16 description {
17 min: 50 50;
18 max: 50 50;
19 state: "default" 0.0;
20 color: 0 0 255 255; /* blue */
21 rel1.relative: 0.0 0.0;
22 rel2.relative: 1.0 1.0;
23 }
24 }
25
26 part {
27 name: "part_two";
28 type: RECT;
29 description {
30 state: "default" 0.0;
31 color: 0 255 0 255; /* green */
32 rel1.relative: -1.0 -1.0;
33 rel2.relative: 0.0 0.0;
34 }
35 }
36 }
37
38 }
39}
diff --git a/src/examples/edje/basic2.edc b/src/examples/edje/basic2.edc
new file mode 100644
index 0000000000..e60e2685ec
--- /dev/null
+++ b/src/examples/edje/basic2.edc
@@ -0,0 +1,24 @@
1collections {
2 group {
3 name: "image_group";
4 max: 500 500;
5 min: 50 50;
6
7 images{
8 image: "bubble.png" COMP;
9 }
10
11 parts{
12 part{
13 name: "part_image";
14 type: IMAGE;
15 description{
16 image{
17 normal: "bubble.png";
18 }
19 }
20 }
21 }
22
23 }
24}
diff --git a/src/examples/edje/box.edc b/src/examples/edje/box.edc
new file mode 100644
index 0000000000..79d04a889c
--- /dev/null
+++ b/src/examples/edje/box.edc
@@ -0,0 +1,142 @@
1collections {
2
3 group {
4 name: "example/group";
5
6 parts {
7 part {
8 name: "bg";
9 type: RECT;
10
11 description {
12 state: "default" 0.0;
13 color: 128 128 128 255;
14 rel1.offset: 20 20;
15 rel2.offset: -21 -21;
16 }
17 }
18
19 part {
20 name: "example/title";
21 type: TEXT;
22
23 description {
24 state: "default" 0.0;
25 color: 0 0 0 255;
26 rel1 {
27 relative: 0.0 0.0;
28 offset: 0 0;
29 to: "bg";
30 }
31 rel2 {
32 relative: 1.0 0.2;
33 offset: -1 -1;
34 to: "bg";
35 }
36 text {
37 text: "Box Example";
38 size: 16;
39 font: "sans";
40 min: 1 1;
41 }
42 }
43 }
44
45 part {
46 name: "example/box";
47 type: BOX;
48
49 description {
50 state: "default" 0.0;
51
52 box {
53 layout: "horizontal_flow";
54 padding: 2 2;
55 align: 0.5 0.5;
56 min: 1 1;
57 }
58 rel1 {
59 relative: 0.0 0.2;
60 offset: 0 0;
61 to: "bg";
62 }
63 rel2 {
64 relative: 1.0 1.0;
65 offset: -1 -61;
66 to: "bg";
67 }
68 }
69 } // example/box
70 }
71 }
72
73 group {
74 name: "example/group2";
75
76 parts {
77 part {
78 name: "bg";
79 type: RECT;
80
81 description {
82 state: "default" 0.0;
83 color: 128 128 128 255;
84 rel1.offset: 20 20;
85 rel2.offset: -21 -21;
86 }
87 }
88
89 part {
90 name: "example/title";
91 type: TEXT;
92
93 description {
94 state: "default" 0.0;
95 color: 0 0 0 255;
96 rel1 {
97 relative: 0.0 0.0;
98 offset: 0 0;
99 to: "bg";
100 }
101 rel2 {
102 relative: 1.0 0.2;
103 offset: -1 -1;
104 to: "bg";
105 }
106 text {
107 text: "Box Example 2";
108 size: 16;
109 font: "sans";
110 min: 1 1;
111 }
112 }
113 }
114
115 part {
116 name: "example/box";
117 type: BOX;
118
119 description {
120 state: "default" 0.0;
121
122 box {
123 layout: "custom_layout";
124 padding: 2 2;
125 align: 0.5 0.5;
126 min: 1 1;
127 }
128 rel1 {
129 relative: 0.0 0.2;
130 offset: 0 0;
131 to: "bg";
132 }
133 rel2 {
134 relative: 1.0 1.0;
135 offset: -1 -61;
136 to: "bg";
137 }
138 }
139 } // example/box
140 }
141 }
142}
diff --git a/src/examples/edje/bubble-blue.png b/src/examples/edje/bubble-blue.png
new file mode 100644
index 0000000000..7cf4dcdc5e
--- /dev/null
+++ b/src/examples/edje/bubble-blue.png
Binary files differ
diff --git a/src/examples/edje/bubble.png b/src/examples/edje/bubble.png
new file mode 100644
index 0000000000..8fc50f93aa
--- /dev/null
+++ b/src/examples/edje/bubble.png
Binary files differ
diff --git a/src/examples/edje/codegen.edc b/src/examples/edje/codegen.edc
new file mode 100644
index 0000000000..5560581baf
--- /dev/null
+++ b/src/examples/edje/codegen.edc
@@ -0,0 +1,84 @@
1collections {
2
3 group {
4
5 name: "example_group";
6 min: 50 50;
7
8 styles {
9 style {
10 name: "textblock_style";
11 base: "font=Sans font_size=22 color=#600 wrap=word";
12 tag: "br" "\n";
13 tag: "hilight" "+ font_weight=Bold";
14 tag: "b" "+ font_weight=Bold";
15 tag: "tab" "\t";
16 }
17 }
18 parts {
19 part {
20 name: "part_one";
21 type: TEXT;
22 api: "part_one";
23 description {
24 min: 50 50;
25 state: "default" 0.0;
26 color: 0 0 255 255; /* blue */
27 rel1.relative: 0.0 0.0;
28 rel2.relative: 1.0 0.3;
29 text {
30 font: "arial";
31 size: 22;
32 min: 1 1;
33 }
34 }
35 }
36 part {
37 name: "part_two";
38 type: SWALLOW;
39 api: "part_two" "The swallow";
40 description {
41 min: 50 50;
42 state: "default" 0.0;
43 rel1.relative: 0.0 0.3;
44 rel2.relative: 0.3 0.6;
45 }
46 }
47
48 part {
49 name: "part_three";
50 type: BOX;
51 api: "part_three" "The BOX";
52 description {
53 state: "default" 0.0;
54 box {
55 layout: "vertical_homogeneous";
56 }
57 rel1.relative: 0.0 0.6;
58 rel2.relative: 0.5 1.0;
59 }
60 }
61 part {
62 name: "part_four";
63 type: TABLE;
64 api: "part_four" "The TABLE";
65 description {
66 state: "default" 0.0;
67 rel1.relative: 0.5 0.6;
68 rel2.relative: 1.0 1.0;
69 }
70 }
71
72 }
73
74 programs {
75 program {
76 name: "part_below.hovered";
77 signal: "mouse,move";
78 source: "part_one";
79 action: SIGNAL_EMIT "mouse,over" "part_below";
80 api: "part_below_over" "mouse over";
81 }
82 }
83 }
84}
diff --git a/src/examples/edje/color-class.edc b/src/examples/edje/color-class.edc
new file mode 100644
index 0000000000..c025455a99
--- /dev/null
+++ b/src/examples/edje/color-class.edc
@@ -0,0 +1,87 @@
1color_classes {
2 color_class {
3 name: "red_class";
4 color: 255 0 0 255; /* red */
5 color2: 255 0 0 255; /* red */
6 color3: 255 0 0 255; /* red */
7 }
8 color_class {
9 name: "green_class";
10 color: 0 255 0 255; /* green */
11 color2: 0 255 0 255; /* green */
12 color3: 0 255 0 255; /* green */
13 }
14 color_class {
15 name: "blue_class";
16 color: 0 0 255 255; /* blue */
17 color2: 0 0 255 255; /* blue */
18 color3: 0 0 255 255; /* blue */
19 }
20}
21
22collections {
23 group {
24 name: "example_color_class";
25 max: 500 500;
26 min: 50 50;
27
28 parts {
29 part {
30 name: "part_one";
31 type: RECT;
32 scale: 1;
33 description {
34 state: "default" 0.0;
35 color: 255 255 255 255;
36 color_class: "blue_class";
37 rel1.relative: 0.0 0.0;
38 rel2.relative: 0.5 0.5;
39 }
40 }
41
42 part {
43 name: "part_two";
44 type: RECT;
45 description {
46 state: "default" 0.0;
47 color: 255 255 255 255;
48 color_class: "green_class";
49 rel1.relative: 0.5 0.0;
50 rel2.relative: 1.0 0.5;
51 }
52 }
53 part {
54 name: "part_three";
55 type: RECT;
56 description {
57 state: "default" 0.0;
58 color: 255 255 255 255;
59 color_class: "red_class";
60 rel1.relative: 0.0 0.5;
61 rel2.relative: 1.0 1.0;
62 }
63 }
64 part {
65 name: "part_four";
66 type: TEXT;
67 effect: OUTLINE_SHADOW;
68 description {
69 state: "default" 0.0;
70 min: 50 50;
71 color: 255 255 255 255;
72 color2: 255 255 255 255;
73 color3: 255 255 255 255;
74 color_class: "blue_class";
75 rel1.relative: 0.0 0.5;
76 rel2.relative: 1.0 1.0;
77 text {
78 text_class: "example";
79 font: "arial";
80 size: 45;
81 min: 1 1;
82 }
83 }
84 }
85 }
86 }
87}
diff --git a/src/examples/edje/drag.edc b/src/examples/edje/drag.edc
new file mode 100644
index 0000000000..b9247ec1cf
--- /dev/null
+++ b/src/examples/edje/drag.edc
@@ -0,0 +1,89 @@
1collections {
2 group {
3 name: "example/group";
4
5 min: 160 160;
6
7 parts {
8 part {
9 name: "bg";
10 type: RECT;
11
12 mouse_events: 0;
13
14 description {
15 state: "default" 0.0;
16 }
17 } // bg
18
19 part {
20 name: "title";
21 type: TEXT;
22 mouse_events: 0;
23
24 description {
25 state: "default" 0.0;
26 color: 0 0 0 255;
27 rel1 {
28 relative: 0.0 0.0;
29 offset: 0 0;
30 to: "bg";
31 }
32 rel2 {
33 relative: 1.0 0.2;
34 offset: -1 -1;
35 to: "bg";
36 }
37 text {
38 text: "Drag Example";
39 size: 16;
40 font: "sans";
41 min: 1 1;
42 }
43 }
44 }
45
46 part {
47 name: "drag_area";
48 type: RECT;
49
50 mouse_events: 0;
51
52 description {
53 state: "default" 0.0;
54 color: 0 0 0 255;
55 rel1 {
56 relative: 0.5 0.3;
57 offset: -5 0;
58 }
59
60 rel2 {
61 relative: 0.5 0.9;
62 offset: 4 0;
63 }
64 }
65 } // drag_area
66
67 part {
68 name: "example/knob";
69 type: RECT;
70
71 mouse_events: 1;
72
73 dragable {
74 confine: "drag_area";
75 x: 0 0 0;
76 y: 1 1 0;
77 }
78
79 description {
80 state: "default" 0.0;
81
82 color: 255 0 0 200;
83
84 }
85 } // example/knob
86
87 }
88 }
89}
diff --git a/src/examples/edje/duck.wav b/src/examples/edje/duck.wav
new file mode 100644
index 0000000000..04a62dce97
--- /dev/null
+++ b/src/examples/edje/duck.wav
Binary files differ
diff --git a/src/examples/edje/edje-animations.c b/src/examples/edje/edje-animations.c
new file mode 100644
index 0000000000..c873781ec6
--- /dev/null
+++ b/src/examples/edje/edje-animations.c
@@ -0,0 +1,227 @@
1/**
2 * Simple Edje example illustrating animations functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc animations.edc && gcc -o edje-animations edje-animations.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH (400)
23#define HEIGHT (300)
24
25static const char commands[] = \
26 "commands are:\n"
27 "\t+ - increase frametime\n"
28 "\t- - decrease frametime\n"
29 "\t= - status of the animation\n"
30 "\ts - pause\n"
31 "\tp - play\n"
32 "\tf - freeze one object\n"
33 "\tF - freeze all objects\n"
34 "\tt - thaw one object\n"
35 "\tT - thaw all objects\n"
36 "\ta - start animation of one object\n"
37 "\tA - stop animation of one object\n"
38 "\tEsc - exit\n"
39 "\th - print help\n";
40
41static double frametime = 1.0 / 30.0; /* default value */
42
43static void
44_on_delete_cb(Ecore_Evas *ee EINA_UNUSED)
45{
46 ecore_main_loop_quit();
47}
48
49static void
50_on_canvas_resize(Ecore_Evas *ee)
51{
52 Evas_Object *bg;
53 Evas_Object *edje_obj;
54 int w;
55 int h;
56
57 bg = ecore_evas_data_get(ee, "background");
58 edje_obj = ecore_evas_data_get(ee, "edje_obj");
59 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
60 evas_object_resize(bg, w, h);
61 evas_object_resize(edje_obj, w, h);
62}
63
64static void
65_on_key_down(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event_info)
66{
67 Evas_Event_Key_Down *ev;
68 double ft;
69
70 ev = (Evas_Event_Key_Down *)event_info;
71
72 if (!strcmp(ev->keyname, "h"))
73 {
74 fprintf(stdout, commands);
75 return;
76 }
77 else if (!strcmp(ev->key, "plus"))
78 {
79 frametime *= 2.0;
80 fprintf(stdout, "Increasing frametime to: %f\n", frametime);
81 edje_frametime_set(frametime);
82 }
83 else if (!strcmp(ev->key, "minus"))
84 {
85 frametime /= 2.0;
86 fprintf(stdout, "Decreasing frametime to: %f\n", frametime);
87 edje_frametime_set(frametime);
88 }
89 else if (!strcmp(ev->key, "equal"))
90 {
91 ft = edje_frametime_get();
92 fprintf(stdout, "Frametime: %f\n", ft);
93 if (edje_object_play_get(obj))
94 fprintf(stdout, "Object is playing\n");
95 else
96 fprintf(stdout, "Object was paused\n");
97 if (edje_object_animation_get(obj))
98 fprintf(stdout, "Animation is running\n");
99 else
100 fprintf(stdout, "Animation was stopped\n");
101 }
102 else if (!strcmp(ev->key, "s"))
103 {
104 edje_object_play_set(obj, EINA_FALSE);
105 fprintf(stdout, "Pausing the object\n");
106 }
107 else if (!strcmp(ev->key, "p"))
108 {
109 edje_object_play_set(obj, EINA_TRUE);
110 fprintf(stdout, "Playing the object\n");
111 }
112 else if (!strcmp(ev->key, "f"))
113 fprintf(stdout, "Freezing object. Count: %d\n", edje_object_freeze(obj));
114 else if (!strcmp(ev->key, "t"))
115 fprintf(stdout, "Thawing object. Count: %d\n", edje_object_thaw(obj));
116 else if (!strcmp(ev->key, "F"))
117 {
118 edje_freeze();
119 fprintf(stdout, "Freezing all objects\n");
120 }
121 else if (!strcmp(ev->key, "T"))
122 {
123 edje_thaw();
124 fprintf(stdout, "Thawing all objects\n");
125 }
126 else if (!strcmp(ev->key, "a"))
127 {
128 edje_object_animation_set(obj, EINA_TRUE);
129 fprintf(stdout, "Starting the animation in the Edje object\n");
130 }
131 else if (!strcmp(ev->key, "A"))
132 {
133 edje_object_animation_set(obj, EINA_FALSE);
134 fprintf(stdout, "Stopping the animation in the Edje object\n");
135 }
136 else if (!strcmp(ev->keyname, "Escape"))
137 ecore_main_loop_quit();
138 else
139 {
140 printf("unhandled key: %s\n", ev->keyname);
141 fprintf(stdout, commands);
142 }
143}
144
145int
146main(int argc EINA_UNUSED, char *argv[])
147{
148 char edje_file_path[PATH_MAX];
149 const char *edje_file = "animations.edj";
150 Ecore_Evas *ee;
151 Evas *evas;
152 Evas_Object *bg;
153 Evas_Object *edje_obj;
154 Eina_Prefix *pfx;
155
156 if (!ecore_evas_init())
157 return EXIT_FAILURE;
158
159 if (!edje_init())
160 goto shutdown_ecore_evas;
161
162 pfx = eina_prefix_new(argv[0], main,
163 "EDJE_EXAMPLES",
164 "edje/examples",
165 edje_file,
166 PACKAGE_BIN_DIR,
167 PACKAGE_LIB_DIR,
168 PACKAGE_DATA_DIR,
169 PACKAGE_DATA_DIR);
170 if (!pfx)
171 goto shutdown_edje;
172
173 /* this will give you a window with an Evas canvas under the first
174 * engine available */
175 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
176 if (!ee)
177 goto free_prefix;
178
179 ecore_evas_callback_delete_request_set(ee, _on_delete_cb);
180 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
181 ecore_evas_title_set(ee, "Edje Animations Example");
182
183 evas = ecore_evas_get(ee);
184
185 bg = evas_object_rectangle_add(evas);
186 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
187 evas_object_move(bg, 0, 0); /* at canvas' origin */
188 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
189 evas_object_show(bg);
190 ecore_evas_data_set(ee, "background", bg);
191
192 edje_obj = edje_object_add(evas);
193
194 snprintf(edje_file_path, sizeof(edje_file_path),
195 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
196 edje_object_file_set(edje_obj, edje_file_path, "animations_group");
197 evas_object_move(edje_obj, 0, 0);
198 evas_object_resize(edje_obj, WIDTH, HEIGHT);
199 evas_object_show(edje_obj);
200 ecore_evas_data_set(ee, "edje_obj", edje_obj);
201
202 evas_object_event_callback_add(edje_obj, EVAS_CALLBACK_KEY_DOWN,
203 _on_key_down, NULL);
204 evas_object_focus_set(edje_obj, EINA_TRUE);
205
206 fprintf(stdout, commands);
207
208 ecore_evas_show(ee);
209
210 ecore_main_loop_begin();
211
212 eina_prefix_free(pfx);
213 ecore_evas_free(ee);
214 ecore_evas_shutdown();
215 edje_shutdown();
216
217 return EXIT_SUCCESS;
218
219 free_prefix:
220 eina_prefix_free(pfx);
221 shutdown_edje:
222 edje_shutdown();
223 shutdown_ecore_evas:
224 ecore_evas_shutdown();
225
226 return EXIT_FAILURE;
227}
diff --git a/src/examples/edje/edje-basic.c b/src/examples/edje/edje-basic.c
new file mode 100644
index 0000000000..4d4bc27531
--- /dev/null
+++ b/src/examples/edje/edje-basic.c
@@ -0,0 +1,257 @@
1/**
2 * Simple Edje example illustrating the very basic functions of the
3 * library
4 *
5 * You'll need at least one Evas engine built for it (excluding the
6 * buffer one). See stdout/stderr for output.
7 *
8 * @verbatim
9 * gcc -o edje-basic edje-basic.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
10 * @endverbatim
11 */
12
13#ifdef HAVE_CONFIG_H
14# include "config.h"
15#else
16# define EINA_UNUSED
17#endif
18
19#include <stdio.h>
20
21#include <Eina.h>
22#include <Ecore.h>
23#include <Ecore_Evas.h>
24#include <Edje.h>
25
26#define WIDTH (300)
27#define HEIGHT (300)
28
29static const char commands[] = \
30 "commands are:\n"
31 "\ts - change Edje's global scaling factor\n"
32 "\tr - change center rectangle's scaling factor\n"
33 "\tEsc - exit\n"
34 "\th - print help\n";
35
36static void
37_on_keydown(void *data,
38 Evas *evas EINA_UNUSED,
39 Evas_Object *o EINA_UNUSED,
40 void *einfo)
41{
42 Evas_Event_Key_Down *ev;
43 Evas_Object *edje_obj;
44
45 ev = (Evas_Event_Key_Down *)einfo;
46 edje_obj = (Evas_Object *)data;
47
48 if (strcmp(ev->keyname, "h") == 0) /* print help */
49 {
50 fprintf(stdout, commands);
51 return;
52 }
53 else if (strcmp(ev->keyname, "s") == 0) /* global scaling factor */
54 {
55 double scale = edje_scale_get();
56
57 printf("got scale %f\n", scale);
58
59 if (scale != 1.0) scale = 1.0;
60 else scale = 2.0;
61
62 edje_scale_set(scale);
63
64 fprintf(stdout, "Setting global scaling factor to %f.\n", scale);
65
66 return;
67 }
68 else if (strcmp(ev->keyname, "r") == 0) /* individual scaling factor */
69 {
70 double scale = edje_object_scale_get(edje_obj);
71
72 printf("got scale %f\n", scale);
73
74 if (!scale) scale = 1.0;
75 else if (scale == 1.0) scale = 2.0;
76 else scale = 0.0;
77
78 edje_object_scale_set(edje_obj, scale);
79
80 fprintf(stdout, "Setting center rectangle's scaling factor to %f.\n",
81 scale);
82
83 return;
84 }
85 else if (!strcmp(ev->keyname, "Escape"))
86 ecore_main_loop_quit();
87 else
88 {
89 printf("unhandled key: %s\n", ev->keyname);
90 fprintf(stdout, commands);
91 }
92}
93
94static void
95_on_delete(Ecore_Evas *ee EINA_UNUSED)
96{
97 ecore_main_loop_quit();
98}
99
100int
101main(int argc EINA_UNUSED, char *argv[])
102{
103 char border_img_path[PATH_MAX];
104 char edje_file_path[PATH_MAX];
105 const char *edje_file = "basic.edj";
106 Ecore_Evas *ee;
107 Evas *evas;
108 Evas_Object *bg;
109 Evas_Object *border;
110 Evas_Object *edje_obj;
111 Eina_Prefix *pfx;
112 int x;
113 int y;
114 int w;
115 int h;
116
117 if (!ecore_evas_init())
118 return EXIT_FAILURE;
119
120 if (!edje_init())
121 goto shutdown_ecore_evas;
122
123 pfx = eina_prefix_new(argv[0], main,
124 "EDJE_EXAMPLES",
125 "edje/examples",
126 edje_file,
127 PACKAGE_BIN_DIR,
128 PACKAGE_LIB_DIR,
129 PACKAGE_DATA_DIR,
130 PACKAGE_DATA_DIR);
131 if (!pfx)
132 goto shutdown_edje;
133
134 /* this will give you a window with an Evas canvas under the first
135 * engine available */
136 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
137 if (!ee)
138 goto free_prefix;
139
140 ecore_evas_callback_delete_request_set(ee, _on_delete);
141 ecore_evas_title_set(ee, "Edje Basics Example");
142
143 evas = ecore_evas_get(ee);
144
145 bg = evas_object_rectangle_add(evas);
146 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
147 evas_object_move(bg, 0, 0); /* at canvas' origin */
148 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
149 evas_object_show(bg);
150 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
151
152 evas_object_focus_set(bg, EINA_TRUE);
153
154 edje_obj = edje_object_add(evas);
155
156 snprintf(edje_file_path, sizeof(edje_file_path),
157 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
158 printf("%s\n", edje_file_path);
159 /* exercising Edje loading error, on purpose */
160 if (!edje_object_file_set(edje_obj, edje_file_path, "unexistant_group"))
161 {
162 int err = edje_object_load_error_get(edje_obj);
163 const char *errmsg = edje_load_error_str(err);
164 fprintf(stderr, "Could not load 'unexistant_group' from basic.edj:"
165 " %s\n", errmsg);
166 }
167
168 if (!edje_object_file_set(edje_obj, edje_file_path, "example_group"))
169 {
170 int err = edje_object_load_error_get(edje_obj);
171 const char *errmsg = edje_load_error_str(err);
172 fprintf(stderr, "Could not load 'example_group' from basic.edj: %s\n",
173 errmsg);
174
175 evas_object_del(edje_obj);
176 goto free_prefix;
177 }
178
179 fprintf(stdout, "Loaded Edje object bound to group 'example_group' from"
180 " file basic.edj with success!\n");
181
182 evas_object_move(edje_obj, 20, 20);
183 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
184 evas_object_show(edje_obj);
185
186 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj);
187
188 snprintf(border_img_path, sizeof(border_img_path),
189 "%s/edje/examples/red.png", eina_prefix_data_get(pfx));
190
191 /* this is a border around the Edje object above, here just to
192 * emphasize its geometry */
193 border = evas_object_image_filled_add(evas);
194 evas_object_image_file_set(border, border_img_path, NULL);
195 evas_object_image_border_set(border, 2, 2, 2, 2);
196 evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE);
197
198 evas_object_resize(border, WIDTH - 40 + 4, HEIGHT - 40 + 4);
199 evas_object_move(border, 20 - 2, 20 - 2);
200 evas_object_show(border);
201
202 fprintf(stdout, "'example_data' data field in group 'example_group' has "
203 "the value: %s\n", edje_object_data_get(edje_obj,
204 "example_data"));
205
206 fprintf(stdout, "Testing if 'part_one' part exists: %s\n",
207 edje_object_part_exists(edje_obj, "part_one") ? "yes!" : "no");
208
209 edje_object_part_geometry_get(edje_obj, "part_one", &x, &y, &w, &h);
210 fprintf(stdout, "The geometry of that part inside the Edje object's area "
211 "is: x = %d, y = %d, w = %d, h = %d\n", x, y, w, h);
212
213 evas_object_color_get(edje_object_part_object_get(edje_obj, "part_one"),
214 &x, &y, &w, &h);
215 fprintf(stdout, "That part's color components are: r = %d, g = %d, b = %d,"
216 " a = %d\n", x, y, w, h);
217
218 edje_object_size_max_get(edje_obj, &w, &h);
219 fprintf(stdout, "The Edje object's max. size is: %d, %d\n", w, h);
220
221 edje_object_size_min_get(edje_obj, &w, &h);
222 fprintf(stdout, "The Edje object's min. size is: %d, %d\n", w, h);
223
224 edje_object_size_min_calc(edje_obj, &w, &h);
225 fprintf(stdout, "The Edje object's min. size reported by min. size"
226 " calculation is: w = %d, h = %d\n", w, h);
227
228 edje_object_size_min_restricted_calc(edje_obj, &w, &h, 500, 500);
229 fprintf(stdout, "The Edje object's min. size reported by *restricted* "
230 "min. size calculation is: w = %d, h = %d\n", w, h);
231
232 edje_object_parts_extends_calc(edje_obj, &x, &y, &w, &h);
233 fprintf(stdout, "The Edje object's \"extended\" geometry is: x = %d, "
234 "y = %d, w = %d, h = %d\n", x, y, w, h);
235
236 fprintf(stdout, commands);
237
238 ecore_evas_show(ee);
239
240 ecore_main_loop_begin();
241
242 eina_prefix_free(pfx);
243 ecore_evas_free(ee);
244 ecore_evas_shutdown();
245 edje_shutdown();
246
247 return EXIT_SUCCESS;
248
249 free_prefix:
250 eina_prefix_free(pfx);
251 shutdown_edje:
252 edje_shutdown();
253 shutdown_ecore_evas:
254 ecore_evas_shutdown();
255
256 return EXIT_FAILURE;
257}
diff --git a/src/examples/edje/edje-basic2.c b/src/examples/edje/edje-basic2.c
new file mode 100644
index 0000000000..e68d1ec6d2
--- /dev/null
+++ b/src/examples/edje/edje-basic2.c
@@ -0,0 +1,171 @@
1/**
2* @verbatim
3* gcc -o edje-basic2 edje-basic2.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
4* @endverbatim
5*/
6
7#ifdef HAVE_CONFIG_H
8# include "config.h"
9#else
10# define EINA_UNUSED
11#endif
12
13#include <stdio.h>
14
15#include <Eina.h>
16#include <Ecore.h>
17#include <Ecore_Evas.h>
18#include <Edje.h>
19
20#define WIDTH (700)
21#define HEIGHT (700)
22
23#define WALK 10
24
25static const char commands[] = "commands are:\nEsc - Exit\nUp - move image up\nDown - move image down\n"\
26 "Right - move image to right\nLeft - move image to left\n";
27
28static void
29_on_key_down(void *data,
30 Evas *evas EINA_UNUSED,
31 Evas_Object *o EINA_UNUSED,
32 void *einfo)
33{
34 Evas_Event_Key_Down *ev;
35 Evas_Object *edje_obj;
36 int x,y;
37
38 ev = (Evas_Event_Key_Down *)einfo;
39 edje_obj = (Evas_Object *)data;
40
41 evas_object_geometry_get(edje_obj, &x, &y, NULL, NULL);
42
43 if(strcmp(ev->keyname,"Escape") == 0)
44 {
45 ecore_main_loop_quit();
46 }
47 else if(strcmp(ev->keyname, "Down") == 0)
48 {
49 y+=WALK;
50 }
51 else if(strcmp(ev->keyname, "Up") == 0)
52 {
53 y-=WALK;
54 }
55 else if(strcmp(ev->keyname, "Right") == 0)
56 {
57 x+=WALK;
58 }
59 else if(strcmp(ev->keyname, "Left") == 0)
60 {
61 x-=WALK;
62 }
63 else
64 {
65 fprintf(stdout, "Key %s not supported.\nCommands:%s", ev->keyname, commands);
66 return;
67 }
68
69 evas_object_move(edje_obj, x, y);
70}
71
72static void
73_on_delete(Ecore_Evas *ee EINA_UNUSED)
74{
75 ecore_main_loop_quit();
76}
77
78int
79main(int argc EINA_UNUSED, char **argv)
80{
81 const char *edje_file = "basic2.edj";
82 char edje_file_path[PATH_MAX];
83 Eina_Prefix *pfx;
84 Ecore_Evas *ee;
85 Evas *evas;
86 Evas_Object *bg;
87 Evas_Object *edje_obj;
88
89 if(!ecore_evas_init())
90 return EXIT_FAILURE;
91
92 if(!edje_init())
93 goto shutdown_ecore_evas;
94
95 pfx = eina_prefix_new(argv[0], main,
96 "EDJE_EXAMPLES",
97 "edje/examples",
98 edje_file,
99 PACKAGE_BIN_DIR,
100 PACKAGE_LIB_DIR,
101 PACKAGE_DATA_DIR,
102 PACKAGE_DATA_DIR);
103
104 if(!pfx)
105 goto shutdown_edje;
106
107 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
108
109 if(!ee)
110 goto eina_prefix_free;
111
112 ecore_evas_callback_delete_request_set(ee, _on_delete);
113 ecore_evas_title_set(ee, "Edje show image");
114
115 evas = ecore_evas_get(ee);
116
117 bg = evas_object_rectangle_add(evas);
118 evas_object_color_set(bg, 255, 255, 255, 255); //White
119 evas_object_move(bg, 0, 0); //orign
120 evas_object_resize(bg, WIDTH, HEIGHT); //cover the window
121 evas_object_show(bg);
122
123 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
124 evas_object_focus_set(bg, EINA_TRUE);
125
126
127 edje_obj = edje_object_add(evas);
128
129 snprintf(edje_file_path, sizeof(edje_file_path),
130 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
131
132 if(!edje_object_file_set(edje_obj, edje_file_path, "image_group"))
133 {
134 int err = edje_object_load_error_get(edje_obj);
135 const char *errmsg = edje_load_error_str(err);
136 fprintf(stderr, "Could not load the edje file - reason:%s\n", errmsg);
137 goto eina_prefix_free;
138 }
139
140
141
142 evas_object_move(edje_obj, 50, 50);
143 evas_object_resize(edje_obj, 64, 64);
144 evas_object_show(edje_obj);
145
146 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, edje_obj);
147
148 ecore_evas_show(ee);
149
150 fprintf(stdout, "%s", commands);
151
152 ecore_main_loop_begin();
153
154 eina_prefix_free(pfx);
155 ecore_evas_free(ee);
156 edje_shutdown();
157 ecore_evas_shutdown();
158
159 return EXIT_SUCCESS;
160
161eina_prefix_free:
162 eina_prefix_free(pfx);
163
164shutdown_edje:
165 edje_shutdown();
166
167shutdown_ecore_evas:
168 ecore_evas_shutdown();
169
170 return EXIT_FAILURE;
171}
diff --git a/src/examples/edje/edje-box.c b/src/examples/edje/edje-box.c
new file mode 100644
index 0000000000..3da66e2bec
--- /dev/null
+++ b/src/examples/edje/edje-box.c
@@ -0,0 +1,252 @@
1/**
2 * Simple Edje example illustrating box functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc box.edc && gcc -o edje-box edje-box.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH 300
23#define HEIGHT 300
24
25#define RECTW 30
26#define RECTH 30
27
28#define NRECTS 20
29
30static const char commands[] = \
31 "commands are:\n"
32 "\ti - prepend rectangle\n"
33 "\ta - append rectangle\n"
34 "\tc - remove\n"
35 "\tEsc - exit\n"
36 "\th - print help\n";
37
38static void
39_on_destroy(Ecore_Evas *ee EINA_UNUSED)
40{
41 ecore_main_loop_quit();
42}
43
44/* here just to keep our example's window size and background image's
45 * size in synchrony */
46static void
47_on_canvas_resize(Ecore_Evas *ee)
48{
49 Evas_Object *bg;
50 Evas_Object *edje_obj;
51 int w;
52 int h;
53
54 bg = ecore_evas_data_get(ee, "background");
55 edje_obj = ecore_evas_data_get(ee, "edje_obj");
56 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
57 evas_object_resize(bg, w, h);
58 evas_object_resize(edje_obj, w, h);
59}
60
61static void
62_on_rect_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info)
63{
64 Ecore_Evas *ee;
65 Evas_Event_Mouse_Down *ev;
66 Evas_Object *edje_obj;
67
68 ee = (Ecore_Evas *)data;
69 ev = (Evas_Event_Mouse_Down *)event_info;
70 edje_obj = ecore_evas_data_get(ee, "edje_obj");
71
72 if (ev->button == 1)
73 {
74 printf("Removing rect %p under the mouse pointer.\n", o);
75 edje_object_part_box_remove(edje_obj, "example/box", o);
76 evas_object_del(o);
77 }
78 else if (ev->button == 3)
79 {
80 Evas_Object *rect;
81 Eina_Bool r;
82
83 rect = evas_object_rectangle_add(e);
84 evas_object_color_set(rect, 0, 0, 255, 255);
85 evas_object_resize(rect, RECTW + 10, RECTH);
86 evas_object_show(rect);
87
88 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
89 r = edje_object_part_box_insert_before(edje_obj, "example/box", rect, o);
90 if (!r)
91 printf("An error ocurred when appending rect %p to the box.\n", rect);
92
93 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
94 }
95}
96
97static void
98_on_bg_key_down(void *data, Evas *e, Evas_Object *o EINA_UNUSED, void *event_info)
99{
100 Ecore_Evas *ee;
101 Evas_Event_Key_Down *ev;
102 Evas_Object *edje_obj;
103 Evas_Object *rect;
104 Eina_Bool r;
105
106 ee = (Ecore_Evas *)data;
107 ev = (Evas_Event_Key_Down *)event_info;
108 edje_obj = ecore_evas_data_get(ee, "edje_obj");
109
110 if (!strcmp(ev->keyname, "h"))
111 {
112 fprintf(stdout, commands);
113 return;
114 }
115 if (!strcmp(ev->keyname, "i"))
116 {
117 rect = evas_object_rectangle_add(e);
118 evas_object_color_set(rect, 0, 0, 128, 255);
119 evas_object_resize(rect, RECTW + 30, RECTH);
120 evas_object_show(rect);
121
122 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
123 r = edje_object_part_box_insert_at(edje_obj, "example/box", rect, 0);
124 if (!r)
125 printf("An error ocurred when appending rect %p to the box.\n", rect);
126
127 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
128 }
129 else if (!strcmp(ev->keyname, "a"))
130 {
131 rect = evas_object_rectangle_add(e);
132 evas_object_color_set(rect, 0, 128, 0, 255);
133 evas_object_resize(rect, RECTW, RECTH);
134 evas_object_show(rect);
135
136 printf("Inserting rect %p before the rectangle under the mouse pointer.\n", rect);
137 r = edje_object_part_box_append(edje_obj, "example/box", rect);
138 if (!r)
139 printf("An error ocurred when appending rect %p to the box.\n", rect);
140
141 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, NULL);
142 }
143 else if (!strcmp(ev->keyname, "c"))
144 edje_object_part_box_remove_all(edje_obj, "example/box", EINA_TRUE);
145 else if (!strcmp(ev->keyname, "Escape"))
146 ecore_main_loop_quit();
147 else
148 {
149 printf("unhandled key: %s\n", ev->keyname);
150 fprintf(stdout, commands);
151 }
152}
153
154int
155main(int argc EINA_UNUSED, char *argv[])
156{
157 char edje_file_path[PATH_MAX];
158 const char *edje_file = "box.edj";
159 Ecore_Evas *ee;
160 Evas *evas;
161 Evas_Object *bg;
162 Evas_Object *edje_obj;
163 Eina_Prefix *pfx;
164 int i;
165
166 if (!ecore_evas_init())
167 return EXIT_FAILURE;
168
169 if (!edje_init())
170 goto shutdown_ecore_evas;
171
172 pfx = eina_prefix_new(argv[0], main,
173 "EDJE_EXAMPLES",
174 "edje/examples",
175 edje_file,
176 PACKAGE_BIN_DIR,
177 PACKAGE_LIB_DIR,
178 PACKAGE_DATA_DIR,
179 PACKAGE_DATA_DIR);
180 if (!pfx)
181 goto shutdown_edje;
182
183 /* this will give you a window with an Evas canvas under the first
184 * engine available */
185 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
186 if (!ee)
187 goto free_prefix;
188
189 ecore_evas_callback_destroy_set(ee, _on_destroy);
190 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
191 ecore_evas_title_set(ee, "Edje Box Example");
192
193 evas = ecore_evas_get(ee);
194
195 bg = evas_object_rectangle_add(evas);
196 evas_object_color_set(bg, 255, 255, 255, 255);
197 evas_object_resize(bg, WIDTH, HEIGHT);
198 evas_object_focus_set(bg, EINA_TRUE);
199 evas_object_show(bg);
200 ecore_evas_data_set(ee, "background", bg);
201
202 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee);
203
204 edje_obj = edje_object_add(evas);
205
206 snprintf(edje_file_path, sizeof(edje_file_path),
207 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
208 edje_object_file_set(edje_obj, edje_file_path, "example/group");
209 evas_object_move(edje_obj, 0, 0);
210 evas_object_resize(edje_obj, WIDTH, HEIGHT);
211 evas_object_show(edje_obj);
212 ecore_evas_data_set(ee, "edje_obj", edje_obj);
213
214 for (i = 0; i < NRECTS; i++)
215 {
216 Evas_Object *rect;
217 Eina_Bool r = EINA_FALSE;
218 int red = (i * 10) % 256;
219 rect = evas_object_rectangle_add(evas);
220 evas_object_color_set(rect, red, 0, 0, 255);
221 evas_object_resize(rect, RECTW, RECTH);
222 r = edje_object_part_box_append(edje_obj, "example/box", rect);
223 if (!r)
224 printf("An error ocurred when appending rect #%d to the box.\n", i);
225 evas_object_show(rect);
226
227 evas_object_event_callback_add(
228 rect, EVAS_CALLBACK_MOUSE_DOWN, _on_rect_mouse_down, ee);
229 }
230
231 fprintf(stdout, commands);
232
233 ecore_evas_show(ee);
234
235 ecore_main_loop_begin();
236
237 eina_prefix_free(pfx);
238 ecore_evas_free(ee);
239 ecore_evas_shutdown();
240 edje_shutdown();
241
242 return EXIT_SUCCESS;
243
244 free_prefix:
245 eina_prefix_free(pfx);
246 shutdown_edje:
247 edje_shutdown();
248 shutdown_ecore_evas:
249 ecore_evas_shutdown();
250
251 return EXIT_FAILURE;
252}
diff --git a/src/examples/edje/edje-box2.c b/src/examples/edje/edje-box2.c
new file mode 100644
index 0000000000..436b62177d
--- /dev/null
+++ b/src/examples/edje/edje-box2.c
@@ -0,0 +1,247 @@
1/**
2 * Simple Edje example illustrating a custom box layout.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc box.edc && gcc -o edje-box2 edje-box2.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <stdlib.h>
19#include <stdio.h>
20#include <string.h>
21
22#include <Ecore.h>
23#include <Evas.h>
24#include <Ecore_Evas.h>
25#include <Edje.h>
26
27static const char commands[] = \
28 "commands are:\n"
29 "\tShift - remove box\n"
30 "\tCtrl - insert box\n"
31 "\tEsc - exit\n"
32 "\th - print help\n";
33
34static void
35custom_layout(Evas_Object *o, Evas_Object_Box_Data *p, void *data EINA_UNUSED)
36{
37 Evas_Object_Box_Option *opt;
38 Eina_List *l;
39 int x, y, w, h;
40 int xx, yy, ww, hh;
41 int count;
42
43 evas_object_geometry_get(o, &x, &y, &w, &h);
44 count = eina_list_count(p->children);
45 ww = w / (count?:1);
46 hh = h / (count?:1);
47 if (ww < 1) ww = 1;
48 if (hh < 1) hh = 1;
49
50 xx = x;
51 yy = y;
52 EINA_LIST_FOREACH(p->children, l, opt)
53 {
54 evas_object_move(opt->obj, xx, yy);
55 xx += ww;
56 yy += hh;
57 }
58}
59
60static Evas_Object *
61new_greenie_block(Evas *e)
62{
63 Evas_Object *o;
64
65 o = evas_object_rectangle_add(e);
66 evas_object_resize(o, 10, 10);
67 evas_object_color_set(o, 0, 255, 0, 255);
68 evas_object_show(o);
69
70 return o;
71}
72
73static void
74on_keydown(void *data, Evas *evas, Evas_Object *o EINA_UNUSED, void *einfo)
75{
76 Evas_Event_Key_Down *ev;
77 Evas_Object *edje_obj;
78 const Evas_Modifier *mods;
79
80 ev = (Evas_Event_Key_Down *)einfo;
81 edje_obj = (Evas_Object *)data;
82
83 mods = evas_key_modifier_get(evas);
84 if (!strcmp(ev->keyname, "h"))
85 {
86 fprintf(stdout, commands);
87 return;
88 }
89 if (evas_key_modifier_is_set(mods, "Shift"))
90 {
91 int pos;
92 Evas_Object *obj = NULL;
93 pos = atoi(ev->keyname);
94 obj = edje_object_part_box_remove_at(edje_obj, "example/box", pos);
95 if (obj)
96 evas_object_del(obj);
97 return;
98 }
99 if (evas_key_modifier_is_set(mods, "Control"))
100 {
101 Evas_Object *obj;
102 int pos;
103 pos = atoi(ev->keyname);
104 obj = new_greenie_block(evas);
105 if (!edje_object_part_box_insert_at(edje_obj, "example/box", obj, pos))
106 edje_object_part_box_append(edje_obj, "example/box", obj);
107 return;
108 }
109 if (!strcmp(ev->keyname, "Escape"))
110 ecore_main_loop_quit();
111}
112
113static Evas_Object *
114box_new(Ecore_Evas *ee, const char *edje_file_path, const char *name, int x, int y, int w, int h)
115{
116 Evas_Object *edje_obj;
117
118 edje_obj = edje_object_add(ecore_evas_get(ee));
119 evas_object_move(edje_obj, x, y);
120 evas_object_resize(edje_obj, w, h);
121 if (!edje_object_file_set(edje_obj, edje_file_path, "example/group2"))
122 {
123 printf("error: could not load file object.\n");
124 }
125 evas_object_show(edje_obj);
126 evas_object_name_set(edje_obj, name);
127 ecore_evas_data_set(ee, "edje_obj", edje_obj);
128
129 return edje_obj;
130}
131
132static void
133on_resize(Ecore_Evas *ee)
134{
135 Evas_Object *bg;
136 Evas_Object *edje_obj;
137 int w;
138 int h;
139
140 bg = ecore_evas_data_get(ee, "background");
141 edje_obj = ecore_evas_data_get(ee, "edje_obj");
142 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
143 evas_object_resize(bg, w, h);
144 evas_object_resize(edje_obj, w, h);
145}
146
147static void
148on_destroy(Ecore_Evas *ee EINA_UNUSED)
149{
150 ecore_main_loop_quit();
151}
152
153int
154main(int argc EINA_UNUSED, char *argv[])
155{
156 char edje_file_path[PATH_MAX];
157 const char *edje_file = "box.edj";
158 Ecore_Evas *ee;
159 Evas *evas;
160 Evas_Object *bg;
161 Evas_Object *edje_obj;
162 Evas_Object *last;
163 Evas_Object *o;
164 Eina_Prefix *pfx;
165 int w;
166 int h;
167 int i;
168
169 if (!ecore_evas_init())
170 return EXIT_FAILURE;
171
172 if (!edje_init())
173 goto shutdown_ecore_evas;
174
175 pfx = eina_prefix_new(argv[0], main,
176 "EDJE_EXAMPLES",
177 "edje/examples",
178 edje_file,
179 PACKAGE_BIN_DIR,
180 PACKAGE_LIB_DIR,
181 PACKAGE_DATA_DIR,
182 PACKAGE_DATA_DIR);
183 if (!pfx)
184 goto shutdown_edje;
185
186 /* this will give you a window with an Evas canvas under the first
187 * engine available */
188 ee = ecore_evas_new(NULL, 0, 0, 640, 480, NULL);
189 if (!ee)
190 goto free_prefix;
191
192 ecore_evas_callback_resize_set(ee, on_resize);
193 ecore_evas_callback_destroy_set(ee, on_destroy);
194 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
195
196 evas = ecore_evas_get(ee);
197
198 bg = evas_object_rectangle_add(evas);
199 evas_object_resize(bg, w, h);
200 evas_object_show(bg);
201 evas_object_focus_set(bg, 1);
202 ecore_evas_data_set(ee, "background", bg);
203
204 edje_box_layout_register("custom_layout", custom_layout, NULL, NULL, NULL, NULL);
205
206 snprintf(edje_file_path, sizeof(edje_file_path),
207 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
208 edje_obj = box_new(ee, edje_file_path, "box", 0, 0, w, h);
209 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, on_keydown, edje_obj);
210
211 for (i = 1; i <= 5; i++)
212 {
213 o = last = evas_object_rectangle_add(evas);
214 evas_object_size_hint_min_set(o, 50, 50);
215 evas_object_resize(o, 50, 50);
216 evas_object_color_set(o, 255, 0, 0, 128);
217 evas_object_show(o);
218
219 if (!edje_object_part_box_append(edje_obj, "example/box", o))
220 {
221 fprintf(stderr, "error appending child object!\n");
222 return 1;
223 }
224 }
225
226 fprintf(stdout, commands);
227
228 ecore_evas_show(ee);
229
230 ecore_main_loop_begin();
231
232 eina_prefix_free(pfx);
233 ecore_evas_free(ee);
234 ecore_evas_shutdown();
235 edje_shutdown();
236
237 return EXIT_SUCCESS;
238
239 free_prefix:
240 eina_prefix_free(pfx);
241 shutdown_edje:
242 edje_shutdown();
243 shutdown_ecore_evas:
244 ecore_evas_shutdown();
245
246 return EXIT_FAILURE;
247}
diff --git a/src/examples/edje/edje-codegen-example.c b/src/examples/edje/edje-codegen-example.c
new file mode 100644
index 0000000000..6eff2339db
--- /dev/null
+++ b/src/examples/edje/edje-codegen-example.c
@@ -0,0 +1,202 @@
1/**
2 * @since 1.8.0
3 * Simple Edje example illustrating the edje_codegen usage.
4 *
5 * edje_codegen is a tool that generates code to acessing the parts and programs
6 * with the keyword "api" of a specified group. This tool make easier working
7 * with edje avoiding common errors caused by typos when acessing the parts
8 * and/or programs.
9 *
10 * To use the edje_codegen:
11 * edje_codegen --prefix <myapp_myobj> <input.edj> <a_group> <source.c> <header.h>
12 *
13 * In case of this example:
14 * edje_codegen --prefix=codegen_example codegen.edj group_example \
15 codegen_example_generated.c codegen_example_generated.h
16 *
17 * @verbatim
18 * edje_cc codegen.edc && edje_codegen --prefix=codegen_example codegen.edj \
19 * example_group codegen_example_generated.c codegen_example_generated.h
20 * gcc -c codegen_example_generated.c `pkg-config --libs --cflags ecore-evas edje`
21 * gcc -o edje-codegen-example codegen_example_generated.o \
22 * edje-codegen-example.c `pkg-config --libs --cflags ecore-evas edje`
23 * @endverbatim
24 */
25
26#ifdef HAVE_CONFIG_H
27# include "config.h"
28#else
29# define EINA_UNUSED
30#endif
31
32#include "codegen_example_generated.h"
33
34#include <Ecore.h>
35#include <Ecore_Evas.h>
36#include <Edje.h>
37
38#define WIDTH (800)
39#define HEIGHT (800)
40
41static void
42_on_delete(Ecore_Evas *ee)
43{
44 ecore_main_loop_quit();
45}
46
47static void
48_columns_rows_print(Evas_Object *edje_obj)
49{
50 int cols, rows;
51
52 if (codegen_example_part_four_col_row_size_get(edje_obj, &cols, &rows))
53 fprintf(stdout, "Number of columns: %d\nNumber of rows: %d\n", cols, rows);
54 else
55 fprintf(stderr, "Cannot get the number of columns and rows\n");
56}
57
58static void
59_on_mouse_over(void *data, Evas_Object *obj, const char *emission,
60 const char *source)
61{
62 Evas_Object *rect;
63 Eina_Bool disabled;
64 static int i = 0;
65
66 printf("Mouse over, source: %s - emission: %s\n",
67 source, emission);
68 if (i == 2)
69 {
70 rect = codegen_example_part_three_remove_at(obj, 0);
71 codegen_example_part_three_append(obj, rect);
72 }
73 if (i++ == 5)
74 {
75 Evas_Object *rect = codegen_example_part_two_get(obj);
76 evas_object_color_set(rect, 0, 255, 0, 255);
77 codegen_example_part_below_over_callback_del_full(obj,_on_mouse_over,
78 NULL);
79 codegen_example_part_four_clear(obj, EINA_TRUE);
80 _columns_rows_print(obj);
81 codegen_example_part_three_remove_all(obj, EINA_TRUE);
82 }
83}
84
85static Evas_Object *
86_rect_create(Evas *e, unsigned char r, unsigned char g, unsigned char b)
87{
88 Evas_Object *o;
89
90 o = evas_object_rectangle_add(e);
91 evas_object_color_set(o, r, g, b, 255);
92 evas_object_size_hint_weight_set(o, 1.0, 1.0);
93 evas_object_size_hint_min_set(o, 100, 100);
94 evas_object_show(o);
95
96 return o;
97}
98
99int
100main(int argc, char *argv[])
101{
102 char edje_file_path[PATH_MAX];
103 const char *edje_file = "codegen.edj", *aux;
104 Ecore_Evas *ee;
105 Evas *evas;
106 Evas_Object *bg;
107 Evas_Object *edje_obj;
108 Evas_Object *red_rect, *yellow_rect, *blue_rect, *rects[4];
109 Eina_Prefix *pfx;
110 Eina_Bool disabled;
111
112 if (!ecore_evas_init())
113 return EXIT_FAILURE;
114
115 if (!edje_init())
116 goto shutdown_ecore_evas;
117
118 pfx = eina_prefix_new(argv[0], main,
119 "EDJE_EXAMPLES",
120 "edje/examples",
121 edje_file,
122 PACKAGE_BIN_DIR,
123 PACKAGE_LIB_DIR,
124 PACKAGE_DATA_DIR,
125 PACKAGE_DATA_DIR);
126 if (!pfx)
127 goto shutdown_edje;
128
129 snprintf(edje_file_path, sizeof(edje_file_path),
130 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
131
132 /* this will give you a window with an Evas canvas under the first
133 * engine available */
134 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
135 if (!ee)
136 goto free_prefix;
137
138 ecore_evas_callback_delete_request_set(ee, _on_delete);
139 ecore_evas_title_set(ee, "Edje codegen Example");
140
141 evas = ecore_evas_get(ee);
142
143 bg = _rect_create(evas, 255, 255, 255);
144 evas_object_move(bg, 0, 0); /* at canvas' origin */
145 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
146 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
147
148 edje_obj = codegen_example_object_add(evas, edje_file_path);
149 evas_object_resize(edje_obj, WIDTH, HEIGHT);
150 evas_object_show(edje_obj);
151
152 codegen_example_part_one_set(edje_obj, "CODEGEN_EXAMPLE");
153 codegen_example_part_below_over_callback_add(edje_obj, _on_mouse_over, NULL);
154
155 red_rect = _rect_create(evas, 255, 0, 0);
156 codegen_example_part_two_set(edje_obj, red_rect);
157
158 blue_rect = _rect_create(evas, 0, 0, 255);
159 codegen_example_part_three_append(edje_obj, blue_rect);
160
161 yellow_rect = _rect_create(evas, 255, 255, 0);
162 codegen_example_part_three_prepend(edje_obj, yellow_rect);
163
164
165 rects[0] = _rect_create(evas, 0, 0, 255);
166 rects[1] = _rect_create(evas, 0, 255, 0);
167 rects[2] = _rect_create(evas, 255, 0, 0);
168 rects[3] = _rect_create(evas, 125, 140, 80);
169
170 if (!codegen_example_part_four_pack(edje_obj, rects[0], 0, 0, 1, 2))
171 fprintf(stderr, "Cannot add the rectangle 1 to table\n");
172
173 if (!codegen_example_part_four_pack(edje_obj, rects[1], 0, 1, 1, 1))
174 fprintf(stderr, "Cannot add the rectangle 2 to table\n");
175
176 if (!codegen_example_part_four_pack(edje_obj, rects[2], 1, 0, 1, 1))
177 fprintf(stderr, "Cannot add the rectangle 3 to table\n");
178
179 if (!codegen_example_part_four_pack(edje_obj, rects[3], 1, 1, 1, 1))
180 fprintf(stderr, "Cannot add the rectangle 4 to table\n");
181
182 _columns_rows_print(edje_obj);
183 ecore_evas_show(ee);
184
185 ecore_main_loop_begin();
186
187 eina_prefix_free(pfx);
188 ecore_evas_free(ee);
189 ecore_evas_shutdown();
190 edje_shutdown();
191
192 return EXIT_SUCCESS;
193
194 free_prefix:
195 eina_prefix_free(pfx);
196 shutdown_edje:
197 edje_shutdown();
198 shutdown_ecore_evas:
199 ecore_evas_shutdown();
200
201 return EXIT_FAILURE;
202}
diff --git a/src/examples/edje/edje-color-class.c b/src/examples/edje/edje-color-class.c
new file mode 100644
index 0000000000..883e258923
--- /dev/null
+++ b/src/examples/edje/edje-color-class.c
@@ -0,0 +1,295 @@
1/**
2 * Simple Edje example illustrating color class functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc color-class.edc && gcc -o edje-table edje-color-class.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH (400)
23#define HEIGHT (400)
24
25typedef int color[4]; /* rgba */
26
27static Ecore_Evas *ee1, *ee2;
28static Evas *evas1, *evas2;
29static Evas_Object *bg1, *edje_obj1, *bg2, *edje_obj2;
30static const char *selected_class;
31
32static color colors_init_data[] =
33 {{255, 0, 0, 255}, /* red */
34 {0, 255, 0, 255}, /* green */
35 {0, 0, 255, 255}, /* blue */
36 {0, 0, 0, 255}, /* black */
37 {255, 255, 255, 255}, /* white */
38 {128, 128, 128, 255}, /* gray */
39 {255, 255, 0, 255}, /* yellow */
40 {255, 0, 255, 255} /* pink */
41 };
42
43static char *color_names[] =
44 {"red", "green", "blue", "black", "white",
45 "gray", "yellow", "pink"};
46
47static Eina_Bool
48_get_color_from_name(const char *n, color *c)
49{
50 int i;
51 for (i = 0; i < 8; i++)
52 if (!strcmp(n, color_names[i]))
53 {
54 (*c)[0] = (colors_init_data[i])[0];
55 (*c)[1] = (colors_init_data[i])[1];
56 (*c)[2] = (colors_init_data[i])[2];
57 (*c)[3] = (colors_init_data[i])[3];
58 return EINA_TRUE;
59 }
60
61 return EINA_FALSE;
62}
63
64static void
65_color_classes_print(void)
66{
67 Eina_List *classes;
68 char *class_name;
69
70 fprintf(stdout, "Getting the color classes\n\n");
71 classes = edje_color_class_list();
72 EINA_LIST_FREE(classes, class_name)
73 {
74 int r1, r2, r3, g1, g2, g3, b1, b2, b3,
75 a1, a2, a3;
76
77 fprintf(stdout, "\ncolor class: %s\n", class_name);
78 if (!edje_color_class_get(class_name, &r1, &g1, &b1, &a1,
79 &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3))
80 fprintf(stderr, "Cannot get the color class\n");
81 else
82 {
83
84 fprintf(stdout,"Object color r: %d g: %d b: %d a: %d\n",
85 r1, g1, b1, a1);
86 fprintf(stdout,"Text outline color r: %d g: %d b: %d a: %d\n",
87 r2, g2, b2, a2);
88 fprintf(stdout,"Text shadow color r: %d g: %d b: %d a: %d\n",
89 r3, g3, b3, a3);
90 }
91 free(class_name);
92 }
93}
94
95static void
96_on_destroy(Ecore_Evas *ee EINA_UNUSED)
97{
98 ecore_main_loop_quit();
99}
100
101static void
102_on_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
103{
104 Evas_Event_Mouse_Down *ev = event_info;
105
106 if (ev->button == 1)
107 {
108 if (obj == edje_obj1)
109 edje_color_class_del(selected_class);
110 else
111 edje_object_color_class_del(edje_obj2, selected_class);
112 }
113}
114
115/* here just to keep our example's window size
116 * in synchrony. */
117static void
118_canvas_resize_cb(Ecore_Evas *_ee)
119{
120 int w, h;
121
122 ecore_evas_geometry_get(_ee, NULL, NULL, &w, &h);
123
124 if (_ee == ee1)
125 {
126 evas_object_resize(bg1, w, h);
127 evas_object_resize(edje_obj1, w, h);
128 }
129 else
130 {
131 evas_object_resize(bg2, w, h);
132 evas_object_resize(edje_obj2, w, h);
133 }
134}
135
136static void
137_color_class_callback_delete(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
138 const char *emission, void *source EINA_UNUSED)
139{
140 if (!strcmp(data, "process"))
141 fprintf(stdout, "Color class: %s deleted on process level\n", emission);
142 else
143 fprintf(stdout, "Color class: %s deleted on object level\n", emission);
144}
145
146static int
147_create_windows(const char *edje_file_path)
148{
149 /* this will give you a window with an Evas canvas under the first
150 * engine available */
151 ee1 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
152 if (!ee1)
153 return 0;
154 ee2 = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
155 if (!ee2)
156 return 0;
157
158 ecore_evas_callback_destroy_set(ee1, _on_destroy);
159 ecore_evas_callback_resize_set(ee1, _canvas_resize_cb);
160 ecore_evas_title_set(ee1, "Edje Color Class Example");
161
162 ecore_evas_callback_destroy_set(ee2, _on_destroy);
163 ecore_evas_callback_resize_set(ee2, _canvas_resize_cb);
164 ecore_evas_title_set(ee2, "Edje Object Color Class Example");
165
166 evas1 = ecore_evas_get(ee1);
167 evas2 = ecore_evas_get(ee2);
168
169 bg1 = evas_object_rectangle_add(evas1);
170 evas_object_color_set(bg1, 255, 255, 255, 255); /* white bg */
171 evas_object_move(bg1, 0, 0); /* at canvas' origin */
172 evas_object_resize(bg1, WIDTH, HEIGHT); /* covers full canvas */
173 evas_object_show(bg1);
174
175 bg2 = evas_object_rectangle_add(evas2);
176 evas_object_color_set(bg2, 255, 255, 255, 255); /* white bg */
177 evas_object_move(bg2, 0, 0); /* at canvas' origin */
178 evas_object_resize(bg2, WIDTH, HEIGHT); /* covers full canvas */
179 evas_object_show(bg2);
180
181 edje_obj1 = edje_object_add(evas1);
182 evas_object_event_callback_add(edje_obj1, EVAS_CALLBACK_MOUSE_DOWN,
183 _on_mouse_down, NULL);
184
185 edje_object_file_set(edje_obj1, edje_file_path, "example_color_class");
186 evas_object_move(edje_obj1, 0, 0); /* at canvas' origin */
187 evas_object_resize(edje_obj1, WIDTH, HEIGHT);
188 edje_object_part_text_set(edje_obj1, "part_four", "EDJE EXAMPLE");
189 edje_object_signal_callback_add(edje_obj1, "color_class,del", "*",
190 (Edje_Signal_Cb) _color_class_callback_delete,
191 "process");
192 evas_object_show(edje_obj1);
193
194 edje_obj2 = edje_object_add(evas2);
195 evas_object_event_callback_add(edje_obj2, EVAS_CALLBACK_MOUSE_DOWN,
196 _on_mouse_down, NULL);
197
198 edje_object_file_set(edje_obj2, edje_file_path, "example_color_class");
199 evas_object_move(edje_obj2, 0, 0); /* at canvas' origin */
200 evas_object_resize(edje_obj2, WIDTH, HEIGHT);
201 edje_object_part_text_set(edje_obj2, "part_four", "EDJE OBJECT EXAMPLE");
202 edje_object_signal_callback_add(edje_obj2, "color_class,del", "*",
203 (Edje_Signal_Cb) _color_class_callback_delete,
204 "object");
205 evas_object_show(edje_obj2);
206
207 return 1;
208}
209
210int
211main(int argc, char *argv[])
212{
213 char edje_file_path[PATH_MAX];
214 const char *edje_file = "color-class.edj";
215 Eina_Prefix *pfx;
216 color c1, c2, c3;
217 int i;
218
219 if (argc != 5)
220 {
221 fprintf(stderr, "You have to use: %s color_class_name color1, color2," \
222 "color3\n", argv[0]);
223 fprintf(stderr, "Available colors:\n");
224 for (i = 0; i < 8; i++)
225 fprintf(stderr, "%s\n", color_names[i]);
226
227 return EXIT_FAILURE;
228 }
229
230 selected_class = argv[1];
231 if (!(_get_color_from_name(argv[2], &c1) &&
232 _get_color_from_name(argv[3], &c2) &&
233 _get_color_from_name(argv[4], &c3)))
234 {
235 fprintf(stderr, "Color not available!\n");
236 return EXIT_FAILURE;
237 }
238
239 if (!ecore_evas_init())
240 return EXIT_FAILURE;
241
242 if (!edje_init())
243 goto shutdown_ecore_evas;
244
245 pfx = eina_prefix_new(argv[0], main,
246 "EDJE_EXAMPLES",
247 "edje/examples",
248 edje_file,
249 PACKAGE_BIN_DIR,
250 PACKAGE_LIB_DIR,
251 PACKAGE_DATA_DIR,
252 PACKAGE_DATA_DIR);
253 if (!pfx)
254 goto shutdown_edje;
255
256 snprintf(edje_file_path, sizeof(edje_file_path),
257 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
258 if (!_create_windows(edje_file_path))
259 goto free_prefix;
260
261 edje_color_class_set(argv[1], /* class name */
262 c1[0], c1[1], c1[2], c1[3], /* Object color */
263 c2[0], c2[1], c2[2], c2[3], /* Text outline */
264 c3[0], c3[1], c3[2], c3[3]); /* Text shadow */
265
266 /* Setting an arbitrary value just to see the difference between */
267 /* process level and object level */
268 edje_object_color_class_set(edje_obj2, argv[1], /* class name */
269 128, 180, 77, 255, /* Object color */
270 200, 22, 86, 255, /* Text outline */
271 39, 90, 187, 255); /* Text shadow */
272
273 _color_classes_print();
274
275 ecore_evas_show(ee1);
276 ecore_evas_show(ee2);
277
278 ecore_main_loop_begin();
279
280 eina_prefix_free(pfx);
281 ecore_evas_free(ee1);
282 ecore_evas_shutdown();
283 edje_shutdown();
284
285 return EXIT_SUCCESS;
286
287 free_prefix:
288 eina_prefix_free(pfx);
289 shutdown_edje:
290 edje_shutdown();
291 shutdown_ecore_evas:
292 ecore_evas_shutdown();
293
294 return EXIT_FAILURE;
295}
diff --git a/src/examples/edje/edje-drag.c b/src/examples/edje/edje-drag.c
new file mode 100644
index 0000000000..6b3f6b22aa
--- /dev/null
+++ b/src/examples/edje/edje-drag.c
@@ -0,0 +1,210 @@
1/**
2 * Simple Edje example illustrating drag functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc drag.edc && gcc -o drag-box drag-box.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH 300
23#define HEIGHT 300
24
25#define RECTW 30
26#define RECTH 30
27
28#define NRECTS 20
29
30static const char commands[] = \
31 "commands are:\n"
32 "\tDdown - set drag step to 1\n"
33 "\tUp - set drag step to -1\n"
34 "\tm - set drag value to 0.5\n"
35 "\tPrior - set drag page to -1\n"
36 "\tNext - set drag page to -1\n"
37 "\tEsc - exit\n"
38 "\th - print help\n";
39
40static const char *PARTNAME = "example/knob";
41
42static void
43_on_destroy(Ecore_Evas *ee EINA_UNUSED)
44{
45 ecore_main_loop_quit();
46}
47
48/* here just to keep our example's window size and background image's
49 * size in synchrony */
50static void
51_on_canvas_resize(Ecore_Evas *ee)
52{
53 Evas_Object *bg;
54 Evas_Object *edje_obj;
55 int w;
56 int h;
57
58 bg = ecore_evas_data_get(ee, "background");
59 edje_obj = ecore_evas_data_get(ee, "edje_obj");
60
61 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
62 evas_object_resize(bg, w, h);
63 evas_object_resize(edje_obj, w, h);
64}
65
66static void
67_on_bg_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
68{
69 Ecore_Evas *ee;
70 Evas_Event_Key_Down *ev;
71 Evas_Object *edje_obj;
72
73 ee = (Ecore_Evas *)data;
74 ev = (Evas_Event_Key_Down *)event_info;
75 edje_obj = ecore_evas_data_get(ee, "edje_obj");
76
77 if (!strcmp(ev->keyname, "h"))
78 {
79 fprintf(stdout, commands);
80 return;
81 }
82 else if (!strcmp(ev->keyname, "Down"))
83 {
84 edje_object_part_drag_step(edje_obj, PARTNAME, 0, 1.0);
85 }
86 else if (!strcmp(ev->keyname, "Up"))
87 {
88 edje_object_part_drag_step(edje_obj, PARTNAME, 0, -1.0);
89 }
90 else if (!strcmp(ev->keyname, "m"))
91 {
92 edje_object_part_drag_value_set(edje_obj, PARTNAME, 0.0, 0.5);
93 }
94 else if (!strcmp(ev->keyname, "Prior"))
95 {
96 edje_object_part_drag_page(edje_obj, PARTNAME, 0.0, -1.0);
97 }
98 else if (!strcmp(ev->keyname, "Next"))
99 {
100 edje_object_part_drag_page(edje_obj, PARTNAME, 0.0, 1.0);
101 }
102 else if (!strcmp(ev->keyname, "Escape"))
103 ecore_main_loop_quit();
104 else
105 {
106 printf("unhandled key: %s\n", ev->keyname);
107 fprintf(stdout, commands);
108 }
109}
110
111static void
112_on_knob_moved(void *data EINA_UNUSED, Evas_Object *o, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
113{
114 double val;
115
116 edje_object_part_drag_value_get(o, PARTNAME, NULL, &val);
117 printf("value changed to: %0.3f\n", val);
118}
119
120int
121main(int argc EINA_UNUSED, char *argv[])
122{
123 char edje_file_path[PATH_MAX];
124 const char *edje_file = "drag.edj";
125 Ecore_Evas *ee;
126 Evas *evas;
127 Evas_Object *bg;
128 Evas_Object *edje_obj;
129 Eina_Prefix *pfx;
130
131 if (!ecore_evas_init())
132 return EXIT_FAILURE;
133
134 if (!edje_init())
135 goto shutdown_ecore_evas;
136
137 pfx = eina_prefix_new(argv[0], main,
138 "EDJE_EXAMPLES",
139 "edje/examples",
140 edje_file,
141 PACKAGE_BIN_DIR,
142 PACKAGE_LIB_DIR,
143 PACKAGE_DATA_DIR,
144 PACKAGE_DATA_DIR);
145 if (!pfx)
146 goto shutdown_edje;
147
148 /* this will give you a window with an Evas canvas under the first
149 * engine available */
150 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
151 if (!ee)
152 goto free_prefix;
153
154 ecore_evas_callback_destroy_set(ee, _on_destroy);
155 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
156 ecore_evas_title_set(ee, "Edje Box Example");
157
158 evas = ecore_evas_get(ee);
159
160 bg = evas_object_rectangle_add(evas);
161 evas_object_color_set(bg, 255, 255, 255, 255);
162 evas_object_resize(bg, WIDTH, HEIGHT);
163 evas_object_focus_set(bg, EINA_TRUE);
164 evas_object_show(bg);
165 ecore_evas_data_set(ee, "background", bg);
166
167 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, ee);
168
169 edje_obj = edje_object_add(evas);
170
171 snprintf(edje_file_path, sizeof(edje_file_path),
172 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
173 edje_object_file_set(edje_obj, edje_file_path, "example/group");
174 evas_object_move(edje_obj, 0, 0);
175 evas_object_resize(edje_obj, WIDTH, HEIGHT);
176 evas_object_show(edje_obj);
177 ecore_evas_data_set(ee, "edje_obj", edje_obj);
178
179 edje_object_part_drag_size_set(edje_obj, PARTNAME, 1.0, 0.4);
180
181 if (!edje_object_part_drag_step_set(edje_obj, PARTNAME, 0.0, 0.1))
182 printf("error when setting drag step size.\n");
183
184 if (!edje_object_part_drag_page_set(edje_obj, PARTNAME, 0.0, 0.3))
185 printf("error when setting drag page step size.\n");
186
187 edje_object_signal_callback_add(edje_obj, "drag", PARTNAME, _on_knob_moved, NULL);
188
189 fprintf(stdout, commands);
190
191 ecore_evas_show(ee);
192
193 ecore_main_loop_begin();
194
195 eina_prefix_free(pfx);
196 ecore_evas_free(ee);
197 ecore_evas_shutdown();
198 edje_shutdown();
199
200 return EXIT_SUCCESS;
201
202 free_prefix:
203 eina_prefix_free(pfx);
204 shutdown_edje:
205 edje_shutdown();
206 shutdown_ecore_evas:
207 ecore_evas_shutdown();
208
209 return EXIT_FAILURE;
210}
diff --git a/src/examples/edje/edje-multisense.c b/src/examples/edje/edje-multisense.c
new file mode 100644
index 0000000000..c66c5681b7
--- /dev/null
+++ b/src/examples/edje/edje-multisense.c
@@ -0,0 +1,80 @@
1/**
2 * Simple example illustrating the very basic functions of multisense
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one) and multisense support ine edje. See stdout/stderr for output.
6 *
7 * @verbatim
8 * gcc -o edje-multisense edje-multisense.c `pkg-config --libs --cflags eina evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#include <Eina.h>
13#include <Evas.h>
14#include <Ecore.h>
15#include <Ecore_Evas.h>
16#include <Edje.h>
17
18#define WIDTH 300
19#define HEIGHT 300
20
21static Evas_Object *create_my_group(Evas *canvas)
22{
23 Evas_Object *edje;
24
25 edje = edje_object_add(canvas);
26 if (!edje)
27 {
28 EINA_LOG_CRIT("could not create edje object!");
29 return NULL;
30 }
31
32 if (!edje_object_file_set(edje, "multisense.edj", "example_group"))
33 {
34 int err = edje_object_load_error_get(edje);
35 const char *errmsg = edje_load_error_str(err);
36 EINA_LOG_ERR("could not load 'example_group' from multisense.edj: %s",
37 errmsg);
38
39 evas_object_del(edje);
40 return NULL;
41 }
42
43 evas_object_move(edje, 0, 0);
44 evas_object_resize(edje, WIDTH, HEIGHT);
45 evas_object_show(edje);
46 return edje;
47}
48
49int main(int argc, char *argv[])
50{
51 Ecore_Evas *window;
52 Evas *canvas;
53 Evas_Object *edje;
54
55 ecore_evas_init();
56 edje_init();
57
58 window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
59 if (!window)
60 {
61 EINA_LOG_CRIT("could not create window.");
62 return -1;
63 }
64 canvas = ecore_evas_get(window);
65
66 edje = create_my_group(canvas);
67 if (!edje)
68 return -2;
69
70 ecore_evas_show(window);
71 ecore_main_loop_begin();
72
73 evas_object_del(edje);
74 ecore_evas_free(window);
75
76 edje_shutdown();
77 ecore_evas_shutdown();
78
79 return 0;
80}
diff --git a/src/examples/edje/edje-nested.edc b/src/examples/edje/edje-nested.edc
new file mode 100644
index 0000000000..d3ea0646fc
--- /dev/null
+++ b/src/examples/edje/edje-nested.edc
@@ -0,0 +1,39 @@
1collections {
2 group {
3 name: "main";
4 parts {
5 part {
6 type: RECT;
7 name: "red_rect";
8 description {
9 state: "default" 0.0;
10 color: 255 0 0 255;
11 rel1.relative: 0.2 0.1;
12 rel2.relative: 0.4 0.8;
13 }
14
15 part { /* This rect is nested in red_rect */
16 type: RECT;
17 name: "green_rect";
18 description {
19 state: "default" 0.0;
20 color: 0 255 0 255;
21 rel2.relative: 0.8 0.5;
22 }
23
24 part { /* This rect is nested in green_rect */
25 type: RECT;
26 name: "blue_rect";
27 description {
28 state: "default" 0.0;
29 color: 0 0 255 255;
30 align: 1.0 1.0;
31 rel1.relative: 0.5 0.5;
32 rel2.relative: 1.0 1.0;
33 }
34 }
35 }
36 }
37 }
38 }
39}
diff --git a/src/examples/edje/edje-perspective.c b/src/examples/edje/edje-perspective.c
new file mode 100644
index 0000000000..dbb3e2268f
--- /dev/null
+++ b/src/examples/edje/edje-perspective.c
@@ -0,0 +1,253 @@
1/**
2 * Simple Edje example illustrating drag functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc drag.edc && gcc -o drag-box drag-box.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH 480
23#define HEIGHT 320
24
25static const char commands[] = \
26 "commands are:\n"
27 "\tDown - move part down\n"
28 "\tUp - move part up\n"
29 "\tLeft - move part left\n"
30 "\tRight - move part right\n"
31 "\tPrior - move part up-left\n"
32 "\tNext - move part down-right\n"
33 "\tInsert - increase focal\n"
34 "\tSuppr - decrease focal\n"
35 "\tEsc - exit\n"
36 "\th - print help\n";
37
38struct _App {
39 Evas_Object *edje_obj;
40 Evas_Object *bg;
41 Edje_Perspective *ps;
42 Eina_Bool animating;
43 int x, y; // relative position of part in the screen
44 int focal;
45};
46
47static void
48_on_destroy(Ecore_Evas *ee EINA_UNUSED)
49{
50 ecore_main_loop_quit();
51}
52
53/* here just to keep our example's window size and background image's
54 * size in synchrony */
55static void
56_on_canvas_resize(Ecore_Evas *ee)
57{
58 int w, h;
59 struct _App *app = ecore_evas_data_get(ee, "app");
60
61 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
62 evas_object_resize(app->bg, w, h);
63 evas_object_resize(app->edje_obj, w, h);
64}
65
66static void
67_part_move(struct _App *app, int dx, int dy)
68{
69 char emission[64];
70
71 if (app->animating)
72 return;
73
74 app->x += dx;
75 app->y += dy;
76 if (app->x > 1)
77 app->x = 1;
78 if (app->x < 0)
79 app->x = 0;
80 if (app->y > 1)
81 app->y = 1;
82 if (app->y < 0)
83 app->y = 0;
84
85 snprintf(emission, sizeof(emission), "move,%d,%d", app->x, app->y);
86 edje_object_signal_emit(app->edje_obj, emission, "");
87 app->animating = EINA_TRUE;
88}
89
90
91static void
92_on_bg_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
93{
94 struct _App *app = data;
95 Evas_Event_Key_Down *ev = event_info;
96
97 if (!strcmp(ev->keyname, "h"))
98 {
99 fprintf(stdout, commands);
100 return;
101 }
102 // just moving the part and text
103 else if (!strcmp(ev->keyname, "Down"))
104 {
105 _part_move(app, 0, 1);
106 }
107 else if (!strcmp(ev->keyname, "Up"))
108 {
109 _part_move(app, 0, -1);
110 }
111 else if (!strcmp(ev->keyname, "Left"))
112 {
113 _part_move(app, -1, 0);
114 }
115 else if (!strcmp(ev->keyname, "Right"))
116 {
117 _part_move(app, 1, 0);
118 }
119 else if (!strcmp(ev->keyname, "Prior"))
120 {
121 _part_move(app, -1, -1);
122 }
123 else if (!strcmp(ev->keyname, "Next"))
124 {
125 _part_move(app, 1, 1);
126 }
127 // adjusting the perspective focal point distance
128 else if (!strcmp(ev->keyname, "KP_Add"))
129 {
130 app->focal += 5;
131 edje_perspective_set(app->ps, 240, 160, 0, app->focal);
132 edje_object_calc_force(app->edje_obj);
133 }
134 else if (!strcmp(ev->keyname, "KP_Subtract"))
135 {
136 app->focal -= 5;
137 if (app->focal < 5)
138 app->focal = 5;
139
140 edje_perspective_set(app->ps, 240, 160, 0, app->focal);
141 edje_object_calc_force(app->edje_obj);
142 }
143 // exiting
144 else if (!strcmp(ev->keyname, "Escape"))
145 ecore_main_loop_quit();
146 else
147 {
148 printf("unhandled key: %s\n", ev->keyname);
149 fprintf(stdout, commands);
150 }
151}
152
153static void
154_animation_end_cb(void *data, Evas_Object *o EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
155{
156 struct _App *app = data;
157
158 app->animating = EINA_FALSE;
159}
160
161int
162main(int argc EINA_UNUSED, char *argv[])
163{
164 char edje_file_path[PATH_MAX];
165 const char *edje_file = "perspective.edj";
166 struct _App app;
167 Ecore_Evas *ee;
168 Evas *evas;
169 Eina_Prefix *pfx;
170
171 if (!ecore_evas_init())
172 return EXIT_FAILURE;
173
174 if (!edje_init())
175 goto shutdown_ecore_evas;
176
177 pfx = eina_prefix_new(argv[0], main,
178 "EDJE_EXAMPLES",
179 "edje/examples",
180 edje_file,
181 PACKAGE_BIN_DIR,
182 PACKAGE_LIB_DIR,
183 PACKAGE_DATA_DIR,
184 PACKAGE_DATA_DIR);
185 if (!pfx)
186 goto shutdown_edje;
187
188 edje_frametime_set(1.0 / 60.0);
189
190 /* this will give you a window with an Evas canvas under the first
191 * engine available */
192 app.animating = EINA_FALSE;
193 app.x = 0;
194 app.y = 0;
195 app.focal = 50;
196
197 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
198 if (!ee)
199 goto free_prefix;
200
201 ecore_evas_callback_destroy_set(ee, _on_destroy);
202 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
203 ecore_evas_title_set(ee, "Edje Box Example");
204
205 ecore_evas_data_set(ee, "app", &app);
206
207 evas = ecore_evas_get(ee);
208
209 app.bg = evas_object_rectangle_add(evas);
210 evas_object_color_set(app.bg, 255, 255, 255, 255);
211 evas_object_resize(app.bg, WIDTH, HEIGHT);
212 evas_object_focus_set(app.bg, EINA_TRUE);
213 evas_object_show(app.bg);
214
215 evas_object_event_callback_add(app.bg, EVAS_CALLBACK_KEY_DOWN, _on_bg_key_down, &app);
216
217 app.edje_obj = edje_object_add(evas);
218
219 snprintf(edje_file_path, sizeof(edje_file_path),
220 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
221 edje_object_file_set(app.edje_obj, edje_file_path, "example/group");
222 evas_object_move(app.edje_obj, 0, 0);
223 evas_object_resize(app.edje_obj, WIDTH, HEIGHT);
224 evas_object_show(app.edje_obj);
225
226 edje_object_signal_callback_add(app.edje_obj, "animation,end", "", _animation_end_cb, &app);
227
228 app.ps = edje_perspective_new(evas);
229 edje_perspective_set(app.ps, 240, 160, 0, app.focal);
230 edje_perspective_global_set(app.ps, EINA_TRUE);
231
232 fprintf(stdout, commands);
233
234 ecore_evas_show(ee);
235
236 ecore_main_loop_begin();
237
238 eina_prefix_free(pfx);
239 ecore_evas_free(ee);
240 ecore_evas_shutdown();
241 edje_shutdown();
242
243 return EXIT_SUCCESS;
244
245 free_prefix:
246 eina_prefix_free(pfx);
247 shutdown_edje:
248 edje_shutdown();
249 shutdown_ecore_evas:
250 ecore_evas_shutdown();
251
252 return EXIT_FAILURE;
253}
diff --git a/src/examples/edje/edje-signals-messages.c b/src/examples/edje/edje-signals-messages.c
new file mode 100644
index 0000000000..380d1e5861
--- /dev/null
+++ b/src/examples/edje/edje-signals-messages.c
@@ -0,0 +1,254 @@
1/**
2 * Simple Edje example illustrating the Edje signals and messages
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * gcc -o edje-signals-messages edje-signals-messages.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#else
15#define PACKAGE_EXAMPLES_DIR "."
16#define EINA_UNUSED
17#endif
18
19#include <Ecore.h>
20#include <Ecore_Evas.h>
21#include <Edje.h>
22#include <stdio.h>
23
24#define WIDTH (300)
25#define HEIGHT (300)
26
27#define MSG_COLOR 1
28#define MSG_TEXT 2
29
30static const char commands[] = \
31 "commands are:\n"
32 "\tt - toggle right rectangle's visibility\n"
33 "\tEsc - exit\n"
34 "\th - print help\n";
35
36static Eina_Bool right_rect_show = EINA_TRUE;
37
38static void
39_on_keydown(void *data,
40 Evas *evas EINA_UNUSED,
41 Evas_Object *o EINA_UNUSED,
42 void *einfo)
43{
44 Evas_Event_Key_Down *ev;
45 Evas_Object *edje_obj;
46
47 ev = (Evas_Event_Key_Down *)einfo;
48 edje_obj = (Evas_Object *)data;
49
50 if (!strcmp(ev->keyname, "h")) /* print help */
51 {
52 fprintf(stdout, commands);
53 return;
54 }
55 else if (!strcmp(ev->keyname, "t")) /* toggle right rectangle's visibility */
56 {
57 char buf[1024];
58
59 right_rect_show = !right_rect_show;
60 snprintf(buf, sizeof(buf), "part_right,%s",
61 right_rect_show ? "show" : "hide");
62
63 printf("emitting %s\n", buf);
64
65 edje_object_signal_emit(edje_obj, buf, "");
66
67 return;
68 }
69 else if (!strcmp(ev->keyname, "Escape"))
70 ecore_main_loop_quit();
71 else
72 {
73 printf("unhandled key: %s\n", ev->keyname);
74 fprintf(stdout, commands);
75 }
76}
77
78static void
79_on_delete(Ecore_Evas *ee EINA_UNUSED)
80{
81 ecore_main_loop_quit();
82}
83
84/* print signals coming from theme */
85static void
86_sig_print(const char *emission,
87 const char *source)
88{
89 fprintf(stdout, "Signal %s coming from part %s!\n", emission, source);
90}
91
92static void
93_on_mouse_wheel(void *data EINA_UNUSED,
94 Evas_Object *obj EINA_UNUSED,
95 const char *emission,
96 const char *source)
97{
98 _sig_print(emission, source);
99}
100
101/* mouse over signals */
102static void
103_on_mouse_over(void *data EINA_UNUSED,
104 Evas_Object *edje_obj,
105 const char *emission,
106 const char *source)
107{
108 int i;
109
110 _sig_print(emission, source);
111
112 Edje_Message_Int_Set *msg = malloc(sizeof(*msg) + 3 * sizeof(int));
113 msg->count = 4;
114 for (i = 0; i < 4; i++)
115 msg->val[i] = rand() % 256;
116
117 edje_object_message_send(edje_obj, EDJE_MESSAGE_INT_SET, MSG_COLOR, msg);
118
119 free(msg);
120}
121
122/* print out received message string */
123static void
124_message_handle(void *data EINA_UNUSED,
125 Evas_Object *obj EINA_UNUSED,
126 Edje_Message_Type type,
127 int id,
128 void *msg)
129{
130 Edje_Message_String *m;
131
132 if (type != EDJE_MESSAGE_STRING) return;
133 if (id != MSG_TEXT) return;
134
135 m = msg;
136
137 fprintf(stdout, "String message received: %s\n", m->str);
138}
139
140int
141main(int argc EINA_UNUSED, char *argv[])
142{
143 char border_img_path[PATH_MAX];
144 char edje_file_path[PATH_MAX];
145 const char *edje_file = "signals-messages.edj";
146 Ecore_Evas *ee;
147 Evas *evas;
148 Evas_Object *bg;
149 Evas_Object *edje_obj;
150 Evas_Object *border;
151 Eina_Prefix *pfx;
152
153 if (!ecore_evas_init())
154 return EXIT_FAILURE;
155
156 if (!edje_init())
157 goto shutdown_ecore_evas;
158
159 pfx = eina_prefix_new(argv[0], main,
160 "EDJE_EXAMPLES",
161 "edje/examples",
162 edje_file,
163 PACKAGE_BIN_DIR,
164 PACKAGE_LIB_DIR,
165 PACKAGE_DATA_DIR,
166 PACKAGE_DATA_DIR);
167 if (!pfx)
168 goto shutdown_edje;
169
170 /* this will give you a window with an Evas canvas under the first
171 * engine available */
172 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
173 if (!ee)
174 goto free_prefix;
175
176 ecore_evas_callback_delete_request_set(ee, _on_delete);
177 ecore_evas_title_set(ee, "Edje Basics Example");
178
179 evas = ecore_evas_get(ee);
180
181 bg = evas_object_rectangle_add(evas);
182 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
183 evas_object_move(bg, 0, 0); /* at canvas' origin */
184 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
185 evas_object_show(bg);
186 evas_object_focus_set(bg, EINA_TRUE);
187 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
188
189 edje_obj = edje_object_add(evas);
190
191 snprintf(edje_file_path, sizeof(edje_file_path),
192 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
193 if (!edje_object_file_set(edje_obj, edje_file_path, "example_group"))
194 {
195 int err = edje_object_load_error_get(edje_obj);
196 const char *errmsg = edje_load_error_str(err);
197 fprintf(stderr, "Could not load 'example_group' from "
198 "signals-messages.edj: %s\n", errmsg);
199
200 evas_object_del(edje_obj);
201 goto free_prefix;
202 }
203
204 edje_object_signal_callback_add(edje_obj, "mouse,wheel,*", "part_left",
205 _on_mouse_wheel, NULL);
206
207 edje_object_signal_callback_add(edje_obj, "mouse,over", "part_right",
208 _on_mouse_over, NULL);
209
210 edje_object_message_handler_set(edje_obj, _message_handle, NULL);
211
212 evas_object_move(edje_obj, 20, 20);
213 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
214 evas_object_show(edje_obj);
215
216 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj);
217
218 snprintf(border_img_path, sizeof(border_img_path),
219 "%s/edje/examples/red.png", eina_prefix_data_get(pfx));
220
221 /* this is a border around the Edje object above, here just to
222 * emphasize its geometry */
223 border = evas_object_image_filled_add(evas);
224 evas_object_image_file_set(border, border_img_path, NULL);
225 evas_object_image_border_set(border, 2, 2, 2, 2);
226 evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE);
227
228 evas_object_resize(border, WIDTH - 40 + 4, HEIGHT - 40 + 4);
229 evas_object_move(border, 20 - 2, 20 - 2);
230 evas_object_repeat_events_set(border, EINA_TRUE);
231 evas_object_show(border);
232
233 fprintf(stdout, commands);
234
235 ecore_evas_show(ee);
236
237 ecore_main_loop_begin();
238
239 eina_prefix_free(pfx);
240 ecore_evas_free(ee);
241 ecore_evas_shutdown();
242 edje_shutdown();
243
244 return EXIT_SUCCESS;
245
246 free_prefix:
247 eina_prefix_free(pfx);
248 shutdown_edje:
249 edje_shutdown();
250 shutdown_ecore_evas:
251 ecore_evas_shutdown();
252
253 return EXIT_FAILURE;
254}
diff --git a/src/examples/edje/edje-swallow.c b/src/examples/edje/edje-swallow.c
new file mode 100644
index 0000000000..4769cc19cf
--- /dev/null
+++ b/src/examples/edje/edje-swallow.c
@@ -0,0 +1,130 @@
1/**
2 * Simple Edje example illustrating swallow functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc swallow.edc && gcc -o edje-swallow edje-swallow.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH (300)
23#define HEIGHT (300)
24
25static void
26_on_delete(Ecore_Evas *ee EINA_UNUSED)
27{
28 ecore_main_loop_quit();
29}
30
31/* here just to keep our example's window size and background image's
32 * size in synchrony */
33static void
34_on_canvas_resize(Ecore_Evas *ee)
35{
36 Evas_Object *bg;
37 int w;
38 int h;
39
40 bg = ecore_evas_data_get(ee, "background");
41 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
42 evas_object_resize(bg, w, h);
43}
44
45int
46main(int argc EINA_UNUSED, char *argv[])
47{
48 char edje_file_path[PATH_MAX];
49 const char *edje_file = "swallow.edj";
50 Ecore_Evas *ee;
51 Evas *evas;
52 Evas_Object *bg;
53 Evas_Object *rect;
54 Evas_Object *obj;
55 Evas_Object *edje_obj;
56 Eina_Prefix *pfx;
57
58 if (!ecore_evas_init())
59 return EXIT_FAILURE;
60
61 if (!edje_init())
62 goto shutdown_ecore_evas;
63
64 pfx = eina_prefix_new(argv[0], main,
65 "EDJE_EXAMPLES",
66 "edje/examples",
67 edje_file,
68 PACKAGE_BIN_DIR,
69 PACKAGE_LIB_DIR,
70 PACKAGE_DATA_DIR,
71 PACKAGE_DATA_DIR);
72 if (!pfx)
73 goto shutdown_edje;
74
75 /* this will give you a window with an Evas canvas under the first
76 * engine available */
77 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
78 if (!ee)
79 goto free_prefix;
80
81 ecore_evas_callback_delete_request_set(ee, _on_delete);
82 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
83 ecore_evas_title_set(ee, "Edje Swallow Example");
84
85 evas = ecore_evas_get(ee);
86
87 bg = evas_object_rectangle_add(evas);
88 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
89 evas_object_move(bg, 0, 0); /* at canvas' origin */
90 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
91 evas_object_show(bg);
92 ecore_evas_data_set(ee, "background", bg);
93
94 edje_obj = edje_object_add(evas);
95
96 snprintf(edje_file_path, sizeof(edje_file_path),
97 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
98 edje_object_file_set(edje_obj, edje_file_path, "example_group");
99 evas_object_move(edje_obj, 20, 20);
100 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
101 evas_object_show(edje_obj);
102
103 rect = evas_object_rectangle_add(evas);
104 evas_object_color_set(rect, 255, 0, 0, 255);
105 edje_object_part_swallow(edje_obj, "part_one", rect);
106
107 obj = edje_object_part_swallow_get(edje_obj, "part_one");
108 if(obj == rect)
109 printf("Swallowing worked!\n");
110
111 ecore_evas_show(ee);
112
113 ecore_main_loop_begin();
114
115 eina_prefix_free(pfx);
116 ecore_evas_free(ee);
117 ecore_evas_shutdown();
118 edje_shutdown();
119
120 return EXIT_SUCCESS;
121
122 free_prefix:
123 eina_prefix_free(pfx);
124 shutdown_edje:
125 edje_shutdown();
126 shutdown_ecore_evas:
127 ecore_evas_shutdown();
128
129 return EXIT_FAILURE;
130}
diff --git a/src/examples/edje/edje-swallow2.c b/src/examples/edje/edje-swallow2.c
new file mode 100644
index 0000000000..884578ce3f
--- /dev/null
+++ b/src/examples/edje/edje-swallow2.c
@@ -0,0 +1,135 @@
1/**
2 * Simple Edje example illustrating swallow functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc swallow.edc && gcc -o edje-swallow2 edje-swallow2.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH (300)
23#define HEIGHT (300)
24
25static void
26_on_delete(Ecore_Evas *ee EINA_UNUSED)
27{
28 ecore_main_loop_quit();
29}
30
31int
32main(int argc EINA_UNUSED, char *argv[])
33{
34 char edje_file_path[PATH_MAX];
35 char img_file_path[PATH_MAX];
36 const char *edje_file = "swallow.edj";
37 const char *img_file = "bubble.png";
38 Ecore_Evas *ee;
39 Evas *evas;
40 Evas_Object *bg;
41 Evas_Object *img;
42 Evas_Object *obj;
43 Evas_Object *edje_obj;
44 Eina_Prefix *pfx;
45 Evas_Load_Error err;
46
47 if (!ecore_evas_init())
48 return EXIT_FAILURE;
49
50 if (!edje_init())
51 goto shutdown_ecore_evas;
52
53 pfx = eina_prefix_new(argv[0], main,
54 "EDJE_EXAMPLES",
55 "edje/examples",
56 edje_file,
57 PACKAGE_BIN_DIR,
58 PACKAGE_LIB_DIR,
59 PACKAGE_DATA_DIR,
60 PACKAGE_DATA_DIR);
61 if (!pfx)
62 goto shutdown_edje;
63
64 /* this will give you a window with an Evas canvas under the first
65 * engine available */
66 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
67 if (!ee)
68 goto free_prefix;
69
70 ecore_evas_callback_delete_request_set(ee, _on_delete);
71
72 ecore_evas_title_set(ee, "Edje Swallow Example");
73
74 evas = ecore_evas_get(ee);
75
76 bg = evas_object_rectangle_add(evas);
77 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
78 evas_object_move(bg, 0, 0); /* at canvas' origin */
79 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
80 evas_object_show(bg);
81 ecore_evas_data_set(ee, "background", bg);
82
83 ecore_evas_object_associate(ee,bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
84
85 edje_obj = edje_object_add(evas);
86
87 snprintf(edje_file_path, sizeof(edje_file_path),
88 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
89 edje_object_file_set(edje_obj, edje_file_path, "example_group");
90 evas_object_move(edje_obj, 20, 20);
91 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
92 evas_object_show(edje_obj);
93
94 snprintf(img_file_path, sizeof(edje_file_path),
95 "%s/examples/%s", eina_prefix_data_get(pfx), img_file);
96
97 img = evas_object_image_filled_add(evas);
98 evas_object_image_file_set(img, img_file_path, NULL);
99
100 err = evas_object_image_load_error_get(img);
101
102 if (err != EVAS_LOAD_ERROR_NONE)
103 {
104 fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
105 img_file_path, evas_load_error_str(err));
106 goto free_prefix;
107 }
108
109 edje_object_part_swallow(edje_obj, "part_one", img);
110
111 obj = edje_object_part_swallow_get(edje_obj, "part_one");
112
113 if(obj == img)
114 printf("Swallowing worked!\n");
115
116 ecore_evas_show(ee);
117
118 ecore_main_loop_begin();
119
120 eina_prefix_free(pfx);
121 ecore_evas_free(ee);
122 ecore_evas_shutdown();
123 edje_shutdown();
124
125 return EXIT_SUCCESS;
126
127 free_prefix:
128 eina_prefix_free(pfx);
129 shutdown_edje:
130 edje_shutdown();
131 shutdown_ecore_evas:
132 ecore_evas_shutdown();
133
134 return EXIT_FAILURE;
135}
diff --git a/src/examples/edje/edje-table.c b/src/examples/edje/edje-table.c
new file mode 100644
index 0000000000..51042d26d7
--- /dev/null
+++ b/src/examples/edje/edje-table.c
@@ -0,0 +1,210 @@
1/**
2 * Simple Edje example illustrating table functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc table.edc && gcc -o edje-table edje-table.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#include <Ecore.h>
19#include <Ecore_Evas.h>
20#include <Edje.h>
21
22#define WIDTH (400)
23#define HEIGHT (400)
24
25static void
26_on_delete(Ecore_Evas *ee EINA_UNUSED)
27{
28 ecore_main_loop_quit();
29}
30
31/* Try to get the number of columns and rows of the table
32 * and print them. */
33static void
34_columns_rows_print(Evas_Object *edje_obj)
35{
36 int cols, rows;
37
38 if (edje_object_part_table_col_row_size_get(edje_obj, "table_part", &cols,
39 &rows))
40 fprintf(stdout, "Number of columns: %d\nNumber of rows: %d\n", cols, rows);
41 else
42 fprintf(stderr, "Cannot get the number of columns and rows\n");
43}
44
45/* here just to keep our example's window size and table items
46 * size in synchrony. */
47static void
48_on_canvas_resize(Ecore_Evas *ee)
49{
50 Evas_Object *bg;
51 Evas_Object *edje_obj;
52 Evas_Object **rects;
53 int i;
54 int w;
55 int h;
56
57 bg = ecore_evas_data_get(ee, "background");
58 edje_obj = ecore_evas_data_get(ee, "edje_obj");
59 rects = ecore_evas_data_get(ee, "rects");
60 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
61
62 evas_object_resize(bg, w, h);
63 evas_object_resize(edje_obj, w, h);
64
65 for (i = 0; i < 4; i++)
66 evas_object_size_hint_min_set(rects[i], w/2, h/2);
67}
68
69/* Mouse button 1 = remove the clicked item
70 * any other button = remove all items. */
71static void
72_on_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event_info)
73{
74 Evas_Event_Mouse_Down *ev;
75 Evas_Object *edje_obj;
76
77 ev = (Evas_Event_Mouse_Down *)event_info;
78 edje_obj = (Evas_Object *)data;
79
80 if (ev->button != 1)
81 edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE);
82 else if (!edje_object_part_table_unpack(edje_obj, "table_part", obj))
83 fprintf(stderr, "Cannot remove the selected rectangle\n");
84