Fix:osd_core:Fixed navigation osd
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 29 Feb 2008 12:58:43 +0000 (12:58 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 29 Feb 2008 12:58:43 +0000 (12:58 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@930 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/graphics.c
navit/src/graphics.h
navit/src/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
navit/src/osd/core/osd_core.c

index 9d5926b..6843aff 100644 (file)
@@ -95,12 +95,12 @@ graphics_register_motion_callback(struct graphics *this_, void (*callback)(void
 }
 
 struct graphics_font *
-graphics_font_new(struct graphics *gra, int size)
+graphics_font_new(struct graphics *gra, int size, int flags)
 {
        struct graphics_font *this_;
 
        this_=g_new0(struct graphics_font,1);
-       this_->priv=gra->meth.font_new(gra->priv, &this_->meth, size);
+       this_->priv=gra->meth.font_new(gra->priv, &this_->meth, size, flags);
        return this_;
 }
 
@@ -392,14 +392,14 @@ xdisplay_draw_elements(struct graphics *gra, GHashTable *display_list, struct it
                                                p.x=di->pnt[0].x+3;
                                                p.y=di->pnt[0].y+10;
                                                if (! gra->font[e->label_size])
-                                                       gra->font[e->label_size]=graphics_font_new(gra, e->label_size*20);
+                                                       gra->font[e->label_size]=graphics_font_new(gra, e->label_size*20, 0);
                                                gra->meth.draw_text(gra->priv, gra->gc[2]->priv, gra->gc[1]->priv, gra->font[e->label_size]->priv, di->label, &p, 0x10000, 0);
                                        }
                                        break;
                                case element_label:
                                        if (di->label) {
                                                if (! gra->font[e->label_size])
-                                                       gra->font[e->label_size]=graphics_font_new(gra, e->label_size*20);
+                                                       gra->font[e->label_size]=graphics_font_new(gra, e->label_size*20, 0);
                                                label_line(gra, gra->gc[2], gra->gc[1], gra->font[e->label_size], di->pnt, di->count, di->label);
                                        }
                                        break;
index 9c33855..6cd4811 100644 (file)
@@ -37,7 +37,7 @@ struct graphics_methods {
        void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
        void (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data);
        void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h);
-       struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, int size);
+       struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags);
        struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
        void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
        struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h);
@@ -106,7 +106,7 @@ void *graphics_get_data(struct graphics *this_, char *type);
 void graphics_register_resize_callback(struct graphics *this_, void (*callback)(void *data, int w, int h), void *data);
 void graphics_register_button_callback(struct graphics *this_, void (*callback)(void *data, int pressed, int button, struct point *p), void *data);
 void graphics_register_motion_callback(struct graphics *this_, void (*callback)(void *data, struct point *p), void *data);
-struct graphics_font *graphics_font_new(struct graphics *gra, int size);
+struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
 struct graphics_gc *graphics_gc_new(struct graphics *gra);
 void graphics_gc_destroy(struct graphics_gc *gc);
 void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
index 8ffc1c4..5ba33f1 100644 (file)
@@ -93,7 +93,7 @@ static struct graphics_font_methods font_methods = {
  * First search for each of the font families and require and exact match on family
  * If no font found, let fontconfig pick the best match
  */
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size)
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
 {
        struct graphics_font_priv *font=g_new(struct graphics_font_priv, 1);
 
@@ -111,6 +111,8 @@ static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct grap
                while (*family && !found) {
                        dbg(1, "Looking for font family %s. exact=%d\n", *family, exact);
                        FcPattern *required = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, *family, NULL);
+                       if (flags)
+                               FcPatternAddInteger(required,FC_WEIGHT,FC_WEIGHT_BOLD);
                        FcConfigSubstitute(FcConfigGetCurrent(), required, FcMatchFont);
                        FcDefaultSubstitute(required);
                        FcResult result;
index 54c7f8f..409664c 100644 (file)
@@ -142,7 +142,7 @@ osd_compass_init(struct compass *this, struct navit *nav)
        graphics_gc_set_foreground(this->green, &c);
        graphics_gc_set_linewidth(this->green, 2);
 
-       this->font=graphics_font_new(this->gr, 200);
+       this->font=graphics_font_new(this->gr, 200, 1);
        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_draw), attr_position_coord_geo, this));
 
        osd_compass_draw(this, nav, NULL);
@@ -290,7 +290,7 @@ osd_eta_init(struct eta *this, struct navit *nav)
        graphics_gc_set_foreground(this->white, &c);
        graphics_gc_set_linewidth(this->white, 2);
 
-       this->font=graphics_font_new(this->gr, 200);
+       this->font=graphics_font_new(this->gr, 200, 1);
        this->flag=graphics_image_new(this->gr, flag);
        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_eta_draw), attr_position_coord_geo, this));
 
@@ -327,17 +327,15 @@ struct osd_navigation {
        struct graphics_font *font;
        int active;
        char last_distance[16];
+       char *last_name;
 };
 
 static void
 osd_navigation_draw(struct osd_navigation *this, struct navit *navit, struct vehicle *v)
 {
        struct point p;
-       char navigation[16];
        char distance[16];
-       int days=0,do_draw=1;
-       time_t navigationt;
-        struct tm tm,navigation_tm,navigation_tm0;
+       int do_draw=0;
        struct attr attr;
        struct navigation *nav=NULL;
        struct map *map=NULL;
@@ -363,6 +361,17 @@ osd_navigation_draw(struct osd_navigation *this, struct navit *navit, struct veh
                 if (item_attr_get(item, attr_length, &attr)) {
                         format_distance(distance, attr.u.num);
                }
+               if (this->active != 1 || strcmp(this->last_distance, distance) || this->last_name != name) {
+                       this->active=1;
+                       strcpy(this->last_distance, distance);
+                       this->last_name=name;
+                       do_draw=1;
+               }
+        } else {
+               if (this->active != 0) {
+                       this->active=0;
+                       do_draw=1;
+               }
        }
         if (mr)
                 map_rect_destroy(mr);
@@ -372,23 +381,25 @@ osd_navigation_draw(struct osd_navigation *this, struct navit *navit, struct veh
                p.x=0;
                p.y=0;
                graphics_draw_rectangle(this->gr, this->bg, &p, this->w, this->h);
-               image=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/xpm/", name, "_32.xpm", NULL);
-               gr_image=graphics_image_new(this->gr, image);
-               if (! gr_image) {
-                       g_free(image);
-                       image=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/xpm/unknown.xpm", NULL);
+               if (this->active) {
+                       image=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/xpm/", name, "_32.xpm", NULL);
                        gr_image=graphics_image_new(this->gr, image);
+                       if (! gr_image) {
+                               g_free(image);
+                               image=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/xpm/unknown.xpm", NULL);
+                               gr_image=graphics_image_new(this->gr, image);
+                       }
+                       dbg(1,"gr_image=%p\n", gr_image);
+                       if (gr_image) {
+                               p.x=(this->w-gr_image->width)/2;
+                               p.y=(46-gr_image->height)/2;
+                               graphics_draw_image(this->gr, this->white, &p, gr_image);
+                               graphics_image_free(this->gr, gr_image);
+                       }
+                       p.x=12;
+                       p.y=56;
+                       graphics_draw_text(this->gr, this->white, NULL, this->font, distance, &p, 0x10000, 0);
                }
-               dbg(1,"gr_image=%p\n", gr_image);
-               if (gr_image) {
-                       p.x=(this->w-gr_image->width)/2;
-                       p.y=(46-gr_image->height)/2;
-                       graphics_draw_image(this->gr, this->white, &p, gr_image);
-                       graphics_image_free(this->gr, gr_image);
-               }
-               p.x=12;
-               p.y=56;
-               graphics_draw_text(this->gr, this->white, NULL, this->font, distance, &p, 0x10000, 0);
                graphics_draw_mode(this->gr, draw_mode_end);
        }
 }
@@ -410,7 +421,7 @@ osd_navigation_init(struct osd_navigation *this, struct navit *nav)
        graphics_gc_set_foreground(this->white, &c);
        graphics_gc_set_linewidth(this->white, 2);
 
-       this->font=graphics_font_new(this->gr, 200);
+       this->font=graphics_font_new(this->gr, 200, 1);
        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_navigation_draw), attr_position_coord_geo, this));
 
        osd_navigation_draw(this, nav, NULL);