25 |
/* OSD_DIAMETER */ |
/* OSD_DIAMETER */ |
26 |
/* OSD_X, OSD_Y */ |
/* OSD_X, OSD_Y */ |
27 |
|
|
28 |
|
#define OSD_SCALE |
29 |
|
|
30 |
|
#define OSD_SCALE_W 100 |
31 |
|
#define OSD_SCALE_H 20 |
32 |
|
|
33 |
#ifndef USE_CAIRO |
#ifndef USE_CAIRO |
34 |
#error "OSD control display lacks a non-cairo implementation!" |
#error "OSD control display lacks a non-cairo implementation!" |
35 |
#endif |
#endif |
44 |
/* the offscreen representation of the OSD */ |
/* the offscreen representation of the OSD */ |
45 |
cairo_surface_t *overlay; |
cairo_surface_t *overlay; |
46 |
|
|
47 |
|
#ifdef OSD_SCALE |
48 |
|
cairo_surface_t *scale; |
49 |
|
#endif |
50 |
|
|
51 |
#ifdef OSD_SOURCE_SEL |
#ifdef OSD_SOURCE_SEL |
52 |
/* values to handle the "source" menu */ |
/* values to handle the "source" menu */ |
53 |
cairo_surface_t *map_source; |
cairo_surface_t *map_source; |
485 |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2); |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2); |
486 |
|
|
487 |
osd_render_source_sel(osd); |
osd_render_source_sel(osd); |
|
|
|
488 |
} |
} |
489 |
|
|
490 |
#define OSD_HZ 15 |
#define OSD_HZ 15 |
586 |
|
|
587 |
/* check for clicks into data area */ |
/* check for clicks into data area */ |
588 |
if(priv->expanded && !priv->handler_id) { |
if(priv->expanded && !priv->handler_id) { |
589 |
|
/* re-adjust from puller top to content top */ |
590 |
|
if(OSD_S_Y < 0) |
591 |
|
y += OSD_S_EXP_H - OSD_S_PH; |
592 |
|
|
593 |
if(x > OSD_S_PW && |
if(x > OSD_S_PW && |
594 |
x < OSD_S_PW + OSD_S_EXP_W && |
x < OSD_S_PW + OSD_S_EXP_W && |
595 |
y > 0 && |
y > 0 && |
596 |
y < OSD_S_EXP_H) { |
y < OSD_S_EXP_H) { |
597 |
|
|
598 |
int step = (priv->height - 2*OSD_TEXT_BORDER) |
int step = (priv->height - 2*OSD_TEXT_BORDER) |
599 |
/ OSM_GPS_MAP_SOURCE_LAST; |
/ OSM_GPS_MAP_SOURCE_LAST; |
600 |
|
|
728 |
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
729 |
} |
} |
730 |
|
|
731 |
|
static float pixel2m(OsmGpsMap *map, int pixel) { |
732 |
|
return pixel*osm_gps_map_get_scale(OSM_GPS_MAP(map)); |
733 |
|
} |
734 |
|
|
735 |
static void |
static void |
736 |
osd_render(osm_gps_map_osd_t *osd) { |
osd_render_scale(osm_gps_map_osd_t *osd) |
737 |
|
{ |
738 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
739 |
|
|
740 |
|
/* first fill with transparency */ |
741 |
|
cairo_t *cr = cairo_create(priv->scale); |
742 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
743 |
|
// cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
744 |
|
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2); |
745 |
|
cairo_paint(cr); |
746 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
747 |
|
|
748 |
|
/* determine the size of the scale width in meters */ |
749 |
|
float width = pixel2m(OSM_GPS_MAP(osd->widget), OSD_SCALE_W); |
750 |
|
printf("width = %f meters\n", width); |
751 |
|
|
752 |
|
/* scale this to useful values */ |
753 |
|
int exp = logf(width)*M_LOG10E; |
754 |
|
int mant = width/pow(10,exp); |
755 |
|
printf("mant = %d, exp = %d \n", mant, exp); |
756 |
|
|
757 |
|
cairo_destroy(cr); |
758 |
|
} |
759 |
|
|
760 |
|
static void |
761 |
|
osd_render(osm_gps_map_osd_t *osd) |
762 |
|
{ |
763 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
764 |
|
|
765 |
#ifndef OSD_COLOR |
#ifndef OSD_COLOR |
844 |
#ifdef OSD_SOURCE_SEL |
#ifdef OSD_SOURCE_SEL |
845 |
osd_render_source_sel(osd); |
osd_render_source_sel(osd); |
846 |
#endif |
#endif |
847 |
|
|
848 |
|
#ifdef OSD_SCALE |
849 |
|
osd_render_scale(osd); |
850 |
|
#endif |
851 |
} |
} |
852 |
|
|
853 |
static void |
static void |
869 |
OSD_S_W+2, OSD_S_H+2); |
OSD_S_W+2, OSD_S_H+2); |
870 |
#endif |
#endif |
871 |
|
|
872 |
|
#ifdef OSD_SCALE |
873 |
|
priv->scale = |
874 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
875 |
|
OSD_SCALE_W, OSD_SCALE_H); |
876 |
|
#endif |
877 |
|
|
878 |
/* ... and render it */ |
/* ... and render it */ |
879 |
osd_render(osd); |
osd_render(osd); |
880 |
} |
} |
914 |
cairo_paint(cr); |
cairo_paint(cr); |
915 |
#endif |
#endif |
916 |
|
|
917 |
|
#ifdef OSD_SCALE |
918 |
|
x = OSD_X; |
919 |
|
y = -OSD_Y; |
920 |
|
if(x < 0) x += osd->widget->allocation.width - OSD_SCALE_W; |
921 |
|
if(y < 0) y += osd->widget->allocation.height - OSD_SCALE_H; |
922 |
|
|
923 |
|
cairo_set_source_surface(cr, priv->scale, x, y); |
924 |
|
cairo_paint(cr); |
925 |
|
#endif |
926 |
|
|
927 |
cairo_destroy(cr); |
cairo_destroy(cr); |
928 |
} |
} |
929 |
|
|
943 |
cairo_surface_destroy(priv->map_source); |
cairo_surface_destroy(priv->map_source); |
944 |
#endif |
#endif |
945 |
|
|
946 |
|
#ifdef OSD_SCALE |
947 |
|
if (priv->scale) |
948 |
|
cairo_surface_destroy(priv->scale); |
949 |
|
#endif |
950 |
|
|
951 |
g_free(priv); |
g_free(priv); |
952 |
} |
} |
953 |
|
|