--- trunk/src/osm-gps-map-osd-classic.c 2009/08/31 14:22:28 88 +++ trunk/src/osm-gps-map-osd-classic.c 2009/09/01 11:16:30 89 @@ -342,8 +342,8 @@ CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, OSD_FONT_SIZE); - int i, step = (priv->height - 2*OSD_TEXT_BORDER) - / OSM_GPS_MAP_SOURCE_LAST; + int i, step = (priv->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; const char *src = osm_gps_map_source_get_friendly_name(i); @@ -431,6 +431,8 @@ cairo_destroy(cr); } +/* re-allocate the buffer used to draw the menu. This is used */ +/* to collapse/expand the buffer */ static void osd_source_reallocate(osm_gps_map_osd_t *osd) { osd_priv_t *priv = (osd_priv_t*)osd->priv; @@ -456,9 +458,6 @@ const char *src = osm_gps_map_source_get_friendly_name(i); cairo_text_extents (cr, src, &extents); - // printf("Source %d: %s = %f %f\n", i, src, - // extents.width, extents.height); - if(extents.width > max_w) max_w = extents.width; if(extents.height > max_h) max_h = extents.height; } @@ -509,10 +508,6 @@ /* 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) + @@ -553,6 +548,7 @@ priv->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd); } +/* check if the user clicked inside the source selection area */ 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; @@ -581,14 +577,33 @@ } /* check for clicks into data area */ - if(priv->expanded) { + if(priv->expanded && !priv->handler_id) { if(x > OSD_S_PW && x < OSD_S_PW + OSD_S_EXP_W && y > 0 && y < OSD_S_EXP_H) { - printf("in OSD source menu area\n"); + int step = (priv->height - 2*OSD_TEXT_BORDER) + / OSM_GPS_MAP_SOURCE_LAST; + + y -= OSD_TEXT_BORDER - OSD_TEXT_SKIP; + y /= step; + y += 1; + + gint old = 0; + g_object_get(osd->widget, "map-source", &old, NULL); + + if(y > OSM_GPS_MAP_SOURCE_NULL && + y <= OSM_GPS_MAP_SOURCE_LAST && + old != y) { + g_object_set(osd->widget, "map-source", y, NULL); + + osd_render_source_sel(osd); + osm_gps_map_repaint(OSM_GPS_MAP(osd->widget)); + } + /* return "clicked in OSD background" to prevent further */ + /* processing by application */ return OSD_BG; } }