live_edit: Fix to reduce round-off error.

Round off values in the end to reduce round-off error.
This commit is contained in:
Jaehyun Cho 2016-08-19 16:10:37 +09:00
parent 265626a86b
commit 5126538a87
1 changed files with 20 additions and 8 deletions

View File

@ -832,10 +832,16 @@ keygrabber_direction_key_down_cb(void *data, Evas *e EINA_UNUSED,
//Calculate the relative value of live view item to 4 places of decimals
double orig_rel1_x = ld->rel_info.rel1_x;
double orig_rel1_y = ld->rel_info.rel1_y;
ld->rel_info.rel1_x = ROUNDING(((double) (x - vx) / vw), 4);
ld->rel_info.rel1_y = ROUNDING(((double) (y - vy) / vh), 4);
ld->rel_info.rel2_x += ROUNDING((ld->rel_info.rel1_x - orig_rel1_x), 4);
ld->rel_info.rel2_y += ROUNDING((ld->rel_info.rel1_y - orig_rel1_y), 4);
ld->rel_info.rel1_x = (double) (x - vx) / vw;
ld->rel_info.rel1_y = (double) (y - vy) / vh;
ld->rel_info.rel2_x += ld->rel_info.rel1_x - orig_rel1_x;
ld->rel_info.rel2_y += ld->rel_info.rel1_y - orig_rel1_y;
//Round off in the end to reduce round-off error.
ROUNDING(ld->rel_info.rel1_x, 4);
ROUNDING(ld->rel_info.rel1_y, 4);
ROUNDING(ld->rel_info.rel2_x, 4);
ROUNDING(ld->rel_info.rel2_y, 4);
ctrl_pt_update(ld);
info_text_update(ld);
@ -1876,10 +1882,16 @@ layout_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
double orig_rel1_x = ld->rel_info.rel1_x;
double orig_rel1_y = ld->rel_info.rel1_y;
ld->rel_info.rel1_x = ROUNDING(((double) (x - vx) / vw), 2);
ld->rel_info.rel1_y = ROUNDING(((double) (y - vy) / vh), 2);
ld->rel_info.rel2_x += ROUNDING((ld->rel_info.rel1_x - orig_rel1_x), 2);
ld->rel_info.rel2_y += ROUNDING((ld->rel_info.rel1_y - orig_rel1_y), 2);
ld->rel_info.rel1_x = (double) (x - vx) / vw;
ld->rel_info.rel1_y = (double) (y - vy) / vh;
ld->rel_info.rel2_x += ld->rel_info.rel1_x - orig_rel1_x;
ld->rel_info.rel2_y += ld->rel_info.rel1_y - orig_rel1_y;
//Round off in the end to reduce round-off error.
ROUNDING(ld->rel_info.rel1_x, 2);
ROUNDING(ld->rel_info.rel1_y, 2);
ROUNDING(ld->rel_info.rel2_x, 2);
ROUNDING(ld->rel_info.rel2_y, 2);
evas_object_move(obj, x, y);