summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/attr.c19
-rw-r--r--navit/attr.h1
-rw-r--r--navit/osd.c58
-rw-r--r--navit/osd/core/osd_core.c218
4 files changed, 147 insertions, 149 deletions
diff --git a/navit/attr.c b/navit/attr.c
index cc0b026b5..e884155ce 100644
--- a/navit/attr.c
+++ b/navit/attr.c
@@ -974,3 +974,22 @@ attr_types_contains_default(enum attr_type *types, enum attr_type type, int defl
}
return attr_types_contains(types, type);
}
+
+/**
+ * @brief Derive absolute value from relative attribute, given value of the whole range.
+ *
+ * @param attrval Value of u.num member of attribute capable of holding relative values.
+ * @param whole Range counted as 100%.
+ * @param treat_neg_as_rel Replace negative absolute values with whole+attr.u.num.
+ *
+ * @return True if the attribute type was found, false if it was not found, {@code deflt} if types is empty.
+ */
+int attr_rel2real(int attrval, int whole, int treat_neg_as_rel)
+{
+ if (attrval > ATTR_REL_MAXABS)
+ return whole * (attrval - ATTR_REL_RELSHIFT)/100;
+ if(treat_neg_as_rel && attrval<0 )
+ return whole+attrval;
+ return attrval;
+}
+
diff --git a/navit/attr.h b/navit/attr.h
index 60e3d5168..6835f6ef2 100644
--- a/navit/attr.h
+++ b/navit/attr.h
@@ -226,6 +226,7 @@ struct attr **attr_list_append(struct attr **attrs, struct attr *attr);
int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret);
int attr_types_contains(enum attr_type *types, enum attr_type type);
int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt);
+int attr_rel2real(int attrval, int whole, int treat_neg_as_rel);
/* end of prototypes */
#ifdef __cplusplus
}
diff --git a/navit/osd.c b/navit/osd.c
index c4b9299ff..3671f331e 100644
--- a/navit/osd.c
+++ b/navit/osd.c
@@ -162,7 +162,10 @@ osd_std_resize(struct osd_item *item)
* @brief Calculates the size and position of an OSD item.
*
* If the geometry of the OSD item is specified relative to screen dimensions,
- * this function will set its absolute dimensions accordingly.
+ * this function will set its absolute dimensions accordingly. If relative width
+ * or relative height is set to 0% (int value is equal to ATTR_REL_RELSHIFT),
+ * object width (height) is not changed here, for button and image osds it means
+ * to derive values from the underlying image.
* @param item
* @param w Available screen width in pixels (the width that corresponds to
* 100%)
@@ -172,21 +175,16 @@ osd_std_resize(struct osd_item *item)
void
osd_std_calculate_sizes(struct osd_item *item, int w, int h)
{
- if (item->rel_w) {
- item->w = (item->rel_w * w) / 100;
- }
-
- if (item->rel_h) {
- item->h = (item->rel_h * h) / 100;
- }
-
- if (item->rel_x) {
- item->p.x = (item->rel_x * w) / 100;
- }
-
- if (item->rel_y) {
- item->p.y = (item->rel_y * h) / 100;
- }
+ if(item->rel_w!=ATTR_REL_RELSHIFT)
+ item->w=attr_rel2real(item->rel_w, w, 1);
+ if(item->w<0)
+ item->w=0;
+ if(item->rel_h!=ATTR_REL_RELSHIFT)
+ item->h=attr_rel2real(item->rel_h, h, 1);
+ if(item->h<0)
+ item->h=0;
+ item->p.x=attr_rel2real(item->rel_x, w, 1);
+ item->p.y=attr_rel2real(item->rel_y, h, 1);
}
/**
@@ -284,42 +282,22 @@ osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags)
attr = attr_search(attrs, NULL, attr_w);
if (attr) {
- if (attr->u.num > ATTR_REL_MAXABS) {
- item->rel_w = attr->u.num - ATTR_REL_RELSHIFT;
- } else {
- item->rel_w = 0;
- item->w = attr->u.num;
- }
+ item->rel_w = attr->u.num;
}
attr = attr_search(attrs, NULL, attr_h);
if (attr) {
- if (attr->u.num > ATTR_REL_MAXABS) {
- item->rel_h = attr->u.num - ATTR_REL_RELSHIFT;
- } else {
- item->rel_h = 0;
- item->h = attr->u.num;
- }
+ item->rel_h = attr->u.num;
}
attr = attr_search(attrs, NULL, attr_x);
if (attr) {
- if (attr->u.num > ATTR_REL_MAXABS) {
- item->rel_x = attr->u.num - ATTR_REL_RELSHIFT;
- } else {
- item->rel_x = 0;
- item->p.x = attr->u.num;
- }
+ item->rel_x = attr->u.num;
}
attr = attr_search(attrs, NULL, attr_y);
if (attr) {
- if (attr->u.num > ATTR_REL_MAXABS) {
- item->rel_y = attr->u.num - ATTR_REL_RELSHIFT;
- } else {
- item->rel_y = 0;
- item->p.y = attr->u.num;
- }
+ item->rel_y = attr->u.num;
}
attr = attr_search(attrs, NULL, attr_font_size);
diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c
index 06bbeeac7..1d17545f8 100644
--- a/navit/osd/core/osd_core.c
+++ b/navit/osd/core/osd_core.c
@@ -223,40 +223,31 @@ int set_std_osd_attr(struct osd_priv *priv, struct attr*the_attr)
{
struct osd_priv_common *opc=(struct osd_priv_common *)priv;
if(opc && the_attr && ATTR_IS_INT(the_attr->type)) {
+ int attr_set=0;
if(attr_w == the_attr->type) {
- opc->osd_item.w = the_attr->u.num;
- if(opc->osd_item.gr) {
- osd_std_resize(&opc->osd_item);
- return 1;
- }
+ opc->osd_item.rel_w = the_attr->u.num;
+ attr_set=1;
}
else if(attr_h == the_attr->type) {
- opc->osd_item.h = the_attr->u.num;
- if(opc->osd_item.gr) {
- osd_std_resize(&opc->osd_item);
- return 1;
- }
+ opc->osd_item.rel_h = the_attr->u.num;
+ attr_set=1;
}
else if(attr_x == the_attr->type) {
- opc->osd_item.p.x = the_attr->u.num;
- if(opc->osd_item.gr) {
- osd_std_resize(&opc->osd_item);
- return 1;
- }
+ opc->osd_item.rel_x = the_attr->u.num;
+ attr_set=1;
}
else if(attr_y == the_attr->type) {
- opc->osd_item.p.y = the_attr->u.num;
- if(opc->osd_item.gr) {
- osd_std_resize(&opc->osd_item);
- return 1;
- }
+ opc->osd_item.rel_y = the_attr->u.num;
+ attr_set=1;
}
else if(attr_font_size == the_attr->type) {
opc->osd_item.font_size = the_attr->u.num;
- if(opc->osd_item.gr) {
- osd_std_resize(&opc->osd_item);
- return 1;
- }
+ attr_set=1;
+ }
+ if(attr_set && opc->osd_item.gr) {
+ osd_std_calculate_sizes(&opc->osd_item, navit_get_width(opc->osd_item.navit), navit_get_height(opc->osd_item.navit));
+ osd_std_resize(&opc->osd_item);
+ return 1;
}
}
if(opc->spec_set_attr_func) {
@@ -437,10 +428,10 @@ osd_route_guard_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = 120;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 80;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
opc->osd_item.navit = nav;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_route_guard_draw);
@@ -914,10 +905,10 @@ osd_odometer_new(struct navit *nav, struct osd_methods *meth,
struct color orange_color={0xffff,0xa5a5,0x0000,0xffff};
opc->data = (void*)this;
- opc->osd_item.p.x = 120;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 80;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
opc->osd_item.navit = nav;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_odometer_draw);
@@ -1133,10 +1124,10 @@ osd_cmd_interface_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = 120;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 80;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
opc->osd_item.navit = nav;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_cmd_interface_draw);
@@ -1294,10 +1285,10 @@ osd_stopwatch_new(struct navit *nav, struct osd_methods *meth,
struct color orange_color={0xffff,0xa5a5,0x0000,0xffff};
opc->data = (void*)this;
- opc->osd_item.p.x = 120;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 80;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
opc->osd_item.navit = nav;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_stopwatch_draw);
@@ -1408,10 +1399,10 @@ osd_compass_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = 20;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 80;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
opc->osd_item.navit = nav;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_compass_draw);
@@ -1430,6 +1421,16 @@ struct osd_button {
char *src_dir,*src;
};
+
+static void
+osd_button_adjust_sizes(struct osd_priv_common *opc, struct graphics_image *img)
+{
+ if(opc->osd_item.rel_w==ATTR_REL_RELSHIFT)
+ opc->osd_item.w=img->width;
+ if(opc->osd_item.rel_h==ATTR_REL_RELSHIFT)
+ opc->osd_item.h=img->height;
+}
+
static void
osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
{
@@ -1444,6 +1445,7 @@ osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
if (this->use_overlay) {
struct graphics_image *img;
img=graphics_image_new(opc->osd_item.gr, this->src);
+ osd_button_adjust_sizes(opc, img);
p.x=(opc->osd_item.w-img->width)/2;
p.y=(opc->osd_item.h-img->height)/2;
osd_std_draw(&opc->osd_item);
@@ -1453,12 +1455,14 @@ osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
struct graphics *gra;
gra = navit_get_graphics(nav);
this->img = graphics_image_new(gra, this->src);
+
if (!this->img) {
dbg(lvl_warning, "failed to load '%s'\n", this->src);
return;
}
osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
+ osd_button_adjust_sizes(opc, this->img);
p = opc->osd_item.p;
p.x+=(opc->osd_item.w-this->img->width)/2;
@@ -1466,7 +1470,6 @@ osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
if (!opc->osd_item.configured)
return;
- osd_wrap_point(&p, nav);
if(this->img)
graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img);
@@ -1485,10 +1488,7 @@ osd_button_init(struct osd_priv_common *opc, struct navit *nav)
dbg(lvl_warning, "failed to load '%s'\n", this->src);
return;
}
- if (!opc->osd_item.w)
- opc->osd_item.w=this->img->width;
- if (!opc->osd_item.h)
- opc->osd_item.h=this->img->height;
+ osd_button_adjust_sizes(opc, this->img);
if (this->use_overlay) {
struct graphics_image *img;
struct point p;
@@ -1543,10 +1543,6 @@ osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr)
dbg(lvl_warning, "failed to load '%s'\n", this_->src);
return 0;
}
- if (!opc->osd_item.w)
- opc->osd_item.w=this_->img->width;
- if (!opc->osd_item.h)
- opc->osd_item.h=this_->img->height;
if(navit_get_blocked(nav)&1)
return 1;
@@ -1571,6 +1567,9 @@ osd_button_new(struct navit *nav, struct osd_methods *meth,
opc->data = (void*)this;
opc->osd_item.navit = nav;
opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
+ /*Value of 0% is stored in relative attributes as ATTR_REL_RELSHIFT, we use this value as "width/height unset" flag */
+ opc->osd_item.rel_w = ATTR_REL_RELSHIFT;
+ opc->osd_item.rel_h = ATTR_REL_RELSHIFT;
meth->set_attr = set_std_osd_attr;
opc->spec_set_attr_func = osd_button_set_attr;
@@ -1623,10 +1622,7 @@ osd_image_init(struct osd_priv_common *opc, struct navit *nav)
dbg(lvl_warning, "failed to load '%s'\n", this->src);
return;
}
- if (!opc->osd_item.w)
- opc->osd_item.w=this->img->width;
- if (!opc->osd_item.h)
- opc->osd_item.h=this->img->height;
+ osd_button_adjust_sizes(opc, this->img);
if (this->use_overlay) {
struct graphics_image *img;
struct point p;
@@ -1658,6 +1654,9 @@ osd_image_new(struct navit *nav, struct osd_methods *meth,
opc->data = (void*)this;
opc->osd_item.navit = nav;
opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
+ /*Value of 0% is stored in relative attributes as ATTR_REL_RELSHIFT, we use this value as "width/height unset" flag */
+ opc->osd_item.rel_w = ATTR_REL_RELSHIFT;
+ opc->osd_item.rel_h = ATTR_REL_RELSHIFT;
meth->set_attr = set_std_osd_attr;
opc->spec_set_attr_func = osd_button_set_attr;
@@ -1794,11 +1793,11 @@ osd_nav_next_turn_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = 20;
- opc->osd_item.p.y = -80;
- opc->osd_item.w = 70;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 70;
opc->osd_item.navit = nav;
- opc->osd_item.h = 70;
+ opc->osd_item.rel_h = 70;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_nav_next_turn_draw);
meth->set_attr = set_std_osd_attr;
@@ -1928,11 +1927,11 @@ osd_nav_toggle_announcer_new(struct navit *nav, struct osd_methods *meth, struct
char *command = "announcer_toggle()";
opc->data = (void*)this;
- opc->osd_item.w = 48;
- opc->osd_item.h = 48;
- opc->osd_item.p.x = -64;
+ opc->osd_item.rel_w = 48;
+ opc->osd_item.rel_h = 48;
+ opc->osd_item.rel_x = -64;
+ opc->osd_item.rel_y = 76;
opc->osd_item.navit = nav;
- opc->osd_item.p.y = 76;
opc->osd_item.meth.draw = osd_draw_cast(osd_nav_toggle_announcer_draw);
meth->set_attr = set_std_osd_attr;
@@ -2455,11 +2454,11 @@ osd_speed_warner_new(struct navit *nav, struct osd_methods *meth, struct attr **
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x=-80;
- opc->osd_item.p.y=20;
- opc->osd_item.w=60;
+ opc->osd_item.rel_x=-80;
+ opc->osd_item.rel_y=20;
+ opc->osd_item.rel_w=60;
+ opc->osd_item.rel_h=60;
opc->osd_item.navit = nav;
- opc->osd_item.h=60;
this->active=-1;
opc->osd_item.meth.draw = osd_draw_cast(osd_speed_warner_draw);
meth->set_attr = set_std_osd_attr;
@@ -3127,10 +3126,10 @@ osd_text_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = -80;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 20;
+ opc->osd_item.rel_x = -80;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 20;
opc->osd_item.navit = nav;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_text_draw);
@@ -3241,9 +3240,9 @@ osd_gps_status_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = 20;
- opc->osd_item.p.y = -80;
- opc->osd_item.w = 60;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 60;
opc->osd_item.navit = nav;
opc->osd_item.h = 40;
opc->osd_item.font_size = 200;
@@ -3317,7 +3316,6 @@ osd_volume_click(struct osd_priv_common *opc, struct navit *nav, int pressed, in
struct volume *this = (struct volume *)opc->data;
struct point bp = opc->osd_item.p;
- osd_wrap_point(&bp, nav);
if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h) && !opc->osd_item.pressed)
return;
navit_ignore_button(nav);
@@ -3352,11 +3350,11 @@ osd_volume_new(struct navit *nav, struct osd_methods *meth,
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.p.x = 20;
- opc->osd_item.p.y = -80;
- opc->osd_item.w = 60;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 40;
opc->osd_item.navit = nav;
- opc->osd_item.h = 40;
opc->osd_item.font_size = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_volume_draw);
meth->set_attr = set_std_osd_attr;
@@ -3422,34 +3420,36 @@ osd_scale_draw(struct osd_priv_common *opc, struct navit *nav)
int scale_x_offset,scale_length_on_map,scale_length_pixels;
double distance_on_map;
char *text;
- struct osd_item scale_item=opc->osd_item;
- int width_reduced=scale_item.w*9/10;
+ int width_reduced;
int imperial=0;
+ osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
+
+ width_reduced=opc->osd_item.w*9/10;
+
if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
imperial=imperial_attr.u.num;
if (!navit_get_attr(nav, attr_transformation, &transformation, NULL))
return;
if (this->use_overlay) {
- graphics_draw_mode(scale_item.gr, draw_mode_begin);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
item_pos.x=0;
item_pos.y=0;
- graphics_draw_rectangle(scale_item.gr, scale_item.graphic_bg, &item_pos, scale_item.w, scale_item.h);
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &item_pos, opc->osd_item.w, opc->osd_item.h);
} else {
- item_pos=scale_item.p;
- osd_wrap_point(&item_pos, nav);
+ item_pos=opc->osd_item.p;
}
scale_line_start=item_pos;
- scale_line_start.y+=scale_item.h/2;
- scale_line_start.x+=(scale_item.w-width_reduced)/2;
+ scale_line_start.y+=opc->osd_item.h/2;
+ scale_line_start.x+=(opc->osd_item.w-width_reduced)/2;
scale_line_end=scale_line_start;
scale_line_end.x+=width_reduced;
distance_on_map=transform_pixels_to_map_distance(transformation.u.transformation, width_reduced);
scale_length_on_map=round_to_nice_value(distance_on_map);
scale_length_pixels=scale_length_on_map/distance_on_map*width_reduced;
- scale_x_offset=(scale_item.w-scale_length_pixels) / 2;
+ scale_x_offset=(opc->osd_item.w-scale_length_pixels) / 2;
p[0]=scale_line_start;
p[1]=scale_line_end;
@@ -3457,12 +3457,12 @@ osd_scale_draw(struct osd_priv_common *opc, struct navit *nav)
p[1].x-=scale_x_offset;
p[2]=p[0];
p[3]=p[0];
- p[2].y-=scale_item.h/10;
- p[3].y+=scale_item.h/10;
+ p[2].y-=opc->osd_item.h/10;
+ p[3].y+=opc->osd_item.h/10;
p[4]=p[1];
p[5]=p[1];
- p[4].y-=scale_item.h/10;
- p[5].y+=scale_item.h/10;
+ p[4].y-=opc->osd_item.h/10;
+ p[5].y+=opc->osd_item.h/10;
p[6]=p[2];
p[6].x-=2;
p[6].y-=2;
@@ -3471,20 +3471,20 @@ osd_scale_draw(struct osd_priv_common *opc, struct navit *nav)
p[8]=p[4];
p[8].x-=2;
p[8].y-=2;
- graphics_draw_rectangle(scale_item.gr, scale_item.graphic_fg_white, p+6, 4,scale_item.h/5+4);
- graphics_draw_rectangle(scale_item.gr, scale_item.graphic_fg_white, p+7, p[1].x-p[0].x, 4);
- graphics_draw_rectangle(scale_item.gr, scale_item.graphic_fg_white, p+8, 4,scale_item.h/5+4);
- graphics_draw_lines(scale_item.gr, this->black, p, 2);
- graphics_draw_lines(scale_item.gr, this->black, p+2, 2);
- graphics_draw_lines(scale_item.gr, this->black, p+4, 2);
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, p+6, 4,opc->osd_item.h/5+4);
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, p+7, p[1].x-p[0].x, 4);
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, p+8, 4,opc->osd_item.h/5+4);
+ graphics_draw_lines(opc->osd_item.gr, this->black, p, 2);
+ graphics_draw_lines(opc->osd_item.gr, this->black, p+2, 2);
+ graphics_draw_lines(opc->osd_item.gr, this->black, p+4, 2);
text=format_distance(scale_length_on_map, "", imperial);
- graphics_get_text_bbox(scale_item.gr, scale_item.font, text, 0x10000, 0, bbox, 0);
- p[0].x=(scale_item.w-bbox[2].x)/2+item_pos.x;
- p[0].y=item_pos.y+scale_item.h-scale_item.h/10;
- graphics_draw_text(scale_item.gr, this->black, scale_item.graphic_fg_white, scale_item.font, text, &p[0], 0x10000, 0);
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
+ p[0].x=(opc->osd_item.w-bbox[2].x)/2+item_pos.x;
+ p[0].y=item_pos.y+opc->osd_item.h-opc->osd_item.h/10;
+ graphics_draw_text(opc->osd_item.gr, this->black, opc->osd_item.graphic_fg_white, opc->osd_item.font, text, &p[0], 0x10000, 0);
g_free(text);
if (this->use_overlay)
- graphics_draw_mode(scale_item.gr, draw_mode_end);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
}
static void
@@ -3636,10 +3636,10 @@ osd_auxmap_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
opc->data = (void*)this;
- opc->osd_item.p.x = 20;
- opc->osd_item.p.y = -80;
- opc->osd_item.w = 60;
- opc->osd_item.h = 40;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 40;
opc->osd_item.font_size = 200;
meth->set_attr = set_std_osd_attr;
osd_set_std_attr(attrs, &opc->osd_item, 0);