summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/gui/internal/gui_internal.c8
-rw-r--r--navit/item_def.h2
-rw-r--r--navit/navigation.c2
-rw-r--r--navit/navit.c30
-rw-r--r--navit/route.c41
-rw-r--r--navit/vehicle/demo/vehicle_demo.c4
6 files changed, 68 insertions, 19 deletions
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index ed3cf79fb..9e465b2de 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -222,6 +222,7 @@ struct gui_priv {
struct callback_list *cbl;
int flags;
int cols;
+ struct attr osd_configuration;
};
@@ -1194,6 +1195,7 @@ gui_internal_top_bar(struct gui_priv *this)
64:Show time
128:Show help
256:Use background for menu headline
+ 512:Set osd_configuration and zoom to route when setting position
*/
w=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|(this->flags & 1 ? 0:flags_fill));
@@ -1537,6 +1539,10 @@ gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void
struct widget *w=wm->data;
dbg(0,"c=%d:0x%x,0x%x\n", w->c.pro, w->c.x, w->c.y);
navit_set_destination(this->nav, &w->c, w->name);
+ if (this->flags & 512) {
+ navit_set_attr(this->nav, &this->osd_configuration);
+ navit_zoom_to_route(this->nav);
+ }
gui_internal_prune_menu(this, NULL);
}
@@ -3567,6 +3573,8 @@ static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods
this->text_foreground_color=(struct color){0xffff,0xffff,0xffff,0xffff};
if( (attr=attr_search(attrs,NULL,attr_columns)))
this->cols=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
+ this->osd_configuration=*attr;
this->data.priv=this;
this->data.gui=&gui_internal_methods_ext;
this->data.widget=&gui_internal_widget_methods;
diff --git a/navit/item_def.h b/navit/item_def.h
index d09f2cef6..e3f0e7cd2 100644
--- a/navit/item_def.h
+++ b/navit/item_def.h
@@ -300,6 +300,8 @@ ITEM(poi_climbing)
ITEM(poi_motor_sport)
ITEM(poi_tennis)
ITEM(house_number)
+ITEM(route_start)
+ITEM(route_end)
/* Line */
ITEM2(0x80000000,line)
ITEM2(0x80000001,line_unspecified)
diff --git a/navit/navigation.c b/navit/navigation.c
index 750d3d3c6..8301812b5 100644
--- a/navit/navigation.c
+++ b/navit/navigation.c
@@ -1628,6 +1628,8 @@ navigation_update(struct navigation *this_, int mode)
return;
dbg(1,"enter\n");
while ((ritem=map_rect_get_item(mr))) {
+ if (ritem->type != type_street_route)
+ continue;
if (first && item_attr_get(ritem, attr_street_item, &street_item)) {
first=0;
if (!item_attr_get(ritem, attr_direction, &street_direction))
diff --git a/navit/navit.c b/navit/navit.c
index 383c234fc..25546fd95 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -1330,26 +1330,30 @@ void
navit_zoom_to_route(struct navit *this_)
{
struct map *map;
- struct map_rect *mr;
+ struct map_rect *mr=NULL;
struct item *item;
struct coord c,*ct;
struct coord_rect r;
int count=0,scale=16;
if (! this_->route)
return;
+ dbg(0,"enter\n");
map=route_get_map(this_->route);
- if (! map)
- return;
- mr=map_rect_new(map, NULL);
- if (! mr)
- return;
- while ((item=map_rect_get_item(mr))) {
- while (item_coord_get(item, &c, 1)) {
- if (!count)
- r.lu=r.rl=c;
- else
- coord_rect_extend(&r, &c);
- count++;
+ dbg(0,"map=%p\n",map);
+ if (map)
+ mr=map_rect_new(map, NULL);
+ dbg(0,"mr=%p\n",mr);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ dbg(0,"item=%s\n", item_to_name(item->type));
+ while (item_coord_get(item, &c, 1)) {
+ dbg(0,"coord\n");
+ if (!count)
+ r.lu=r.rl=c;
+ else
+ coord_rect_extend(&r, &c);
+ count++;
+ }
}
}
if (! count)
diff --git a/navit/route.c b/navit/route.c
index b02f9a961..7aac9a710 100644
--- a/navit/route.c
+++ b/navit/route.c
@@ -2069,6 +2069,8 @@ rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
struct map_rect_priv *mr = priv_data;
struct route_path_segment *seg=mr->seg;
struct route *route=mr->mpriv->route;
+ if (mr->item.type != type_street_route)
+ return 0;
attr->type=attr_type;
switch (attr_type) {
case attr_any:
@@ -2129,6 +2131,16 @@ rm_coord_get(void *priv_data, struct coord *c, int count)
struct route *r = mr->mpriv->route;
enum projection pro = route_projection(r);
+ if (mr->item.type == type_route_start || mr->item.type == type_route_end) {
+ if (! count || mr->last_coord)
+ return 0;
+ mr->last_coord=1;
+ if (mr->item.type == type_route_start)
+ c[0]=r->pos->c;
+ else
+ c[0]=r->dst->c;
+ return 1;
+ }
if (! seg)
return 0;
for (i=0; i < count; i++) {
@@ -2321,14 +2333,19 @@ rm_rect_new(struct map_priv *priv, struct map_selection *sel)
return NULL;
if (! route_get_dst(priv->route))
return NULL;
+#if 0
if (! priv->route->path2)
return NULL;
+#endif
mr=g_new0(struct map_rect_priv, 1);
mr->mpriv = priv;
mr->item.priv_data = mr;
- mr->item.type = type_street_route;
+ mr->item.type = type_none;
mr->item.meth = &methods_route_item;
- mr->seg_next=priv->route->path2->path;
+ if (priv->route->path2)
+ mr->seg_next=priv->route->path2->path;
+ else
+ mr->seg_next=NULL;
return mr;
}
@@ -2457,10 +2474,24 @@ rm_get_item(struct map_rect_priv *mr)
{
dbg(1,"enter\n", mr->pos);
- mr->seg=mr->seg_next;
- if (! mr->seg)
+ switch (mr->item.type) {
+ case type_none:
+ mr->item.type=type_route_start;
+ if (mr->mpriv->route->pos)
+ break;
+ default:
+ mr->item.type=type_street_route;
+ mr->seg=mr->seg_next;
+ if (mr->seg) {
+ mr->seg_next=mr->seg->next;
+ break;
+ }
+ mr->item.type=type_route_end;
+ if (mr->mpriv->route->dst)
+ break;
+ case type_route_end:
return NULL;
- mr->seg_next=mr->seg->next;
+ }
mr->last_coord = 0;
mr->item.id_lo++;
rm_attr_rewind(mr);
diff --git a/navit/vehicle/demo/vehicle_demo.c b/navit/vehicle/demo/vehicle_demo.c
index e922a0bb0..76d56349e 100644
--- a/navit/vehicle/demo/vehicle_demo.c
+++ b/navit/vehicle/demo/vehicle_demo.c
@@ -110,7 +110,9 @@ vehicle_demo_timer(struct vehicle_priv *priv)
if (route_map)
mr=map_rect_new(route_map, NULL);
if (mr)
- item=map_rect_get_item(mr);
+ item=map_rect_get_item(mr);
+ if (item && item->type == type_route_start)
+ item=map_rect_get_item(mr);
if (item && item_coord_get(item, &pos, 1)) {
priv->position_set=0;
dbg(1, "current pos=0x%x,0x%x\n", pos.x, pos.y);