aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/edje
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-02-26 18:54:38 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-02-28 16:02:38 -0500
commit3d9dcbd478e0e9e8a120b08344e08154cbc25d39 (patch)
tree265665cee10ea0747c81b9e44dbde2a62bb1b066 /src/bin/edje
parentedje_cc: add "id" toplevel property (diff)
downloadefl-3d9dcbd478e0e9e8a120b08344e08154cbc25d39.tar.gz
edje: add ability to reference images from other edje files
this uses the just-added "id" property to allow referencing images by name from that theme. example: =FILE1= id: "myfile"; images.image: "someimage.png" COMP; =FILE2= requires: "myfile"; images.image: "someimage.png" EXTERNAL "myfile"; FILE2 will now load someimage.png from FILE1 at runtime if FILE1 is currently opened in edje, and FILE1 will be kept open until FILE2 is closed @feature
Diffstat (limited to 'src/bin/edje')
-rw-r--r--src/bin/edje/edje_cc.c2
-rw-r--r--src/bin/edje/edje_cc.h2
-rw-r--r--src/bin/edje/edje_cc_handlers.c67
-rw-r--r--src/bin/edje/edje_cc_out.c20
-rw-r--r--src/bin/edje/edje_decc.c1
5 files changed, 82 insertions, 10 deletions
diff --git a/src/bin/edje/edje_cc.c b/src/bin/edje/edje_cc.c
index 52d2e28af1..df2a877c5a 100644
--- a/src/bin/edje/edje_cc.c
+++ b/src/bin/edje/edje_cc.c
@@ -33,6 +33,7 @@ char *depfile = NULL;
char *authors = NULL;
char *license = NULL;
Eina_List *licenses = NULL;
+Eina_Array *requires;
static const char *progname = NULL;
@@ -418,6 +419,7 @@ main(int argc, char **argv)
edje_file->efl_version.major = 1;
edje_file->efl_version.minor = 18;
edje_file->base_scale = FROM_INT(1);
+ requires = eina_array_new(10);
#ifdef HAVE_SYS_RESOURCE_H
{
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 3bcea20871..6208d139d1 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -355,5 +355,5 @@ extern int beta;
extern int had_quote;
extern unsigned int max_open_files;
-
+extern Eina_Array *requires;
#endif
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index e5109d1c8d..efefe32b29 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -203,6 +203,7 @@ static void *_part_free(Edje_Part_Collection *pc, Edje_Part *ep);
static void check_has_anchors(void);
static void st_id(void);
+static void st_requires(void);
static void st_efl_version(void);
static void st_externals_external(void);
@@ -703,6 +704,7 @@ static void _handle_vector_image(void);
New_Statement_Handler statement_handlers[] =
{
{"id", st_id},
+ {"requires", st_requires},
{"efl_version", st_efl_version},
{"externals.external", st_externals_external},
IMAGE_STATEMENTS("")
@@ -2243,10 +2245,47 @@ st_efl_version(void)
static void
st_id(void)
{
+ Eina_Array_Iterator it;
+ unsigned int i;
+ char *str, *id;
+
+ check_arg_count(1);
+ id = parse_str(0);
+
+ EINA_ARRAY_ITER_NEXT(requires, i, str, it)
+ if (eina_streq(str, id))
+ error_and_abort(NULL, "Cannot use same id for file as one of its required files!");
+ free((void*)edje_file->id);
+ edje_file->id = id;
+}
+
+/** @edcsubsection{toplevel_requires,
+ * requires} */
+
+/**
+ @page edcref
+
+ @property
+ requires
+ @parameters
+ [name]
+ @effect
+ Specifying this property informs edje not to close the
+ file with the corresponding id property for as long as this
+ file is open. Multiple requires properties can be individually specified.
+ @since 1.21
+ @endproperty
+ */
+static void
+st_requires(void)
+{
+ char *str;
check_arg_count(1);
- free(edje_file->id);
- edje_file->id = parse_str(0);
+ str = parse_str(0);
+ if (eina_streq(str, edje_file->id))
+ error_and_abort(NULL, "Cannot require the current file!");
+ eina_array_push(requires, str);
}
/** @edcsubsection{toplevel_externals,
@@ -2353,7 +2392,7 @@ st_externals_external(void)
@property
image
@parameters
- [image file] [compression method] (compression level)
+ [image file] [compression method] (compression level)(edje file id)
@effect
Used to include each image file. The full path to the directory holding
the images can be defined later with edje_cc's "-id" option.
@@ -2364,6 +2403,7 @@ st_externals_external(void)
@li LOSSY_ETC1 [0-100]: ETC1 lossy texture compression with quality from 0 to 100.
@li LOSSY_ETC2 [0-100]: ETC2 lossy texture compression with quality from 0 to 100 (supports alpha).
@li USER: Do not embed the file, refer to the external file instead.
+ @li EXTERNAL: The file exists in the edje file with the specified id.
Defaults: compression level for lossy methods is 90.
@endproperty
@@ -2417,6 +2457,7 @@ st_images_image(void)
"LOSSY_ETC1", 3,
"LOSSY_ETC2", 4,
"USER", 5,
+ "EXTERNAL", 6,
NULL);
if (v == 0)
{
@@ -2448,16 +2489,29 @@ st_images_image(void)
img->source_type = EDJE_IMAGE_SOURCE_TYPE_USER;
img->source_param = 0;
}
+ else if (v == 6)
+ {
+ img->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
+ img->source_param = 0;
+ img->external_id = parse_str(2);
+ }
if ((img->source_type < EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) ||
- (img->source_type > EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2))
+ (img->source_type == EDJE_IMAGE_SOURCE_TYPE_USER))
check_arg_count(2);
- else
+ else if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL)
{
if (check_range_arg_count(2, 3) > 2)
img->source_param = parse_int_range(2, 0, 100);
else
img->source_param = 90;
}
+ if (!edje_file->image_id_hash)
+ edje_file->image_id_hash = eina_hash_string_superfast_new(free);
+ {
+ Edje_Image_Hash *eih = mem_alloc(SZ(Edje_Image_Hash));
+ eih->id = img->id;
+ eina_hash_add(edje_file->image_id_hash, tmp, eih);
+ }
}
static void
@@ -2736,7 +2790,7 @@ ob_images_set_image(void)
@property
image
@parameters
- [image file] [compression method] (compression level)
+ [image file] [compression method] (compression level)(edje file id)
@effect
Used to include each image file. The full path to the directory holding
the images can be defined later with edje_cc's "-id" option.
@@ -2747,6 +2801,7 @@ ob_images_set_image(void)
@li LOSSY_ETC1 [0-100]: ETC1 lossy texture compression with quality from 0 to 100.
@li LOSSY_ETC2 [0-100]: ETC2 lossy texture compression with quality from 0 to 100 (supports alpha).
@li USER: Do not embed the file, refer to the external file instead.
+ @li EXTERNAL: The file exists in the edje file with the specified id.
Defaults: compression level for lossy methods is 90.
@endproperty
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index b13cf20abd..f315526e4f 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -1381,7 +1381,7 @@ data_write_images(void)
Image_Write *iw;
img = &edje_file->image_dir->entries[cur_image_entry];
- if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_USER) || !img->entry)
+ if ((img->source_type >= EDJE_IMAGE_SOURCE_TYPE_USER) || !img->entry)
continue;
if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 ||
@@ -1452,7 +1452,7 @@ data_write_images(void)
}
}
- if (img->source_type != EDJE_IMAGE_SOURCE_TYPE_USER)
+ if (img->source_type < EDJE_IMAGE_SOURCE_TYPE_USER)
{
ext = strrchr(img->entry, '.');
if (ext && (!strcasecmp(ext, ".svg") || !strcasecmp(ext, ".svgz")))
@@ -2713,6 +2713,20 @@ data_write(void)
EFL_VERSION_MAJOR, EFL_VERSION_MINOR);
}
+ if (eina_array_count(requires))
+ {
+ int i = 0;
+
+ edje_file->requires_count = eina_array_count(requires);
+ edje_file->requires = mem_alloc(edje_file->requires_count * sizeof(void*));
+ do
+ {
+ edje_file->requires[i] = eina_array_pop(requires);
+ i++;
+ } while (eina_array_count(requires));
+ eina_array_free(requires);
+ }
+
check_groups(ef);
ecore_thread_max_set(ecore_thread_max_get() * 2);
@@ -3947,7 +3961,7 @@ free_group:
if ((de->entry) && (!strcmp(de->entry, image->name)))
{
- if (de->source_type == EDJE_IMAGE_SOURCE_TYPE_USER)
+ if (de->source_type >= EDJE_IMAGE_SOURCE_TYPE_USER)
*(image->dest) = -de->id - 1;
else
*(image->dest) = de->id;
diff --git a/src/bin/edje/edje_decc.c b/src/bin/edje/edje_decc.c
index ee640479d7..dfee86affe 100644
--- a/src/bin/edje/edje_decc.c
+++ b/src/bin/edje/edje_decc.c
@@ -304,6 +304,7 @@ output(void)
if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
(ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_USER) &&
+ (ei->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
(ei->entry))
{
Ecore_Evas *ee;