]> err.no Git - mapper/commitdiff
Draw destination icon.
authorKaj-Michael Lang <milang@tal.org>
Wed, 9 Apr 2008 09:29:11 +0000 (12:29 +0300)
committerKaj-Michael Lang <milang@tal.org>
Wed, 9 Apr 2008 09:29:11 +0000 (12:29 +0300)
src/map.c
src/map.h

index 455ca249252b89ac3129fa154590015b089eb064..f919d7ec8d6846063e6587450944169e0fbc0955 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -482,12 +482,15 @@ map_render_data(void)
 if (map_drag_id>0)
        return;
 
-if (_home.valid)
-       map_draw_position_icon(&_home);
-
 if(_show_poi)
        map_render_all_pois(buf_width_pixels, buf_height_pixels);
 
+if (_home.valid)
+       map_draw_position_icon(&_home, "home");
+
+if (_dest.valid)
+       map_draw_position_icon(&_dest, "destination");
+
 if(_show_tracks>0)
        map_render_paths();
 }
@@ -746,15 +749,11 @@ map_update_location(lat, lon, TRUE);
 return FALSE;
 }
 
-/**
- * Draw given pixbuf on map, centered on x,y
- */
 void
-map_draw_pixbuf(guint unitx, guint unity, GdkPixbuf *p)
+map_draw_pixbuf_on_buffer(gint x, gint y, GdkPixbuf *p)
 {
-gint x,y;
-x = unit2bufx(unitx);
-y = unit2bufy(unity);
+if ((x < 0) || (y < 0))
+       return;
 
 if ((x > buf_width_pixels) || (y > buf_height_pixels))
        return;
@@ -767,29 +766,47 @@ gdk_draw_pixbuf(map_pixmap, _gc[COLORABLE_POI],
 }
 
 /**
- * Draw an icon on given Position.
- * 
- * XXX: don't hardcode as home.png !
+ * Draw given pixbuf on map, centered on x,y
  */
 void
-map_draw_position_icon(Position *pos)
+map_draw_pixbuf(guint unitx, guint unity, GdkPixbuf *p)
 {
-guint x,y, x1,y1;
+gint x,y;
+x=unit2bufx(unitx);
+y=unit2bufy(unity);
+
+map_draw_pixbuf_on_buffer(x, y, p);
+}
+
+/**
+ * Draw an icon at given Position.
+ * 
+ */
+static void
+map_draw_position_icon(Position *pos, const gchar *icon)
+{
+gint x, y;
+guint ux, uy;
+gchar buffer[128];
 GdkPixbuf *p;
 
-latlon2unit(pos->lat, pos->lon, x, y);
-x1=unit2bufx(x);
-y1=unit2bufy(y);
+latlon2unit(pos->lat, pos->lon, ux, uy);
+x=unit2bufx(ux);
+y=unit2bufy(uy);
 
-if ((x1 > buf_width_pixels) || (y1 > buf_height_pixels))
+if ((x < 0) || (y < 0))
        return;
 
-p=gdk_pixbuf_new_from_file(DATADIR "/pixmaps/mapper/home.png", NULL);
-if (p) {
-       map_draw_pixbuf(x,y,p);
-       g_object_unref(p);
-}
+if ((x > buf_width_pixels) || (y > buf_height_pixels))
+       return;
+
+g_snprintf(buffer, sizeof(buffer), "%s/pixmaps/mapper/%s.png", DATADIR, icon);
+p=gdk_pixbuf_new_from_file(buffer, NULL);
+if (!p)
+       return;
 
+map_draw_pixbuf_on_buffer(x, y, p);
+g_object_unref(p);
 }
 
 /**
index 7d9ec10b1d6aca2e797e6b40ac6ea67ed3d0faaf..5105a48a0c62f0a652ce54d6629edb5ec365de38 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -206,7 +206,7 @@ gboolean map_render_tile(guint tilex, guint tiley, guint destx, guint desty, gbo
 void map_render_waypoint(guint x1, guint y1, GdkGC *gc);
 void map_render_paths(void);
 void map_force_redraw(void);
-void map_draw_position_icon(Position *pos);
+void map_draw_position_icon(Position *pos, const gchar *icon);
 GdkPixmap *map_pixmap_get(void);
 
 void map_center_unit(guint new_center_unitx, guint new_center_unity);