Fix:Core:Add option to set timeout with new map center
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 29 Jul 2009 11:14:27 +0000 (11:14 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 29 Jul 2009 11:14:27 +0000 (11:14 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2424 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/binding/dbus/binding_dbus.c
navit/navit/binding/python/navit.c
navit/navit/gui/gtk/destination.c
navit/navit/gui/gtk/gui_gtk_window.c
navit/navit/gui/internal/gui_internal.c
navit/navit/gui/win32/gui_win32.c
navit/navit/navit.c
navit/navit/navit.h

index ed15be5..0a45d2d 100644 (file)
@@ -377,7 +377,7 @@ request_navit_set_center(DBusConnection *connection, DBusMessage *message)
        if (!pcoord_get_from_message(message, &iter, &pc))
                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     
-       navit_set_center(navit, &pc);
+       navit_set_center(navit, &pc, 0);
        return empty_reply(connection, message);
 }
 
@@ -402,7 +402,7 @@ request_navit_set_center_screen(DBusConnection *connection, DBusMessage *message
 
        if (!point_get_from_message(message, &iter, &p))
                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       navit_set_center_screen(navit, &p);
+       navit_set_center_screen(navit, &p, 0);
        return empty_reply(connection, message);
 }
 
index 0a92210..ada8cd7 100644 (file)
@@ -47,7 +47,7 @@ navit_set_center_py(navitObject *self, PyObject *args)
        PyObject *pcoord;
        if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord))
                return NULL;
-       navit_set_center(self->navit, pcoord_py_get(pcoord));
+       navit_set_center(self->navit, pcoord_py_get(pcoord), 0);
        Py_RETURN_NONE;
 }
 
index d2003b6..a9c5b2c 100644 (file)
@@ -63,7 +63,7 @@ static void button_map(GtkWidget *widget, struct search_param *search)
                return;
        gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
        if (c) {
-               navit_set_center(search->nav, c);
+               navit_set_center(search->nav, c, 1);
        }
 }
 
index bad44b6..a95b8e1 100644 (file)
@@ -90,22 +90,22 @@ keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this)
        case KEY_UP:
                p.x=w/2;
                p.y=0;
-               navit_set_center_screen(this->nav, &p);
+               navit_set_center_screen(this->nav, &p, 1);
                break;
        case KEY_DOWN:
                p.x=w/2;
                p.y=h;
-               navit_set_center_screen(this->nav, &p);
+               navit_set_center_screen(this->nav, &p, 1);
                break;
        case KEY_LEFT:
                p.x=0;
                p.y=h/2;
-               navit_set_center_screen(this->nav, &p);
+               navit_set_center_screen(this->nav, &p, 1);
                break;
        case KEY_RIGHT:
                p.x=w;
                p.y=h/2;
-               navit_set_center_screen(this->nav, &p);
+               navit_set_center_screen(this->nav, &p, 1);
                break;
        case KEY_ZOOM_IN:
                navit_zoom_in(this->nav, 2, NULL);
@@ -164,7 +164,7 @@ keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this)
                p->x+=50*sin(transform_get_yaw(t)*M_PI/180);
                pc.x=p->x;
                pc.y=p->y;
-               navit_set_center(this->nav, &pc);
+               navit_set_center(this->nav, &pc, 1);
                }
                break;
        case 'g':
@@ -178,7 +178,7 @@ keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this)
                p->x-=50*sin(transform_get_yaw(t)*M_PI/180);
                pc.x=p->x;
                pc.y=p->y;
-               navit_set_center(this->nav, &pc);
+               navit_set_center(this->nav, &pc, 1);
                }
                break;
        #ifdef USE_HILDON
index 363517e..2e79e9b 100644 (file)
@@ -1970,7 +1970,7 @@ gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *dat
                graphics_clear_selection(this->gra, NULL);
                graphics_add_selection(this->gra, &w->item, NULL);
        }
-       navit_set_center(this->nav, &w->c);
+       navit_set_center(this->nav, &w->c, 1);
        gui_internal_prune_menu(this, NULL);
 }
 
@@ -3724,22 +3724,22 @@ static void gui_internal_keypress(void *data, char *key)
                case NAVIT_KEY_UP:
                        p.x=w/2;
                        p.y=0;
-                       navit_set_center_screen(this->nav, &p);
+                       navit_set_center_screen(this->nav, &p, 1);
                        break;
                case NAVIT_KEY_DOWN:
                        p.x=w/2;
                        p.y=h;
-                       navit_set_center_screen(this->nav, &p);
+                       navit_set_center_screen(this->nav, &p, 1);
                        break;
                case NAVIT_KEY_LEFT:
                        p.x=0;
                        p.y=h/2;
-                       navit_set_center_screen(this->nav, &p);
+                       navit_set_center_screen(this->nav, &p, 1);
                        break;
                case NAVIT_KEY_RIGHT:
                        p.x=w;
                        p.y=h/2;
-                       navit_set_center_screen(this->nav, &p);
+                       navit_set_center_screen(this->nav, &p, 1);
                        break;
                case NAVIT_KEY_ZOOM_IN:
                        navit_zoom_in(this->nav, 2, NULL);
index 135450b..3596496 100644 (file)
@@ -371,19 +371,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
                        if (wParam == VK_LEFT || wParam == '4') {
                                p.x=0;
                                p.y=h/2;
-                               navit_set_center_screen(gui->nav, &p);
+                               navit_set_center_screen(gui->nav, &p, 1);
                        } else if (wParam == VK_RIGHT || wParam == '6') {
                                p.x=w;
                                p.y=h/2;
-                               navit_set_center_screen(gui->nav, &p);
+                               navit_set_center_screen(gui->nav, &p, 1);
                        } else if (wParam == VK_UP || wParam == '2') {
                                p.x=w/2;
                                p.y=0;
-                               navit_set_center_screen(gui->nav, &p);
+                               navit_set_center_screen(gui->nav, &p, 1);
                        } else if (wParam == VK_DOWN || wParam == '8') {
                                p.x=w/2;
                                p.y=h;
-                               navit_set_center_screen(gui->nav, &p);
+                               navit_set_center_screen(gui->nav, &p, 1);
                        } else if (wParam == '1') {
                                navit_zoom_in(gui->nav, 2, NULL);
                        } else if (wParam == '3') {
index 16e191d..d2897f4 100644 (file)
@@ -320,6 +320,14 @@ update_transformation(struct transformation *tr, struct point *old, struct point
        transform_set_center(tr, &c);
 }
 
+static void
+navit_set_timeout(struct navit *this_)
+{
+       struct attr follow;
+       follow.type=attr_follow;
+       follow.u.num=this_->center_timeout;
+}
+
 int
 navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback)
 {
@@ -342,7 +350,7 @@ navit_handle_button(struct navit *this_, int pressed, int button, struct point *
                                this_->button_timeout=event_add_timeout(500, 0, popup_callback);
                }
                if (button == 2)
-                       navit_set_center_screen(this_, p);
+                       navit_set_center_screen(this_, p, 1);
                if (button == 3)
                        popup(this_, button, p);
                if (button == 4 && this_->use_mousewheel) {
@@ -354,18 +362,13 @@ navit_handle_button(struct navit *this_, int pressed, int button, struct point *
                        navit_zoom_out(this_, 2, p);
                }
        } else {
-               struct attr follow;
-               follow.type=attr_follow;
-               follow.u.num=this_->center_timeout;
 
                this_->button_pressed=0;
                if (this_->button_timeout) {
                        event_remove_timeout(this_->button_timeout);
                        this_->button_timeout=NULL;
                        if (! this_->moved && ! transform_within_border(this_->trans, p, border)) {
-                               if (!this_->zoomed) 
-                                       navit_set_attr(this_, &follow);
-                               navit_set_center_screen(this_, p);
+                               navit_set_center_screen(this_, p, !this_->zoomed);
                        }
                }
                if (this_->motion_timeout) {
@@ -384,7 +387,7 @@ navit_handle_button(struct navit *this_, int pressed, int button, struct point *
                        graphics_draw_drag(this_->gra, NULL);
                        graphics_overlay_disable(this_->gra, 0);
                        if (!this_->zoomed) 
-                               navit_set_attr(this_, &follow);
+                               navit_set_timeout(this_);
                        navit_draw(this_);
                } else
                        return 1;
@@ -1432,6 +1435,7 @@ navit_cmd_zoom_to_route(struct navit *this)
        navit_zoom_to_route(this, 0);
 }
 
+
 /**
  * Change the current zoom level
  *
@@ -1440,7 +1444,7 @@ navit_cmd_zoom_to_route(struct navit *this)
  * @returns nothing
  */
 void
-navit_set_center(struct navit *this_, struct pcoord *center)
+navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout)
 {
        struct coord *c=transform_center(this_->trans);
        struct coord c1,c2;
@@ -1454,12 +1458,14 @@ navit_set_center(struct navit *this_, struct pcoord *center)
                c2.y = center->y;
        }
        *c=c2;
+       if (set_timeout) 
+               navit_set_timeout(this_);
        if (this_->ready == 3)
                navit_draw(this_);
 }
 
 static void
-navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p)
+navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout)
 {
        int width, height;
        struct point po;
@@ -1468,6 +1474,8 @@ navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point
        po.x=width/2;
        po.y=height/2;
        update_transformation(this_->trans, &po, p, NULL);
+       if (set_timeout)
+               navit_set_timeout(this_);
 }
 
 static int
@@ -1505,7 +1513,7 @@ navit_set_center_cursor(struct navit *this_)
        struct navit_vehicle *nv=this_->vehicle;
        navit_get_cursor_pnt(this_, &pn, &dir);
        transform_set_yaw(this_->trans, dir);
-       navit_set_center_coord_screen(this_, &nv->coord, &pn);
+       navit_set_center_coord_screen(this_, &nv->coord, &pn, 0);
        navit_autozoom(this_, &nv->coord, nv->speed, 0);
        if (this_->ready == 3)
                navit_draw_async(this_, 1);
@@ -1518,7 +1526,7 @@ navit_cmd_set_center_cursor(struct navit *this_)
 }
 
 void
-navit_set_center_screen(struct navit *this_, struct point *p)
+navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout)
 {
        struct coord c;
        struct pcoord pc;
@@ -1526,7 +1534,7 @@ navit_set_center_screen(struct navit *this_, struct point *p)
        pc.x = c.x;
        pc.y = c.y;
        pc.pro = transform_get_projection(this_->trans);
-       navit_set_center(this_, &pc);
+       navit_set_center(this_, &pc, set_timeout);
 }
 
 #if 0
index c0ef137..665f4e4 100644 (file)
@@ -84,8 +84,8 @@ void navit_window_roadbook_destroy(struct navit *this_);
 void navit_window_roadbook_new(struct navit *this_);
 void navit_init(struct navit *this_);
 void navit_zoom_to_route(struct navit *this_, int orientation);
-void navit_set_center(struct navit *this_, struct pcoord *center);
-void navit_set_center_screen(struct navit *this_, struct point *p);
+void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout);
+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);
 int navit_add_attr(struct navit *this_, struct attr *attr);