266 |
cairo_stroke (cr); |
cairo_stroke (cr); |
267 |
|
|
268 |
if (priv->balloon.cb) { |
if (priv->balloon.cb) { |
269 |
|
osm_gps_map_balloon_event_t event; |
270 |
|
|
271 |
/* clip in case application tries to draw in */ |
/* clip in case application tries to draw in */ |
272 |
/* exceed of the balloon */ |
/* exceed of the balloon */ |
273 |
cairo_rectangle (cr, priv->balloon.rect.x, priv->balloon.rect.y, |
cairo_rectangle (cr, priv->balloon.rect.x, priv->balloon.rect.y, |
274 |
priv->balloon.rect.w, priv->balloon.rect.h); |
priv->balloon.rect.w, priv->balloon.rect.h); |
275 |
cairo_clip (cr); |
cairo_clip (cr); |
276 |
cairo_new_path (cr); /* current path is not |
cairo_new_path (cr); /* current path is not consumed by cairo_clip */ |
277 |
consumed by cairo_clip() */ |
|
278 |
|
/* request the application to draw the balloon contents */ |
279 |
|
event.type = OSM_GPS_MAP_BALLOON_EVENT_TYPE_DRAW; |
280 |
|
event.data.draw.rect = &priv->balloon.rect; |
281 |
|
event.data.draw.cr = cr; |
282 |
|
|
283 |
priv->balloon.cb(cr, &priv->balloon.rect, priv->balloon.data); |
priv->balloon.cb(&event, priv->balloon.data); |
284 |
} |
} |
285 |
|
|
286 |
cairo_destroy(cr); |
cairo_destroy(cr); |
289 |
/* return true if balloon is being displayed and if */ |
/* return true if balloon is being displayed and if */ |
290 |
/* the given coordinate is within this balloon */ |
/* the given coordinate is within this balloon */ |
291 |
static gboolean |
static gboolean |
292 |
osd_balloon_check(osm_gps_map_osd_t *osd, gboolean down, gint x, gint y) |
osd_balloon_check(osm_gps_map_osd_t *osd, gboolean click, gboolean down, gint x, gint y) |
293 |
{ |
{ |
294 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
295 |
|
|
308 |
(x > xs) && (x < xs + priv->balloon.rect.w) && |
(x > xs) && (x < xs + priv->balloon.rect.w) && |
309 |
(y > ys) && (y < ys + priv->balloon.rect.h); |
(y > ys) && (y < ys + priv->balloon.rect.h); |
310 |
|
|
311 |
/* handle the fact that the balloon may have been created by the */ |
/* is this a real click or is the application just checking for something? */ |
312 |
/* button down event */ |
if(click) { |
313 |
if(!is_in && !down && !priv->balloon.just_created) { |
|
314 |
/* the user actually clicked outside the balloon */ |
/* handle the fact that the balloon may have been created by the */ |
315 |
|
/* button down event */ |
316 |
|
if(!is_in && !down && !priv->balloon.just_created) { |
317 |
|
/* the user actually clicked outside the balloon */ |
318 |
|
|
319 |
|
/* close the balloon! */ |
320 |
|
osm_gps_map_osd_clear_balloon (OSM_GPS_MAP(osd->widget)); |
321 |
|
|
322 |
/* close the balloon! */ |
/* and inform application about this */ |
323 |
osm_gps_map_osd_clear_balloon (OSM_GPS_MAP(osd->widget)); |
if(priv->balloon.cb) { |
324 |
|
osm_gps_map_balloon_event_t event; |
325 |
|
event.type = OSM_GPS_MAP_BALLOON_EVENT_TYPE_REMOVED; |
326 |
|
priv->balloon.cb(&event, priv->balloon.data); |
327 |
|
} |
328 |
|
|
329 |
|
} |
330 |
|
|
331 |
|
if(is_in && priv->balloon.cb) { |
332 |
|
osm_gps_map_balloon_event_t event; |
333 |
|
|
334 |
|
/* notify application of click */ |
335 |
|
event.type = OSM_GPS_MAP_BALLOON_EVENT_TYPE_CLICK; |
336 |
|
event.data.click.x = x - xs; |
337 |
|
event.data.click.y = y - ys; |
338 |
|
event.data.click.down = down; |
339 |
|
|
340 |
|
priv->balloon.cb(&event, priv->balloon.data); |
341 |
|
} |
342 |
} |
} |
343 |
|
|
344 |
return is_in; |
return is_in; |
975 |
#endif // OSD_SOURCE_SEL |
#endif // OSD_SOURCE_SEL |
976 |
|
|
977 |
static osd_button_t |
static osd_button_t |
978 |
osd_check(osm_gps_map_osd_t *osd, gboolean down, gint x, gint y) { |
osd_check_int(osm_gps_map_osd_t *osd, gboolean click, gboolean down, gint x, gint y) { |
979 |
osd_button_t but = OSD_NONE; |
osd_button_t but = OSD_NONE; |
980 |
|
|
981 |
#ifdef OSD_BALLOON |
#ifdef OSD_BALLOON |
1016 |
#ifdef OSD_BALLOON |
#ifdef OSD_BALLOON |
1017 |
if(but == OSD_NONE) { |
if(but == OSD_NONE) { |
1018 |
/* check if user clicked into balloon */ |
/* check if user clicked into balloon */ |
1019 |
if(osd_balloon_check(osd, down, x, y)) |
if(osd_balloon_check(osd, click, down, x, y)) |
1020 |
but = OSD_BG; |
but = OSD_BG; |
1021 |
} |
} |
1022 |
#endif |
#endif |
1959 |
#endif |
#endif |
1960 |
} |
} |
1961 |
|
|
1962 |
|
static osd_button_t |
1963 |
|
osd_check(osm_gps_map_osd_t *osd, gboolean down, gint x, gint y) { |
1964 |
|
return osd_check_int(osd, TRUE, down, x, y); |
1965 |
|
} |
1966 |
|
|
1967 |
static osm_gps_map_osd_t osd_classic = { |
static osm_gps_map_osd_t osd_classic = { |
1968 |
.widget = NULL, |
.widget = NULL, |
1969 |
|
|
2019 |
osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); |
osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); |
2020 |
g_return_val_if_fail (osd, OSD_NONE); |
g_return_val_if_fail (osd, OSD_NONE); |
2021 |
|
|
2022 |
return osd_check(osd, TRUE, x, y); |
return osd_check_int(osd, FALSE, TRUE, x, y); |
2023 |
} |
} |