aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <d.willmann@samsung.com>2012-11-15 09:31:08 +0000
committerDaniel Willmann <daniel@totalueberwachung.de>2012-11-15 09:31:08 +0000
commitc5996880a6feedd355cc7011d4317959754a0435 (patch)
tree788e7970a0a736b4960c8dd612a4a9f8e809c574
parentadd comments in cserve2 bin webp loader too. (diff)
downloadefl-c5996880a6feedd355cc7011d4317959754a0435.tar.gz
edje: Add embryo function get_image_id
This makes it possible to change the image from an embryo script Signed-off-by: Daniel Willmann <d.willmann@samsung.com> SVN revision: 79327
-rw-r--r--legacy/edje/AUTHORS1
-rw-r--r--legacy/edje/ChangeLog4
-rw-r--r--legacy/edje/NEWS1
-rw-r--r--legacy/edje/data/include/edje.inc1
-rw-r--r--legacy/edje/src/examples/Makefile.am1
-rw-r--r--legacy/edje/src/examples/bubble-blue.pngbin0 -> 4505 bytes
-rw-r--r--legacy/edje/src/examples/embryo_custom_state.edc50
-rw-r--r--legacy/edje/src/lib/edje_embryo.c28
-rw-r--r--legacy/edje/src/lib/edje_private.h4
9 files changed, 88 insertions, 2 deletions
diff --git a/legacy/edje/AUTHORS b/legacy/edje/AUTHORS
index bb02878a3b..60107efdf0 100644
--- a/legacy/edje/AUTHORS
+++ b/legacy/edje/AUTHORS
@@ -31,3 +31,4 @@ WooHyun Jung (woohyun) <woohyun0705@gmail.com>
Guilherme Silveira <xguiga@gmail.com>
Flavio Ceolin <flavio.ceolin@profusion.mobi>
Daniel Zaoui <daniel.zaoui@yahoo.com>
+Daniel Willmann <d.willmann@samsung.com>
diff --git a/legacy/edje/ChangeLog b/legacy/edje/ChangeLog
index 450b7b6042..336978b374 100644
--- a/legacy/edje/ChangeLog
+++ b/legacy/edje/ChangeLog
@@ -675,3 +675,7 @@
2012-11-02 ChunEon Park (Hermet)
* Fix to not update map uv for proxy
+
+2012-11-15 Daniel Willmann
+
+ * Add embryo function get_image_id
diff --git a/legacy/edje/NEWS b/legacy/edje/NEWS
index 07c274a3e2..08aaf8b65f 100644
--- a/legacy/edje/NEWS
+++ b/legacy/edje/NEWS
@@ -9,6 +9,7 @@ Additions:
* Add EDJE_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN
* Add edje_codegen - A code generator to working with edje files.
* Add more tags(preedit_sub1~4) for a variety of preediting states.
+ * Add embryo function get_image_id
Improvements:
* Change Edje to use Eo.
diff --git a/legacy/edje/data/include/edje.inc b/legacy/edje/data/include/edje.inc
index dfa5416069..55eb9ee7ae 100644
--- a/legacy/edje/data/include/edje.inc
+++ b/legacy/edje/data/include/edje.inc
@@ -84,6 +84,7 @@ native cancel_anim(id);
*/
native emit (sig[], src[]);
native get_part_id (part[]);
+native get_image_id (image[]);
native set_state (part_id, state[], Float:state_val);
native get_state (part_id, dst[], maxlen, &Float:val);
native set_tween_state (part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val);
diff --git a/legacy/edje/src/examples/Makefile.am b/legacy/edje/src/examples/Makefile.am
index 1c62c9e65f..99f32df0f1 100644
--- a/legacy/edje/src/examples/Makefile.am
+++ b/legacy/edje/src/examples/Makefile.am
@@ -60,6 +60,7 @@ filesdir = $(pkgdatadir)/examples
files_DATA = \
$(EDCS) \
bubble.png \
+bubble-blue.png \
red.png \
test.png \
Vera.ttf \
diff --git a/legacy/edje/src/examples/bubble-blue.png b/legacy/edje/src/examples/bubble-blue.png
new file mode 100644
index 0000000000..7cf4dcdc5e
--- /dev/null
+++ b/legacy/edje/src/examples/bubble-blue.png
Binary files differ
diff --git a/legacy/edje/src/examples/embryo_custom_state.edc b/legacy/edje/src/examples/embryo_custom_state.edc
index 9277c9075b..35a39980ce 100644
--- a/legacy/edje/src/examples/embryo_custom_state.edc
+++ b/legacy/edje/src/examples/embryo_custom_state.edc
@@ -1,10 +1,29 @@
collections {
+ images {
+ image: "bubble.png" COMP;
+ image: "bubble-blue.png" COMP;
+ }
+
group { name: "main";
script {
/* define 3 global vars to hold the rotation values */
public rotx;
public roty;
public rotz;
+
+ public change_image(part[], img[]) {
+ new imgid;
+ new partid;
+
+ partid = get_part_id(part);
+ imgid = get_image_id(img);
+
+ custom_state(partid, "default", 0.0);
+ /* change the rotation in the custom state */
+ set_state_val(partid, STATE_IMAGE, imgid);
+ /* apply the custom state */
+ set_state(partid, "custom", 0.0);
+ }
}
parts {
part { name: "bg";
@@ -13,6 +32,18 @@ collections {
color: 255 255 255 255;
}
}
+ part { name: "img";
+ type: IMAGE;
+ description { state: "default" 0.0;
+ image { normal: "bubble.png"; }
+ }
+ /* Dummy state - otherwise edje_cc discards bubble-blue.png
+ as it thinks it's unused */
+ description { state: "foo" 0.0;
+ image { normal: "bubble-blue.png"; }
+ }
+ }
+
part { name: "title";
type: TEXT;
description { state: "default" 0.0;
@@ -61,6 +92,18 @@ collections {
}
}
}
+ part { name: "setimg";
+ type: TEXT;
+ description { state: "default" 0.0;
+ color: 0 0 0 255;
+ text {
+ text: "Change image";
+ font: "Sans";
+ size: 12;
+ align: 0.5 1;
+ }
+ }
+ }
part { name: "rect";
type: RECT;
mouse_events: 0;
@@ -129,6 +172,13 @@ collections {
set_text(PART:"Z", buf);
}
}
+ program {
+ signal: "mouse,down,1";
+ source: "setimg";
+ script {
+ change_image("img", "bubble-blue.png");
+ }
+ }
}
}
}
diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c
index cad3b60e76..16e6f027c3 100644
--- a/legacy/edje/src/lib/edje_embryo.c
+++ b/legacy/edje/src/lib/edje_embryo.c
@@ -828,6 +828,33 @@ _edje_embryo_fn_get_part_id(Embryo_Program *ep, Embryo_Cell *params)
return -1;
}
+/* get_image_id(img[]) */
+static Embryo_Cell
+_edje_embryo_fn_get_image_id(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje *ed;
+ Edje_File *file;
+ Edje_Image_Directory *dir;
+ Edje_Image_Directory_Entry *dirent;
+ char *p;
+ unsigned int i, j;
+
+ CHKPARAM(1);
+ ed = embryo_program_data_get(ep);
+ GETSTR(p, params[1]);
+ if (!p) return -1;
+ file = ed->file;
+ if (!file) return -1;
+ dir = file->image_dir;
+ dirent = dir->entries;
+ for (i = 0; i < dir->entries_count; i++, dirent++)
+ {
+ if (!dirent->entry) continue;
+ if (!strcmp(dirent->entry, p)) return dirent->id;
+ }
+ return -1;
+}
+
static Embryo_Cell
_edje_embryo_fn_play_sample(Embryo_Program *ep, Embryo_Cell *params)
{
@@ -3022,6 +3049,7 @@ _edje_embryo_script_init(Edje_Part_Collection *edc)
embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit);
embryo_program_native_call_add(ep, "get_part_id", _edje_embryo_fn_get_part_id);
+ embryo_program_native_call_add(ep, "get_image_id", _edje_embryo_fn_get_image_id);
embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state);
embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state);
embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state);
diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h
index 20439f493f..0a93a34b64 100644
--- a/legacy/edje/src/lib/edje_private.h
+++ b/legacy/edje/src/lib/edje_private.h
@@ -530,8 +530,8 @@ struct _Edje_Image_Directory
Edje_Image_Directory_Entry *entries; /* an array of Edje_Image_Directory_Entry */
unsigned int entries_count;
- Edje_Image_Directory_Set *sets;
- unsigned int sets_count; /* an array of Edje_Image_Directory_Set */
+ Edje_Image_Directory_Set *sets; /* an array of Edje_Image_Directory_Set */
+ unsigned int sets_count;
};
struct _Edje_Image_Directory_Entry