[libshumate] marker-layer: Floor down x/y
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libshumate] marker-layer: Floor down x/y
- Date: Thu, 4 Mar 2021 20:40:49 +0000 (UTC)
commit 6efbb0a1e20547ce6f7d29bbbe3b0d1fe03e4d3f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Mar 4 15:33:44 2021 -0300
marker-layer: Floor down x/y
While technically ceiling the x/y of each marker gives slightly more precise
results, it also makes markers wiggle often while dragging the viewport. Floor,
on the other hand, is very very slightly less precise, much makes markers'
position much more stable.
Use floorf() instead of ceilf() to calculate each marker's position.
shumate/shumate-marker-layer.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/shumate/shumate-marker-layer.c b/shumate/shumate-marker-layer.c
index ae0f02f..ccb022d 100644
--- a/shumate/shumate-marker-layer.c
+++ b/shumate/shumate-marker-layer.c
@@ -133,8 +133,8 @@ update_marker_visibility (ShumateMarkerLayer *layer,
gtk_widget_measure (GTK_WIDGET (marker), GTK_ORIENTATION_HORIZONTAL, -1, 0, &marker_width, NULL, NULL);
gtk_widget_measure (GTK_WIDGET (marker), GTK_ORIENTATION_VERTICAL, -1, 0, &marker_height, NULL, NULL);
- x = roundf (shumate_viewport_longitude_to_widget_x (viewport, GTK_WIDGET (layer), lon) - marker_width/2.f);
- y = roundf (shumate_viewport_latitude_to_widget_y (viewport, GTK_WIDGET (layer), lat) - marker_height/2.f);
+ x = floorf (shumate_viewport_longitude_to_widget_x (viewport, GTK_WIDGET (layer), lon) - marker_width/2.f);
+ y = floorf (shumate_viewport_latitude_to_widget_y (viewport, GTK_WIDGET (layer), lat) - marker_height/2.f);
within_viewport = x > -marker_width && x <= width &&
y > -marker_height && y <= height &&
@@ -227,8 +227,8 @@ shumate_marker_layer_size_allocate (GtkWidget *widget,
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, -1, 0, &marker_width, NULL, NULL);
gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL, -1, 0, &marker_height, NULL, NULL);
- x = roundf (shumate_viewport_longitude_to_widget_x (viewport, widget, lon) - marker_width/2.f);
- y = roundf (shumate_viewport_latitude_to_widget_y (viewport, widget, lat) - marker_height/2.f);
+ x = floorf (shumate_viewport_longitude_to_widget_x (viewport, widget, lon) - marker_width/2.f);
+ y = floorf (shumate_viewport_latitude_to_widget_y (viewport, widget, lat) - marker_height/2.f);
allocation.x = x;
allocation.y = y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]