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

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

revision 108 by harbaum, Fri Sep 11 19:20:55 2009 UTC revision 111 by harbaum, Mon Sep 14 12:16:08 2009 UTC
# Line 46  typedef struct { Line 46  typedef struct {
46      } controls;      } controls;
47    
48  #ifdef OSD_SCALE  #ifdef OSD_SCALE
49      cairo_surface_t *scale;      struct {
50      int scale_zoom;          cairo_surface_t *surface;
51            int zoom;
52        } scale;
53  #endif  #endif
54    
55  #ifdef OSD_CROSSHAIR  #ifdef OSD_CROSSHAIR
56      cairo_surface_t *crosshair;      struct {
57            cairo_surface_t *surface;
58            gboolean rendered;
59        } crosshair;
60  #endif  #endif
61    
62  #ifdef OSD_COORDINATES  #ifdef OSD_COORDINATES
63      cairo_surface_t *coordinates;      struct {
64      float coo_lat, coo_lon;          cairo_surface_t *surface;
65            float lat, lon;
66        } coordinates;
67  #endif  #endif
68    
69  #ifdef OSD_SOURCE_SEL  #ifdef OSD_SOURCE_SEL
70      /* values to handle the "source" menu */      struct {
71      cairo_surface_t *map_source;          /* values to handle the "source" menu */
72      gboolean expanded;          cairo_surface_t *surface;
73      gint shift, dir, count;          gboolean expanded;
74      gint handler_id;          gint shift, dir, count;
75      gint width, height;          gint handler_id;
76            gint width, height;
77            gboolean rendered;
78        } source_sel;
79  #endif  #endif
80    
81  } osd_priv_t;  } osd_priv_t;
# Line 292  osd_check_zoom(gint x, gint y) { Line 302  osd_check_zoom(gint x, gint y) {
302  #define OSD_S_H   (OSD_S_PH + OSD_SHADOW)  #define OSD_S_H   (OSD_S_PH + OSD_SHADOW)
303    
304  /* size of usable area when expanded */  /* size of usable area when expanded */
305  #define OSD_S_AREA_W (priv->width)  #define OSD_S_AREA_W (priv->source_sel.width)
306  #define OSD_S_AREA_H (priv->height)  #define OSD_S_AREA_H (priv->source_sel.height)
307  #define OSD_S_EXP_W  (OSD_S_PW + OSD_S_AREA_W + OSD_SHADOW)  #define OSD_S_EXP_W  (OSD_S_PW + OSD_S_AREA_W + OSD_SHADOW)
308  #define OSD_S_EXP_H  (OSD_S_AREA_H + OSD_SHADOW)  #define OSD_S_EXP_H  (OSD_S_AREA_H + OSD_SHADOW)
309    
# Line 309  osd_check_zoom(gint x, gint y) { Line 319  osd_check_zoom(gint x, gint y) {
319  /* or the entire menu incl. the puller (expanded) */  /* or the entire menu incl. the puller (expanded) */
320  static void  static void
321  osd_source_shape(osd_priv_t *priv, cairo_t *cr, gint x, gint y) {  osd_source_shape(osd_priv_t *priv, cairo_t *cr, gint x, gint y) {
322      if(!priv->expanded) {      if(!priv->source_sel.expanded) {
323          /* just draw the puller */          /* just draw the puller */
324          cairo_move_to (cr, x + OSD_S_PW, y + OSD_S_PH);          cairo_move_to (cr, x + OSD_S_PW, y + OSD_S_PH);
325          cairo_arc (cr, x+OSD_S_RAD, y+OSD_S_RAD, OSD_S_RAD, M_PI/2, -M_PI/2);          cairo_arc (cr, x+OSD_S_RAD, y+OSD_S_RAD, OSD_S_RAD, M_PI/2, -M_PI/2);
# Line 337  osd_source_content(osm_gps_map_osd_t *os Line 347  osd_source_content(osm_gps_map_osd_t *os
347    
348      int py = offset + OSD_S_RAD - OSD_S_D0;      int py = offset + OSD_S_RAD - OSD_S_D0;
349    
350      if(!priv->expanded) {      if(!priv->source_sel.expanded) {
351          /* draw the "puller" open (<) arrow */          /* draw the "puller" open (<) arrow */
352          cairo_move_to (cr, offset + OSD_S_RAD + OSD_S_D0/2, py);          cairo_move_to (cr, offset + OSD_S_RAD + OSD_S_D0/2, py);
353          cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0);          cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0);
# Line 362  osd_source_content(osm_gps_map_osd_t *os Line 372  osd_source_content(osm_gps_map_osd_t *os
372                                      CAIRO_FONT_WEIGHT_BOLD);                                      CAIRO_FONT_WEIGHT_BOLD);
373              cairo_set_font_size (cr, OSD_FONT_SIZE);              cairo_set_font_size (cr, OSD_FONT_SIZE);
374    
375              int i, step = (priv->height - 2*OSD_TEXT_BORDER) /              int i, step = (priv->source_sel.height - 2*OSD_TEXT_BORDER) /
376                  OSM_GPS_MAP_SOURCE_LAST;                  OSM_GPS_MAP_SOURCE_LAST;
377              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++) {
378                  cairo_text_extents_t extents;                  cairo_text_extents_t extents;
# Line 376  osd_source_content(osm_gps_map_osd_t *os Line 386  osd_source_content(osm_gps_map_osd_t *os
386                  if(source == i) {                  if(source == i) {
387                      cairo_rectangle(cr, x - OSD_TEXT_BORDER/2,                      cairo_rectangle(cr, x - OSD_TEXT_BORDER/2,
388                                      y - OSD_TEXT_SKIP,                                      y - OSD_TEXT_SKIP,
389                                      priv->width - OSD_TEXT_BORDER,                                      priv->source_sel.width - OSD_TEXT_BORDER,
390                                      step + OSD_TEXT_SKIP);                                      step + OSD_TEXT_SKIP);
391                      cairo_fill(cr);                      cairo_fill(cr);
392    
# Line 407  osd_source_content(osm_gps_map_osd_t *os Line 417  osd_source_content(osm_gps_map_osd_t *os
417  }  }
418    
419  static void  static void
420  osd_render_source_sel(osm_gps_map_osd_t *osd) {  osd_render_source_sel(osm_gps_map_osd_t *osd, gboolean force_rerender) {
421      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
422    
423        if(priv->source_sel.rendered && !force_rerender)
424            return;
425    
426        priv->source_sel.rendered = TRUE;
427    
428  #ifndef OSD_COLOR  #ifndef OSD_COLOR
429      GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL];      GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL];
430      GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL];      GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL];
# Line 417  osd_render_source_sel(osm_gps_map_osd_t Line 432  osd_render_source_sel(osm_gps_map_osd_t
432  #endif  #endif
433    
434      /* draw source selector */      /* draw source selector */
435      cairo_t *cr = cairo_create(priv->map_source);      cairo_t *cr = cairo_create(priv->source_sel.surface);
436      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
437      cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0);      cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0);
438      cairo_paint(cr);      cairo_paint(cr);
# Line 458  osd_source_reallocate(osm_gps_map_osd_t Line 473  osd_source_reallocate(osm_gps_map_osd_t
473      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
474    
475      /* re-allocate offscreen bitmap */      /* re-allocate offscreen bitmap */
476      g_assert (priv->map_source);      g_assert (priv->source_sel.surface);
477    
478      int w = OSD_S_W, h = OSD_S_H;      int w = OSD_S_W, h = OSD_S_H;
479      if(priv->expanded) {      if(priv->source_sel.expanded) {
480          cairo_text_extents_t extents;          cairo_text_extents_t extents;
481    
482          /* determine content size */          /* determine content size */
483          cairo_t *cr = cairo_create(priv->map_source);          cairo_t *cr = cairo_create(priv->source_sel.surface);
484          cairo_select_font_face (cr, "Sans",          cairo_select_font_face (cr, "Sans",
485                                  CAIRO_FONT_SLANT_NORMAL,                                  CAIRO_FONT_SLANT_NORMAL,
486                                  CAIRO_FONT_WEIGHT_BOLD);                                  CAIRO_FONT_WEIGHT_BOLD);
# Line 482  osd_source_reallocate(osm_gps_map_osd_t Line 497  osd_source_reallocate(osm_gps_map_osd_t
497          }          }
498          cairo_destroy(cr);          cairo_destroy(cr);
499    
500          priv->width  = max_w + 2*OSD_TEXT_BORDER;          priv->source_sel.width  = max_w + 2*OSD_TEXT_BORDER;
501          priv->height = OSM_GPS_MAP_SOURCE_LAST *          priv->source_sel.height = OSM_GPS_MAP_SOURCE_LAST *
502              (max_h + 2*OSD_TEXT_SKIP) + 2*OSD_TEXT_BORDER;              (max_h + 2*OSD_TEXT_SKIP) + 2*OSD_TEXT_BORDER;
503    
504          w = OSD_S_EXP_W;          w = OSD_S_EXP_W;
505          h = OSD_S_EXP_H;          h = OSD_S_EXP_H;
506      }      }
507    
508      cairo_surface_destroy(priv->map_source);      cairo_surface_destroy(priv->source_sel.surface);
509      priv->map_source =      priv->source_sel.surface =
510          cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2);          cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2);
511    
512      osd_render_source_sel(osd);      osd_render_source_sel(osd, TRUE);
513  }  }
514    
515  #define OSD_HZ      15  #define OSD_HZ      15
# Line 505  static gboolean osd_source_animate(gpoin Line 520  static gboolean osd_source_animate(gpoin
520      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
521      int diff = OSD_S_EXP_W - OSD_S_W - OSD_S_X;      int diff = OSD_S_EXP_W - OSD_S_W - OSD_S_X;
522      gboolean done = FALSE;      gboolean done = FALSE;
523      priv->count += priv->dir;      priv->source_sel.count += priv->source_sel.dir;
524    
525      /* shifting in */      /* shifting in */
526      if(priv->dir < 0) {      if(priv->source_sel.dir < 0) {
527          if(priv->count <= 0) {          if(priv->source_sel.count <= 0) {
528              priv->count = 0;              priv->source_sel.count = 0;
529              done = TRUE;              done = TRUE;
530          }          }
531      } else {      } else {
532          if(priv->count >= 1000) {          if(priv->source_sel.count >= 1000) {
533              priv->expanded = FALSE;              priv->source_sel.expanded = FALSE;
534              osd_source_reallocate(osd);              osd_source_reallocate(osd);
535    
536              priv->count = 1000;              priv->source_sel.count = 1000;
537              done = TRUE;              done = TRUE;
538          }          }
539      }      }
# Line 526  static gboolean osd_source_animate(gpoin Line 541  static gboolean osd_source_animate(gpoin
541    
542      /* 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 */
543    
544      /* nicer sinoid mapping */      /* nice sinoid mapping */
545      float m = 0.5-cos(priv->count * M_PI / 1000.0)/2;      float m = 0.5-cos(priv->source_sel.count * M_PI / 1000.0)/2;
546      priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) +      priv->source_sel.shift =
547            (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) +
548          m * diff;          m * diff;
549    
550        /* make sure the screen is updated */
551      osm_gps_map_repaint(OSM_GPS_MAP(osd->widget));      osm_gps_map_repaint(OSM_GPS_MAP(osd->widget));
552    
553        /* stop animation if done */
554      if(done)      if(done)
555          priv->handler_id = 0;          priv->source_sel.handler_id = 0;
556    
557      return !done;      return !done;
558  }  }
# Line 546  osd_source_toggle(osm_gps_map_osd_t *osd Line 564  osd_source_toggle(osm_gps_map_osd_t *osd
564      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
565    
566      /* ignore clicks while animation is running */      /* ignore clicks while animation is running */
567      if(priv->handler_id)      if(priv->source_sel.handler_id)
568          return;          return;
569    
570      /* expand immediately, collapse is handle at the end of the collapse animation */      /* expand immediately, collapse is handle at the end of the */
571      if(!priv->expanded) {      /* collapse animation */
572          priv->expanded = TRUE;      if(!priv->source_sel.expanded) {
573            priv->source_sel.expanded = TRUE;
574          osd_source_reallocate(osd);          osd_source_reallocate(osd);
575    
576          priv->count = 1000;          priv->source_sel.count = 1000;
577          priv->shift = osd->widget->allocation.width - OSD_S_W;          priv->source_sel.shift = osd->widget->allocation.width - OSD_S_W;
578          priv->dir = -1000/OSD_HZ;          priv->source_sel.dir = -1000/OSD_HZ;
579      } else {      } else {
580          priv->count =  0;          priv->source_sel.count =  0;
581          priv->shift = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X;          priv->source_sel.shift = osd->widget->allocation.width -
582          priv->dir = +1000/OSD_HZ;              OSD_S_EXP_W + OSD_S_X;
583            priv->source_sel.dir = +1000/OSD_HZ;
584      }      }
585    
586      priv->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd);      /* start timer to handle animation */
587        priv->source_sel.handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ,
588                                                      osd_source_animate, osd);
589  }  }
590    
591  /* check if the user clicked inside the source selection area */  /* check if the user clicked inside the source selection area */
# Line 571  static osd_button_t Line 593  static osd_button_t
593  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) {
594      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
595    
596      if(!priv->expanded)      if(!priv->source_sel.expanded)
597          x -= osd->widget->allocation.width - OSD_S_W;          x -= osd->widget->allocation.width - OSD_S_W;
598      else      else
599          x -= osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X;          x -= osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X;
# Line 595  osd_source_check(osm_gps_map_osd_t *osd, Line 617  osd_source_check(osm_gps_map_osd_t *osd,
617      }      }
618    
619      /* check for clicks into data area */      /* check for clicks into data area */
620      if(priv->expanded && !priv->handler_id) {      if(priv->source_sel.expanded && !priv->source_sel.handler_id) {
621          /* re-adjust from puller top to content top */          /* re-adjust from puller top to content top */
622          if(OSD_S_Y < 0)          if(OSD_S_Y < 0)
623              y += OSD_S_EXP_H - OSD_S_PH;              y += OSD_S_EXP_H - OSD_S_PH;
# Line 605  osd_source_check(osm_gps_map_osd_t *osd, Line 627  osd_source_check(osm_gps_map_osd_t *osd,
627             y > 0 &&             y > 0 &&
628             y < OSD_S_EXP_H) {             y < OSD_S_EXP_H) {
629    
630              int step = (priv->height - 2*OSD_TEXT_BORDER)              int step = (priv->source_sel.height - 2*OSD_TEXT_BORDER)
631                  / OSM_GPS_MAP_SOURCE_LAST;                  / OSM_GPS_MAP_SOURCE_LAST;
632    
633              y -= OSD_TEXT_BORDER - OSD_TEXT_SKIP;              y -= OSD_TEXT_BORDER - OSD_TEXT_SKIP;
# Line 620  osd_source_check(osm_gps_map_osd_t *osd, Line 642  osd_source_check(osm_gps_map_osd_t *osd,
642                 old != y) {                 old != y) {
643                  g_object_set(osd->widget, "map-source", y, NULL);                  g_object_set(osd->widget, "map-source", y, NULL);
644    
645                  osd_render_source_sel(osd);                  osd_render_source_sel(osd, TRUE);
646                  osm_gps_map_repaint(OSM_GPS_MAP(osd->widget));                  osm_gps_map_repaint(OSM_GPS_MAP(osd->widget));
647              }              }
648    
# Line 815  osd_render_coordinates(osm_gps_map_osd_t Line 837  osd_render_coordinates(osm_gps_map_osd_t
837      g_object_get(osd->widget, "latitude", &lat, "longitude", &lon, NULL);      g_object_get(osd->widget, "latitude", &lat, "longitude", &lon, NULL);
838    
839      /* check if position has changed enough to require redraw */      /* check if position has changed enough to require redraw */
840      if(!isnan(priv->coo_lat) && !isnan(priv->coo_lon))      if(!isnan(priv->coordinates.lat) && !isnan(priv->coordinates.lon))
841          if((fabsf(lat - priv->coo_lat) < 1/60000) &&     /* 1/60000 == 1/1000 minute */          /* 1/60000 == 1/1000 minute */
842             (fabsf(lon - priv->coo_lon) < 1/60000))          if((fabsf(lat - priv->coordinates.lat) < 1/60000) &&
843               (fabsf(lon - priv->coordinates.lon) < 1/60000))
844              return;              return;
845    
846      priv->coo_lat = lat;      priv->coordinates.lat = lat;
847      priv->coo_lon = lon;      priv->coordinates.lon = lon;
848    
849      /* first fill with light transparency */      /* first fill with transparency */
850      cairo_t *cr = cairo_create(priv->coordinates);      cairo_t *cr = cairo_create(priv->coordinates.surface);
851      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
852      cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5);      //    cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5);
853        cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
854      cairo_paint(cr);      cairo_paint(cr);
855      cairo_set_operator(cr, CAIRO_OPERATOR_OVER);      cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
856    
# Line 911  osd_render_crosshair(osm_gps_map_osd_t * Line 935  osd_render_crosshair(osm_gps_map_osd_t *
935  {  {
936      osd_priv_t *priv = (osd_priv_t*)osd->priv;      osd_priv_t *priv = (osd_priv_t*)osd->priv;
937    
938        if(priv->crosshair.rendered)
939            return;
940    
941        priv->crosshair.rendered = TRUE;
942    
943      /* first fill with transparency */      /* first fill with transparency */
944      cairo_t *cr = cairo_create(priv->crosshair);      cairo_t *cr = cairo_create(priv->crosshair.surface);
945      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
946      cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);      cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
     //    cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2);  
947      cairo_paint(cr);      cairo_paint(cr);
948      cairo_set_operator(cr, CAIRO_OPERATOR_OVER);      cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
949    
# Line 956  osd_render_scale(osm_gps_map_osd_t *osd) Line 984  osd_render_scale(osm_gps_map_osd_t *osd)
984      /* this only needs to be rendered if the zoom has changed */      /* this only needs to be rendered if the zoom has changed */
985      gint zoom;      gint zoom;
986      g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL);      g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL);
987      if(zoom == priv->scale_zoom)      if(zoom == priv->scale.zoom)
988          return;          return;
989    
990      priv->scale_zoom = zoom;      priv->scale.zoom = zoom;
991    
992      float m_per_pix = osm_gps_map_get_scale(OSM_GPS_MAP(osd->widget));      float m_per_pix = osm_gps_map_get_scale(OSM_GPS_MAP(osd->widget));
993    
994      /* first fill with transparency */      /* first fill with transparency */
995      cairo_t *cr = cairo_create(priv->scale);      cairo_t *cr = cairo_create(priv->scale.surface);
996      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);      cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
997      cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0);      cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0);
998      // pink for testing:    cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2);      // pink for testing:    cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2);
# Line 1092  osd_render_controls(osm_gps_map_osd_t *o Line 1120  osd_render_controls(osm_gps_map_osd_t *o
1120  #ifdef OSD_GPS_BUTTON  #ifdef OSD_GPS_BUTTON
1121      priv->controls.gps_enabled = (osd->cb != NULL);      priv->controls.gps_enabled = (osd->cb != NULL);
1122  #endif  #endif
1123        priv->controls.rendered = TRUE;
1124    
1125  #ifndef OSD_COLOR  #ifndef OSD_COLOR
1126      GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL];      GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL];
# Line 1176  osd_render_controls(osm_gps_map_osd_t *o Line 1205  osd_render_controls(osm_gps_map_osd_t *o
1205  static void  static void
1206  osd_render(osm_gps_map_osd_t *osd)  osd_render(osm_gps_map_osd_t *osd)
1207  {  {
1208        /* this function is actually called pretty often since the */
1209        /* OSD contents may have changed (due to a coordinate/zoom change). */
1210        /* The different OSD parts have to make sure that they don't */
1211        /* render unneccessarily often and thus waste CPU power */
1212    
1213      osd_render_controls(osd);      osd_render_controls(osd);
1214    
1215  #ifdef OSD_SOURCE_SEL  #ifdef OSD_SOURCE_SEL
1216      osd_render_source_sel(osd);      osd_render_source_sel(osd, FALSE);
1217  #endif  #endif
1218    
1219  #ifdef OSD_SCALE  #ifdef OSD_SCALE
# Line 1214  osd_draw(osm_gps_map_osd_t *osd, GdkDraw Line 1248  osd_draw(osm_gps_map_osd_t *osd, GdkDraw
1248    
1249  #ifdef OSD_SOURCE_SEL  #ifdef OSD_SOURCE_SEL
1250          /* the initial OSD state is alway not-expanded */          /* the initial OSD state is alway not-expanded */
1251          priv->map_source =          priv->source_sel.surface =
1252              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
1253                                             OSD_S_W+2, OSD_S_H+2);                                             OSD_S_W+2, OSD_S_H+2);
1254            priv->source_sel.rendered = FALSE;
1255  #endif  #endif
1256    
1257  #ifdef OSD_SCALE  #ifdef OSD_SCALE
1258          priv->scale =          priv->scale.surface =
1259              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
1260                                         OSD_SCALE_W, OSD_SCALE_H);                                         OSD_SCALE_W, OSD_SCALE_H);
1261          priv->scale_zoom = -1;          priv->scale.zoom = -1;
1262  #endif  #endif
1263    
1264  #ifdef OSD_CROSSHAIR  #ifdef OSD_CROSSHAIR
1265          priv->crosshair =          priv->crosshair.surface =
1266              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
1267                                         OSD_CROSSHAIR_W, OSD_CROSSHAIR_H);                                         OSD_CROSSHAIR_W, OSD_CROSSHAIR_H);
1268            priv->crosshair.rendered = FALSE;
1269  #endif  #endif
1270    
1271  #ifdef OSD_COORDINATES  #ifdef OSD_COORDINATES
1272          priv->coordinates =          priv->coordinates.surface =
1273              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,              cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
1274                                         OSD_COORDINATES_W, OSD_COORDINATES_H);                                         OSD_COORDINATES_W, OSD_COORDINATES_H);
1275    
1276          priv->coo_lat = priv->coo_lon = OSM_GPS_MAP_INVALID;          priv->coordinates.lat = priv->coordinates.lon = OSM_GPS_MAP_INVALID;
1277  #endif  #endif
1278    
1279          /* ... and render it */          /* ... and render it */
# Line 1255  osd_draw(osm_gps_map_osd_t *osd, GdkDraw Line 1291  osd_draw(osm_gps_map_osd_t *osd, GdkDraw
1291      if(x < 0) x += osd->widget->allocation.width - OSD_SCALE_W;      if(x < 0) x += osd->widget->allocation.width - OSD_SCALE_W;
1292      if(y < 0) y += osd->widget->allocation.height - OSD_SCALE_H;      if(y < 0) y += osd->widget->allocation.height - OSD_SCALE_H;
1293    
1294      cairo_set_source_surface(cr, priv->scale, x, y);      cairo_set_source_surface(cr, priv->scale.surface, x, y);
1295      cairo_paint(cr);      cairo_paint(cr);
1296  #endif  #endif
1297    
# Line 1263  osd_draw(osm_gps_map_osd_t *osd, GdkDraw Line 1299  osd_draw(osm_gps_map_osd_t *osd, GdkDraw
1299      x = (osd->widget->allocation.width - OSD_CROSSHAIR_W)/2;      x = (osd->widget->allocation.width - OSD_CROSSHAIR_W)/2;
1300      y = (osd->widget->allocation.height - OSD_CROSSHAIR_H)/2;      y = (osd->widget->allocation.height - OSD_CROSSHAIR_H)/2;
1301    
1302      cairo_set_source_surface(cr, priv->crosshair, x, y);      cairo_set_source_surface(cr, priv->crosshair.surface, x, y);
1303      cairo_paint(cr);      cairo_paint(cr);
1304  #endif  #endif
1305    
# Line 1273  osd_draw(osm_gps_map_osd_t *osd, GdkDraw Line 1309  osd_draw(osm_gps_map_osd_t *osd, GdkDraw
1309      if(x < 0) x += osd->widget->allocation.width - OSD_COORDINATES_W;      if(x < 0) x += osd->widget->allocation.width - OSD_COORDINATES_W;
1310      if(y < 0) y += osd->widget->allocation.height - OSD_COORDINATES_H;      if(y < 0) y += osd->widget->allocation.height - OSD_COORDINATES_H;
1311    
1312      cairo_set_source_surface(cr, priv->coordinates, x, y);      cairo_set_source_surface(cr, priv->coordinates.surface, x, y);
1313      cairo_paint(cr);      cairo_paint(cr);
1314  #endif  #endif
1315    
# Line 1289  osd_draw(osm_gps_map_osd_t *osd, GdkDraw Line 1325  osd_draw(osm_gps_map_osd_t *osd, GdkDraw
1325      cairo_paint(cr);      cairo_paint(cr);
1326    
1327  #ifdef OSD_SOURCE_SEL  #ifdef OSD_SOURCE_SEL
1328      if(!priv->handler_id) {      if(!priv->source_sel.handler_id) {
1329          /* the OSD source selection is not being animated */          /* the OSD source selection is not being animated */
1330          if(!priv->expanded)          if(!priv->source_sel.expanded)
1331              x = osd->widget->allocation.width - OSD_S_W;              x = osd->widget->allocation.width - OSD_S_W;
1332          else          else
1333              x = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X;              x = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X;
1334      } else      } else
1335          x = priv->shift;          x = priv->source_sel.shift;
1336    
1337      y = OSD_S_Y;      y = OSD_S_Y;
1338      if(OSD_S_Y < 0) {      if(OSD_S_Y < 0) {
1339          if(!priv->expanded)          if(!priv->source_sel.expanded)
1340              y = osd->widget->allocation.height - OSD_S_H + OSD_S_Y;              y = osd->widget->allocation.height - OSD_S_H + OSD_S_Y;
1341          else          else
1342              y = osd->widget->allocation.height - OSD_S_EXP_H + OSD_S_Y;              y = osd->widget->allocation.height - OSD_S_EXP_H + OSD_S_Y;
1343      }      }
1344    
1345      cairo_set_source_surface(cr, priv->map_source, x, y);      cairo_set_source_surface(cr, priv->source_sel.surface, x, y);
1346      cairo_paint(cr);      cairo_paint(cr);
1347  #endif  #endif
1348    
# Line 1322  osd_free(osm_gps_map_osd_t *osd) Line 1358  osd_free(osm_gps_map_osd_t *osd)
1358           cairo_surface_destroy(priv->controls.surface);           cairo_surface_destroy(priv->controls.surface);
1359    
1360  #ifdef OSD_SOURCE_SEL  #ifdef OSD_SOURCE_SEL
1361      if(priv->handler_id)      if(priv->source_sel.handler_id)
1362          gtk_timeout_remove(priv->handler_id);          gtk_timeout_remove(priv->source_sel.handler_id);
1363    
1364      if (priv->map_source)      if (priv->source_sel.surface)
1365           cairo_surface_destroy(priv->map_source);           cairo_surface_destroy(priv->source_sel.surface);
1366  #endif  #endif
1367    
1368  #ifdef OSD_SCALE  #ifdef OSD_SCALE
1369      if (priv->scale)      if (priv->scale.surface)
1370           cairo_surface_destroy(priv->scale);           cairo_surface_destroy(priv->scale.surface);
1371  #endif  #endif
1372    
1373  #ifdef OSD_CROSSHAIR  #ifdef OSD_CROSSHAIR
1374      if (priv->crosshair)      if (priv->crosshair.surface)
1375           cairo_surface_destroy(priv->crosshair);           cairo_surface_destroy(priv->crosshair.surface);
1376  #endif  #endif
1377    
1378  #ifdef OSD_COORDINATES  #ifdef OSD_COORDINATES
1379      if (priv->coordinates)      if (priv->coordinates.surface)
1380           cairo_surface_destroy(priv->coordinates);           cairo_surface_destroy(priv->coordinates.surface);
1381  #endif  #endif
1382    
1383      g_free(priv);      g_free(priv);
# Line 1352  osd_busy(osm_gps_map_osd_t *osd) Line 1388  osd_busy(osm_gps_map_osd_t *osd)
1388  {  {
1389  #ifdef OSD_SOURCE_SEL  #ifdef OSD_SOURCE_SEL
1390      osd_priv_t *priv = (osd_priv_t *)(osd->priv);      osd_priv_t *priv = (osd_priv_t *)(osd->priv);
1391      return (priv->handler_id != 0);      return (priv->source_sel.handler_id != 0);
1392  #else  #else
1393      return FALSE;      return FALSE;
1394  #endif  #endif

Legend:
Removed from v.108  
changed lines
  Added in v.111