From 76b6a25a0f8df4590f6e66f9aae1ad22811349ce Mon Sep 17 00:00:00 2001 From: mvglasow Date: Mon, 1 Feb 2016 21:40:54 +0100 Subject: Fix:osd:Draw correct icon for navigation_status OSD when resizing window Signed-off-by: mvglasow --- navit/osd/core/osd_core.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c index 922947ab3..f2a898c22 100644 --- a/navit/osd/core/osd_core.c +++ b/navit/osd/core/osd_core.c @@ -1723,12 +1723,16 @@ struct navigation_status { /** - * @brief Draws a {@code navigation_status} OSD. + * @brief Draws a `navigation_status` OSD. + * + * This method performs the actual operation of selecting and drawing the image. It can be called + * directly as a callback method for the `navigation.nav_status` attribute, or indirectly through the + * draw method. * * @param opc The OSD to draw * @param status The status of the navigation engine (the value of the {@code nav_status} attribute) */ -static void osd_navigation_status_draw(struct osd_priv_common *opc, int status) { +static void osd_navigation_status_draw_do(struct osd_priv_common *opc, int status) { struct navigation_status *this = (struct navigation_status *)opc->data; struct point p; int do_draw = opc->osd_item.do_draw; @@ -1787,6 +1791,29 @@ static void osd_navigation_status_draw(struct osd_priv_common *opc, int status) } +/** + * @brief Draws a `navigation_status` OSD. + * + * This is the draw method for the OSD. It exposes the standard signature for the `draw` method and acts + * as a wrapper around `osd_navigation_status_draw_do()`. + * + * @param osd The OSD to draw. + * @param navit The navit instance + * @param v The vehicle (not used but part of the prototype) + */ +static void osd_navigation_status_draw(struct osd_priv *osd, struct navit *navit, struct vehicle *v) { + struct navigation *nav = NULL; + struct attr attr; + + if (navit) + nav = navit_get_navigation(navit); + if (nav) { + if (navigation_get_attr(nav, attr_nav_status, &attr, NULL)) + osd_navigation_status_draw_do((struct osd_priv_common *) osd, attr.u.num); + } +} + + /** * @brief Initializes a new {@code navigation_status} OSD. * @@ -1806,9 +1833,9 @@ static void osd_navigation_status_init(struct osd_priv_common *opc, struct navit if (navit) nav = navit_get_navigation(navit); if (nav) { - navigation_register_callback(nav, attr_nav_status, callback_new_attr_1(callback_cast(osd_navigation_status_draw), attr_nav_status, opc)); + navigation_register_callback(nav, attr_nav_status, callback_new_attr_1(callback_cast(osd_navigation_status_draw_do), attr_nav_status, opc)); if (navigation_get_attr(nav, attr_nav_status, &attr, NULL)) - osd_navigation_status_draw(opc, attr.u.num); + osd_navigation_status_draw_do(opc, attr.u.num); } else dbg(lvl_error, "navigation instance is NULL, OSD will never update\n"); -- cgit v1.2.1