74 |
gint shift, dir, count; |
gint shift, dir, count; |
75 |
gint handler_id; |
gint handler_id; |
76 |
gint width, height; |
gint width, height; |
77 |
|
gboolean rendered; |
78 |
} source_sel; |
} source_sel; |
79 |
#endif |
#endif |
80 |
|
|
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]; |
509 |
priv->source_sel.surface = |
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 |
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->source_sel.count * M_PI / 1000.0)/2; |
float m = 0.5-cos(priv->source_sel.count * M_PI / 1000.0)/2; |
546 |
priv->source_sel.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->source_sel.handler_id = 0; |
priv->source_sel.handler_id = 0; |
556 |
|
|
567 |
if(priv->source_sel.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 |
|
/* collapse animation */ |
572 |
if(!priv->source_sel.expanded) { |
if(!priv->source_sel.expanded) { |
573 |
priv->source_sel.expanded = TRUE; |
priv->source_sel.expanded = TRUE; |
574 |
osd_source_reallocate(osd); |
osd_source_reallocate(osd); |
578 |
priv->source_sel.dir = -1000/OSD_HZ; |
priv->source_sel.dir = -1000/OSD_HZ; |
579 |
} else { |
} else { |
580 |
priv->source_sel.count = 0; |
priv->source_sel.count = 0; |
581 |
priv->source_sel.shift = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; |
priv->source_sel.shift = osd->widget->allocation.width - |
582 |
|
OSD_S_EXP_W + OSD_S_X; |
583 |
priv->source_sel.dir = +1000/OSD_HZ; |
priv->source_sel.dir = +1000/OSD_HZ; |
584 |
} |
} |
585 |
|
|
586 |
priv->source_sel.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 */ |
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 |
|
|
846 |
priv->coordinates.lat = lat; |
priv->coordinates.lat = lat; |
847 |
priv->coordinates.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.surface); |
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 |
|
|
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 |
1251 |
priv->source_sel.surface = |
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 |