Add:Core:Support for invisible cursors
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 16 Aug 2010 06:17:30 +0000 (06:17 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 16 Aug 2010 06:17:30 +0000 (06:17 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3528 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/navit.c
navit/navit/vehicle.c

index f052c26..320ba32 100644 (file)
@@ -1372,9 +1372,12 @@ navit_set_cursors(struct navit *this_)
        v=g_list_first(this_->vehicles); // GList of navit_vehicles
        while (v) {
                nv=v->data;
-               if (vehicle_get_attr(nv->vehicle, attr_cursorname, &name, NULL))
-                       c=layout_get_cursor(this_->layout_current, name.u.str);
-               else
+               if (vehicle_get_attr(nv->vehicle, attr_cursorname, &name, NULL)) {
+                       if (!strcmp(name.u.str,"none"))
+                               c=NULL;
+                       else
+                               c=layout_get_cursor(this_->layout_current, name.u.str);
+               } else
                        c=layout_get_cursor(this_->layout_current, "default");
                vehicle_set_cursor(nv->vehicle, c);
                v=g_list_next(v);
index 28d0739..86f92cc 100644 (file)
@@ -276,30 +276,29 @@ vehicle_remove_attr(struct vehicle *this_, struct attr *attr)
 void
 vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor)
 {
-       if (!cursor) {  // we require this for now.
-               return;
-       }
-
        if (this_->animate_callback) {
                event_remove_timeout(this_->animate_timer);
                this_->animate_timer=NULL;              // dangling pointer! prevent double freeing.
                callback_destroy(this_->animate_callback);
                this_->animate_callback=NULL;   // dangling pointer! prevent double freeing.
        }
-       if (cursor->interval) {
+       if (cursor && cursor->interval) {
                this_->animate_callback=callback_new_2(callback_cast(vehicle_draw_do), this_, 0);
                this_->animate_timer=event_add_timeout(cursor->interval, 1, this_->animate_callback);
        }
 
-       if (this_->gra) {
+       if (cursor && this_->gra) {
                this_->cursor_pnt.x+=(this_->cursor->w - cursor->w)/2;
                this_->cursor_pnt.y+=(this_->cursor->h - cursor->h)/2;
                graphics_overlay_resize(this_->gra, &this_->cursor_pnt, cursor->w, cursor->h, 65535, 0);
        }
 
        struct point sc;
-       sc.x=cursor->w/2;
-       sc.y=cursor->h/2;
+       if (cursor) { 
+               sc.x=cursor->w/2;
+               sc.y=cursor->h/2;
+       } else
+               sc.x=sc.y=0;
        transform_set_screen_center(this_->trans, &sc);
 
        this_->cursor=cursor;
@@ -322,13 +321,13 @@ vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt, int
                angle+=360;
        dbg(1,"enter this=%p gra=%p pnt=%p lazy=%d dir=%d speed=%d\n", this_, gra, pnt, lazy, angle, speed);
        dbg(1,"point %d,%d\n", pnt->x, pnt->y);
+       this_->cursor_pnt=*pnt;
+       this_->angle=angle;
+       this_->speed=speed;
        if (!this_->cursor)
                return;
-       this_->cursor_pnt=*pnt;
        this_->cursor_pnt.x-=this_->cursor->w/2;
        this_->cursor_pnt.y-=this_->cursor->h/2;
-       this_->angle=angle;
-       this_->speed=speed;
        if (!this_->gra) {
                struct color c;
                this_->gra=graphics_overlay_new(gra, &this_->cursor_pnt, this_->cursor->w, this_->cursor->h, 65535, 0);
@@ -342,6 +341,14 @@ vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt, int
        vehicle_draw_do(this_, lazy);
 }
 
+int
+vehicle_get_cursor_data(struct vehicle *this, struct point *pnt, int *angle, int *speed)
+{
+       *pnt=this->cursor_pnt;
+       *angle=this->angle;
+       *speed=this->speed;
+       return 1;
+}
 
 
 static void