-
From 3df3e1ef417de753f03f4742165c25b3bbc11557 Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Fri, 3 Oct 2014 16:20:37 +0200
Subject: [PATCH 1/8] osd/core: Make button resize correctly with use_overlay
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd/core/osd_core.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index de53e7f..df6c770 100644
a
|
b
|
static void |
1434 | 1434 | osd_button_draw(struct osd_priv_common *opc, struct navit *nav) |
1435 | 1435 | { |
1436 | 1436 | struct osd_button *this = (struct osd_button *)opc->data; |
1437 | | |
1438 | | struct point bp = opc->osd_item.p; |
1439 | | if (!opc->osd_item.configured) |
| 1437 | struct graphics *gra; |
| 1438 | gra = navit_get_graphics(nav); |
| 1439 | this->img = graphics_image_new(gra, this->src); |
| 1440 | if (!this->img) { |
| 1441 | dbg(1, "failed to load '%s'\n", this->src); |
1440 | 1442 | return; |
1441 | | osd_wrap_point(&bp, nav); |
1442 | | if(this->img) |
1443 | | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &bp, this->img); |
| 1443 | } |
| 1444 | if (!opc->osd_item.w) |
| 1445 | opc->osd_item.w=this->img->width; |
| 1446 | if (!opc->osd_item.h) |
| 1447 | opc->osd_item.h=this->img->height; |
| 1448 | |
| 1449 | if(navit_get_blocked(nav)&1) |
| 1450 | return; |
| 1451 | |
| 1452 | if (this->use_overlay) { |
| 1453 | struct graphics_image *img; |
| 1454 | struct point p; |
| 1455 | img=graphics_image_new(opc->osd_item.gr, this->src); |
| 1456 | p.x=(opc->osd_item.w-this->img->width)/2; |
| 1457 | p.y=(opc->osd_item.h-this->img->height)/2; |
| 1458 | osd_std_draw(&opc->osd_item); |
| 1459 | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img); |
| 1460 | graphics_image_free(opc->osd_item.gr, img); |
| 1461 | } else { |
| 1462 | struct point bp = opc->osd_item.p; |
| 1463 | if (!opc->osd_item.configured) |
| 1464 | return; |
| 1465 | osd_wrap_point(&bp, nav); |
| 1466 | |
| 1467 | if(this->img) |
| 1468 | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &bp, this->img); |
| 1469 | } |
1444 | 1470 | } |
1445 | 1471 | |
1446 | 1472 | static void |
-
--
1.7.9.5
From ab41d5cbddda6fd38f932862282032e862dd802b Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Fri, 3 Oct 2014 17:26:37 +0200
Subject: [PATCH 2/8] osd/core: Correct relative placement for buttons with
use_overlay=0
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd.c | 2 +-
navit/navit/osd.h | 1 +
navit/navit/osd/core/osd_core.c | 14 ++++++++++----
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/navit/navit/osd.c b/navit/navit/osd.c
index 00e2411..d125ced 100644
a
|
b
|
osd_std_resize(struct osd_item *item) |
169 | 169 | * @param h Available screen height in pixels (the height that corresponds to |
170 | 170 | * 100%) |
171 | 171 | */ |
172 | | static void |
| 172 | void |
173 | 173 | osd_std_calculate_sizes(struct osd_item *item, int w, int h) |
174 | 174 | { |
175 | 175 | if (item->rel_w) { |
-
diff --git a/navit/navit/osd.h b/navit/navit/osd.h
index f30b62b..2c636c1 100644
a
|
b
|
void osd_set_keypress(struct navit *nav, struct osd_item *item); |
71 | 71 | void osd_set_std_config(struct navit *nav, struct osd_item *item); |
72 | 72 | void osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *priv); |
73 | 73 | void osd_std_resize(struct osd_item *item); |
| 74 | void osd_std_calculate_sizes(struct osd_item *item, int w, int h); |
74 | 75 | void osd_std_draw(struct osd_item *item); |
75 | 76 | int osd_set_attr(struct osd *osd, struct attr* attr); |
76 | 77 | int osd_get_attr(struct osd *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter); |
-
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index df6c770..75f8e1e 100644
a
|
b
|
osd_button_draw(struct osd_priv_common *opc, struct navit *nav) |
1449 | 1449 | if(navit_get_blocked(nav)&1) |
1450 | 1450 | return; |
1451 | 1451 | |
| 1452 | struct point p; |
| 1453 | |
1452 | 1454 | if (this->use_overlay) { |
1453 | 1455 | struct graphics_image *img; |
1454 | | struct point p; |
1455 | 1456 | img=graphics_image_new(opc->osd_item.gr, this->src); |
1456 | 1457 | p.x=(opc->osd_item.w-this->img->width)/2; |
1457 | 1458 | p.y=(opc->osd_item.h-this->img->height)/2; |
… |
… |
osd_button_draw(struct osd_priv_common *opc, struct navit *nav) |
1459 | 1460 | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img); |
1460 | 1461 | graphics_image_free(opc->osd_item.gr, img); |
1461 | 1462 | } else { |
1462 | | struct point bp = opc->osd_item.p; |
| 1463 | osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav)); |
| 1464 | |
| 1465 | p = opc->osd_item.p; |
| 1466 | p.x+=(opc->osd_item.w-this->img->width)/2; |
| 1467 | p.y+=(opc->osd_item.h-this->img->height)/2; |
| 1468 | |
1463 | 1469 | if (!opc->osd_item.configured) |
1464 | 1470 | return; |
1465 | | osd_wrap_point(&bp, nav); |
| 1471 | osd_wrap_point(&p, nav); |
1466 | 1472 | |
1467 | 1473 | if(this->img) |
1468 | | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &bp, this->img); |
| 1474 | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img); |
1469 | 1475 | } |
1470 | 1476 | } |
1471 | 1477 | |
-
--
1.7.9.5
From 4e47293c367bb3cd175395292f9e617e010cdf06 Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Fri, 3 Oct 2014 21:49:44 +0200
Subject: [PATCH 3/8] osd/core: remove duplicated code for button
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd/core/osd_core.c | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index 75f8e1e..a2051d9 100644
a
|
b
|
static void |
1434 | 1434 | osd_button_draw(struct osd_priv_common *opc, struct navit *nav) |
1435 | 1435 | { |
1436 | 1436 | struct osd_button *this = (struct osd_button *)opc->data; |
1437 | | struct graphics *gra; |
1438 | | gra = navit_get_graphics(nav); |
1439 | | this->img = graphics_image_new(gra, this->src); |
1440 | | if (!this->img) { |
1441 | | dbg(1, "failed to load '%s'\n", this->src); |
1442 | | return; |
1443 | | } |
1444 | | if (!opc->osd_item.w) |
1445 | | opc->osd_item.w=this->img->width; |
1446 | | if (!opc->osd_item.h) |
1447 | | opc->osd_item.h=this->img->height; |
1448 | 1437 | |
| 1438 | // FIXME: Do we need this check? |
1449 | 1439 | if(navit_get_blocked(nav)&1) |
1450 | 1440 | return; |
1451 | 1441 | |
… |
… |
osd_button_draw(struct osd_priv_common *opc, struct navit *nav) |
1454 | 1444 | if (this->use_overlay) { |
1455 | 1445 | struct graphics_image *img; |
1456 | 1446 | img=graphics_image_new(opc->osd_item.gr, this->src); |
1457 | | p.x=(opc->osd_item.w-this->img->width)/2; |
1458 | | p.y=(opc->osd_item.h-this->img->height)/2; |
| 1447 | p.x=(opc->osd_item.w-img->width)/2; |
| 1448 | p.y=(opc->osd_item.h-img->height)/2; |
1459 | 1449 | osd_std_draw(&opc->osd_item); |
1460 | 1450 | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img); |
1461 | 1451 | graphics_image_free(opc->osd_item.gr, img); |
1462 | 1452 | } else { |
| 1453 | struct graphics *gra; |
| 1454 | gra = navit_get_graphics(nav); |
| 1455 | this->img = graphics_image_new(gra, this->src); |
| 1456 | if (!this->img) { |
| 1457 | dbg(1, "failed to load '%s'\n", this->src); |
| 1458 | return; |
| 1459 | } |
| 1460 | |
1463 | 1461 | osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav)); |
1464 | 1462 | |
1465 | 1463 | p = opc->osd_item.p; |
… |
… |
osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr) |
1553 | 1551 | if(navit_get_blocked(nav)&1) |
1554 | 1552 | return 1; |
1555 | 1553 | |
1556 | | if (this_->use_overlay) { |
1557 | | struct graphics_image *img; |
1558 | | struct point p; |
1559 | | img=graphics_image_new(opc->osd_item.gr, this_->src); |
1560 | | p.x=(opc->osd_item.w-this_->img->width)/2; |
1561 | | p.y=(opc->osd_item.h-this_->img->height)/2; |
1562 | | osd_std_draw(&opc->osd_item); |
1563 | | graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img); |
1564 | | graphics_image_free(opc->osd_item.gr, img); |
1565 | | } |
1566 | 1554 | osd_button_draw(opc,nav); |
1567 | 1555 | navit_draw(opc->osd_item.navit); |
1568 | 1556 | return 1; |
-
--
1.7.9.5
From a9a4e34e6f519211b288c8653a702433ec8ec0b6 Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Sat, 4 Oct 2014 00:04:40 +0200
Subject: [PATCH 4/8] osd/core: Make text resize correctly
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd/core/osd_core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index a2051d9..fb1ea6c 100644
a
|
b
|
osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle * |
2858 | 2858 | oti=oti->next; |
2859 | 2859 | } |
2860 | 2860 | |
2861 | | if ( this->last && str && !strcmp(this->last, str) ) { |
2862 | | do_draw=0; |
2863 | | } else { |
| 2861 | if ( !this->last || !str || strcmp(this->last, str) ) { |
2864 | 2862 | do_draw=1; |
2865 | 2863 | if (this->last) |
2866 | 2864 | g_free(this->last); |
2867 | 2865 | this->last = g_strdup(str); |
2868 | | } |
| 2866 | } else if ((opc->osd_item.rel_h) || (opc->osd_item.rel_w) || (opc->osd_item.rel_x) || (opc->osd_item.rel_y)) |
| 2867 | do_draw=1; |
2869 | 2868 | |
2870 | 2869 | absbegin=str; |
2871 | 2870 | if (do_draw) { |
-
--
1.7.9.5
From e9f44b4b7932ff0b91fabbe30e7e0d0084e7cf6c Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Sat, 4 Oct 2014 00:09:25 +0200
Subject: [PATCH 5/8] osd/core: Make gps_status resize correctly
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd/core/osd_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index fb1ea6c..30fc94c 100644
a
|
b
|
osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit, |
3194 | 3194 | if (this->strength != strength) { |
3195 | 3195 | this->strength=strength; |
3196 | 3196 | do_draw=1; |
3197 | | } |
| 3197 | } else if ((opc->osd_item.rel_h) || (opc->osd_item.rel_w) || (opc->osd_item.rel_x) || (opc->osd_item.rel_y)) |
| 3198 | do_draw=1; |
3198 | 3199 | if (do_draw) { |
3199 | 3200 | osd_std_draw(&opc->osd_item); |
3200 | 3201 | if (this->active) { |
-
--
1.7.9.5
From 7fb2a485c84a66bc2833887f629b2ad3db82c86b Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Sat, 4 Oct 2014 01:29:55 +0200
Subject: [PATCH 6/8] osd/core: Make navigation_next_turn resize correctly
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd/core/osd_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index 30fc94c..4f99e50 100644
a
|
b
|
osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit, |
1731 | 1731 | do_draw = 1; |
1732 | 1732 | } |
1733 | 1733 | } |
| 1734 | if ((opc->osd_item.rel_h) || (opc->osd_item.rel_w) || (opc->osd_item.rel_x) || (opc->osd_item.rel_y)) |
| 1735 | do_draw=1; |
1734 | 1736 | if (mr) |
1735 | 1737 | map_rect_destroy(mr); |
1736 | 1738 | |
-
--
1.7.9.5
From db8848fa11e3bd9e97cff8f6c9296614a889a228 Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Sat, 4 Oct 2014 15:41:15 +0200
Subject: [PATCH 7/8] osd/core: Implement do_draw member for osd_item
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/osd.c | 2 ++
navit/navit/osd.h | 1 +
navit/navit/osd/core/osd_core.c | 14 +++++---------
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/navit/navit/osd.c b/navit/navit/osd.c
index d125ced..33a5776 100644
a
|
b
|
osd_std_calculate_sizes_and_redraw(struct osd_item *item, struct osd_priv *priv, |
208 | 208 | osd_std_calculate_sizes(item, w, h); |
209 | 209 | |
210 | 210 | osd_std_resize(item); |
| 211 | item->do_draw=1; |
211 | 212 | if (item->meth.draw) { |
212 | 213 | if (navit_get_attr(item->navit, attr_vehicle, &vehicle_attr, NULL)) { |
213 | 214 | item->meth.draw(priv, item->navit, vehicle_attr.u.vehicle); |
| 215 | item->do_draw=0; |
214 | 216 | } |
215 | 217 | } |
216 | 218 | } |
-
diff --git a/navit/navit/osd.h b/navit/navit/osd.h
index 2c636c1..851377d 100644
a
|
b
|
struct osd_item { |
55 | 55 | char *command; |
56 | 56 | struct command_saved *enable_cs; |
57 | 57 | char *accesskey; |
| 58 | int do_draw; /**< Whether the item needs to be redrawn. */ |
58 | 59 | }; |
59 | 60 | |
60 | 61 | /* prototypes */ |
-
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index 4f99e50..a081a56 100644
a
|
b
|
osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit, |
1698 | 1698 | struct nav_next_turn *this = (struct nav_next_turn *)opc->data; |
1699 | 1699 | |
1700 | 1700 | struct point p; |
1701 | | int do_draw = 0; |
| 1701 | int do_draw = opc->osd_item.do_draw; |
1702 | 1702 | struct navigation *nav = NULL; |
1703 | 1703 | struct map *map = NULL; |
1704 | 1704 | struct map_rect *mr = NULL; |
… |
… |
osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit, |
1731 | 1731 | do_draw = 1; |
1732 | 1732 | } |
1733 | 1733 | } |
1734 | | if ((opc->osd_item.rel_h) || (opc->osd_item.rel_w) || (opc->osd_item.rel_x) || (opc->osd_item.rel_y)) |
1735 | | do_draw=1; |
1736 | 1734 | if (mr) |
1737 | 1735 | map_rect_destroy(mr); |
1738 | 1736 | |
… |
… |
osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle * |
2726 | 2724 | struct osd_text *this = (struct osd_text *)opc->data; |
2727 | 2725 | struct point p, p2[4]; |
2728 | 2726 | char *str,*last,*next,*value,*absbegin; |
2729 | | int do_draw = 0; |
| 2727 | int do_draw = opc->osd_item.do_draw; |
2730 | 2728 | struct attr attr, vehicle_attr, maxspeed_attr, imperial_attr; |
2731 | 2729 | struct navigation *nav = NULL; |
2732 | 2730 | struct tracking *tracking = NULL; |
… |
… |
osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle * |
2865 | 2863 | if (this->last) |
2866 | 2864 | g_free(this->last); |
2867 | 2865 | this->last = g_strdup(str); |
2868 | | } else if ((opc->osd_item.rel_h) || (opc->osd_item.rel_w) || (opc->osd_item.rel_x) || (opc->osd_item.rel_y)) |
2869 | | do_draw=1; |
| 2866 | } |
2870 | 2867 | |
2871 | 2868 | absbegin=str; |
2872 | 2869 | if (do_draw) { |
… |
… |
osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit, |
3160 | 3157 | struct gps_status *this = (struct gps_status *)opc->data; |
3161 | 3158 | |
3162 | 3159 | struct point p; |
3163 | | int do_draw = 0; |
| 3160 | int do_draw = opc->osd_item.do_draw; |
3164 | 3161 | struct graphics_image *gr_image; |
3165 | 3162 | char *image; |
3166 | 3163 | struct attr attr, vehicle_attr; |
… |
… |
osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit, |
3196 | 3193 | if (this->strength != strength) { |
3197 | 3194 | this->strength=strength; |
3198 | 3195 | do_draw=1; |
3199 | | } else if ((opc->osd_item.rel_h) || (opc->osd_item.rel_w) || (opc->osd_item.rel_x) || (opc->osd_item.rel_y)) |
3200 | | do_draw=1; |
| 3196 | } |
3201 | 3197 | if (do_draw) { |
3202 | 3198 | osd_std_draw(&opc->osd_item); |
3203 | 3199 | if (this->active) { |
-
--
1.7.9.5
From e9e599a65e91c8cc31dfb9aac85c91a1ea8291b7 Mon Sep 17 00:00:00 2001
From: mvglasow <michael -at- vonglasow.com>
Date: Sun, 5 Oct 2014 23:04:53 +0200
Subject: [PATCH 8/8] osd/core: Fix resize and update bugs for
toggle_announcer
Signed-off-by: mvglasow <michael -at- vonglasow.com>
---
navit/navit/navit.c | 2 +-
navit/navit/osd/core/osd_core.c | 12 ++++--------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/navit/navit/navit.c b/navit/navit/navit.c
index 243055b..cc05b6a 100644
a
|
b
|
navit_cmd_announcer_toggle(struct navit *this_) |
1855 | 1855 | return; |
1856 | 1856 | |
1857 | 1857 | // announce that the speech attribute has changed |
1858 | | callback_list_call_attr_0(this_->attr_cbl, attr_speech); |
| 1858 | callback_list_call_attr_1(this_->attr_cbl, attr_speech, this_); |
1859 | 1859 | } |
1860 | 1860 | |
1861 | 1861 | void |
-
diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c
index a081a56..25fb0c0 100644
a
|
b
|
osd_nav_toggle_announcer_draw(struct osd_priv_common *opc, struct navit *navit, |
1851 | 1851 | struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data; |
1852 | 1852 | |
1853 | 1853 | struct point p; |
1854 | | int do_draw = 0; |
| 1854 | int do_draw = opc->osd_item.do_draw; |
1855 | 1855 | struct graphics_image *gr_image; |
1856 | 1856 | char *path; |
1857 | 1857 | char *gui_sound_off = "gui_sound_off"; |
1858 | 1858 | char *gui_sound_on = "gui_sound"; |
1859 | 1859 | struct attr attr, speechattr; |
1860 | 1860 | |
1861 | | if (this->last_state == -1) |
1862 | | { |
1863 | | if (!navit_get_attr(navit, attr_speech, &speechattr, NULL) || !speech_get_attr(speechattr.u.speech, attr_active, &attr, NULL)) |
1864 | | attr.u.num = 1; |
1865 | | this->active = attr.u.num; |
1866 | | } else |
1867 | | this->active = !this->active; |
| 1861 | if (!navit_get_attr(navit, attr_speech, &speechattr, NULL) || !speech_get_attr(speechattr.u.speech, attr_active, &attr, NULL)) |
| 1862 | attr.u.num = 1; |
| 1863 | this->active = attr.u.num; |
1868 | 1864 | |
1869 | 1865 | if(this->active != this->last_state) |
1870 | 1866 | { |