/*
* MapWidget: Display a map
- * Copyright (C) 2007 Kaj-Michael Lang
+ * Copyright (C) 2007-2008 Kaj-Michael Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
*
*/
-
#include "config.h"
#include <stdlib.h>
}
/* XXX: WTF, scale is not drawn properly with cairo without this thing slowing us down ????*/
+#if 1
g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");
g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");g_debug("HUH");
+#endif
#ifdef WITH_CAIRO
cairo_save(priv->ct);
pixbuf=image_cache_get(priv->icache, key, buffer);
if (!pixbuf) {
-#if 0
g_unlink(buffer);
-
+#if 0
if (_auto_download && _curr_repo->type != REPOTYPE_NONE && !((_zoom + zoff - (_curr_repo->double_size ? 1 : 0)) % _curr_repo->dl_zoom_steps)) {
if (download)
map_initiate_download(tilex >> zoff, tiley >> zoff, _zoom + zoff, -INITIAL_DOWNLOAD_RETRIES);
gtk_map_refresh(widget);
}
+
+/**
+ * gtk_map_render_tile:
+ * @widget
+ * @tilex
+ * @tiley
+ * @destx
+ * @desty
+ * @fast_fail
+ *
+ * Renders given tile x,y on buffer pixmap at dest x,y. If an exact tile is not found then it tries to load a
+ * tile for a another zoom level and scale it to match.
+ * If no suitable tile is found, a black box will be drawn on the buffer at dest x,y instead.
+ *
+ * Returns: TRUE if a tile is found. FALSE on error.
+ */
static gboolean
gtk_map_render_tile(GtkWidget *widget, guint tilex, guint tiley, guint destx, guint desty, gboolean fast_fail)
{
}
if (pixbuf) {
- gdk_draw_pixbuf(priv->buffer,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- pixbuf, 0, 0, destx, desty,
- GTK_MAP_TILE_SIZE_PIXELS,
- GTK_MAP_TILE_SIZE_PIXELS,
+ gdk_draw_pixbuf(priv->buffer, widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
+ pixbuf, 0, 0, destx, desty, GTK_MAP_TILE_SIZE_PIXELS, GTK_MAP_TILE_SIZE_PIXELS,
GDK_RGB_DITHER_NONE, 0, 0);
g_object_unref(pixbuf);
return TRUE;
}
-gdk_draw_rectangle(priv->buffer,
- widget->style->black_gc, TRUE,
- destx, desty,
- GTK_MAP_TILE_SIZE_PIXELS,
- GTK_MAP_TILE_SIZE_PIXELS);
-return TRUE;
+
+gdk_draw_rectangle(priv->buffer, widget->style->black_gc, TRUE, destx, desty, GTK_MAP_TILE_SIZE_PIXELS, GTK_MAP_TILE_SIZE_PIXELS);
+return FALSE;
}
/******************************************************************************/
priv=GTK_MAP_GET_PRIVATE(map);
style=widget->style;
-/* Assure that _center.unitx/y are bounded. */
+/* Assure that the given unitx/y are inside our world. */
BOUND(unitx, priv->min_center.unitx, priv->max_center.unitx);
BOUND(unity, priv->min_center.unity, priv->max_center.unity);
-priv->center.unitx = unitx;
-priv->center.unity = unity;
+priv->center.unitx=unitx;
+priv->center.unity=unity;
-new_base_tilex = grid2tile((gint) pixel2grid((gint)unit2pixel((gint) priv->center.unitx)) - (gint)priv->screen_grids_halfwidth);
-new_base_tiley = grid2tile(pixel2grid(unit2pixel(priv->center.unity)) - priv->screen_grids_halfheight);
+new_base_tilex=grid2tile((gint) pixel2grid((gint)unit2pixel((gint) priv->center.unitx)) - (gint)priv->screen_grids_halfwidth);
+new_base_tiley=grid2tile(pixel2grid(unit2pixel(priv->center.unity)) - priv->screen_grids_halfheight);
/* Same zoom level, so it's likely that we can reuse some of the old buffer's pixels. */
-
-if (new_base_tilex != priv->base_tilex || new_base_tiley != priv->base_tiley) {
+if ((new_base_tilex != priv->base_tilex || new_base_tiley != priv->base_tiley) && priv->rotate_view==FALSE) {
/* If copying from old parts to new parts, we need to make sure we
* don't overwrite the old parts when copying, so set up new_x,
* new_y, old_x, old_y, iox, and ioy with that in mind. */
}
}
}
+ gtk_map_recalc_offset(priv);
+ gtk_map_recalc_focus_base(priv);
+ gtk_widget_queue_draw(widget);
+} else {
+ priv->base_tilex=new_base_tilex;
+ priv->base_tiley=new_base_tiley;
+ gtk_map_recalc_offset(priv);
+ gtk_map_recalc_focus_base(priv);
+ gtk_map_refresh(widget);
}
-gtk_map_recalc_offset(priv);
-gtk_map_recalc_focus_base(priv);
-gtk_map_refresh(widget);
g_signal_emit(widget, gtk_map_signals[MAP_LOCATION_CHANGED], 0, priv->zoom);
}
/**
* gtk_map_refresh:
+ * @widget
*
* Force a redraw of the map view.
*/