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);
{"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},
}
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;
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
int *dest;
};
+struct _Slave_Lookup
+{
+ int *master;
+ int *slave;
+};
+
struct _Code_Lookup
{
char *ptr;
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); \
}
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;
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;
}
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;
}
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