Ticket #1260: trac1260.patch

File trac1260.patch, 15.6 KB (added by mvglasow (2), 8 years ago)

Updated patch, which also fixes toggle_announcer

  • navit/navit/osd/core/osd_core.c

    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 
    14341434osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
    14351435{
    14361436        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);
    14401442                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        }
    14441470}
    14451471
    14461472static void
  • navit/navit/osd.c

    -- 
    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) 
    169169 * @param h Available screen height in pixels (the height that corresponds to
    170170 * 100%)
    171171 */
    172 static void
     172void
    173173osd_std_calculate_sizes(struct osd_item *item, int w, int h)
    174174{
    175175        if (item->rel_w) {
  • navit/navit/osd.h

    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); 
    7171void osd_set_std_config(struct navit *nav, struct osd_item *item);
    7272void osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *priv);
    7373void osd_std_resize(struct osd_item *item);
     74void osd_std_calculate_sizes(struct osd_item *item, int w, int h);
    7475void osd_std_draw(struct osd_item *item);
    7576int osd_set_attr(struct osd *osd, struct attr* attr);
    7677int osd_get_attr(struct osd *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
  • navit/navit/osd/core/osd_core.c

    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) 
    14491449        if(navit_get_blocked(nav)&1)
    14501450                return;
    14511451
     1452        struct point p;
     1453
    14521454        if (this->use_overlay) {
    14531455                struct graphics_image *img;
    1454                 struct point p;
    14551456                img=graphics_image_new(opc->osd_item.gr, this->src);
    14561457                p.x=(opc->osd_item.w-this->img->width)/2;
    14571458                p.y=(opc->osd_item.h-this->img->height)/2;
    osd_button_draw(struct osd_priv_common *opc, struct navit *nav) 
    14591460                graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
    14601461                graphics_image_free(opc->osd_item.gr, img);
    14611462        } 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
    14631469                if (!opc->osd_item.configured)
    14641470                        return;
    1465                 osd_wrap_point(&bp, nav);
     1471                osd_wrap_point(&p, nav);
    14661472
    14671473                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);
    14691475        }
    14701476}
    14711477
  • navit/navit/osd/core/osd_core.c

    -- 
    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 
    14341434osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
    14351435{
    14361436        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;
    14481437
     1438        // FIXME: Do we need this check?
    14491439        if(navit_get_blocked(nav)&1)
    14501440                return;
    14511441
    osd_button_draw(struct osd_priv_common *opc, struct navit *nav) 
    14541444        if (this->use_overlay) {
    14551445                struct graphics_image *img;
    14561446                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;
    14591449                osd_std_draw(&opc->osd_item);
    14601450                graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
    14611451                graphics_image_free(opc->osd_item.gr, img);
    14621452        } 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
    14631461                osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
    14641462
    14651463                p = opc->osd_item.p;
    osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr) 
    15531551                if(navit_get_blocked(nav)&1)
    15541552                        return 1;
    15551553
    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                 }
    15661554                osd_button_draw(opc,nav);
    15671555                navit_draw(opc->osd_item.navit);
    15681556                return 1;
  • navit/navit/osd/core/osd_core.c

    -- 
    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 * 
    28582858                oti=oti->next;
    28592859        }
    28602860
    2861         if ( this->last && str && !strcmp(this->last, str) ) {
    2862                 do_draw=0;
    2863         } else {
     2861        if ( !this->last || !str || strcmp(this->last, str) ) {
    28642862                do_draw=1;
    28652863                if (this->last)
    28662864                        g_free(this->last);
    28672865                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;
    28692868
    28702869        absbegin=str;
    28712870        if (do_draw) {
  • navit/navit/osd/core/osd_core.c

    -- 
    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, 
    31943194        if (this->strength != strength) {
    31953195                this->strength=strength;
    31963196                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;
    31983199        if (do_draw) {
    31993200                osd_std_draw(&opc->osd_item);
    32003201                if (this->active) {
  • navit/navit/osd/core/osd_core.c

    -- 
    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, 
    17311731                        do_draw = 1;
    17321732                }
    17331733        }
     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;
    17341736        if (mr)
    17351737                map_rect_destroy(mr);
    17361738
  • navit/navit/osd.c

    -- 
    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, 
    208208        osd_std_calculate_sizes(item, w, h);
    209209
    210210        osd_std_resize(item);
     211        item->do_draw=1;
    211212        if (item->meth.draw) {
    212213                if (navit_get_attr(item->navit, attr_vehicle, &vehicle_attr, NULL)) {
    213214                        item->meth.draw(priv, item->navit, vehicle_attr.u.vehicle);
     215                        item->do_draw=0;
    214216                }
    215217        }
    216218}
  • navit/navit/osd.h

    diff --git a/navit/navit/osd.h b/navit/navit/osd.h
    index 2c636c1..851377d 100644
    a b struct osd_item { 
    5555        char *command;
    5656        struct command_saved *enable_cs;
    5757        char *accesskey;
     58        int do_draw; /**< Whether the item needs to be redrawn. */
    5859};
    5960
    6061/* prototypes */
  • navit/navit/osd/core/osd_core.c

    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, 
    16981698        struct nav_next_turn *this = (struct nav_next_turn *)opc->data;
    16991699
    17001700        struct point p;
    1701         int do_draw = 0;
     1701        int do_draw = opc->osd_item.do_draw;
    17021702        struct navigation *nav = NULL;
    17031703        struct map *map = NULL;
    17041704        struct map_rect *mr = NULL;
    osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit, 
    17311731                        do_draw = 1;
    17321732                }
    17331733        }
    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;
    17361734        if (mr)
    17371735                map_rect_destroy(mr);
    17381736
    osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle * 
    27262724        struct osd_text *this = (struct osd_text *)opc->data;
    27272725        struct point p, p2[4];
    27282726        char *str,*last,*next,*value,*absbegin;
    2729         int do_draw = 0;
     2727        int do_draw = opc->osd_item.do_draw;
    27302728        struct attr attr, vehicle_attr, maxspeed_attr, imperial_attr;
    27312729        struct navigation *nav = NULL;
    27322730        struct tracking *tracking = NULL;
    osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle * 
    28652863                if (this->last)
    28662864                        g_free(this->last);
    28672865                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        }
    28702867
    28712868        absbegin=str;
    28722869        if (do_draw) {
    osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit, 
    31603157        struct gps_status *this = (struct gps_status *)opc->data;
    31613158
    31623159        struct point p;
    3163         int do_draw = 0;
     3160        int do_draw = opc->osd_item.do_draw;
    31643161        struct graphics_image *gr_image;
    31653162        char *image;
    31663163        struct attr attr, vehicle_attr;
    osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit, 
    31963193        if (this->strength != strength) {
    31973194                this->strength=strength;
    31983195                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        }
    32013197        if (do_draw) {
    32023198                osd_std_draw(&opc->osd_item);
    32033199                if (this->active) {
  • navit/navit/navit.c

    -- 
    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_) 
    18551855        return;
    18561856
    18571857    // 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_);
    18591859}
    18601860
    18611861void
  • navit/navit/osd/core/osd_core.c

    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, 
    18511851        struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
    18521852
    18531853        struct point p;
    1854         int do_draw = 0;
     1854        int do_draw = opc->osd_item.do_draw;
    18551855        struct graphics_image *gr_image;
    18561856        char *path;
    18571857        char *gui_sound_off = "gui_sound_off";
    18581858        char *gui_sound_on = "gui_sound";
    18591859    struct attr attr, speechattr;
    18601860
    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;
    18681864
    18691865    if(this->active != this->last_state)
    18701866    {