--- trunk/src/osm-gps-map-osd-classic.c 2009/08/25 12:49:03 77 +++ trunk/src/osm-gps-map-osd-classic.c 2009/08/30 19:05:44 86 @@ -21,6 +21,10 @@ #include // abs #include // M_PI +#define OSD_SOURCE_SEL + +#define OSD_Y (-10) + /* parameters that can be overwritten from the config file: */ /* OSD_DIAMETER */ /* OSD_X, OSD_Y */ @@ -38,6 +42,11 @@ typedef struct { /* the offscreen representation of the OSD */ cairo_surface_t *overlay; + + cairo_surface_t *map_source; + gboolean expanded; + gint shift, dir, count; + gint handler_id; } osd_priv_t; /* position and extent of bounding box */ @@ -100,7 +109,7 @@ /* create the cairo shape used for the zoom buttons */ static void -osm_gps_map_osd_zoom_shape(cairo_t *cr, gint x, gint y) +osd_zoom_shape(cairo_t *cr, gint x, gint y) { cairo_move_to (cr, x+Z_LEFT, y+Z_TOP); cairo_line_to (cr, x+Z_RIGHT, y+Z_TOP); @@ -109,15 +118,77 @@ cairo_arc (cr, x+Z_LEFT, y+Z_MID, Z_RAD, M_PI/2, -M_PI/2); } +/* ------------------- color/shadow functions ----------------- */ + +#ifndef OSD_COLOR +/* if no color has been specified we just use the gdks default colors */ +static void +osd_labels(cairo_t *cr, gint width, gboolean enabled, + GdkColor *fg, GdkColor *disabled) { + if(enabled) gdk_cairo_set_source_color(cr, fg); + else gdk_cairo_set_source_color(cr, disabled); + cairo_set_line_width (cr, width); + cairo_stroke (cr); +} +#else +static void +osd_labels(cairo_t *cr, gint width, gboolean enabled) { + if(enabled) cairo_set_source_rgb (cr, OSD_COLOR); + else cairo_set_source_rgb (cr, OSD_COLOR_DISABLED); + cairo_set_line_width (cr, width); + cairo_stroke (cr); +} +#endif + +#ifdef OSD_SHADOW_ENABLE +static void +osd_labels_shadow(cairo_t *cr, gint width, gboolean enabled) { + cairo_set_source_rgba (cr, 0, 0, 0, enabled?0.3:0.15); + cairo_set_line_width (cr, width); + cairo_stroke (cr); +} +#endif + #ifndef OSD_NO_DPAD /* create the cairo shape used for the dpad */ static void -osm_gps_map_osd_dpad_shape(cairo_t *cr, gint x, gint y) +osd_dpad_shape(cairo_t *cr, gint x, gint y) { cairo_arc (cr, x+D_RAD, y+D_RAD, D_RAD, 0, 2 * M_PI); } #endif +#ifdef OSD_SHADOW_ENABLE +static void +osd_shape_shadow(cairo_t *cr) { + cairo_set_source_rgba (cr, 0, 0, 0, 0.2); + cairo_fill (cr); + cairo_stroke (cr); +} +#endif + +#ifndef OSD_COLOR +/* if no color has been specified we just use the gdks default colors */ +static void +osd_shape(cairo_t *cr, GdkColor *bg, GdkColor *fg) { + gdk_cairo_set_source_color(cr, bg); + cairo_fill_preserve (cr); + gdk_cairo_set_source_color(cr, fg); + cairo_set_line_width (cr, 1); + cairo_stroke (cr); +} +#else +static void +osd_shape(cairo_t *cr) { + cairo_set_source_rgb (cr, OSD_COLOR_BG); + cairo_fill_preserve (cr); + cairo_set_source_rgb (cr, OSD_COLOR); + cairo_set_line_width (cr, 1); + cairo_stroke (cr); +} +#endif + + static gboolean osm_gps_map_in_circle(gint x, gint y, gint cx, gint cy, gint rad) { @@ -127,7 +198,7 @@ #ifndef OSD_NO_DPAD /* check whether x/y is within the dpad */ static osd_button_t -osm_gps_map_osd_check_dpad(gint x, gint y) +osd_check_dpad(gint x, gint y) { /* within entire dpad circle */ if( osm_gps_map_in_circle(x, y, D_RAD, D_RAD, D_RAD)) @@ -162,7 +233,7 @@ /* check whether x/y is within the zoom pads */ static osd_button_t -osm_gps_map_osd_check_zoom(gint x, gint y) { +osd_check_zoom(gint x, gint y) { if( x > 0 && x < OSD_W && y > Z_TOP && y < Z_BOT) { /* within circle around (-) label */ @@ -191,10 +262,245 @@ return OSD_NONE; } +/* place source selection at right border */ +#define OSD_S_RAD (Z_RAD) +#define OSD_S_X (-OSD_X) +#define OSD_S_Y (OSD_Y) +#define OSD_S_PW (2 * Z_RAD) +#define OSD_S_W (OSD_S_PW) +#define OSD_S_PH (2 * Z_RAD) +#define OSD_S_H (OSD_S_PH + OSD_SHADOW) + +/* size of usable area when exapnded */ +#define OSD_S_AREA_W (200) +#define OSD_S_AREA_H (200) +#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) + +/* internal value to draw the arrow on the "puller" */ +#define OSD_S_D0 (OSD_S_RAD/2) + +static void +osd_source_shape(osd_priv_t *priv, cairo_t *cr, gint x, gint y) { + if(!priv->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); + cairo_line_to (cr, x + OSD_S_PW, y); + } else { + /* draw the puller and the area itself */ + cairo_move_to (cr, x + OSD_S_PW + OSD_S_AREA_W, y + OSD_S_AREA_H); + cairo_line_to (cr, x + OSD_S_PW, y + OSD_S_AREA_H); + if(OSD_S_Y > 0) { + cairo_line_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); + } else { + cairo_arc (cr, x+OSD_S_RAD, y+OSD_S_AREA_H-OSD_S_RAD, OSD_S_RAD, M_PI/2, -M_PI/2); + cairo_line_to (cr, x + OSD_S_PW, y + OSD_S_AREA_H - OSD_S_PH); + cairo_line_to (cr, x + OSD_S_PW, y); + } + cairo_line_to (cr, x + OSD_S_PW + OSD_S_AREA_W, y); + cairo_close_path (cr); + } +} + +static void +osd_source_content(osd_priv_t *priv, cairo_t *cr, gint x, gint y) { + y += OSD_S_RAD - OSD_S_D0; + + if(!priv->expanded) { + /* draw the "puller" open (<) arrow */ + cairo_move_to (cr, x + OSD_S_RAD + OSD_S_D0/2, y); + cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0); + cairo_rel_line_to (cr, +OSD_S_D0, +OSD_S_D0); + } else { + if(OSD_S_Y < 0) + y += OSD_S_AREA_H - OSD_S_PH; + + /* draw the "puller" close (>) arrow */ + cairo_move_to (cr, x + OSD_S_RAD - OSD_S_D0/2, y); + cairo_rel_line_to (cr, +OSD_S_D0, +OSD_S_D0); + cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0); + } +} + +static void +osd_render_source_sel(osm_gps_map_osd_t *osd) { + osd_priv_t *priv = (osd_priv_t*)osd->priv; + +#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]; + GdkColor da = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_INSENSITIVE]; +#endif + + /* draw source selector */ + cairo_t *cr = cairo_create(priv->map_source); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); + cairo_paint(cr); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + +#ifdef OSD_SHADOW_ENABLE + osd_source_shape(priv, cr, 1+OSD_SHADOW, 1+OSD_SHADOW); + osd_shape_shadow(cr); +#endif + + osd_source_shape(priv, cr, 1, 1); +#ifndef OSD_COLOR + osd_shape(cr, &bg, &fg); +#else + osd_shape(cr); +#endif + +#ifdef OSD_SHADOW_ENABLE + osd_source_content(priv, cr, 1+OSD_LBL_SHADOW, 1+OSD_LBL_SHADOW); + osd_labels_shadow(cr, Z_RAD/3, TRUE); +#endif + osd_source_content(priv, cr, 1, 1); +#ifndef OSD_COLOR + osd_labels(cr, Z_RAD/3, TRUE, &fg, &da); +#else + osd_labels(cr, Z_RAD/3, TRUE); +#endif + + cairo_destroy(cr); +} + +static void +osd_source_reallocate(osm_gps_map_osd_t *osd) { + osd_priv_t *priv = (osd_priv_t*)osd->priv; + + /* re-allocate offscreen bitmap */ + g_assert (priv->map_source); + cairo_surface_destroy(priv->map_source); + + int w = OSD_S_W, h = OSD_S_H; + if(priv->expanded) { + w = OSD_S_EXP_W; + h = OSD_S_EXP_H; + } + + priv->map_source = + cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2); + + osd_render_source_sel(osd); + +} + +#define OSD_HZ 15 +#define OSD_TIME 1000 + +static gboolean osd_source_animate(gpointer data) { + osm_gps_map_osd_t *osd = (osm_gps_map_osd_t*)data; + 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; + + /* shifting in */ + if(priv->dir < 0) { + if(priv->count <= 0) { + priv->count = 0; + done = TRUE; + } + } else { + if(priv->count >= 1000) { + priv->expanded = FALSE; + osd_source_reallocate(osd); + + priv->count = 1000; + done = TRUE; + } + } + + + /* count runs linearly from 0 to 1000, map this nicely onto a position */ + + /* simple linear mapping */ + // priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) + + // (diff * priv->count)/1000; + + /* 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) + + m * diff; + + osm_gps_map_repaint(OSM_GPS_MAP(osd->widget)); + + if(done) + priv->handler_id = 0; + + return !done; +} + +/* switch between expand and collapse mode of source selection */ +static void +osd_source_toggle(osm_gps_map_osd_t *osd) +{ + osd_priv_t *priv = (osd_priv_t*)osd->priv; + + /* ignore clicks while animation is running */ + if(priv->handler_id) + return; + + /* expand immediately, collapse is handle at the end of the collapse animation */ + if(!priv->expanded) { + priv->expanded = TRUE; + osd_source_reallocate(osd); + + priv->count = 1000; + priv->shift = osd->widget->allocation.width - OSD_S_W; + priv->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->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd); +} + +static osd_button_t +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) + x -= osd->widget->allocation.width - OSD_S_W; + else + x -= osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; + + if(OSD_S_Y > 0) + y -= OSD_S_Y; + else + y -= osd->widget->allocation.height - OSD_S_PH + OSD_S_Y; + + /* within square around puller? */ + if(y > 0 && y < OSD_S_PH && x > 0 && x < OSD_S_PW) { + /* really within puller shape? */ + if(x > Z_RAD || osm_gps_map_in_circle(x, y, Z_RAD, Z_RAD, Z_RAD)) { + /* expand source selector */ + osd_source_toggle(osd); + + /* tell upper layers that user clicked some background element */ + /* of the OSD */ + return OSD_BG; + } + } + return OSD_NONE; +} + static osd_button_t -osm_gps_map_osd_check(osm_gps_map_osd_t *osd, gint x, gint y) { +osd_check(osm_gps_map_osd_t *osd, gint x, gint y) { osd_button_t but = OSD_NONE; +#ifdef OSD_SOURCE_SEL + /* the source selection area is handles internally */ + but = osd_source_check(osd, x, y); + if(but != OSD_NONE) + return but; +#endif + x -= OSD_X; y -= OSD_Y; @@ -208,49 +514,19 @@ /* this is just to avoid an unnecessary detailed test */ if(x > 0 && x < OSD_W && y > 0 && y < OSD_H) { #ifndef OSD_NO_DPAD - but = osm_gps_map_osd_check_dpad(x, y); + but = osd_check_dpad(x, y); #endif if(but == OSD_NONE) - but = osm_gps_map_osd_check_zoom(x, y); + but = osd_check_zoom(x, y); } return but; } -#ifdef OSD_SHADOW_ENABLE -static void -osm_gps_map_osd_shape_shadow(cairo_t *cr) { - cairo_set_source_rgba (cr, 0, 0, 0, 0.2); - cairo_fill (cr); - cairo_stroke (cr); -} -#endif - -#ifndef OSD_COLOR -/* if no color has been specified we just use the gdks default colors */ -static void -osm_gps_map_osd_shape(cairo_t *cr, GdkColor *bg, GdkColor *fg) { - gdk_cairo_set_source_color(cr, bg); - cairo_fill_preserve (cr); - gdk_cairo_set_source_color(cr, fg); - cairo_set_line_width (cr, 1); - cairo_stroke (cr); -} -#else -static void -osm_gps_map_osd_shape(cairo_t *cr) { - cairo_set_source_rgb (cr, OSD_COLOR_BG); - cairo_fill_preserve (cr); - cairo_set_source_rgb (cr, OSD_COLOR); - cairo_set_line_width (cr, 1); - cairo_stroke (cr); -} -#endif - #ifndef OSD_NO_DPAD static void -osm_gps_map_osd_dpad_labels(cairo_t *cr, gint x, gint y) { +osd_dpad_labels(cairo_t *cr, gint x, gint y) { /* move reference to dpad center */ x += D_RAD; y += D_RAD; @@ -285,7 +561,7 @@ /* this is either drawn in the center of the dpad (if present) */ /* or in the middle of the zoom area */ static void -osm_gps_map_osd_dpad_gps(cairo_t *cr, gint x, gint y) { +osd_dpad_gps(cairo_t *cr, gint x, gint y) { /* move reference to dpad center */ x += (1-Z_GPS) * D_RAD + Z_GPS * Z_RAD * 3; y += (1-Z_GPS) * D_RAD + Z_GPS * Z_RAD + GPS_V0; @@ -308,7 +584,7 @@ #define Z_LEN (2*Z_RAD/3) static void -osm_gps_map_osd_zoom_labels(cairo_t *cr, gint x, gint y) { +osd_zoom_labels(cairo_t *cr, gint x, gint y) { cairo_move_to (cr, x + Z_LEFT - Z_LEN, y + Z_MID); cairo_line_to (cr, x + Z_LEFT + Z_LEN, y + Z_MID); @@ -318,119 +594,89 @@ cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); } -#ifndef OSD_COLOR -/* if no color has been specified we just use the gdks default colors */ -static void -osm_gps_map_osd_labels(cairo_t *cr, gint width, gboolean enabled, - GdkColor *fg, GdkColor *disabled) { - if(enabled) gdk_cairo_set_source_color(cr, fg); - else gdk_cairo_set_source_color(cr, disabled); - cairo_set_line_width (cr, width); - cairo_stroke (cr); -} -#else static void -osm_gps_map_osd_labels(cairo_t *cr, gint width, gboolean enabled) { - if(enabled) cairo_set_source_rgb (cr, OSD_COLOR); - else cairo_set_source_rgb (cr, OSD_COLOR_DISABLED); - cairo_set_line_width (cr, width); - cairo_stroke (cr); -} -#endif - -#ifdef OSD_SHADOW_ENABLE -static void -osm_gps_map_osd_labels_shadow(cairo_t *cr, gint width, gboolean enabled) { - cairo_set_source_rgba (cr, 0, 0, 0, enabled?0.3:0.15); - cairo_set_line_width (cr, width); - cairo_stroke (cr); -} -#endif - -static void -osm_gps_map_osd_render(osm_gps_map_osd_t *osd) { +osd_render(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->overlay); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); - cairo_paint(cr); - #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]; GdkColor da = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_INSENSITIVE]; #endif + /* first fill with transparency */ + cairo_t *cr = cairo_create(priv->overlay); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); + cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); /* --------- draw zoom and dpad shape shadow ----------- */ - gint x = 0, y = 0; - #ifdef OSD_SHADOW_ENABLE - osm_gps_map_osd_zoom_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); - osm_gps_map_osd_shape_shadow(cr); + osd_zoom_shape(cr, 1+OSD_SHADOW, 1+OSD_SHADOW); + osd_shape_shadow(cr); #ifndef OSD_NO_DPAD - osm_gps_map_osd_dpad_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); - osm_gps_map_osd_shape_shadow(cr); + osd_dpad_shape(cr, 1+OSD_SHADOW, 1+OSD_SHADOW); + osd_shape_shadow(cr); #endif #endif /* --------- draw zoom and dpad shape ----------- */ - osm_gps_map_osd_zoom_shape(cr, x, y); + osd_zoom_shape(cr, 1, 1); #ifndef OSD_COLOR - osm_gps_map_osd_shape(cr, &bg, &fg); + osd_shape(cr, &bg, &fg); #else - osm_gps_map_osd_shape(cr); + osd_shape(cr); #endif #ifndef OSD_NO_DPAD - osm_gps_map_osd_dpad_shape(cr, x, y); + osd_dpad_shape(cr, 1, 1); #ifndef OSD_COLOR - osm_gps_map_osd_shape(cr, &bg, &fg); + osd_shape(cr, &bg, &fg); #else - osm_gps_map_osd_shape(cr); + osd_shape(cr); #endif #endif /* --------- draw zoom and dpad labels --------- */ #ifdef OSD_SHADOW_ENABLE - osm_gps_map_osd_zoom_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); + osd_zoom_labels(cr, 1+OSD_LBL_SHADOW, 1+OSD_LBL_SHADOW); #ifndef OSD_NO_DPAD - osm_gps_map_osd_dpad_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); + osd_dpad_labels(cr, 1+OSD_LBL_SHADOW, 1+OSD_LBL_SHADOW); #endif - osm_gps_map_osd_labels_shadow(cr, Z_RAD/3, TRUE); + osd_labels_shadow(cr, Z_RAD/3, TRUE); #ifdef OSD_GPS_BUTTON - osm_gps_map_osd_dpad_gps(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); - osm_gps_map_osd_labels_shadow(cr, Z_RAD/6, osd->cb != NULL); + osd_dpad_gps(cr, 1+OSD_LBL_SHADOW, 1+OSD_LBL_SHADOW); + osd_labels_shadow(cr, Z_RAD/6, osd->cb != NULL); #endif #endif - osm_gps_map_osd_zoom_labels(cr, x, y); + osd_zoom_labels(cr, 1, 1); #ifndef OSD_NO_DPAD - osm_gps_map_osd_dpad_labels(cr, x, y); + osd_dpad_labels(cr, 1, 1); #endif #ifndef OSD_COLOR - osm_gps_map_osd_labels(cr, Z_RAD/3, TRUE, &fg, &da); + osd_labels(cr, Z_RAD/3, TRUE, &fg, &da); #else - osm_gps_map_osd_labels(cr, Z_RAD/3, TRUE); + osd_labels(cr, Z_RAD/3, TRUE); #endif #ifdef OSD_GPS_BUTTON - osm_gps_map_osd_dpad_gps(cr, x, y); + osd_dpad_gps(cr, 1, 1); #ifndef OSD_COLOR - osm_gps_map_osd_labels(cr, Z_RAD/6, osd->cb != NULL, &fg, &da); + osd_labels(cr, Z_RAD/6, osd->cb != NULL, &fg, &da); #else - osm_gps_map_osd_labels(cr, Z_RAD/6, osd->cb != NULL); + osd_labels(cr, Z_RAD/6, osd->cb != NULL); #endif #endif cairo_destroy(cr); + + osd_render_source_sel(osd); } static void -osm_gps_map_osd_draw(osm_gps_map_osd_t *osd, GdkDrawable *drawable) +osd_draw(osm_gps_map_osd_t *osd, GdkDrawable *drawable) { osd_priv_t *priv = (osd_priv_t*)osd->priv; @@ -439,9 +685,15 @@ if(!priv->overlay) { /* create overlay ... */ priv->overlay = - cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W, OSD_H); + cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W+2, OSD_H+2); + + /* the initial OSD state is alway not-expanded */ + priv->map_source = + cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + OSD_S_W+2, OSD_S_H+2); + /* ... and render it */ - osm_gps_map_osd_render(osd); + osd_render(osd); } // now draw this onto the original context @@ -456,25 +708,54 @@ cairo_set_source_surface(cr, priv->overlay, x, y); cairo_paint(cr); + +#ifdef OSD_SOURCE_SEL + if(!priv->handler_id) { + /* the OSD source selection is not being animated */ + if(!priv->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; + + y = OSD_S_Y; + if(OSD_S_Y < 0) { + if(!priv->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 + cairo_destroy(cr); } static void -osm_gps_map_osd_free(osm_gps_map_osd_t *osd) +osd_free(osm_gps_map_osd_t *osd) { osd_priv_t *priv = (osd_priv_t *)(osd->priv); + if(priv->handler_id) + gtk_timeout_remove(priv->handler_id); + if (priv->overlay) cairo_surface_destroy(priv->overlay); + if (priv->map_source) + cairo_surface_destroy(priv->map_source); + g_free(priv); } static osm_gps_map_osd_t osd_classic = { - .draw = osm_gps_map_osd_draw, - .check = osm_gps_map_osd_check, - .render = osm_gps_map_osd_render, - .free = osm_gps_map_osd_free, + .draw = osd_draw, + .check = osd_check, + .render = osd_render, + .free = osd_free, .cb = NULL, .data = NULL, @@ -499,7 +780,6 @@ void osm_gps_map_osd_enable_gps (OsmGpsMap *map, OsmGpsMapOsdCallback cb, gpointer data) { osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); - g_return_if_fail (osd); osd->cb = cb; @@ -512,3 +792,11 @@ osm_gps_map_redraw(map); } #endif + +osd_button_t +osm_gps_map_osd_check(OsmGpsMap *map, gint x, gint y) { + osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); + g_return_val_if_fail (osd, OSD_NONE); + + return osd_check(osd, x, y); +}