From 65cb55c7dbebf19ce094f4941d5bb67be4558a1f Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 16 Oct 2007 13:52:39 +0300 Subject: [PATCH] Add goto location helpers. Cleanups. --- src/map.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/map.c b/src/map.c index 47ce72c..9098a55 100644 --- a/src/map.c +++ b/src/map.c @@ -91,6 +91,8 @@ void map_force_redraw(); static void map_update_location(gint x, gint y, gboolean force); void map_draw_position_icon(Position *pos); +/******************************************************************************/ + gboolean map_cb_configure(GtkWidget * widget, GdkEventConfigure * event) { @@ -124,7 +126,7 @@ return TRUE; * _map_widget. This method does not queue the draw area. */ static void -map_draw_mark() +map_draw_mark(void) { gdk_draw_arc(_map_widget->window, _conn_state == RCVR_FIXED ? _gc[COLORABLE_MARK] : _gc[COLORABLE_MARK_OLD], FALSE, @@ -335,7 +337,7 @@ if(_show_tracks>0) * background maps from disk and redrawing the tracks on top of them. */ void -map_force_redraw() +map_force_redraw(void) { guint new_x, new_y; @@ -496,6 +498,35 @@ if (_center_mode > 0) map_center_unit(_center.unitx + delta_unitx, _center.unity + delta_unity); } +/** + * Helper to center map on given lat/lon + */ +map_center_latlon(gdouble lat, gdouble lon) +{ +guint unitx, unity; + +latlon2unit(lat, lon, unitx, unity); +map_center_unit(unitx, unity); +} + +/** + * Helper to goto given point and update location + * + */ +gboolean +map_goto_position(Position *pos) +{ +if (pos->valid==FALSE) { + return FALSE; +} + +_center_mode=CENTER_MANUAL; +map_center_latlon(pos->lat, pos->lon); +map_set_autozoom(FALSE); +map_update_location_from_center(); +return TRUE; +} + /** * Initiate a move of the mark from the old location to the current * location. This function queues the draw area of the old mark (to force @@ -518,14 +549,14 @@ gtk_widget_queue_draw_area(_map_widget, } gboolean -map_update_location_from_gps() +map_update_location_from_gps(void) { map_update_location(_pos.unitx, _pos.unity, FALSE); return FALSE; } gboolean -map_update_location_from_center() +map_update_location_from_center(void) { /* Force re-validation of place if user is clicking around */ map_loc.valid=FALSE; @@ -575,7 +606,7 @@ if (p) { * the view if the mark is appropriately close to the edge of the view. */ void -map_refresh_mark() +map_refresh_mark(void) { guint new_center_unitx; guint new_center_unity; @@ -678,7 +709,7 @@ map_render_path(Path * path, GdkGC ** gc) } void -map_render_paths() +map_render_paths(void) { if ((_show_tracks & ROUTES_MASK) && _route.head != _route.tail) { map_render_path(&_route, _gc + COLORABLE_ROUTE); @@ -734,7 +765,7 @@ return FALSE; } gboolean -map_key_zoom_timeout() +map_key_zoom_timeout(void) { if (_key_zoom_new < _zoom) { /* We're currently zooming in (_zoom is decreasing). */ @@ -895,7 +926,7 @@ return nzoom; } static gboolean -map_autozoomer() +map_autozoomer(void) { static gfloat z=5.0; static gint last=5; @@ -1034,6 +1065,9 @@ map_update_destination(lat, lon); inp=FALSE; } +/** + * Mouse scroller zoom in/out callback + */ gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event) { @@ -1047,6 +1081,9 @@ if (event->direction == GDK_SCROLL_UP) { return FALSE; } +/** + * Start map drag operation + */ static void map_drag_start(gint x,gint y) { @@ -1057,6 +1094,9 @@ before[1] = press[1]; map_drag_id=g_signal_connect(G_OBJECT(_map_widget), "motion_notify_event", G_CALLBACK(map_follow_move), NULL); } +/** + * Stop map drag operation + */ static void map_drag_stop(gint x, gint y) { -- 2.39.5