--- trunk/src/osm-gps-map-osd-classic.c 2009/09/09 19:57:45 105 +++ trunk/src/osm-gps-map-osd-classic.c 2009/09/12 20:56:35 110 @@ -25,8 +25,6 @@ /* OSD_DIAMETER */ /* OSD_X, OSD_Y */ -#define OSD_CROSSHAIR - #ifndef USE_CAIRO #error "OSD control display lacks a non-cairo implementation!" #endif @@ -39,24 +37,44 @@ //the osd controls typedef struct { /* the offscreen representation of the OSD */ - cairo_surface_t *overlay; + struct { + cairo_surface_t *surface; + gboolean rendered; +#ifdef OSD_GPS_BUTTON + gboolean gps_enabled; +#endif + } controls; #ifdef OSD_SCALE - cairo_surface_t *scale; - int scale_zoom; + struct { + cairo_surface_t *surface; + int zoom; + } scale; #endif - + #ifdef OSD_CROSSHAIR - cairo_surface_t *crosshair; + struct { + cairo_surface_t *surface; + gboolean rendered; + } crosshair; +#endif + +#ifdef OSD_COORDINATES + struct { + cairo_surface_t *surface; + float lat, lon; + } coordinates; #endif #ifdef OSD_SOURCE_SEL - /* values to handle the "source" menu */ - cairo_surface_t *map_source; - gboolean expanded; - gint shift, dir, count; - gint handler_id; - gint width, height; + struct { + /* values to handle the "source" menu */ + cairo_surface_t *surface; + gboolean expanded; + gint shift, dir, count; + gint handler_id; + gint width, height; + } source_sel; #endif } osd_priv_t; @@ -283,8 +301,8 @@ #define OSD_S_H (OSD_S_PH + OSD_SHADOW) /* size of usable area when expanded */ -#define OSD_S_AREA_W (priv->width) -#define OSD_S_AREA_H (priv->height) +#define OSD_S_AREA_W (priv->source_sel.width) +#define OSD_S_AREA_H (priv->source_sel.height) #define OSD_S_EXP_W (OSD_S_PW + OSD_S_AREA_W + OSD_SHADOW) #define OSD_S_EXP_H (OSD_S_AREA_H + OSD_SHADOW) @@ -300,7 +318,7 @@ /* or the entire menu incl. the puller (expanded) */ static void osd_source_shape(osd_priv_t *priv, cairo_t *cr, gint x, gint y) { - if(!priv->expanded) { + if(!priv->source_sel.expanded) { /* just draw the puller */ cairo_move_to (cr, x + OSD_S_PW, y + OSD_S_PH); cairo_arc (cr, x+OSD_S_RAD, y+OSD_S_RAD, OSD_S_RAD, M_PI/2, -M_PI/2); @@ -328,7 +346,7 @@ int py = offset + OSD_S_RAD - OSD_S_D0; - if(!priv->expanded) { + if(!priv->source_sel.expanded) { /* draw the "puller" open (<) arrow */ cairo_move_to (cr, offset + OSD_S_RAD + OSD_S_D0/2, py); cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0); @@ -353,7 +371,7 @@ CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, OSD_FONT_SIZE); - int i, step = (priv->height - 2*OSD_TEXT_BORDER) / + int i, step = (priv->source_sel.height - 2*OSD_TEXT_BORDER) / OSM_GPS_MAP_SOURCE_LAST; for(i=OSM_GPS_MAP_SOURCE_NULL+1;i<=OSM_GPS_MAP_SOURCE_LAST;i++) { cairo_text_extents_t extents; @@ -367,7 +385,7 @@ if(source == i) { cairo_rectangle(cr, x - OSD_TEXT_BORDER/2, y - OSD_TEXT_SKIP, - priv->width - OSD_TEXT_BORDER, + priv->source_sel.width - OSD_TEXT_BORDER, step + OSD_TEXT_SKIP); cairo_fill(cr); @@ -408,7 +426,7 @@ #endif /* draw source selector */ - cairo_t *cr = cairo_create(priv->map_source); + cairo_t *cr = cairo_create(priv->source_sel.surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); cairo_paint(cr); @@ -449,14 +467,14 @@ osd_priv_t *priv = (osd_priv_t*)osd->priv; /* re-allocate offscreen bitmap */ - g_assert (priv->map_source); + g_assert (priv->source_sel.surface); int w = OSD_S_W, h = OSD_S_H; - if(priv->expanded) { + if(priv->source_sel.expanded) { cairo_text_extents_t extents; /* determine content size */ - cairo_t *cr = cairo_create(priv->map_source); + cairo_t *cr = cairo_create(priv->source_sel.surface); cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); @@ -473,16 +491,16 @@ } cairo_destroy(cr); - priv->width = max_w + 2*OSD_TEXT_BORDER; - priv->height = OSM_GPS_MAP_SOURCE_LAST * + priv->source_sel.width = max_w + 2*OSD_TEXT_BORDER; + priv->source_sel.height = OSM_GPS_MAP_SOURCE_LAST * (max_h + 2*OSD_TEXT_SKIP) + 2*OSD_TEXT_BORDER; w = OSD_S_EXP_W; h = OSD_S_EXP_H; } - cairo_surface_destroy(priv->map_source); - priv->map_source = + cairo_surface_destroy(priv->source_sel.surface); + priv->source_sel.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2); osd_render_source_sel(osd); @@ -496,20 +514,20 @@ osd_priv_t *priv = (osd_priv_t*)osd->priv; int diff = OSD_S_EXP_W - OSD_S_W - OSD_S_X; gboolean done = FALSE; - priv->count += priv->dir; + priv->source_sel.count += priv->source_sel.dir; /* shifting in */ - if(priv->dir < 0) { - if(priv->count <= 0) { - priv->count = 0; + if(priv->source_sel.dir < 0) { + if(priv->source_sel.count <= 0) { + priv->source_sel.count = 0; done = TRUE; } } else { - if(priv->count >= 1000) { - priv->expanded = FALSE; + if(priv->source_sel.count >= 1000) { + priv->source_sel.expanded = FALSE; osd_source_reallocate(osd); - priv->count = 1000; + priv->source_sel.count = 1000; done = TRUE; } } @@ -518,14 +536,14 @@ /* count runs linearly from 0 to 1000, map this nicely onto a position */ /* nicer sinoid mapping */ - float m = 0.5-cos(priv->count * M_PI / 1000.0)/2; - priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) + + float m = 0.5-cos(priv->source_sel.count * M_PI / 1000.0)/2; + priv->source_sel.shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) + m * diff; osm_gps_map_repaint(OSM_GPS_MAP(osd->widget)); if(done) - priv->handler_id = 0; + priv->source_sel.handler_id = 0; return !done; } @@ -537,24 +555,24 @@ osd_priv_t *priv = (osd_priv_t*)osd->priv; /* ignore clicks while animation is running */ - if(priv->handler_id) + if(priv->source_sel.handler_id) return; /* expand immediately, collapse is handle at the end of the collapse animation */ - if(!priv->expanded) { - priv->expanded = TRUE; + if(!priv->source_sel.expanded) { + priv->source_sel.expanded = TRUE; osd_source_reallocate(osd); - priv->count = 1000; - priv->shift = osd->widget->allocation.width - OSD_S_W; - priv->dir = -1000/OSD_HZ; + priv->source_sel.count = 1000; + priv->source_sel.shift = osd->widget->allocation.width - OSD_S_W; + priv->source_sel.dir = -1000/OSD_HZ; } else { - priv->count = 0; - priv->shift = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; - priv->dir = +1000/OSD_HZ; + priv->source_sel.count = 0; + priv->source_sel.shift = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; + priv->source_sel.dir = +1000/OSD_HZ; } - priv->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd); + priv->source_sel.handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd); } /* check if the user clicked inside the source selection area */ @@ -562,7 +580,7 @@ osd_source_check(osm_gps_map_osd_t *osd, gint x, gint y) { osd_priv_t *priv = (osd_priv_t*)osd->priv; - if(!priv->expanded) + if(!priv->source_sel.expanded) x -= osd->widget->allocation.width - OSD_S_W; else x -= osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; @@ -586,7 +604,7 @@ } /* check for clicks into data area */ - if(priv->expanded && !priv->handler_id) { + if(priv->source_sel.expanded && !priv->source_sel.handler_id) { /* re-adjust from puller top to content top */ if(OSD_S_Y < 0) y += OSD_S_EXP_H - OSD_S_PH; @@ -596,7 +614,7 @@ y > 0 && y < OSD_S_EXP_H) { - int step = (priv->height - 2*OSD_TEXT_BORDER) + int step = (priv->source_sel.height - 2*OSD_TEXT_BORDER) / OSM_GPS_MAP_SOURCE_LAST; y -= OSD_TEXT_BORDER - OSD_TEXT_SKIP; @@ -729,28 +747,202 @@ cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); } +#ifdef OSD_COORDINATES + +#ifndef OSD_COORDINATES_FONT_SIZE +#define OSD_COORDINATES_FONT_SIZE 12 +#endif + +#define OSD_COORDINATES_OFFSET (OSD_COORDINATES_FONT_SIZE/6) + +#define OSD_COORDINATES_W (8*OSD_COORDINATES_FONT_SIZE+2*OSD_COORDINATES_OFFSET) +#define OSD_COORDINATES_H (2*OSD_COORDINATES_FONT_SIZE+OSD_COORDINATES_OFFSET) + +/* these can be overwritten with versions that support */ +/* localization */ +#ifndef OSD_COORDINATES_CHR_N +#define OSD_COORDINATES_CHR_N "N" +#endif +#ifndef OSD_COORDINATES_CHR_S +#define OSD_COORDINATES_CHR_S "S" +#endif +#ifndef OSD_COORDINATES_CHR_E +#define OSD_COORDINATES_CHR_E "E" +#endif +#ifndef OSD_COORDINATES_CHR_W +#define OSD_COORDINATES_CHR_W "W" +#endif + + + +/* this is the classic geocaching notation */ +static char +*osd_latitude_str(float latitude) { + char *c = OSD_COORDINATES_CHR_N; + float integral, fractional; + + if(isnan(latitude)) + return NULL; + + if(latitude < 0) { + latitude = fabs(latitude); + c = OSD_COORDINATES_CHR_S; + } + + fractional = modff(latitude, &integral); + + return g_strdup_printf("%s %02d° %06.3f'", + c, (int)integral, fractional*60.0); +} + +static char +*osd_longitude_str(float longitude) { + char *c = OSD_COORDINATES_CHR_E; + float integral, fractional; + + if(isnan(longitude)) + return NULL; + + if(longitude < 0) { + longitude = fabs(longitude); + c = OSD_COORDINATES_CHR_W; + } + + fractional = modff(longitude, &integral); + + return g_strdup_printf("%s %03d° %06.3f'", + c, (int)integral, fractional*60.0); +} + +static void +osd_render_coordinates(osm_gps_map_osd_t *osd) +{ + osd_priv_t *priv = (osd_priv_t*)osd->priv; + + /* get current map position */ + gfloat lat, lon; + g_object_get(osd->widget, "latitude", &lat, "longitude", &lon, NULL); + + /* check if position has changed enough to require redraw */ + if(!isnan(priv->coordinates.lat) && !isnan(priv->coordinates.lon)) + /* 1/60000 == 1/1000 minute */ + if((fabsf(lat - priv->coordinates.lat) < 1/60000) && + (fabsf(lon - priv->coordinates.lon) < 1/60000)) + return; + + priv->coordinates.lat = lat; + priv->coordinates.lon = lon; + + /* first fill with light transparency */ + cairo_t *cr = cairo_create(priv->coordinates.surface); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5); + cairo_paint(cr); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + + cairo_select_font_face (cr, "Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); + cairo_set_font_size (cr, OSD_COORDINATES_FONT_SIZE); + + char *latitude = osd_latitude_str(lat); + char *longitude = osd_longitude_str(lon); + + cairo_text_extents_t lat_extents, lon_extents; + cairo_text_extents (cr, latitude, &lat_extents); + cairo_text_extents (cr, longitude, &lon_extents); + + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_set_line_width (cr, OSD_COORDINATES_FONT_SIZE/6); + cairo_move_to (cr, + (OSD_COORDINATES_W - lat_extents.width)/2, + OSD_COORDINATES_OFFSET - lat_extents.y_bearing); + cairo_text_path (cr, latitude); + cairo_move_to (cr, + (OSD_COORDINATES_W - lon_extents.width)/2, + OSD_COORDINATES_OFFSET - lon_extents.y_bearing + + OSD_COORDINATES_FONT_SIZE); + cairo_text_path (cr, longitude); + cairo_stroke (cr); + + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + cairo_move_to (cr, + (OSD_COORDINATES_W - lat_extents.width)/2, + OSD_COORDINATES_OFFSET - lat_extents.y_bearing); + cairo_show_text (cr, latitude); + cairo_move_to (cr, + (OSD_COORDINATES_W - lon_extents.width)/2, + OSD_COORDINATES_OFFSET - lon_extents.y_bearing + + OSD_COORDINATES_FONT_SIZE); + cairo_show_text (cr, longitude); + + g_free(latitude); + g_free(longitude); + + cairo_destroy(cr); +} +#endif // OSD_COORDINATES + #ifdef OSD_CROSSHAIR #ifndef OSD_CROSSHAIR_RADIUS -#define OSD_CROSSHAIR_RADIUS 20 +#define OSD_CROSSHAIR_RADIUS 10 #endif -#define OSD_CROSSHAIR_W (OSD_CROSSHAIR_RADIUS*2) -#define OSD_CROSSHAIR_H (OSD_CROSSHAIR_RADIUS*2) +#define OSD_CROSSHAIR_TICK (OSD_CROSSHAIR_RADIUS/2) +#define OSD_CROSSHAIR_BORDER (OSD_CROSSHAIR_TICK + OSD_CROSSHAIR_RADIUS/4) +#define OSD_CROSSHAIR_W ((OSD_CROSSHAIR_RADIUS+OSD_CROSSHAIR_BORDER)*2) +#define OSD_CROSSHAIR_H ((OSD_CROSSHAIR_RADIUS+OSD_CROSSHAIR_BORDER)*2) + +static void +osd_render_crosshair_shape(cairo_t *cr) { + cairo_arc (cr, OSD_CROSSHAIR_W/2, OSD_CROSSHAIR_H/2, + OSD_CROSSHAIR_RADIUS, 0, 2*M_PI); + + cairo_move_to (cr, OSD_CROSSHAIR_W/2 - OSD_CROSSHAIR_RADIUS, + OSD_CROSSHAIR_H/2); + cairo_rel_line_to (cr, -OSD_CROSSHAIR_TICK, 0); + cairo_move_to (cr, OSD_CROSSHAIR_W/2 + OSD_CROSSHAIR_RADIUS, + OSD_CROSSHAIR_H/2); + cairo_rel_line_to (cr, OSD_CROSSHAIR_TICK, 0); + + cairo_move_to (cr, OSD_CROSSHAIR_W/2, + OSD_CROSSHAIR_H/2 - OSD_CROSSHAIR_RADIUS); + cairo_rel_line_to (cr, 0, -OSD_CROSSHAIR_TICK); + cairo_move_to (cr, OSD_CROSSHAIR_W/2, + OSD_CROSSHAIR_H/2 + OSD_CROSSHAIR_RADIUS); + cairo_rel_line_to (cr, 0, OSD_CROSSHAIR_TICK); + + cairo_stroke (cr); +} static void osd_render_crosshair(osm_gps_map_osd_t *osd) { osd_priv_t *priv = (osd_priv_t*)osd->priv; + if(priv->crosshair.rendered) + return; + + priv->crosshair.rendered = TRUE; + /* first fill with transparency */ - cairo_t *cr = cairo_create(priv->crosshair); + cairo_t *cr = cairo_create(priv->crosshair.surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - // cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); - cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2); + cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + + cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.5); + cairo_set_line_width (cr, OSD_CROSSHAIR_RADIUS/2); + osd_render_crosshair_shape(cr); + + cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5); + cairo_set_line_width (cr, OSD_CROSSHAIR_RADIUS/4); + osd_render_crosshair_shape(cr); + cairo_destroy(cr); } #endif @@ -778,15 +970,15 @@ /* this only needs to be rendered if the zoom has changed */ gint zoom; g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); - if(zoom == priv->scale_zoom) + if(zoom == priv->scale.zoom) return; - priv->scale_zoom = zoom; + priv->scale.zoom = zoom; float m_per_pix = osm_gps_map_get_scale(OSM_GPS_MAP(osd->widget)); /* first fill with transparency */ - cairo_t *cr = cairo_create(priv->scale); + cairo_t *cr = cairo_create(priv->scale.surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); // pink for testing: cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2); @@ -900,10 +1092,22 @@ #endif static void -osd_render(osm_gps_map_osd_t *osd) +osd_render_controls(osm_gps_map_osd_t *osd) { osd_priv_t *priv = (osd_priv_t*)osd->priv; + if(priv->controls.rendered +#ifdef OSD_GPS_BUTTON + && (priv->controls.gps_enabled == (osd->cb != NULL)) +#endif + ) + return; + +#ifdef OSD_GPS_BUTTON + priv->controls.gps_enabled = (osd->cb != NULL); +#endif + priv->controls.rendered = TRUE; + #ifndef OSD_COLOR GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL]; GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL]; @@ -911,7 +1115,7 @@ #endif /* first fill with transparency */ - cairo_t *cr = cairo_create(priv->overlay); + cairo_t *cr = cairo_create(priv->controls.surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); cairo_paint(cr); @@ -982,6 +1186,12 @@ cairo_stroke(cr); cairo_destroy(cr); +} + +static void +osd_render(osm_gps_map_osd_t *osd) +{ + osd_render_controls(osd); #ifdef OSD_SOURCE_SEL osd_render_source_sel(osd); @@ -994,6 +1204,10 @@ #ifdef OSD_CROSSHAIR osd_render_crosshair(osd); #endif + +#ifdef OSD_COORDINATES + osd_render_coordinates(osd); +#endif } static void @@ -1003,29 +1217,43 @@ /* OSD itself uses some off-screen rendering, so check if the */ /* offscreen buffer is present and create it if not */ - if(!priv->overlay) { + if(!priv->controls.surface) { /* create overlay ... */ - priv->overlay = + priv->controls.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W+2, OSD_H+2); + priv->controls.rendered = FALSE; +#ifdef OSD_GPS_BUTTON + priv->controls.gps_enabled = FALSE; +#endif + #ifdef OSD_SOURCE_SEL /* the initial OSD state is alway not-expanded */ - priv->map_source = + priv->source_sel.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_S_W+2, OSD_S_H+2); #endif #ifdef OSD_SCALE - priv->scale = + priv->scale.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_SCALE_W, OSD_SCALE_H); - priv->scale_zoom = -1; + priv->scale.zoom = -1; #endif #ifdef OSD_CROSSHAIR - priv->crosshair = + priv->crosshair.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_CROSSHAIR_W, OSD_CROSSHAIR_H); + priv->crosshair.rendered = FALSE; +#endif + +#ifdef OSD_COORDINATES + priv->coordinates.surface = + cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + OSD_COORDINATES_W, OSD_COORDINATES_H); + + priv->coordinates.lat = priv->coordinates.lon = OSM_GPS_MAP_INVALID; #endif /* ... and render it */ @@ -1035,53 +1263,66 @@ // now draw this onto the original context cairo_t *cr = gdk_cairo_create(drawable); - int x = OSD_X, y = OSD_Y; - if(OSD_X < 0) - x = osd->widget->allocation.width - OSD_W + OSD_X; + int x, y; - if(OSD_Y < 0) - y = osd->widget->allocation.height - OSD_H + OSD_Y; +#ifdef OSD_SCALE + x = OSD_X; + y = -OSD_Y; + if(x < 0) x += osd->widget->allocation.width - OSD_SCALE_W; + if(y < 0) y += osd->widget->allocation.height - OSD_SCALE_H; - cairo_set_source_surface(cr, priv->overlay, x, y); + cairo_set_source_surface(cr, priv->scale.surface, x, y); + cairo_paint(cr); +#endif + +#ifdef OSD_CROSSHAIR + x = (osd->widget->allocation.width - OSD_CROSSHAIR_W)/2; + y = (osd->widget->allocation.height - OSD_CROSSHAIR_H)/2; + + cairo_set_source_surface(cr, priv->crosshair.surface, x, y); + cairo_paint(cr); +#endif + +#ifdef OSD_COORDINATES + x = -OSD_X; + y = -OSD_Y; + if(x < 0) x += osd->widget->allocation.width - OSD_COORDINATES_W; + if(y < 0) y += osd->widget->allocation.height - OSD_COORDINATES_H; + + cairo_set_source_surface(cr, priv->coordinates.surface, x, y); + cairo_paint(cr); +#endif + + x = OSD_X; + if(x < 0) + x += osd->widget->allocation.width - OSD_W; + + y = OSD_Y; + if(y < 0) + y += osd->widget->allocation.height - OSD_H; + + cairo_set_source_surface(cr, priv->controls.surface, x, y); cairo_paint(cr); #ifdef OSD_SOURCE_SEL - if(!priv->handler_id) { + if(!priv->source_sel.handler_id) { /* the OSD source selection is not being animated */ - if(!priv->expanded) + if(!priv->source_sel.expanded) x = osd->widget->allocation.width - OSD_S_W; else x = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; } else - x = priv->shift; + x = priv->source_sel.shift; y = OSD_S_Y; if(OSD_S_Y < 0) { - if(!priv->expanded) + if(!priv->source_sel.expanded) y = osd->widget->allocation.height - OSD_S_H + OSD_S_Y; else y = osd->widget->allocation.height - OSD_S_EXP_H + OSD_S_Y; } - cairo_set_source_surface(cr, priv->map_source, x, y); - cairo_paint(cr); -#endif - -#ifdef OSD_SCALE - x = OSD_X; - y = -OSD_Y; - if(x < 0) x += osd->widget->allocation.width - OSD_SCALE_W; - if(y < 0) y += osd->widget->allocation.height - OSD_SCALE_H; - - cairo_set_source_surface(cr, priv->scale, x, y); - cairo_paint(cr); -#endif - -#ifdef OSD_CROSSHAIR - x = (osd->widget->allocation.width - OSD_CROSSHAIR_W)/2; - y = (osd->widget->allocation.height - OSD_CROSSHAIR_H)/2; - - cairo_set_source_surface(cr, priv->crosshair, x, y); + cairo_set_source_surface(cr, priv->source_sel.surface, x, y); cairo_paint(cr); #endif @@ -1093,25 +1334,30 @@ { osd_priv_t *priv = (osd_priv_t *)(osd->priv); - if (priv->overlay) - cairo_surface_destroy(priv->overlay); + if (priv->controls.surface) + cairo_surface_destroy(priv->controls.surface); #ifdef OSD_SOURCE_SEL - if(priv->handler_id) - gtk_timeout_remove(priv->handler_id); + if(priv->source_sel.handler_id) + gtk_timeout_remove(priv->source_sel.handler_id); - if (priv->map_source) - cairo_surface_destroy(priv->map_source); + if (priv->source_sel.surface) + cairo_surface_destroy(priv->source_sel.surface); #endif #ifdef OSD_SCALE - if (priv->scale) - cairo_surface_destroy(priv->scale); + if (priv->scale.surface) + cairo_surface_destroy(priv->scale.surface); #endif #ifdef OSD_CROSSHAIR - if (priv->crosshair) - cairo_surface_destroy(priv->crosshair); + if (priv->crosshair.surface) + cairo_surface_destroy(priv->crosshair.surface); +#endif + +#ifdef OSD_COORDINATES + if (priv->coordinates.surface) + cairo_surface_destroy(priv->coordinates.surface); #endif g_free(priv); @@ -1122,7 +1368,7 @@ { #ifdef OSD_SOURCE_SEL osd_priv_t *priv = (osd_priv_t *)(osd->priv); - return (priv->handler_id != 0); + return (priv->source_sel.handler_id != 0); #else return FALSE; #endif