summaryrefslogtreecommitdiff
path: root/navit/navit.c
diff options
context:
space:
mode:
authorkazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-08-18 14:52:39 +0000
committerkazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-08-18 14:52:39 +0000
commit5bd4b745675e01603f2c38c78dc989260294ab45 (patch)
tree953134d883ccacbe6229bc13ffc743d3ec30afb0 /navit/navit.c
parentd019e52ab9b2ba0a55c9db5642a5390cee9927ce (diff)
downloadnavit-5bd4b745675e01603f2c38c78dc989260294ab45.tar.gz
Fixed ticket #442, Cursor centering offset should be speed dependent, patch from niccolo (thanks)
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2488 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/navit.c')
-rw-r--r--navit/navit.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/navit/navit.c b/navit/navit.c
index 70fdd6e15..5305a9add 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -1488,10 +1488,25 @@ navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir)
{
int width, height;
struct navit_vehicle *nv=this_->vehicle;
+
+ float offset; // Cursor offset from the center of the screen (percent).
+ float min_offset = 0.; // Percent offset at min_offset_speed.
+ float max_offset = 30.; // Percent offset at max_offset_speed.
+ int min_offset_speed = 2; // Speed in km/h
+ int max_offset_speed = 50; // Speed ini km/h
+ // Calculate cursor offset from the center of the screen, upon speed.
+ if (nv->speed <= min_offset_speed) {
+ offset = min_offset;
+ } else if (nv->speed > max_offset_speed) {
+ offset = max_offset;
+ } else {
+ offset = (max_offset - min_offset) / (max_offset_speed - min_offset_speed) * (nv->speed - min_offset_speed);
+ }
+
transform_get_size(this_->trans, &width, &height);
if (this_->orientation == -1) {
p->x=50*width/100;
- p->y=80*height/100;
+ p->y=(50 + offset)*height/100;
if (dir)
*dir=nv->dir;
} else {
@@ -1502,8 +1517,8 @@ navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir)
mdir=nv->dir-this_->orientation;
}
- p->x=(50 - 30.*sin(M_PI*mdir/180.))*width/100;
- p->y=(50 + 30.*cos(M_PI*mdir/180.))*height/100;
+ p->x=(50 - offset*sin(M_PI*mdir/180.))*width/100;
+ p->y=(50 + offset*cos(M_PI*mdir/180.))*height/100;
if (dir)
*dir=this_->orientation;
}