diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2011-02-05 20:17:39 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2011-02-05 20:17:39 +0100 |
commit | 2dcf578c120e3dab375bbe345f0f8f5bac151be9 (patch) | |
tree | de516f0d4adaa58d3a0adcafcda27173b03db713 | |
parent | dca71f66c3cf65537017d5add98617a60235e5d7 (diff) | |
download | logdiag-2dcf578c120e3dab375bbe345f0f8f5bac151be9.tar.gz logdiag-2dcf578c120e3dab375bbe345f0f8f5bac151be9.tar.xz logdiag-2dcf578c120e3dab375bbe345f0f8f5bac151be9.zip |
Use correct rounding when moving selection.
-rw-r--r-- | liblogdiag/ld-canvas.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/liblogdiag/ld-canvas.c b/liblogdiag/ld-canvas.c index 4238876..b449560 100644 --- a/liblogdiag/ld-canvas.c +++ b/liblogdiag/ld-canvas.c @@ -1390,14 +1390,17 @@ static void oper_move_selection_motion (LdCanvas *self, gdouble x, gdouble y) { MoveSelectionData *data; - gdouble scale, move_x, move_y; + gdouble scale, dx, dy, move_x, move_y; gdouble move = FALSE; scale = ld_canvas_get_scale_in_px (self); data = &OPER_DATA (self, move_selection); - move_x = floor ((x - data->move_origin.x) / scale); - move_y = floor ((y - data->move_origin.y) / scale); + dx = x - data->move_origin.x; + dy = y - data->move_origin.y; + + move_x = dx < 0 ? ceil (dx / scale) : floor (dx / scale); + move_y = dy < 0 ? ceil (dy / scale) : floor (dy / scale); if (ABS (move_x) >= 1) { |