summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-10-30 16:58:57 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-10-30 16:58:57 +0000
commitc4d93a430abfc5a769f8e63576b5e0ba886ce6c0 (patch)
tree9e8ad218792bc8f082b74fd3336e63a8085e10f8 /navit
parent2412e9e8df985f8e349bb560bc0f82dfccbe8748 (diff)
downloadnavit-c4d93a430abfc5a769f8e63576b5e0ba886ce6c0.tar.gz
Add:Core:Exported navit_set_center_cursor function
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3633 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/navit.c33
-rw-r--r--navit/navit.h1
-rw-r--r--navit/plugin/pedestrian/pedestrian.c14
3 files changed, 28 insertions, 20 deletions
diff --git a/navit/navit.c b/navit/navit.c
index c2309add9..9ef40c1f8 100644
--- a/navit/navit.c
+++ b/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.h b/navit/navit.h
index 47180b087..5fcfc0f53 100644
--- a/navit/navit.h
+++ b/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/plugin/pedestrian/pedestrian.c b/navit/plugin/pedestrian/pedestrian.c
index 6d5e7fbff..b73b5529e 100644
--- a/navit/plugin/pedestrian/pedestrian.c
+++ b/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");