Enlightenment CVS committal
Author : tsauerbeck
Project : e17
Module : libs/edje
Dir : e17/libs/edje/src/bin
Modified Files:
edje_cc_handlers.c edje_cc_out.c edje_cc.h
Log Message:
New feature: part descriptions can inherit attributes from other descriptions of the
same part. All attributes are inherited, except description name and value, of course.
Syntax: inherit, "desc_name" desc_value;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_handlers.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- edje_cc_handlers.c 13 Oct 2004 18:07:56 -0000 1.40
+++ edje_cc_handlers.c 19 Oct 2004 16:37:19 -0000 1.41
@@ -32,6 +32,7 @@
static void st_collections_group_parts_part_dragable_confine(void);
static void ob_collections_group_parts_part_description(void);
+static void st_collections_group_parts_part_description_inherit(void);
static void st_collections_group_parts_part_description_state(void);
static void st_collections_group_parts_part_description_visible(void);
static void st_collections_group_parts_part_description_align(void);
@@ -120,6 +121,7 @@
{"collections.group.parts.part.images.image", st_images_image}, /* dup */
{"collections.group.parts.part.font", st_fonts_font}, /* dup */
{"collections.group.parts.part.fonts.font", st_fonts_font}, /* dup */
+ {"collections.group.parts.part.description.inherit",
st_collections_group_parts_part_description_inherit},
{"collections.group.parts.part.description.state",
st_collections_group_parts_part_description_state},
{"collections.group.parts.part.description.visible",
st_collections_group_parts_part_description_visible},
{"collections.group.parts.part.description.align",
st_collections_group_parts_part_description_align},
@@ -744,6 +746,115 @@
}
static void
+st_collections_group_parts_part_description_inherit(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Part_Description *ed, *parent = NULL;
+ Evas_List *l;
+ char *parent_name, *state_name;
+ double parent_val, state_val;
+
+ pc = evas_list_data(evas_list_last(edje_collections));
+ ep = evas_list_data(evas_list_last(pc->parts));
+
+ /* inherit may not be used in the default description */
+ if (!ep->other_desc)
+ {
+ fprintf(stderr, "part %s: "
+ "inherit may not be used in the default description!\n",
+ ep->name);
+ exit(-1);
+ }
+
+ ed = evas_list_data(evas_list_last(ep->other_desc));
+
+ if (!ed->state.name)
+ {
+ fprintf(stderr, "part %s: "
+ "inherit may only be used after state!\n",
+ ep->name);
+ exit(-1);
+ }
+
+ /* find the description that we inherit from */
+ parent_name = parse_str(0);
+ parent_val = parse_float_range(1, 0.0, 1.0);
+
+ if (!strcmp (parent_name, "default") && parent_val == 0.0)
+ parent = ep->default_desc;
+ else
+ {
+ double min_dst = 999.0;
+
+ if (!strcmp(parent_name, "default"))
+ {
+ parent = ep->default_desc;
+ min_dst = ABS(ep->default_desc->state.value - parent_val);
+ }
+
+ for (l = ep->other_desc; l; l = l->next)
+ {
+ Edje_Part_Description *d = l->data;
+
+ if (!strcmp (d->state.name, parent_name))
+ {
+ double dst;
+
+ dst = ABS(d->state.value - parent_val);
+ if (dst < min_dst)
+ {
+ parent = d;
+ min_dst = dst;
+ }
+ }
+ }
+ }
+
+ if (!parent)
+ {
+ fprintf (stderr, "part %s: "
+ "cannot find referenced part state %s %lf\n",
+ ep->name, parent_name, parent_val);
+ exit(-1);
+ }
+
+ free (parent_name);
+
+ /* now do a full copy, only state info will be kept */
+ state_name = ed->state.name;
+ state_val = ed->state.value;
+
+ *ed = *parent;
+
+ ed->state.name = state_name;
+ ed->state.value = state_val;
+
+ data_queue_part_slave_lookup(&parent->rel1.id_x, &ed->rel1.id_x);
+ data_queue_part_slave_lookup(&parent->rel1.id_y, &ed->rel1.id_y);
+ data_queue_part_slave_lookup(&parent->rel2.id_x, &ed->rel2.id_x);
+ data_queue_part_slave_lookup(&parent->rel2.id_y, &ed->rel2.id_y);
+ data_queue_image_slave_lookup(&parent->image.id, &ed->image.id);
+
+ /* make sure all the allocated memory is getting copied, not just
+ * referenced
+ */
+ ed->image.tween_list = NULL;
+
+ for (l = parent->image.tween_list; l; l = l->next)
+ ed->image.tween_list = evas_list_append(ed->image.tween_list, l->data);
+
+#define STRDUP(x) x ? strdup(x) : NULL
+
+ ed->color_class = STRDUP(ed->color_class);
+ ed->text.text = STRDUP(ed->text.text);
+ ed->text.text_class = STRDUP(ed->text.text_class);
+ ed->text.font = STRDUP(ed->text.font);
+
+#undef STRDUP
+}
+
+static void
st_collections_group_parts_part_description_state(void)
{
Edje_Part_Collection *pc;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_out.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- edje_cc_out.c 12 Oct 2004 16:58:18 -0000 1.32
+++ edje_cc_out.c 19 Oct 2004 16:37:20 -0000 1.33
@@ -7,6 +7,7 @@
typedef struct _Part_Lookup Part_Lookup;
typedef struct _Program_Lookup Program_Lookup;
typedef struct _Image_Lookup Image_Lookup;
+typedef struct _Slave_Lookup Slave_Lookup;
typedef struct _Code_Lookup Code_Lookup;
struct _Part_Lookup
@@ -29,6 +30,12 @@
int *dest;
};
+struct _Slave_Lookup
+{
+ int *master;
+ int *slave;
+};
+
struct _Code_Lookup
{
char *ptr;
@@ -60,6 +67,8 @@
static Evas_List *part_lookups = NULL;
static Evas_List *program_lookups = NULL;
static Evas_List *image_lookups = NULL;
+static Evas_List *part_slave_lookups = NULL;
+static Evas_List *image_slave_lookups= NULL;
#define ABORT_WRITE(eet_file, file) \
eet_close(eet_file); \
@@ -709,6 +718,42 @@
}
void
+data_queue_part_slave_lookup(int *master, int *slave)
+{
+ Slave_Lookup *sl;
+
+ sl = mem_alloc(SZ(Slave_Lookup));
+ part_slave_lookups = evas_list_append(part_slave_lookups, sl);
+ sl->master = master;
+ sl->slave = slave;
+}
+
+void
+data_queue_image_slave_lookup(int *master, int *slave)
+{
+ Slave_Lookup *sl;
+
+ sl = mem_alloc(SZ(Slave_Lookup));
+ image_slave_lookups = evas_list_append(image_slave_lookups, sl);
+ sl->master = master;
+ sl->slave = slave;
+}
+
+void
+handle_slave_lookup(Evas_List *list, int *master, int value)
+{
+ Evas_List *l;
+
+ for (l = list; l; l = l->next)
+ {
+ Slave_Lookup *sl = l->data;
+
+ if (sl->master == master)
+ *sl->slave = value;
+ }
+}
+
+void
data_process_lookups(void)
{
Evas_List *l;
@@ -726,6 +771,7 @@
ep = l->data;
if ((ep->name) && (!strcmp(ep->name, pl->name)))
{
+ handle_slave_lookup(part_slave_lookups, pl->dest, ep->id);
*(pl->dest) = ep->id;
break;
}
@@ -786,6 +832,7 @@
de = l->data;
if ((de->entry) && (!strcmp(de->entry, il->name)))
{
+ handle_slave_lookup(image_slave_lookups, il->dest, de->id);
*(il->dest) = de->id;
break;
}
@@ -802,6 +849,18 @@
free(il->name);
free(il);
}
+
+ while (part_slave_lookups)
+ {
+ free(part_slave_lookups->data);
+ part_slave_lookups = evas_list_remove_list(part_slave_lookups,
part_slave_lookups);
+ }
+
+ while (image_slave_lookups)
+ {
+ free(image_slave_lookups->data);
+ image_slave_lookups = evas_list_remove_list(image_slave_lookups,
image_slave_lookups);
+ }
}
static void
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- edje_cc.h 13 Oct 2004 18:07:55 -0000 1.19
+++ edje_cc.h 19 Oct 2004 16:37:20 -0000 1.20
@@ -22,6 +22,10 @@
#include <alloca.h>
#endif
+#ifndef ABS
+#define ABS(x) x < 0 ? -x : x
+#endif
+
/* types */
typedef struct _New_Object_Handler New_Object_Handler;
typedef struct _New_Statement_Handler New_Statement_Handler;
@@ -86,6 +90,8 @@
void data_queue_part_lookup(Edje_Part_Collection *pc, char *name, int *dest);
void data_queue_program_lookup(Edje_Part_Collection *pc, char *name, int *dest);
void data_queue_image_lookup(char *name, int *dest);
+void data_queue_part_slave_lookup(int *master, int *slave);
+void data_queue_image_slave_lookup(int *master, int *slave);
void data_process_lookups(void);
void data_process_scripts(void);
void data_process_script_lookups(void);
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs