Diff of /trunk/src/map-tool.c

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

revision 42 by harbaum, Mon Aug 3 19:18:13 2009 UTC revision 44 by harbaum, Tue Aug 4 14:07:18 2009 UTC
# Line 380  static int dist2pixel(map_context_t *con Line 380  static int dist2pixel(map_context_t *con
380    return 1000.0*km/m_per_pix;    return 1000.0*km/m_per_pix;
381  }  }
382    
383  #define CLICK_FUZZ (10)  #define CLICK_FUZZ (16)
384    
385  static gboolean  static gboolean
386  on_map_button_press_event(GtkWidget *widget,  on_map_button_press_event(GtkWidget *widget,
387                              GdkEventButton *event, map_context_t *context) {                              GdkEventButton *event, map_context_t *context) {
388    OsmGpsMap *map = OSM_GPS_MAP(context->widget);    OsmGpsMap *map = OSM_GPS_MAP(context->widget);
389    
390      /* got a press event without release event? eat it! */
391      if(context->press_on != NULL) {
392        printf("PRESS: already\n");
393        return TRUE;
394      }
395    
396    pos_t pos =    pos_t pos =
397      coord2pos(osm_gps_map_get_co_ordinates(map, event->x, event->y));      coord2pos(osm_gps_map_get_co_ordinates(map, event->x, event->y));
398    
399    cache_t *nearest = map_closest(context, &pos);    cache_t *nearest = map_closest(context, &pos);
400    if(nearest) {    if(nearest) {
401      float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);      float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);
402      if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ) {      if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ)
403        context->press_on = nearest;        context->press_on = nearest;
       return TRUE;  
     }  
404    }    }
405    
   context->press_on = NULL;  
406    return FALSE;    return FALSE;
407  }  }
408    
# Line 415  on_map_button_release_event(GtkWidget *w Line 418  on_map_button_release_event(GtkWidget *w
418      cache_t *nearest = map_closest(context, &pos);      cache_t *nearest = map_closest(context, &pos);
419      if(nearest && nearest == context->press_on) {      if(nearest && nearest == context->press_on) {
420        float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);        float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);
421        if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ) {        if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ)
   
422          cache_popup(context, nearest);          cache_popup(context, nearest);
   
         context->press_on = NULL;  
         return TRUE;  
       }  
423      }      }
424        context->press_on = NULL;
425    }    }
426    
   context->press_on = NULL;  
427    return FALSE;    return FALSE;
428  }  }
429    
430    
431  #if MAEMO_VERSION_MAJOR == 5  #if MAEMO_VERSION_MAJOR == 5
432  static void on_window_destroy(GtkWidget *widget, map_context_t *context) {  static void on_window_destroy(GtkWidget *widget, map_context_t *context) {
433    printf("destroy map view\n");    printf("destroy map view\n");
# Line 472  void map(appdata_t *appdata) { Line 471  void map(appdata_t *appdata) {
471  #ifdef USE_MAEMO  #ifdef USE_MAEMO
472    } else {    } else {
473      map_draw_cachelist(context->widget, appdata->cur_gpx->cache);      map_draw_cachelist(context->widget, appdata->cur_gpx->cache);
474      name = g_strdup(_("appdata->cur_gpx->name"));      name = g_strdup(appdata->cur_gpx->name);
475    }    }
476  #endif  #endif
477    

Legend:
Removed from v.42  
changed lines
  Added in v.44