static osm_location map_loc = {NULL, NULL, NULL, FALSE, FALSE, 0, 0, 0.0, 0.0, 0 };
-typedef struct _map_tile_rdata map_tile_rdata;
-struct _map_tile_rdata {
- guint tilex, tiley, zoom;
- guint destx, desty;
-};
-
/* Tile max age, 1 week */
#define TILE_MAX_AGE (604800)
speed_context=gtk_widget_get_pango_context(map_widget);
speed_layout=pango_layout_new(speed_context);
speed_fontdesc=pango_font_description_new();
-pango_font_description_set_size(speed_fontdesc, 64 * PANGO_SCALE);
+pango_font_description_set_size(speed_fontdesc, 48 * PANGO_SCALE);
pango_layout_set_font_description(speed_layout, speed_fontdesc);
pango_layout_set_alignment(speed_layout, PANGO_ALIGN_CENTER);
gdk_draw_rectangle(_map_pixmap, _map_widget->style->black_gc, TRUE, destx, desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
}
-gboolean
-map_render_tile_idle(map_tile_rdata *mtr)
-{
-map_render_tile(mtr->tilex, mtr->tiley, mtr->destx, mtr->desty, FALSE);
-gtk_widget_queue_draw_area(_map_widget, mtr->destx, mtr->desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
-
-g_slice_free(map_tile_rdata, mtr);
-return FALSE;
-}
-
void
map_render_data(void)
{
_center.unitx = new_center_unitx;
_center.unity = new_center_unity;
-new_base_tilex = grid2tile((gint) pixel2grid((gint)unit2pixel((gint) _center.unitx))
- - (gint)_screen_grids_halfwidth);
-new_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity))
- - _screen_grids_halfheight);
+new_base_tilex = grid2tile((gint) pixel2grid((gint)unit2pixel((gint) _center.unitx)) - (gint)_screen_grids_halfwidth);
+new_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity)) - _screen_grids_halfheight);
/* Same zoom level, so it's likely that we can reuse some of the old
* buffer's pixels. */
new_x = base_new_x;
old_x = base_old_x;
/* Iterate over the x tile values. */
- for (k = 0; k < BUF_WIDTH_TILES;
- ++k, new_x += iox, old_x += iox) {
+ for (k = 0; k < BUF_WIDTH_TILES; ++k, new_x += iox, old_x += iox) {
/* Can we get this grid block from the old buffer?. */
- if (old_x >= 0 && old_x < BUF_WIDTH_TILES
- && old_y >= 0 && old_y < BUF_HEIGHT_TILES) {
+ if (old_x >= 0 && old_x < BUF_WIDTH_TILES && old_y >= 0 && old_y < BUF_HEIGHT_TILES) {
/* Copy from old buffer to new buffer. */
gdk_draw_drawable(_map_pixmap,
_gc[COLORABLE_MARK],
return TRUE;
}
+static void
+map_information_text(guint x, guint y, GdkGC *gc, gchar *msg)
+{
+guint width, height;
+
+pango_layout_set_text(speed_layout, msg, -1);
+pango_layout_get_pixel_size(speed_layout, &width, &height);
+gtk_widget_queue_draw_area(_map_widget, x - 5, y - 5, width * 3 + 15, height + 5);
+gdk_window_process_all_updates();
+gdk_draw_layout(_map_widget->window, gc, x, y, speed_layout);
+}
+
static void
map_speed_draw(void)
{
GdkGC *gc;
gfloat cur_speed;
gchar *buffer;
-static guint x = 0, y = 0, width = 0, height = 0;
cur_speed = _gps.speed * UNITS_CONVERT[_units];
-
-if (cur_speed > _speed_limit) {
- gc = speed_gc1;
-} else {
- gc = speed_gc2;
-}
-
+gc=(cur_speed > _speed_limit) ? speed_gc1 : speed_gc2;
buffer = g_strdup_printf("%0.0f", cur_speed);
-pango_layout_set_text(speed_layout, buffer, -1);
-pango_layout_get_pixel_size(speed_layout, &width, &height);
-
-gtk_widget_queue_draw_area(_map_widget, x - 5, y - 5, width * 3 + 15, height + 5);
-gdk_window_process_all_updates();
-
-x = 10;
-y = 10;
-
-gdk_draw_layout(_map_widget->window, gc, x, y, speed_layout);
+map_information_text(10, 10, gc, buffer);
g_free(buffer);
}