From 61ac6247c69faa0f38e95229b17c115f1f501c62 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 30 Oct 2010 16:58:57 +0000 Subject: [PATCH] Add:Core:Exported navit_set_center_cursor function git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3633 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/navit.c | 33 ++++++++++++++++++------------ navit/navit/navit.h | 1 + navit/navit/plugin/pedestrian/pedestrian.c | 14 ++++++------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/navit/navit/navit.c b/navit/navit/navit.c index c2309ad..9ef40c1 100644 --- a/navit/navit/navit.c +++ b/navit/navit/navit.c @@ -157,7 +157,7 @@ static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv); static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt); static int navit_add_vehicle(struct navit *this_, struct vehicle *v); static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init); -static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir); +static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir); static void navit_set_cursors(struct navit *this_); static void navit_cmd_zoom_to_route(struct navit *this); static void navit_cmd_set_center_cursor(struct navit *this_); @@ -617,7 +617,7 @@ static int navit_cmd_zoom_in(struct navit *this_) { struct point p; - if (this_->vehicle && this_->vehicle->follow_curr == 1 && navit_get_cursor_pnt(this_, &p, NULL)) { + if (this_->vehicle && this_->vehicle->follow_curr == 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) { navit_zoom_in(this_, 2, &p); this_->vehicle->follow_curr=this_->vehicle->follow; } else @@ -629,7 +629,7 @@ static int navit_cmd_zoom_out(struct navit *this_) { struct point p; - if (this_->vehicle && this_->vehicle->follow_curr == 1 && navit_get_cursor_pnt(this_, &p, NULL)) { + if (this_->vehicle && this_->vehicle->follow_curr == 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) { navit_zoom_out(this_, 2, &p); this_->vehicle->follow_curr=this_->vehicle->follow; } else @@ -1422,7 +1422,7 @@ navit_set_cursors(struct navit *this_) } static int -navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir) +navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) { int width, height; struct navit_vehicle *nv=this_->vehicle; @@ -1444,11 +1444,11 @@ navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir) #endif transform_get_size(this_->trans, &width, &height); - if (this_->orientation == -1) { + if (this_->orientation == -1 || keep_orientation) { p->x=50*width/100; p->y=(50 + offset)*height/100; - if (dir) - *dir=nv->dir; + if (dir) + *dir=keep_orientation?this_->orientation:nv->dir; } else { int mdir; if (this_->tracking && this_->tracking_flag) { @@ -1465,16 +1465,23 @@ navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir) return 1; } -static void -navit_set_center_cursor(struct navit *this_) +void +navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) { int dir; struct point pn; struct navit_vehicle *nv=this_->vehicle; - navit_get_cursor_pnt(this_, &pn, &dir); + navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); transform_set_yaw(this_->trans, dir); navit_set_center_coord_screen(this_, &nv->coord, &pn, 0); - navit_autozoom(this_, &nv->coord, nv->speed, 0); + if (autozoom) + navit_autozoom(this_, &nv->coord, nv->speed, 0); +} + +static void +navit_set_center_cursor_draw(struct navit *this_) +{ + navit_set_center_cursor(this_,1,0); if (this_->ready == 3) navit_draw_async(this_, 1); } @@ -1482,7 +1489,7 @@ navit_set_center_cursor(struct navit *this_) static void navit_cmd_set_center_cursor(struct navit *this_) { - navit_set_center_cursor(this_); + navit_set_center_cursor_draw(this_); } void @@ -2080,7 +2087,7 @@ navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv) transform(this_->trans, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans, &cursor_pnt, border))) - navit_set_center_cursor(this_); + navit_set_center_cursor_draw(this_); else navit_vehicle_draw(this_, nv, pnt); diff --git a/navit/navit/navit.h b/navit/navit/navit.h index 47180b0..5fcfc0f 100644 --- a/navit/navit/navit.h +++ b/navit/navit/navit.h @@ -83,6 +83,7 @@ void navit_init(struct navit *this_); void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r); void navit_zoom_to_route(struct navit *this_, int orientation); void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout); +void navit_set_center_cursor(struct navit *this_, int keep_orientation, int autozoom); void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout); int navit_set_attr(struct navit *this_, struct attr *attr); int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter); diff --git a/navit/navit/plugin/pedestrian/pedestrian.c b/navit/navit/plugin/pedestrian/pedestrian.c index 6d5e7fb..b73b552 100644 --- a/navit/navit/plugin/pedestrian/pedestrian.c +++ b/navit/navit/plugin/pedestrian/pedestrian.c @@ -915,7 +915,7 @@ static struct map_methods map_route_occluded_methods = { }; -struct map_priv * +static struct map_priv * map_route_occluded_new(struct map_methods *meth, struct attr **attrs) { struct map_priv *ret; @@ -931,7 +931,7 @@ map_route_occluded_new(struct map_methods *meth, struct attr **attrs) return ret; } -void +static void pedestrian_graphics_resize(struct graphics *gra, int w, int h) { #ifndef HAVE_API_ANDROID @@ -1010,7 +1010,7 @@ pedestrian_draw_arrows(struct graphics *gra) map_rect_destroy(route_map_rect); } -void +static void pedestrian_graphics_postdraw(struct graphics *gra) { #if 0 @@ -1189,13 +1189,13 @@ android_sensors(struct navit *nav, int sensor, float *x, float *y, float *z) navit_set_attr(nav, &attr); dbg(1,"yaw %d %f\n",orientation,yaw); if (orientation == 2) - navit_set_center_cursor_nodraw(nav, 0); + navit_set_center_cursor(nav, 1, 0); } } } #endif -void +static void pedestrian_log(char **logstr) { #ifdef HAVE_API_ANDROID @@ -1227,7 +1227,7 @@ vehicle_changed(struct vehicle *v, struct transformation *trans) #endif -void +static void pedestrian_navit_init(struct navit *nav) { struct attr route; @@ -1341,7 +1341,7 @@ pedestrian_navit_init(struct navit *nav) } -void +static void pedestrian_navit(struct navit *nav, int add) { dbg(0,"enter\n"); -- 2.7.4