summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_calc.c
diff options
context:
space:
mode:
authorJeeyong Um <conr2d@gmail.com>2017-04-25 16:25:11 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-04-25 16:25:15 -0700
commite105646041545ee3c8a0acc3cbac73dc36ed9e95 (patch)
treeda9fcf1026a2cfb70eb1c4cc853ab940fee41bb2 /src/lib/edje/edje_calc.c
parent7f5ec0c8ea00020be823808edbee12ad74c19fe6 (diff)
edje_cc: introduce "Anchors" - easy way to set parts relationship
Test Plan: compile src/examples/edc-anchors.c and run Reviewers: zmike, raster, cedric, jpeg Reviewed By: raster, jpeg Subscribers: raster, barbieri, zmike, SanghyeonLee, taxi2se, Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D4775 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_calc.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index bf0d809c5a..37163c3a14 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -1114,42 +1114,71 @@ _edje_part_recalc_single_rel(Edje *ed,
1114{ 1114{
1115 FLOAT_T x, w; 1115 FLOAT_T x, w;
1116 FLOAT_T y, h; 1116 FLOAT_T y, h;
1117 FLOAT_T offset, sc;
1118 Eina_Bool offset_is_scaled = (desc->offset_is_scaled) && (ep->part->scale);
1119
1120 if (offset_is_scaled)
1121 {
1122 sc = DIV(ed->scale, ed->file->base_scale);
1123 if (EQ(sc, ZERO)) sc = DIV(_edje_scale, ed->file->base_scale);
1124 }
1125
1126 if (offset_is_scaled)
1127 offset = SCALE(sc, desc->rel1.offset_x);
1128 else
1129 offset = FROM_INT(desc->rel1.offset_x);
1117 1130
1118 if (rel1_to_x) 1131 if (rel1_to_x)
1119 x = ADD(FROM_INT(desc->rel1.offset_x + rel1_to_x->x), 1132 x = ADD(ADD(offset, FROM_INT(rel1_to_x->x)),
1120 SCALE(desc->rel1.relative_x, rel1_to_x->w)); 1133 SCALE(desc->rel1.relative_x, rel1_to_x->w));
1121 else 1134 else
1122 x = ADD(FROM_INT(desc->rel1.offset_x), 1135 x = ADD(offset,
1123 SCALE(desc->rel1.relative_x, ed->w)); 1136 SCALE(desc->rel1.relative_x, ed->w));
1124 params->eval.x = x; 1137 params->eval.x = x;
1125 1138
1139 if (offset_is_scaled)
1140 offset = SUB(SCALE(sc, desc->rel2.offset_x + 1), FROM_INT(1));
1141 else
1142 offset = FROM_INT(desc->rel2.offset_x);
1143
1126 if (rel2_to_x) 1144 if (rel2_to_x)
1127 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x + rel2_to_x->x), 1145 w = ADD(SUB(ADD(ADD(offset, FROM_INT(rel2_to_x->x)),
1128 SCALE(desc->rel2.relative_x, rel2_to_x->w)), 1146 SCALE(desc->rel2.relative_x, rel2_to_x->w)),
1129 x), 1147 x),
1130 FROM_INT(1)); 1148 FROM_INT(1));
1131 else 1149 else
1132 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x), 1150 w = ADD(SUB(ADD(offset,
1133 SCALE(desc->rel2.relative_x, ed->w)), 1151 SCALE(desc->rel2.relative_x, ed->w)),
1134 x), 1152 x),
1135 FROM_INT(1)); 1153 FROM_INT(1));
1136 params->eval.w = w; 1154 params->eval.w = w;
1137 1155
1156
1157 if (offset_is_scaled)
1158 offset = SCALE(sc, desc->rel1.offset_y);
1159 else
1160 offset = FROM_INT(desc->rel1.offset_y);
1161
1138 if (rel1_to_y) 1162 if (rel1_to_y)
1139 y = ADD(FROM_INT(desc->rel1.offset_y + rel1_to_y->y), 1163 y = ADD(ADD(offset, FROM_INT(rel1_to_y->y)),
1140 SCALE(desc->rel1.relative_y, rel1_to_y->h)); 1164 SCALE(desc->rel1.relative_y, rel1_to_y->h));
1141 else 1165 else
1142 y = ADD(FROM_INT(desc->rel1.offset_y), 1166 y = ADD(offset,
1143 SCALE(desc->rel1.relative_y, ed->h)); 1167 SCALE(desc->rel1.relative_y, ed->h));
1144 params->eval.y = y; 1168 params->eval.y = y;
1145 1169
1170 if (offset_is_scaled)
1171 offset = SUB(SCALE(sc, desc->rel2.offset_y + 1), FROM_INT(1));
1172 else
1173 offset = FROM_INT(desc->rel2.offset_y);
1174
1146 if (rel2_to_y) 1175 if (rel2_to_y)
1147 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y + rel2_to_y->y), 1176 h = ADD(SUB(ADD(ADD(offset, FROM_INT(rel2_to_y->y)),
1148 SCALE(desc->rel2.relative_y, rel2_to_y->h)), 1177 SCALE(desc->rel2.relative_y, rel2_to_y->h)),
1149 y), 1178 y),
1150 FROM_INT(1)); 1179 FROM_INT(1));
1151 else 1180 else
1152 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y), 1181 h = ADD(SUB(ADD(offset,
1153 SCALE(desc->rel2.relative_y, ed->h)), 1182 SCALE(desc->rel2.relative_y, ed->h)),
1154 y), 1183 y),
1155 FROM_INT(1)); 1184 FROM_INT(1));
@@ -4577,6 +4606,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4577 rp1[Rel2X], rp1[Rel2Y], clip1, confine_to, 4606 rp1[Rel2X], rp1[Rel2Y], clip1, confine_to,
4578 threshold, p1, mmw, mmh, 4607 threshold, p1, mmw, mmh,
4579 pos); 4608 pos);
4609
4580#ifdef EDJE_CALC_CACHE 4610#ifdef EDJE_CALC_CACHE
4581 if (flags == FLAG_XY) ep->param1.state = ed->state; 4611 if (flags == FLAG_XY) ep->param1.state = ed->state;
4582#endif 4612#endif
@@ -4622,6 +4652,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4622 rp2[Rel2X], rp2[Rel2Y], clip2, confine_to, 4652 rp2[Rel2X], rp2[Rel2Y], clip2, confine_to,
4623 threshold, p2, mmw, mmh, 4653 threshold, p2, mmw, mmh,
4624 pos); 4654 pos);
4655
4625#ifdef EDJE_CALC_CACHE 4656#ifdef EDJE_CALC_CACHE
4626 if (flags == FLAG_XY) ep->param2->state = ed->state; 4657 if (flags == FLAG_XY) ep->param2->state = ed->state;
4627#endif 4658#endif
@@ -4705,7 +4736,6 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
4705 p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth; 4736 p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth;
4706 4737
4707 /* FIXME: do x and y separately base on flag */ 4738 /* FIXME: do x and y separately base on flag */
4708
4709 p3->final.x = INTP(p1->final.x, p2->final.x, pos); 4739 p3->final.x = INTP(p1->final.x, p2->final.x, pos);
4710 p3->final.y = INTP(p1->final.y, p2->final.y, pos); 4740 p3->final.y = INTP(p1->final.y, p2->final.y, pos);
4711 p3->final.w = INTP(p1->final.w, p2->final.w, pos); 4741 p3->final.w = INTP(p1->final.w, p2->final.w, pos);