Cleanup navit.c, remove navit_cb_cursor_offscreen
authorhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 11 Aug 2007 13:23:45 +0000 (13:23 +0000)
committerhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 11 Aug 2007 13:23:45 +0000 (13:23 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@382 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/cursor.c
navit/src/cursor.h
navit/src/navit.c
navit/src/navit.h

index 3584cd9..ba7051a 100644 (file)
@@ -28,7 +28,6 @@ struct cursor {
        struct graphics_gc *cursor_gc;
        struct transformation *trans;
        struct point cursor_pnt;
-       struct callback_list *offscreen_cbl;
        struct callback_list *update_cbl;
        struct vehicle *v;
        struct callback *vehicle_cb;
@@ -211,7 +210,6 @@ cursor_update(struct cursor *this, struct vehicle *v)
        double *dir;
        double *speed;
        enum projection pro;
-       int border=10;
 
        if (v) {
                pos=vehicle_pos_get(v); 
@@ -223,10 +221,7 @@ cursor_update(struct cursor *this, struct vehicle *v)
                this->pos=*pos;
                this->pro=pro;
                callback_list_call_1(this->update_cbl, this);
-               if (!transform(this->trans, pro, &this->pos, &pnt) || !transform_within_border(this->trans, &pnt, border)) {
-                       callback_list_call_1(this->offscreen_cbl, this);
-                       transform(this->trans, this->pro, &this->pos, &pnt);
-               }
+               transform(this->trans, pro, &this->pos, &pnt);
                cursor_draw(this, &pnt, *dir-transform_get_angle(this->trans, 0), *speed > 2.5);
        }
 #if 0
@@ -239,7 +234,9 @@ cursor_new(struct graphics *gra, struct vehicle *v, struct color *c, struct tran
 {
        dbg(2,"enter gra=%p v=%p c=%p t=%p\n", gra, v, c, t);
        struct cursor *this=g_new(struct cursor,1);
+#if 0
        this->offscreen_cbl=callback_list_new();
+#endif
        this->update_cbl=callback_list_new();
        this->gra=gra;
        this->trans=t;
@@ -254,10 +251,7 @@ cursor_new(struct graphics *gra, struct vehicle *v, struct color *c, struct tran
 }
 
 void
-cursor_add_callback(struct cursor *this, int offscreen, struct callback *cb)
+cursor_add_callback(struct cursor *this, struct callback *cb)
 {
-       if (offscreen)
-               callback_list_add(this->offscreen_cbl, cb);
-       else
-               callback_list_add(this->update_cbl, cb);
+       callback_list_add(this->update_cbl, cb);
 }
index 88b3b38..ff14f05 100644 (file)
@@ -12,5 +12,5 @@ void cursor_redraw(struct cursor *this);
 int cursor_get_dir(struct cursor *this);
 int cursor_get_speed(struct cursor *this);
 struct cursor *cursor_new(struct graphics *gra, struct vehicle *v, struct color *c, struct transformation *t);
-void cursor_add_callback(struct cursor *this, int offscreen, struct callback *cb);
+void cursor_add_callback(struct cursor *this, struct callback *cb);
 /* end of prototypes */
index 652563d..aa2450f 100644 (file)
@@ -27,6 +27,7 @@
 #include "navigation.h"
 #include "speech.h"
 #include "track.h"
+#include "vehicle.h"
 
 #define _(STRING)    gettext(STRING)
 
@@ -39,7 +40,6 @@ struct navit_vehicle {
        struct menu *menu;
        struct cursor *cursor;
        struct vehicle *vehicle;
-       struct callback *offscreen_cb;
        struct callback *update_cb;
 };
 
@@ -856,19 +856,14 @@ navit_toggle_tracking(struct navit *this_)
 }
 
 static void
-navit_cursor_offscreen(struct navit *this_, struct cursor *cursor)
-{
-       if (!this_->cursor_flag || !this_->vehicle || this_->vehicle->cursor != cursor)
-               return;
-       navit_set_center(this_, cursor_pos_get(cursor));
-}
-
-static void
 navit_cursor_update(struct navit *this_, struct cursor *cursor)
 {
+       struct point pnt;
        struct coord *cursor_c=cursor_pos_get(cursor);
        int dir=cursor_get_dir(cursor);
        int speed=cursor_get_speed(cursor);
+       enum projection pro;
+       int border=10;
 
        if (!this_->vehicle || this_->vehicle->cursor != cursor)
                return;
@@ -876,6 +871,14 @@ navit_cursor_update(struct navit *this_, struct cursor *cursor)
        cursor_c=cursor_pos_get(cursor);
        dir=cursor_get_dir(cursor);
        speed=cursor_get_speed(cursor);
+       pro=vehicle_projection(this_->vehicle);
+
+       if (!transform(this_->trans, pro, cursor_c, &pnt) || !transform_within_border(this_->trans, &pnt, border)) {
+               if (!this_->cursor_flag)
+                       return;
+               navit_set_center(this_, cursor_c);
+               transform(this_->trans, pro, cursor_c, &pnt);
+       }
 
        if (this_->pid && speed > 2)
                kill(this_->pid, SIGWINCH);
@@ -929,10 +932,8 @@ navit_add_vehicle(struct navit *this_, struct vehicle *v, const char *name, stru
        nv->update_curr=nv->update=update;
        nv->follow_curr=nv->follow=follow;
        nv->cursor=cursor_new(this_->gra, v, c, this_->trans);
-       nv->offscreen_cb=callback_new_1(callback_cast(navit_cursor_offscreen), this_);
-       cursor_add_callback(nv->cursor, 1, nv->offscreen_cb);
        nv->update_cb=callback_new_1(callback_cast(navit_cursor_update), this_);
-       cursor_add_callback(nv->cursor, 0, nv->update_cb);
+       cursor_add_callback(nv->cursor, nv->update_cb);
 
        this_->vehicles=g_list_append(this_->vehicles, nv);
        return nv;
index 7e79aa4..48399e6 100644 (file)
@@ -4,6 +4,7 @@ extern "C" {
 extern struct gui *main_loop_gui;
 /* prototypes */
 enum projection;
+enum item_type;
 struct callback;
 struct color;
 struct coord;
@@ -42,6 +43,11 @@ void navit_add_menu_vehicles(struct navit *this_, struct menu *men);
 void navit_add_menu_vehicle(struct navit *this_, struct menu *men);
 void navit_speak(struct navit *this_);
 void navit_window_roadbook_new(struct navit *this_);
+void navit_window_roadbook_destroy(struct navit *this_);
+struct navit_window_items * navit_window_items_new(char *name, int distance);
+void navit_window_items_add_item(struct navit_window_items *nwi, enum item_type type);
+void navit_add_window_items(struct navit *this_, struct navit_window_items *nwi);
+void navit_add_menu_windows_items(struct navit *this_, struct menu *men);
 void navit_init(struct navit *this_);
 void navit_set_center(struct navit *this_, struct coord *center);
 void navit_set_center_screen(struct navit *this_, struct point *p);