Diff of /trunk/src/osm-gps-map-osd-classic.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 88 by harbaum, Mon Aug 31 14:22:28 2009 UTC revision 89 by harbaum, Tue Sep 1 11:16:30 2009 UTC
# Line 342  osd_source_content(osm_gps_map_osd_t *os Line 342  osd_source_content(osm_gps_map_osd_t *os
342                                      CAIRO_FONT_WEIGHT_BOLD);                                      CAIRO_FONT_WEIGHT_BOLD);
343              cairo_set_font_size (cr, OSD_FONT_SIZE);              cairo_set_font_size (cr, OSD_FONT_SIZE);
344    
345              int i, step = (priv->height - 2*OSD_TEXT_BORDER)              int i, step = (priv->height - 2*OSD_TEXT_BORDER) /
346                  / OSM_GPS_MAP_SOURCE_LAST;                  OSM_GPS_MAP_SOURCE_LAST;
347              for(i=OSM_GPS_MAP_SOURCE_NULL+1;i<=OSM_GPS_MAP_SOURCE_LAST;i++) {              for(i=OSM_GPS_MAP_SOURCE_NULL+1;i<=OSM_GPS_MAP_SOURCE_LAST;i++) {
348                  cairo_text_extents_t extents;                  cairo_text_extents_t extents;
349                  const char *src = osm_gps_map_source_get_friendly_name(i);                  const char *src = osm_gps_map_source_get_friendly_name(i);
# Line 431  osd_render_source_sel(osm_gps_map_osd_t Line 431  osd_render_source_sel(osm_gps_map_osd_t
431      cairo_destroy(cr);      cairo_destroy(cr);
432  }  }
433    
434    /* re-allocate the buffer used to draw the menu. This is used */
435    /* to collapse/expand the buffer */
436  static void  static void
437  osd_source_reallocate(osm_gps_map_osd_t *osd) {  osd_source_reallocate(osm_gps_map_osd_t *osd) {
438      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
# Line 456  osd_source_reallocate(osm_gps_map_osd_t Line 458  osd_source_reallocate(osm_gps_map_osd_t
458              const char *src = osm_gps_map_source_get_friendly_name(i);              const char *src = osm_gps_map_source_get_friendly_name(i);
459              cairo_text_extents (cr, src, &extents);              cairo_text_extents (cr, src, &extents);
460    
             //            printf("Source %d: %s = %f %f\n", i, src,  
             //                   extents.width, extents.height);  
   
461              if(extents.width > max_w) max_w = extents.width;              if(extents.width > max_w) max_w = extents.width;
462              if(extents.height > max_h) max_h = extents.height;              if(extents.height > max_h) max_h = extents.height;
463          }          }
# Line 509  static gboolean osd_source_animate(gpoin Line 508  static gboolean osd_source_animate(gpoin
508    
509      /* count runs linearly from 0 to 1000, map this nicely onto a position */      /* count runs linearly from 0 to 1000, map this nicely onto a position */
510    
     /* simple linear mapping */  
     //    priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) +  
     //        (diff * priv->count)/1000;  
   
511      /* nicer sinoid mapping */      /* nicer sinoid mapping */
512      float m = 0.5-cos(priv->count * M_PI / 1000.0)/2;      float m = 0.5-cos(priv->count * M_PI / 1000.0)/2;
513      priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) +      priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) +
# Line 553  osd_source_toggle(osm_gps_map_osd_t *osd Line 548  osd_source_toggle(osm_gps_map_osd_t *osd
548      priv->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd);      priv->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd);
549  }  }
550    
551    /* check if the user clicked inside the source selection area */
552  static osd_button_t  static osd_button_t
553  osd_source_check(osm_gps_map_osd_t *osd, gint x, gint y) {  osd_source_check(osm_gps_map_osd_t *osd, gint x, gint y) {
554      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
# Line 581  osd_source_check(osm_gps_map_osd_t *osd, Line 577  osd_source_check(osm_gps_map_osd_t *osd,
577      }      }
578    
579      /* check for clicks into data area */      /* check for clicks into data area */
580      if(priv->expanded) {      if(priv->expanded && !priv->handler_id) {
581          if(x > OSD_S_PW &&          if(x > OSD_S_PW &&
582             x < OSD_S_PW + OSD_S_EXP_W &&             x < OSD_S_PW + OSD_S_EXP_W &&
583             y > 0 &&             y > 0 &&
584             y < OSD_S_EXP_H) {             y < OSD_S_EXP_H) {
585    
586              printf("in OSD source menu area\n");              int step = (priv->height - 2*OSD_TEXT_BORDER)
587                    / OSM_GPS_MAP_SOURCE_LAST;
588    
589                y -= OSD_TEXT_BORDER - OSD_TEXT_SKIP;
590                y /= step;
591                y += 1;
592    
593                gint old = 0;
594                g_object_get(osd->widget, "map-source", &old, NULL);
595    
596                if(y > OSM_GPS_MAP_SOURCE_NULL &&
597                   y <= OSM_GPS_MAP_SOURCE_LAST &&
598                   old != y) {
599                    g_object_set(osd->widget, "map-source", y, NULL);
600    
601                    osd_render_source_sel(osd);
602                    osm_gps_map_repaint(OSM_GPS_MAP(osd->widget));
603                }
604    
605                /* return "clicked in OSD background" to prevent further */
606                /* processing by application */
607              return OSD_BG;              return OSD_BG;
608          }          }
609      }      }

Legend:
Removed from v.88  
changed lines
  Added in v.89