--- trunk/src/osm-gps-map-osd-classic.c 2009/09/16 20:04:38 114 +++ trunk/src/osm-gps-map-osd-classic.c 2009/09/21 13:15:25 122 @@ -25,6 +25,8 @@ /* OSD_DIAMETER */ /* OSD_X, OSD_Y */ +#define OSD_NAV + #ifndef USE_CAIRO #error "OSD control display lacks a non-cairo implementation!" #endif @@ -76,6 +78,12 @@ } crosshair; #endif +#ifdef OSD_NAV + struct { + cairo_surface_t *surface; + } nav; +#endif + #ifdef OSD_COORDINATES struct { cairo_surface_t *surface; @@ -288,13 +296,12 @@ xs += priv->balloon.rect.x + priv->balloon.offset_x; ys += priv->balloon.rect.y + priv->balloon.offset_y; - /* handle the fact that the balloon may have been created by the */ - /* button down event */ - gboolean is_in = (x > xs) && (x < xs + priv->balloon.rect.w) && (y > ys) && (y < ys + priv->balloon.rect.h); + /* handle the fact that the balloon may have been created by the */ + /* button down event */ if(!is_in && !down && !priv->balloon.just_created) { /* the user actually clicked outside the balloon */ @@ -953,25 +960,25 @@ #endif if(but == OSD_NONE) { - x -= OSD_X; - y -= OSD_Y; + gint mx = x - OSD_X; + gint my = y - OSD_Y; if(OSD_X < 0) - x -= (osd->widget->allocation.width - OSD_W); + mx -= (osd->widget->allocation.width - OSD_W); if(OSD_Y < 0) - y -= (osd->widget->allocation.height - OSD_H); + my -= (osd->widget->allocation.height - OSD_H); /* first do a rough test for the OSD area. */ /* this is just to avoid an unnecessary detailed test */ - if(x > 0 && x < OSD_W && y > 0 && y < OSD_H) { + if(mx > 0 && mx < OSD_W && my > 0 && my < OSD_H) { #ifndef OSD_NO_DPAD - but = osd_check_dpad(x, y); + but = osd_check_dpad(mx, my); #endif } if(but == OSD_NONE) - but = osd_check_zoom(x, y); + but = osd_check_zoom(mx, my); } #ifdef OSD_BALLOON @@ -1192,6 +1199,28 @@ } #endif // OSD_COORDINATES +#ifdef OSD_NAV +#define OSD_NAV_W (100) +#define OSD_NAV_H (100) + +static void +osd_render_nav(osm_gps_map_osd_t *osd) +{ + osd_priv_t *priv = (osd_priv_t*)osd->priv; + + /* first fill with transparency */ + cairo_t *cr = cairo_create(priv->nav.surface); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2); + cairo_paint(cr); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + + cairo_destroy(cr); +} + +#endif // OSD_NAV + + #ifdef OSD_CROSSHAIR #ifndef OSD_CROSSHAIR_RADIUS @@ -1519,6 +1548,10 @@ osd_render_crosshair(osd); #endif +#ifdef OSD_NAV + osd_render_nav(osd); +#endif + #ifdef OSD_COORDINATES osd_render_coordinates(osd); #endif @@ -1563,6 +1596,12 @@ priv->crosshair.rendered = FALSE; #endif +#ifdef OSD_NAV + priv->nav.surface = + cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + OSD_NAV_W, OSD_NAV_H); +#endif + #ifdef OSD_COORDINATES priv->coordinates.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, @@ -1598,6 +1637,15 @@ cairo_paint(cr); #endif +#ifdef OSD_NAV + x = OSD_X; + if(x < 0) x += osd->widget->allocation.width - OSD_NAV_W; + y = (osd->widget->allocation.height - OSD_NAV_H)/2; + + cairo_set_source_surface(cr, priv->nav.surface, x, y); + cairo_paint(cr); +#endif + #ifdef OSD_COORDINATES x = -OSD_X; y = -OSD_Y; @@ -1689,6 +1737,11 @@ cairo_surface_destroy(priv->crosshair.surface); #endif +#ifdef OSD_NAV + if (priv->nav.surface) + cairo_surface_destroy(priv->nav.surface); +#endif + #ifdef OSD_COORDINATES if (priv->coordinates.surface) cairo_surface_destroy(priv->coordinates.surface);