Ticket #1029: odometer2.diff

File odometer2.diff, 2.8 KB (added by antiram, 8 years ago)

respects autostart=1

  • home/navit/_navit_develop/work/navit_repo/navit/navit/osd/core/osd_core.c

     
    8181struct odometer;
    8282
    8383int set_std_osd_attr(struct osd_priv_common*opc, struct attr*the_attr);
    84 static void osd_odometer_reset(struct osd_priv_common *opc, int force);
     84static void osd_odometer_reset(struct osd_priv_common *opc);
    8585static void osd_cmd_odometer_reset(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid);
    8686static void osd_odometer_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v);
    8787static struct osd_text_item * oti_new(struct osd_text_item * parent);
     
    522522{
    523523        if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
    524524          GList* list = odometer_list;
     525          struct odometer *odm;
    525526          while(list) {
    526             if(!strcmp(((struct odometer*)((struct osd_priv_common *)(list->data))->data)->name,in[0]->u.str)) {
    527               osd_odometer_reset(list->data,1);
    528                   osd_odometer_draw(list->data,this,NULL);
     527            odm = (struct odometer*) ((struct osd_priv_common *) (list->data))->data;
     528            if (!strcmp(odm->name, in[0]->u.str)) {
     529              double curr_time;
     530              struct timeval tv;
     531              gettimeofday(&tv, NULL);
     532              curr_time = (double) (tv.tv_usec) / 1000000.0 + tv.tv_sec;
     533              odm->last_click_time = curr_time;
     534              osd_odometer_reset(list->data);
     535              osd_odometer_draw(list->data,this,NULL);
    529536            }
    530537            list = g_list_next(list);
    531538          }
     
    775782
    776783
    777784static void
    778 osd_odometer_reset(struct osd_priv_common *opc, int force)
     785osd_odometer_reset(struct osd_priv_common *opc)
    779786{
    780787  struct odometer *this = (struct odometer *)opc->data;
    781788
    782   if(!this->bDisableReset || force) {
    783     this->bActive         = 0;
    784     this->sum_dist        = 0;
    785     this->sum_time        = 0;
    786     this->max_speed       = 0;
    787     this->last_start_time = 0;
    788     this->last_coord.x    = -1;
    789     this->last_coord.y    = -1;
    790   }
     789  this->sum_dist        = 0;
     790  this->sum_time        = 0;
     791  this->max_speed       = 0;
     792  this->last_start_time = 0;
     793  this->last_coord.x    = -1;
     794  this->last_coord.y    = -1;
    791795}
    792796
    793797static void
     
    821825
    822826  this->bActive ^= 1;  //toggle active flag
    823827
    824   if (curr_time-double_click_timewin <= this->last_click_time) { //double click handling
    825     osd_odometer_reset(opc,0);
     828  if (curr_time-double_click_timewin <= this->last_click_time && !this->bDisableReset) { //double click handling
     829      this->bActive = 0;
     830      osd_odometer_reset(opc);
    826831  }
    827832
    828833  this->last_click_time = curr_time;