From 2dcf578c120e3dab375bbe345f0f8f5bac151be9 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 5 Feb 2011 20:17:39 +0100
Subject: Use correct rounding when moving selection.
---
liblogdiag/ld-canvas.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
(limited to 'liblogdiag')
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)
{
--
cgit v1.2.3-70-g09d2