separate x & y relative "to" params. the old .edc format is still supported

where "to" implies both x & y. to_x == only in x dir, to_y == only in y dir :)


SVN revision: 7315
This commit is contained in:
Carsten Haitzler 2003-08-14 03:22:38 +00:00
parent 97700a07e9
commit 211959c6c0
6 changed files with 217 additions and 70 deletions

View File

@ -393,6 +393,32 @@ collections {
}
}
}
part {
name, "dragable";
mouse_events, 1;
dragable {
// drag in: DIR, ON/OFF STEPPING COUNT;
x, 1 1 0;
y, 1 1 0;
confine, "background";
}
description {
state, "default" 0.0;
min, 36 36;
rel1 {
relative, 0.5 0.5;
offset, 0 0;
}
rel2 {
relative, 0.5 0.5;
offset, 0 0;
}
image {
normal, "bg.png";
}
border, 12 12 12 12;
}
}
}
programs {
program {

View File

@ -39,9 +39,13 @@ static void st_collections_group_parts_part_description_aspect(void);
static void st_collections_group_parts_part_description_rel1_relative(void);
static void st_collections_group_parts_part_description_rel1_offset(void);
static void st_collections_group_parts_part_description_rel1_to(void);
static void st_collections_group_parts_part_description_rel1_to_x(void);
static void st_collections_group_parts_part_description_rel1_to_y(void);
static void st_collections_group_parts_part_description_rel2_relative(void);
static void st_collections_group_parts_part_description_rel2_offset(void);
static void st_collections_group_parts_part_description_rel2_to(void);
static void st_collections_group_parts_part_description_rel2_to_x(void);
static void st_collections_group_parts_part_description_rel2_to_y(void);
static void st_collections_group_parts_part_description_image_normal(void);
static void st_collections_group_parts_part_description_image_tween(void);
static void st_collections_group_parts_part_description_border(void);
@ -103,9 +107,13 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.parts.part.description.rel1.relative", st_collections_group_parts_part_description_rel1_relative},
{"collections.group.parts.part.description.rel1.offset", st_collections_group_parts_part_description_rel1_offset},
{"collections.group.parts.part.description.rel1.to", st_collections_group_parts_part_description_rel1_to},
{"collections.group.parts.part.description.rel1.to_x", st_collections_group_parts_part_description_rel1_to_x},
{"collections.group.parts.part.description.rel1.to_y", st_collections_group_parts_part_description_rel1_to_y},
{"collections.group.parts.part.description.rel2.relative", st_collections_group_parts_part_description_rel2_relative},
{"collections.group.parts.part.description.rel2.offset", st_collections_group_parts_part_description_rel2_offset},
{"collections.group.parts.part.description.rel2.to", st_collections_group_parts_part_description_rel2_to},
{"collections.group.parts.part.description.rel2.to_x", st_collections_group_parts_part_description_rel2_to_x},
{"collections.group.parts.part.description.rel2.to_y", st_collections_group_parts_part_description_rel2_to_y},
{"collections.group.parts.part.description.image.normal", st_collections_group_parts_part_description_image_normal},
{"collections.group.parts.part.description.image.tween", st_collections_group_parts_part_description_image_tween},
{"collections.group.parts.part.description.border", st_collections_group_parts_part_description_border},
@ -527,12 +535,14 @@ ob_collections_group_parts_part_description(void)
ed->rel1.relative_y = 0.0;
ed->rel1.offset_x = 0;
ed->rel1.offset_x = 0;
ed->rel1.id = -1;
ed->rel1.id_x = -1;
ed->rel1.id_y = -1;
ed->rel2.relative_x = 1.0;
ed->rel2.relative_y = 1.0;
ed->rel2.offset_x = -1;
ed->rel2.offset_x = -1;
ed->rel2.id = -1;
ed->rel2.id_x = -1;
ed->rel2.id_y = -1;
ed->image.id = -1;
ed->fill.smooth = 1;
ed->fill.pos_rel_x = 0.0;
@ -708,7 +718,48 @@ st_collections_group_parts_part_description_rel1_to(void)
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(ed->rel1.id));
data_queue_part_lookup(pc, name, &(ed->rel1.id_x));
data_queue_part_lookup(pc, name, &(ed->rel1.id_y));
free(name);
}
}
static void
st_collections_group_parts_part_description_rel1_to_x(void)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
Edje_Part_Description *ed;
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
{
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(ed->rel1.id_x));
free(name);
}
}
static void
st_collections_group_parts_part_description_rel1_to_y(void)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
Edje_Part_Description *ed;
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
{
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(ed->rel1.id_y));
free(name);
}
}
@ -758,7 +809,48 @@ st_collections_group_parts_part_description_rel2_to(void)
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(ed->rel2.id));
data_queue_part_lookup(pc, name, &(ed->rel2.id_x));
data_queue_part_lookup(pc, name, &(ed->rel2.id_y));
free(name);
}
}
static void
st_collections_group_parts_part_description_rel2_to_x(void)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
Edje_Part_Description *ed;
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
{
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(ed->rel2.id_x));
free(name);
}
}
static void
st_collections_group_parts_part_description_rel2_to_y(void)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
Edje_Part_Description *ed;
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
{
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(ed->rel2.id_y));
free(name);
}
}

View File

@ -1,7 +1,7 @@
#include "Edje.h"
#include "edje_private.h"
static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep, Edje_Part_Description *desc, Edje_Part_Description *chosen_desc, Edje_Real_Part *rel1_to, Edje_Real_Part *rel2_to, Edje_Real_Part *confine_to, Edje_Calc_Params *params);
static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep, Edje_Part_Description *desc, Edje_Part_Description *chosen_desc, Edje_Real_Part *rel1_to_x, Edje_Real_Part *rel1_to_y, Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y, Edje_Real_Part *confine_to, Edje_Calc_Params *params);
static void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep);
void
@ -87,14 +87,20 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char *d1, double v1,
}
ep->param1.description = desc_found;
}
ep->param1.rel1_to = NULL;
ep->param1.rel2_to = NULL;
ep->param1.rel1_to_x = NULL;
ep->param1.rel1_to_y = NULL;
ep->param1.rel2_to_x = NULL;
ep->param1.rel2_to_y = NULL;
if (ep->param1.description)
{
if (ep->param1.description->rel1.id >= 0)
ep->param1.rel1_to = evas_list_nth(ed->parts, ep->param1.description->rel1.id);
if (ep->param1.description->rel2.id >= 0)
ep->param1.rel2_to = evas_list_nth(ed->parts, ep->param1.description->rel2.id);
if (ep->param1.description->rel1.id_x >= 0)
ep->param1.rel1_to_x = evas_list_nth(ed->parts, ep->param1.description->rel1.id_x);
if (ep->param1.description->rel1.id_y >= 0)
ep->param1.rel1_to_y = evas_list_nth(ed->parts, ep->param1.description->rel1.id_y);
if (ep->param1.description->rel2.id_x >= 0)
ep->param1.rel2_to_x = evas_list_nth(ed->parts, ep->param1.description->rel2.id_x);
if (ep->param1.description->rel2.id_y >= 0)
ep->param1.rel2_to_y = evas_list_nth(ed->parts, ep->param1.description->rel2.id_y);
}
if (!strcmp(d2, "default") && (v2 == 0.0))
@ -140,23 +146,35 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char *d1, double v1,
}
if (!ep->param1.description)
ep->param1.description = ep->part->default_desc;
ep->param1.rel1_to = NULL;
ep->param1.rel2_to = NULL;
ep->param1.rel1_to_x = NULL;
ep->param1.rel1_to_y = NULL;
ep->param1.rel2_to_x = NULL;
ep->param1.rel2_to_y = NULL;
if (ep->param1.description)
{
if (ep->param1.description->rel1.id >= 0)
ep->param1.rel1_to = evas_list_nth(ed->parts, ep->param1.description->rel1.id);
if (ep->param1.description->rel2.id >= 0)
ep->param1.rel2_to = evas_list_nth(ed->parts, ep->param1.description->rel2.id);
if (ep->param1.description->rel1.id_x >= 0)
ep->param1.rel1_to_x = evas_list_nth(ed->parts, ep->param1.description->rel1.id_x);
if (ep->param1.description->rel1.id_y >= 0)
ep->param1.rel1_to_y = evas_list_nth(ed->parts, ep->param1.description->rel1.id_y);
if (ep->param1.description->rel2.id_x >= 0)
ep->param1.rel2_to_x = evas_list_nth(ed->parts, ep->param1.description->rel2.id_x);
if (ep->param1.description->rel2.id_y >= 0)
ep->param1.rel2_to_y = evas_list_nth(ed->parts, ep->param1.description->rel2.id_y);
}
ep->param2.rel1_to = NULL;
ep->param2.rel2_to = NULL;
ep->param2.rel1_to_x = NULL;
ep->param2.rel1_to_y = NULL;
ep->param2.rel2_to_x = NULL;
ep->param2.rel2_to_y = NULL;
if (ep->param2.description)
{
if (ep->param2.description->rel1.id >= 0)
ep->param2.rel1_to = evas_list_nth(ed->parts, ep->param2.description->rel1.id);
if (ep->param2.description->rel2.id >= 0)
ep->param2.rel2_to = evas_list_nth(ed->parts, ep->param2.description->rel2.id);
if (ep->param2.description->rel1.id_x >= 0)
ep->param2.rel1_to_x = evas_list_nth(ed->parts, ep->param2.description->rel1.id_x);
if (ep->param2.description->rel1.id_y >= 0)
ep->param2.rel1_to_y = evas_list_nth(ed->parts, ep->param2.description->rel1.id_y);
if (ep->param2.description->rel2.id_x >= 0)
ep->param2.rel2_to_x = evas_list_nth(ed->parts, ep->param2.description->rel2.id_x);
if (ep->param2.description->rel2.id_y >= 0)
ep->param2.rel2_to_y = evas_list_nth(ed->parts, ep->param2.description->rel2.id_y);
}
ed->dirty = 1;
@ -196,46 +214,44 @@ _edje_part_recalc_single(Edje *ed,
Edje_Real_Part *ep,
Edje_Part_Description *desc,
Edje_Part_Description *chosen_desc,
Edje_Real_Part *rel1_to,
Edje_Real_Part *rel2_to,
Edje_Real_Part *rel1_to_x,
Edje_Real_Part *rel1_to_y,
Edje_Real_Part *rel2_to_x,
Edje_Real_Part *rel2_to_y,
Edje_Real_Part *confine_to,
Edje_Calc_Params *params)
{
int minw, minh, maxw, maxh;
/* relative coords of top left & bottom right */
if (rel1_to)
{
params->x = desc->rel1.offset_x +
rel1_to->x + (desc->rel1.relative_x * rel1_to->w);
params->y = desc->rel1.offset_y +
rel1_to->y + (desc->rel1.relative_y * rel1_to->h);
}
if (rel1_to_x)
params->x = desc->rel1.offset_x +
rel1_to_x->x + (desc->rel1.relative_x * rel1_to_x->w);
else
{
params->x = desc->rel1.offset_x +
(desc->rel1.relative_x * ed->w);
params->y = desc->rel1.offset_y +
(desc->rel1.relative_y * ed->h);
}
if (rel2_to)
{
params->w = desc->rel2.offset_x +
rel2_to->x + (desc->rel2.relative_x * rel2_to->w) -
params->x;
params->h = desc->rel2.offset_y +
rel2_to->y + (desc->rel2.relative_y * rel2_to->h) -
params->y;
}
params->x = desc->rel1.offset_x +
(desc->rel1.relative_x * ed->w);
if (rel1_to_y)
params->y = desc->rel1.offset_y +
rel1_to_y->y + (desc->rel1.relative_y * rel1_to_y->h);
else
{
params->w = (double)desc->rel2.offset_x +
(desc->rel2.relative_x * (double)ed->w) -
params->x + 1;
params->h = (double)desc->rel2.offset_y +
(desc->rel2.relative_y * (double)ed->h) -
params->y + 1;
}
params->y = desc->rel1.offset_y +
(desc->rel1.relative_y * ed->h);
if (rel2_to_x)
params->w = desc->rel2.offset_x +
rel2_to_x->x + (desc->rel2.relative_x * rel2_to_x->w) -
params->x;
else
params->w = (double)desc->rel2.offset_x +
(desc->rel2.relative_x * (double)ed->w) -
params->x + 1;
if (rel2_to_y)
params->h = desc->rel2.offset_y +
rel2_to_y->y + (desc->rel2.relative_y * rel2_to_y->h) -
params->y;
else
params->h = (double)desc->rel2.offset_y +
(desc->rel2.relative_y * (double)ed->h) -
params->y + 1;
/* aspect */
if (params->h > 0)
@ -503,11 +519,15 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep)
double pos = 0.0;
if (ep->calculated) return;
if (ep->param1.rel1_to) _edje_part_recalc(ed, ep->param1.rel1_to);
if (ep->param1.rel2_to) _edje_part_recalc(ed, ep->param1.rel2_to);
if (ep->param1.rel1_to_x) _edje_part_recalc(ed, ep->param1.rel1_to_x);
if (ep->param1.rel1_to_y) _edje_part_recalc(ed, ep->param1.rel1_to_y);
if (ep->param1.rel2_to_x) _edje_part_recalc(ed, ep->param1.rel2_to_x);
if (ep->param1.rel2_to_y) _edje_part_recalc(ed, ep->param1.rel2_to_y);
if (ep->param1.confine_to) _edje_part_recalc(ed, ep->param1.confine_to);
if (ep->param2.rel1_to) _edje_part_recalc(ed, ep->param2.rel1_to);
if (ep->param2.rel2_to) _edje_part_recalc(ed, ep->param2.rel2_to);
if (ep->param2.rel1_to_x) _edje_part_recalc(ed, ep->param2.rel1_to_x);
if (ep->param2.rel1_to_y) _edje_part_recalc(ed, ep->param2.rel1_to_y);
if (ep->param2.rel2_to_x) _edje_part_recalc(ed, ep->param2.rel2_to_x);
if (ep->param2.rel2_to_y) _edje_part_recalc(ed, ep->param2.rel2_to_y);
if (ep->param2.confine_to) _edje_part_recalc(ed, ep->param2.confine_to);
/* actually calculate now */
@ -518,10 +538,10 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep)
ep->chosen_description = chosen_desc;
if (ep->param1.description)
_edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, ep->param1.rel1_to, ep->param1.rel2_to, ep->param1.confine_to, &p1);
_edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y, ep->param1.confine_to, &p1);
if (ep->param2.description)
{
_edje_part_recalc_single(ed, ep, ep->param2.description, chosen_desc, ep->param2.rel1_to, ep->param2.rel2_to, ep->param2.confine_to, &p2);
_edje_part_recalc_single(ed, ep, ep->param2.description, chosen_desc, ep->param2.rel1_to_x, ep->param2.rel1_to_y, ep->param2.rel2_to_x, ep->param2.rel2_to_y, ep->param2.confine_to, &p2);
pos = ep->description_pos;

View File

@ -117,12 +117,14 @@ _edje_edd_setup(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel1.relative_y", rel1.relative_y, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel1.offset_x", rel1.offset_x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel1.offset_y", rel1.offset_y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel1.id", rel1.id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel1.id_x", rel1.id_x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel1.id_y", rel1.id_y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.relative_x", rel2.relative_x, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.relative_y", rel2.relative_y, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.offset_x", rel2.offset_x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.offset_y", rel2.offset_y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.id", rel2.id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.id_x", rel2.id_x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "rel2.id_y", rel2.id_y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "image.id", image.id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_description, Edje_Part_Description, "image.tween_list", image.tween_list, _edje_edd_edje_part_image_id);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "border.l", border.l, EET_T_INT);

View File

@ -141,10 +141,14 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
Edje_Real_Part *rp;
rp = l->data;
if (rp->param1.description->rel1.id >= 0)
rp->param1.rel1_to = evas_list_nth(ed->parts, rp->param1.description->rel1.id);
if (rp->param1.description->rel2.id >= 0)
rp->param1.rel2_to = evas_list_nth(ed->parts, rp->param1.description->rel2.id);
if (rp->param1.description->rel1.id_x >= 0)
rp->param1.rel1_to_x = evas_list_nth(ed->parts, rp->param1.description->rel1.id_x);
if (rp->param1.description->rel1.id_y >= 0)
rp->param1.rel1_to_y = evas_list_nth(ed->parts, rp->param1.description->rel1.id_y);
if (rp->param1.description->rel2.id_x >= 0)
rp->param1.rel2_to_x = evas_list_nth(ed->parts, rp->param1.description->rel2.id_x);
if (rp->param1.description->rel2.id_y >= 0)
rp->param1.rel2_to_y = evas_list_nth(ed->parts, rp->param1.description->rel2.id_y);
_edje_text_part_on_add_clippers(ed, rp);
if (rp->part->clip_to_id >= 0)
{

View File

@ -289,7 +289,8 @@ struct _Edje_Part_Description
double relative_y;
int offset_x;
int offset_y;
int id; /* -1 = whole part collection, or part ID */
int id_x; /* -1 = whole part collection, or part ID */
int id_y; /* -1 = whole part collection, or part ID */
} rel1, rel2;
struct {
@ -430,8 +431,10 @@ struct _Edje_Real_Part
Edje_Part_Description *chosen_description;
struct {
Edje_Part_Description *description;
Edje_Real_Part *rel1_to;
Edje_Real_Part *rel2_to;
Edje_Real_Part *rel1_to_x;
Edje_Real_Part *rel1_to_y;
Edje_Real_Part *rel2_to_x;
Edje_Real_Part *rel2_to_y;
Edje_Real_Part *confine_to;
} param1, param2;