summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWildemann Stefan <stefan.wildemann@corpuls.com>2019-07-15 14:48:49 +0200
committerWildemann Stefan <stefan.wildemann@corpuls.com>2019-07-15 15:04:40 +0200
commit6853f5d2844cf5197bdd196f68b460363f79307f (patch)
tree37cf8aff4df08549df9b107f1a32791ecb3c0f6a
parent0f08c04dd9816533ffbaa2b684b8b0d57f0da9a5 (diff)
downloadnavit-6853f5d2844cf5197bdd196f68b460363f79307f.tar.gz
Initial dpi scaling support
-rw-r--r--navit/attr.c71
-rw-r--r--navit/attr.h136
-rw-r--r--navit/attr_def.h23
-rw-r--r--navit/graphics.c15
-rw-r--r--navit/graphics.h180
-rw-r--r--navit/graphics/qt5/graphics_qt5.cpp19
-rw-r--r--navit/gui/internal/gui_internal.c5
-rw-r--r--navit/osd.c69
-rw-r--r--navit/osd.h61
-rw-r--r--navit/osd/core/osd_core.c234
10 files changed, 499 insertions, 314 deletions
diff --git a/navit/attr.c b/navit/attr.c
index f7e5d1fac..a01cec1e6 100644
--- a/navit/attr.c
+++ b/navit/attr.c
@@ -43,6 +43,7 @@
#include "util.h"
#include "types.h"
#include "xmlconfig.h"
+#include "osd.h"
struct attr_name {
enum attr_type attr;
@@ -214,7 +215,7 @@ attr_new_from_text(const char *name, const char *value) {
ret->u.str=g_strdup(value);
break;
}
- if (attr >= attr_type_int_begin && attr < attr_type_rel_abs_begin) {
+ if (attr >= attr_type_int_begin && attr < attr_type_boolean_begin) {
char *tail;
if (value[0] == '0' && value[1] == 'x')
ret->u.num=strtoul(value, &tail, 0);
@@ -227,28 +228,23 @@ attr_new_from_text(const char *name, const char *value) {
}
break;
}
- if (attr >= attr_type_rel_abs_begin && attr < attr_type_boolean_begin) {
- char *tail;
- int value_is_relative=0;
- ret->u.num=strtol(value, &tail, 0);
+ if (attr >= attr_type_osd_coordinate_begin && attr <= attr_type_osd_coordinate_end) {
+ char * tail;
+ ret->u.osd_display_coordinate = g_malloc(sizeof(*(ret->u.osd_display_coordinate)));
+ ret->u.osd_display_coordinate->type = PIXELS;
+ ret->u.osd_display_coordinate->num=strtod(value,&tail);
if (*tail) {
- if (!strcmp(tail, "%")) {
- value_is_relative=1;
+ if(!strcmp(tail, "%")) {
+ ret->u.osd_display_coordinate->type=REL;
+ } else if(!strcmp(tail, "in")) {
+ ret->u.osd_display_coordinate->type=IN;
+ } else if(!strcmp(tail, "mm")) {
+ ret->u.osd_display_coordinate->type=MM;
} else {
- dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a number or a relative value in percent. "
+ dbg(lvl_error,
+ "Incorrect value '%s' for attribute '%s'; expected a number (pixels), value in inches, value in mm, or a relative value in percent. "
"Defaulting to 0.\n", value, name);
- ret->u.num=0;
- }
- }
- if (value_is_relative) {
- if ((ret->u.num > ATTR_REL_MAXREL) || (ret->u.num < ATTR_REL_MINREL)) {
- dbg(lvl_error, "Relative possibly-relative attribute with value out of range: %li", ret->u.num);
- }
-
- ret->u.num += ATTR_REL_RELSHIFT;
- } else {
- if ((ret->u.num > ATTR_REL_MAXABS) || (ret->u.num < ATTR_REL_MINABS)) {
- dbg(lvl_error, "Non-relative possibly-relative attribute with value out of range: %li", ret->u.num);
+ ret->u.osd_display_coordinate->num=0;
}
}
break;
@@ -468,6 +464,22 @@ char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum
if (type >= attr_type_item_type_begin && type <= attr_type_item_type_end) {
return g_strdup_printf("0x%ld[%s]",attr->u.num,item_to_name(attr->u.num));
}
+ if (type >= attr_type_osd_coordinate_begin && type <= attr_type_osd_coordinate_end) {
+ switch(attr->u.osd_display_coordinate->type) {
+ case PIXELS:
+ return g_strdup_printf("%f",attr->u.osd_display_coordinate->num);
+ break;
+ case REL:
+ return g_strdup_printf("%f %%",attr->u.osd_display_coordinate->num);
+ break;
+ case IN:
+ return g_strdup_printf("%f in",attr->u.osd_display_coordinate->num);
+ break;
+ case MM:
+ return g_strdup_printf("%f mm",attr->u.osd_display_coordinate->num);
+ break;
+ }
+ }
if (type == attr_nav_status) {
return nav_status_to_text(attr->u.num);
}
@@ -770,6 +782,8 @@ int attr_data_size(struct attr *attr) {
while (attr->u.attr_types[i++] != attr_none);
return i*sizeof(enum attr_type);
}
+ if (attr->type >= attr_type_osd_coordinate_begin && attr->type <= attr_type_osd_coordinate_end)
+ return sizeof(*(attr->u.osd_display_coordinate));
dbg(lvl_error,"size for %s unknown", attr_to_name(attr->type));
return 0;
}
@@ -993,20 +1007,5 @@ int attr_types_contains_default(enum attr_type *types, enum attr_type type, int
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 Absolute value corresponding to given relative value.
- */
-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 dca3a6107..72c398c68 100644
--- a/navit/attr.h
+++ b/navit/attr.h
@@ -35,8 +35,8 @@ enum attr_type {
#define ATTR2(x,y) attr_##y=x,
#define ATTR(x) attr_##x,
-/* Special macro for unused attribute types. Creates a placeholder entry
- * in the enum so the following values do not change. */
+ /* Special macro for unused attribute types. Creates a placeholder entry
+ * in the enum so the following values do not change. */
#define ATTR_UNUSED ATTR_UNUSED_L(__LINE__)
#define ATTR_UNUSED_L(x) ATTR_UNUSED_WITH_LINE_NUMBER(x)
#define ATTR_UNUSED_WITH_LINE_NUMBER(x) ATTR_UNUSED_##x,
@@ -52,8 +52,8 @@ enum attr_type {
};
enum attr_format {
- attr_format_default=0,
- attr_format_with_units=1,
+ attr_format_default=0,
+ attr_format_with_units=1,
};
#define AF_ONEWAY (1<<0)
@@ -120,19 +120,19 @@ enum attr_format {
/** Indicates whether a position is valid **/
enum attr_position_valid {
- attr_position_valid_invalid, /**< The position is invalid and should be discarded. **/
- attr_position_valid_static, /**< The position is valid but the vehicle is not moving, or moving very slowly.
+ attr_position_valid_invalid, /**< The position is invalid and should be discarded. **/
+ attr_position_valid_static, /**< The position is valid but the vehicle is not moving, or moving very slowly.
Calculations that involve the difference between two consecutive positions,
such as bearing, may therefore be inaccurate. **/
- attr_position_valid_extrapolated_time, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
+ attr_position_valid_extrapolated_time, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
The position is the vehicle's last known position, and the consumer of the
information should be aware that the vehicle may have moved since. **/
- attr_position_valid_extrapolated_spatial, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
+ attr_position_valid_extrapolated_spatial, /**< FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957.
The position is a prediction of the vehicle's current position, based on
its last known position, the time elapsed since it was obtained and possibly
other factors. This would be used for positions obtained through inertial
navigation. **/
- attr_position_valid_valid, /**< The position is valid and can be used for all purposes. **/
+ attr_position_valid_valid, /**< The position is valid and can be used for all purposes. **/
};
#define ATTR_IS_INT(x) ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
@@ -146,70 +146,72 @@ enum attr_position_valid {
#define ATTR_IS_PCOORD(x) ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)
#define ATTR_IS_COORD(x) ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)
#define ATTR_IS_GROUP(x) ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)
+#define ATTR_IS_OSD_DISPLAY_COORDINATE(x) ((x) >= attr_type_osd_coordinate_begin && (x) <= attr_type_osd_coordinate_end)
#define ATTR_INT(x,y) ((struct attr){attr_##x,{.num=y}})
#define ATTR_OBJECT(x,y) ((struct attr){attr_##x,{.navit=y}})
struct range {
- short min, max;
+ short min, max;
};
struct attr {
- enum attr_type type;
- union {
- char *str;
- void *data;
- long num;
- struct item *item;
- enum item_type item_type;
- enum projection projection;
- double * numd;
- struct color *color;
- struct coord_geo *coord_geo;
- struct navit *navit;
- struct callback *callback;
- struct callback_list *callback_list;
- struct vehicle *vehicle;
- struct layout *layout;
- struct layer *layer;
- struct map *map;
- struct mapset *mapset;
- struct log *log;
- struct route *route;
- struct navigation *navigation;
- struct coord *coord;
- struct pcoord *pcoord;
- struct gui *gui;
- struct graphics *graphics;
- struct tracking *tracking;
- struct itemgra *itemgra;
- struct plugin *plugin;
- struct plugins *plugins;
- struct polygon *polygon;
- struct polyline *polyline;
- struct circle *circle;
- struct text *text;
- struct icon *icon;
- struct image *image;
- struct arrows *arrows;
- struct element *element;
- struct speech *speech;
- struct cursor *cursor;
- struct displaylist *displaylist;
- struct transformation *transformation;
- struct vehicleprofile *vehicleprofile;
- struct roadprofile *roadprofile;
- struct bookmarks *bookmarks;
- struct config *config;
- struct osd *osd;
- struct range range;
- struct navit_object *navit_object;
- int *dash;
- enum item_type *item_types;
- enum attr_type *attr_types;
- long long *num64;
- struct attr *attrs;
- } u;
+ enum attr_type type;
+ union {
+ char *str;
+ void *data;
+ long num;
+ struct item *item;
+ enum item_type item_type;
+ enum projection projection;
+ double * numd;
+ struct color *color;
+ struct coord_geo *coord_geo;
+ struct navit *navit;
+ struct callback *callback;
+ struct callback_list *callback_list;
+ struct vehicle *vehicle;
+ struct layout *layout;
+ struct layer *layer;
+ struct map *map;
+ struct mapset *mapset;
+ struct log *log;
+ struct route *route;
+ struct navigation *navigation;
+ struct coord *coord;
+ struct pcoord *pcoord;
+ struct gui *gui;
+ struct graphics *graphics;
+ struct tracking *tracking;
+ struct itemgra *itemgra;
+ struct plugin *plugin;
+ struct plugins *plugins;
+ struct polygon *polygon;
+ struct polyline *polyline;
+ struct circle *circle;
+ struct text *text;
+ struct icon *icon;
+ struct image *image;
+ struct arrows *arrows;
+ struct element *element;
+ struct speech *speech;
+ struct cursor *cursor;
+ struct displaylist *displaylist;
+ struct transformation *transformation;
+ struct vehicleprofile *vehicleprofile;
+ struct roadprofile *roadprofile;
+ struct bookmarks *bookmarks;
+ struct config *config;
+ struct osd *osd;
+ struct range range;
+ struct navit_object *navit_object;
+ struct osd_display_coordinate *osd_display_coordinate;
+ int *dash;
+ enum item_type *item_types;
+ enum attr_type *attr_types;
+ long long *num64;
+ struct attr *attrs;
+ } u;
};
struct attr_iter;
@@ -222,7 +224,8 @@ struct attr *attr_new_from_text(const char *name, const char *value);
char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map);
char *attr_to_text(struct attr *attr, struct map *map, int pretty);
struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
-int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr,
+ struct attr_iter *iter);
struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
struct attr **attr_generic_add_attr(struct attr **attrs, struct attr *attr);
struct attr **attr_generic_add_attr_list(struct attr **attrs, struct attr **add);
@@ -243,7 +246,6 @@ 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/attr_def.h b/navit/attr_def.h
index 4d859d1fa..f6829d4a0 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -200,16 +200,6 @@ ATTR(turn_around_penalty)
ATTR(turn_around_penalty2)
ATTR(autozoom_max)
ATTR(nav_status)
-ATTR2(0x00027500,type_rel_abs_begin)
-/* These attributes are int that can either hold relative or absolute values. See the
- * documentation of ATTR_REL_RELSHIFT for details.
- */
-ATTR(h)
-ATTR(w)
-ATTR(x)
-ATTR(y)
-ATTR(font_size)
-
ATTR2(0x00028000,type_boolean_begin)
/* boolean */
ATTR(overwrite)
@@ -414,6 +404,19 @@ ATTR(ch_edge)
ATTR(zipfile_ref_block)
ATTR(item_id)
ATTR(pdl_gps_update)
+ATTR2(0x00044000,type_osd_coordinate_begin)
+/** These attributes hold display coordinates and sizes. They may be given in
+ * -% for relative to scrren width or height,
+ * -in for size in inches. Obeys dpi value.
+ * -mm for size in mm. Obeys dpi value.
+ * in pixels.
+ */
+ATTR(h)
+ATTR(w)
+ATTR(x)
+ATTR(y)
+ATTR(font_size)
+ATTR2(0x0004ffff,type_osd_coordinate_end)
ATTR2(0x0004ffff,type_special_end)
ATTR2(0x00050000,type_double_begin)
ATTR(position_height)
diff --git a/navit/graphics.c b/navit/graphics.c
index 1bb7dbd3c..c69f62bbb 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -51,6 +51,7 @@
#include "callback.h"
#include "file.h"
#include "event.h"
+#include "osd.h"
//##############################################################################################################
@@ -203,7 +204,7 @@ static int graphics_set_attr_do(struct graphics *gra, struct attr *attr) {
gra->contrast=attr->u.num;
break;
case attr_font_size:
- gra->font_size=attr->u.num;
+ gra->font_size=attr->u.osd_display_coordinate->num;
return 1;
default:
return 0;
@@ -2941,3 +2942,15 @@ static void graphics_process_selection(struct graphics *gra, struct displaylist
}
}
+/**
+ * @brief get display resolution in DPI
+ * This method returns the native display density in DPI
+ * @param gra graphics handle
+ * @returns dpi value. May be fraction therefore double.
+ */
+double graphics_get_dpi(struct graphics *gra) {
+ if (!gra->meth.get_dpi)
+ return 96;
+ return (gra->meth.get_dpi(gra->priv));
+}
+
diff --git a/navit/graphics.h b/navit/graphics.h
index befeb8e2b..7bbf796f3 100644
--- a/navit/graphics.h
+++ b/navit/graphics.h
@@ -42,7 +42,7 @@ struct mapset;
/* This enum must be synchronized with the constants in NavitGraphics.java. */
enum draw_mode_num {
- draw_mode_begin, draw_mode_end
+ draw_mode_begin, draw_mode_end
};
struct graphics_priv;
@@ -54,14 +54,14 @@ struct graphics_gc_methods;
struct graphics_image_methods;
enum graphics_image_type {
- graphics_image_type_unknown=0,
+ graphics_image_type_unknown=0,
};
struct graphics_image_buffer {
- char magic[8]; /* buffer:\0 */
- enum graphics_image_type type;
- void *start;
- int len;
+ char magic[8]; /* buffer:\0 */
+ enum graphics_image_type type;
+ void *start;
+ int len;
};
struct graphics_keyboard_priv;
@@ -70,20 +70,20 @@ struct graphics_keyboard_priv;
* Describes an instance of the native on-screen keyboard or other input method.
*/
struct graphics_keyboard {
- int w; /**< The width of the area obscured by the keyboard (-1 for full width) */
- int h; /**< The height of the area obscured by the keyboard (-1 for full height) */
- /* TODO mode is currently a copy of the respective value in the internal GUI and uses the same values.
- * This may need to be changed to something with globally available enum, possibly with revised values.
- * The Android implementation (the first to support a native on-screen keyboard) does not use this field
- * due to limitations of the platform. */
- int mode; /**< Mode flags for the keyboard */
- char *lang; /**< The preferred language for text input, may be {@code NULL}. */
- void *gui_priv; /**< Private data determined by the GUI. The GUI may store
+ int w; /**< The width of the area obscured by the keyboard (-1 for full width) */
+ int h; /**< The height of the area obscured by the keyboard (-1 for full height) */
+ /* TODO mode is currently a copy of the respective value in the internal GUI and uses the same values.
+ * This may need to be changed to something with globally available enum, possibly with revised values.
+ * The Android implementation (the first to support a native on-screen keyboard) does not use this field
+ * due to limitations of the platform. */
+ int mode; /**< Mode flags for the keyboard */
+ char *lang; /**< The preferred language for text input, may be {@code NULL}. */
+ void *gui_priv; /**< Private data determined by the GUI. The GUI may store
* a pointer to a data structure of its choice here. It is
* the responsibility of the GUI to free the data structure
* when it is no longer needed. The graphics plugin should
* not access this member. */
- struct graphics_keyboard_priv *gra_priv; /**< Private data determined by the graphics plugin. The
+ struct graphics_keyboard_priv *gra_priv; /**< Private data determined by the graphics plugin. The
* graphics plugin is responsible for its management. If it
* uses this member, it must free the associated data in
* its {@code hide_native_keyboard} method. */
@@ -108,67 +108,75 @@ struct graphics_keyboard {
* to be visible as long as Navit is in the foreground.
*/
struct padding {
- int left;
- int top;
- int right;
- int bottom;
+ int left;
+ int top;
+ int right;
+ int bottom;
};
struct graphics_methods {
- void (*graphics_destroy)(struct graphics_priv *gr);
- void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
- void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
- void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
- void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h);
- void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r);
- void (*draw_text)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy);
- 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, struct graphics_image_priv *img);
- void (*draw_drag)(struct graphics_priv *gr, struct point *p);
- struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, 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, int wraparound);
- /** @brief Load an image from a file.
- *
- * @param gr graphics object
- * @param meth output parameter for graphics methods object
- * @param path file name/path of image to load
- * @param w In: width to scale image to, or IMAGE_W_H_UNSET for original width.
- * Out: Actual width of returned image.
- * @param h heigth; see w
- * @param hot output parameter for image hotspot
- * @param rotate angle to rotate the image, in 90 degree steps (not supported by all plugins).
- * @return pointer to allocated image, to be freed by image_free()
- * @see image_free()
- */
- struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation);
- void *(*get_data)(struct graphics_priv *gr, const char *type);
- void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
- void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate);
- void (*overlay_disable)(struct graphics_priv *gr, int disable);
- void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound);
- int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
- int (*show_native_keyboard)(struct graphics_keyboard *kbd);
- void (*hide_native_keyboard)(struct graphics_keyboard *kbd);
+ void (*graphics_destroy)(struct graphics_priv *gr);
+ void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
+ void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
+ void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
+ void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h);
+ void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r);
+ void (*draw_text)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg,
+ struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy);
+ 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,
+ struct graphics_image_priv *img);
+ void (*draw_drag)(struct graphics_priv *gr, struct point *p);
+ struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font,
+ 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, int wraparound);
+ /** @brief Load an image from a file.
+ *
+ * @param gr graphics object
+ * @param meth output parameter for graphics methods object
+ * @param path file name/path of image to load
+ * @param w In: width to scale image to, or IMAGE_W_H_UNSET for original width.
+ * Out: Actual width of returned image.
+ * @param h heigth; see w
+ * @param hot output parameter for image hotspot
+ * @param rotate angle to rotate the image, in 90 degree steps (not supported by all plugins).
+ * @return pointer to allocated image, to be freed by image_free()
+ * @see image_free()
+ */
+ struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path,
+ int *w, int *h, struct point *hot, int rotation);
+ void *(*get_data)(struct graphics_priv *gr, const char *type);
+ void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
+ void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy,
+ struct point *ret, int estimate);
+ void (*overlay_disable)(struct graphics_priv *gr, int disable);
+ void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound);
+ int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
+ int (*show_native_keyboard)(struct graphics_keyboard *kbd);
+ void (*hide_native_keyboard)(struct graphics_keyboard *kbd);
+ double (*get_dpi)(struct graphics_priv * gr);
};
struct graphics_font_methods {
- void (*font_destroy)(struct graphics_font_priv *font);
+ void (*font_destroy)(struct graphics_font_priv *font);
};
struct graphics_font {
- struct graphics_font_priv *priv;
- struct graphics_font_methods meth;
+ struct graphics_font_priv *priv;
+ struct graphics_font_methods meth;
};
struct graphics_gc_methods {
- void (*gc_destroy)(struct graphics_gc_priv *gc);
- void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
- void (*gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n);
- void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
- void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
+ void (*gc_destroy)(struct graphics_gc_priv *gc);
+ void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
+ void (*gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n);
+ void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
+ void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
};
/**
@@ -177,26 +185,26 @@ struct graphics_gc_methods {
* linewidth and drawing color.
*/
struct graphics_gc {
- struct graphics_gc_priv *priv;
- struct graphics_gc_methods meth;
- struct graphics *gra;
+ struct graphics_gc_priv *priv;
+ struct graphics_gc_methods meth;
+ struct graphics *gra;
};
struct graphics_image_methods {
- void (*image_destroy)(struct graphics_image_priv *img);
+ void (*image_destroy)(struct graphics_image_priv *img);
};
struct graphics_image {
- struct graphics_image_priv *priv;
- struct graphics_image_methods meth;
- int width;
- int height;
- struct point hot;
+ struct graphics_image_priv *priv;
+ struct graphics_image_methods meth;
+ int width;
+ int height;
+ struct point hot;
};
struct graphics_data_image {
- void *data;
- int size;
+ void *data;
+ int size;
};
/* prototypes */
@@ -250,9 +258,12 @@ void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
-void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill);
-void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy);
-void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
+void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h,
+ int r, int fill);
+void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2,
+ struct graphics_font *font, char *text, struct point *p, int dx, int dy);
+void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy,
+ struct point *ret, int estimate);
void graphics_overlay_disable(struct graphics *this_, int disable);
int graphics_is_disabled(struct graphics *this_);
void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
@@ -261,8 +272,10 @@ void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p);
char *graphics_icon_path(const char *icon);
void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label);
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags);
-void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags);
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans,
+ struct layout *l, int flags);
+void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset,
+ struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags);
int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
@@ -276,14 +289,17 @@ int graphics_displayitem_get_coord_count(struct displayitem *di);
char *graphics_displayitem_get_label(struct displayitem *di);
int graphics_displayitem_get_displayed(struct displayitem *di);
int graphics_displayitem_get_z_order(struct displayitem *di);
-int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist);
+int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p,
+ int dist);
void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
int graphics_show_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd);
int graphics_hide_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd);
void graphics_draw_polygon_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pin, int count_in);
-void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int poly);
+void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count,
+ int *width, int poly);
+double graphics_get_dpi(struct graphics *gra);
/* end of prototypes */
#ifdef __cplusplus
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp
index e7b31c605..5b6c62509 100644
--- a/navit/graphics/qt5/graphics_qt5.cpp
+++ b/navit/graphics/qt5/graphics_qt5.cpp
@@ -809,6 +809,21 @@ static void overlay_resize(struct graphics_priv* gr, struct point* p, int w, int
#endif
}
+/**
+ * @brief Return number of dots per inch
+ * @param gr self handle
+ * @return dpi value
+ */
+double get_dpi(struct graphics_priv * gr) {
+ qreal dpi = 96;
+ QScreen* primary = navit_app->primaryScreen();
+ if (primary != NULL) {
+ dpi = primary->logicalDotsPerInch();
+ }
+ return (double)dpi;
+
+}
+
static struct graphics_methods graphics_methods = {
graphics_destroy,
draw_mode,
@@ -830,6 +845,10 @@ static struct graphics_methods graphics_methods = {
get_text_bbox,
overlay_disable,
overlay_resize,
+ NULL, //set_attr
+ NULL, //show_native_keyboard
+ NULL, //hide_native_keyboard
+ get_dpi
};
/* create new graphics context on given context */
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index 726a03d17..8c9e35660 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -79,6 +79,7 @@
#include "debug.h"
#include "fib.h"
#include "types.h"
+#include "osd.h"
#include "gui_internal_widget.h"
#include "gui_internal_priv.h"
#include "gui_internal_html.h"
@@ -1642,6 +1643,7 @@ char *gui_internal_cmd_match_expand(char *pattern, struct attr **in) {
break;
case '\\':
p=*pattern++;
+ // fall through
default:
*r++=p;
}
@@ -1663,6 +1665,7 @@ static int gui_internal_match(const char *pattern, const char *string) {
break;
case '\\':
p=*pattern++;
+ // fall through
default:
if (*string++ != p)
return 0;
@@ -3195,7 +3198,7 @@ static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods
gui_internal_command_init(this, attrs);
if( (attr=attr_search(attrs,NULL,attr_font_size))) {
- this->config.font_size=attr->u.num;
+ this->config.font_size=attr->u.osd_display_coordinate->num;
} else {
this->config.font_size=-1;
}
diff --git a/navit/osd.c b/navit/osd.c
index 8b548b044..57e6af78f 100644
--- a/navit/osd.c
+++ b/navit/osd.c
@@ -188,16 +188,16 @@ void osd_std_calculate_sizes(struct osd_item *item, int w, int h) {
h -= (padding->top + padding->bottom);
}
- if(item->rel_w!=ATTR_REL_RELSHIFT)
- item->w=attr_rel2real(item->rel_w, w, 1);
+ if(!((item->rel_w.type == REL) && (item->rel_w.num == 0)))
+ item->w=osd_rel2real(item->navit, &(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->rel_h.type == REL) && (item->rel_h.num == 0)))
+ item->h=osd_rel2real(item->navit,&(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);
+ item->p.x=osd_rel2real(item->navit, &(item->rel_x), w, 1);
+ item->p.y=osd_rel2real(item->navit, &(item->rel_y), h, 1);
/* add left and top padding to item->p */
if (padding) {
@@ -312,27 +312,27 @@ void osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags) {
attr = attr_search(attrs, NULL, attr_w);
if (attr) {
- item->rel_w = attr->u.num;
+ item->rel_w = *(attr->u.osd_display_coordinate);
}
attr = attr_search(attrs, NULL, attr_h);
if (attr) {
- item->rel_h = attr->u.num;
+ item->rel_h = *(attr->u.osd_display_coordinate);
}
attr = attr_search(attrs, NULL, attr_x);
if (attr) {
- item->rel_x = attr->u.num;
+ item->rel_x = *(attr->u.osd_display_coordinate);
}
attr = attr_search(attrs, NULL, attr_y);
if (attr) {
- item->rel_y = attr->u.num;
+ item->rel_y = *(attr->u.osd_display_coordinate);
}
attr = attr_search(attrs, NULL, attr_font_size);
if (attr)
- item->font_size = attr->u.num;
+ item->font_size = *(attr->u.osd_display_coordinate);
attr=attr_search(attrs, NULL, attr_background_color);
if (attr)
@@ -442,7 +442,7 @@ void osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_pr
graphics_gc_set_foreground(item->graphic_fg, &item->color_fg);
if (item->flags & ITEM_HAS_TEXT) {
- item->font = graphics_named_font_new(item->gr, item->font_name, item->font_size, 1);
+ item->font = graphics_named_font_new(item->gr, item->font_name, item->font_size.num, 1);
item->graphic_fg_text = graphics_gc_new(item->gr);
graphics_gc_set_foreground(item->graphic_fg_text, &item->text_color);
}
@@ -477,3 +477,48 @@ struct object_func osd_func = {
(object_func_ref)navit_object_ref,
(object_func_unref)navit_object_unref,
};
+
+/**
+ * @brief Convert mm to inches
+ *
+ * @param Value in mm
+ *
+ * @return Value in inches
+ */
+static inline double osd_mm_to_in(double mm) {
+ return (mm * 0.03937007874);
+}
+
+/**
+ * @brief Derive absolute value from relative attribute, given value of the whole range.
+ *
+ * @param nav navit handle to get screen dpi value.
+ * @param attrval Value of u.osd_display_coordinate member of attribute capable of holding display coordinates.
+ * @param whole Range counted as 100%.
+ * @param treat_neg_as_rel Replace negative absolute values with whole+attr.u.num.
+ *
+ * @return Absolute value corresponding to given relative value.
+ */
+int osd_rel2real(struct navit *nav, const struct osd_display_coordinate * attrval, int whole, int treat_neg_as_rel) {
+ int result;
+ double dpi;
+
+ /* get graphics handle if one */
+ struct graphics *navit_gr = navit_get_graphics(nav);
+ /* get screen dpi value */
+ dpi = graphics_get_dpi(navit_gr);
+
+ if (attrval->type == REL)
+ result = (((double)whole) * attrval->num)/ ((double)100);
+ else if (attrval->type == MM) {
+ result = osd_mm_to_in(attrval->num) * dpi;
+ } else if (attrval->type == IN) {
+ result = attrval->num * dpi;
+ } else
+ result = attrval->num;
+ if(treat_neg_as_rel && (result <0) )
+ result = whole+result;
+ dbg(lvl_error, "attrval->type %d, attrval->num %f, whole %d, neg_as_rel %d, dpi %f, -> %d", attrval->type, attrval->num,
+ whole, treat_neg_as_rel, dpi, result);
+ return result;
+}
diff --git a/navit/osd.h b/navit/osd.h
index 8694bcd05..6e454358f 100644
--- a/navit/osd.h
+++ b/navit/osd.h
@@ -28,38 +28,50 @@ struct attr;
#define DISABLE_OVERLAY 4
struct osd_methods {
- void (*osd_destroy)(struct osd_priv *osd);
- int (*set_attr)(struct osd_priv *osd, struct attr* attr);
- void (*destroy)(struct osd_priv *osd);
- int (*get_attr)(struct osd_priv *osd, enum attr_type type, struct attr* attr);
+ void (*osd_destroy)(struct osd_priv *osd);
+ int (*set_attr)(struct osd_priv *osd, struct attr* attr);
+ void (*destroy)(struct osd_priv *osd);
+ int (*get_attr)(struct osd_priv *osd, enum attr_type type, struct attr* attr);
};
#define osd_draw_cast(x) (void (*)(struct osd_priv *osd, struct navit *navit, struct vehicle *v))(x)
struct osd_item_methods {
- void (*draw)(struct osd_priv *osd, struct navit *navit, struct vehicle *v);
+ void (*draw)(struct osd_priv *osd, struct navit *navit, struct vehicle *v);
+};
+
+typedef enum {
+ PIXELS=0, /** number is in pixels. No calculation required */
+ MM, /** number is in mm. Use dpi value to calculate to pixels */
+ IN, /** number is in inches. Use dpi value to calculate to pixels */
+ REL /** number is in % display space. Use available pixels to calculate to pixels */
+} osd_display_coordinate_type;
+
+struct osd_display_coordinate {
+ double num;
+ osd_display_coordinate_type type;
};
struct osd_item {
- struct point p;
- struct osd_item_methods meth;
- int flags, w, h, fg_line_width, font_size, osd_configuration, configured;
- int rel_w, rel_h, rel_x, rel_y;
- struct color color_bg, color_fg, text_color;
- struct navit *navit;
- struct graphics *gr;
- struct graphics_gc *graphic_bg, *graphic_fg, *graphic_fg_text;
- struct graphics_font *font;
- char *font_name;
- struct callback *cb;
- struct callback *resize_cb;
- struct callback *reconfig_cb;
- struct callback *keypress_cb;
- int pressed;
- char *command;
- struct command_saved *enable_cs;
- char *accesskey;
- int do_draw; /**< Whether the item needs to be redrawn. */
+ struct point p;
+ struct osd_item_methods meth;
+ int flags, w, h, fg_line_width, osd_configuration, configured;
+ struct osd_display_coordinate rel_w, rel_h, rel_x, rel_y, font_size;
+ struct color color_bg, color_fg, text_color;
+ struct navit *navit;
+ struct graphics *gr;
+ struct graphics_gc *graphic_bg, *graphic_fg, *graphic_fg_text;
+ struct graphics_font *font;
+ char *font_name;
+ struct callback *cb;
+ struct callback *resize_cb;
+ struct callback *reconfig_cb;
+ struct callback *keypress_cb;
+ int pressed;
+ char *command;
+ struct command_saved *enable_cs;
+ char *accesskey;
+ int do_draw; /**< Whether the item needs to be redrawn. */
};
/* prototypes */
@@ -80,6 +92,7 @@ void osd_std_calculate_sizes(struct osd_item *item, int w, int h);
void osd_fill_with_bgcolor(struct osd_item *item);
int osd_set_attr(struct osd *osd, struct attr* attr);
int osd_get_attr(struct osd *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int osd_rel2real(struct navit *nav, const struct osd_display_coordinate * attrval, int whole, int treat_neg_as_rel);
/* end of prototypes */
#endif
diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c
index e1329ffe2..1f255dc22 100644
--- a/navit/osd/core/osd_core.c
+++ b/navit/osd/core/osd_core.c
@@ -310,22 +310,22 @@ static char *format_float_0(double num) {
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)) {
+ if(opc && the_attr && ATTR_IS_OSD_DISPLAY_COORDINATE(the_attr->type)) {
int attr_set=0;
if(attr_w == the_attr->type) {
- opc->osd_item.rel_w = the_attr->u.num;
+ opc->osd_item.rel_w = *(the_attr->u.osd_display_coordinate);
attr_set=1;
} else if(attr_h == the_attr->type) {
- opc->osd_item.rel_h = the_attr->u.num;
+ opc->osd_item.rel_h = *(the_attr->u.osd_display_coordinate);
attr_set=1;
} else if(attr_x == the_attr->type) {
- opc->osd_item.rel_x = the_attr->u.num;
+ opc->osd_item.rel_x = *(the_attr->u.osd_display_coordinate);
attr_set=1;
} else if(attr_y == the_attr->type) {
- opc->osd_item.rel_y = the_attr->u.num;
+ opc->osd_item.rel_y = *(the_attr->u.osd_display_coordinate);
attr_set=1;
} else if(attr_font_size == the_attr->type) {
- opc->osd_item.font_size = the_attr->u.num;
+ opc->osd_item.font_size = *(the_attr->u.osd_display_coordinate);
attr_set=1;
}
if(attr_set && opc->osd_item.gr) {
@@ -504,12 +504,17 @@ static struct osd_priv *osd_route_guard_new(struct navit *nav, struct osd_method
struct attr *attr;
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 120;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 80;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_route_guard_draw);
meth->set_attr = set_std_osd_attr;
@@ -722,7 +727,7 @@ static void draw_multiline_osd_text(char *buffer,struct osd_item *osd_item, stru
* */
static void draw_aligned_osd_text(char *buffer, int align, struct osd_item *osd_item, struct graphics_gc *curr_color) {
- int height=osd_item->font_size*13/256;
+ int height=osd_item->font_size.num*13/256;
int yspacing=height/2;
int xspacing=height/4;
char *next, *last;
@@ -767,6 +772,7 @@ static void draw_aligned_osd_text(char *buffer, int align, struct osd_item *osd_
if (do_draw) {
osd_std_resize(osd_item);
}
+ //fall through
default:
p.y=(osd_item->h-lines*(height+yspacing)-yspacing)/2;
}
@@ -1052,12 +1058,17 @@ static struct osd_priv *osd_odometer_new(struct navit *nav, struct osd_methods *
struct color orange_color= {0xffff,0xa5a5,0x0000,0xffff};
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 120;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 80;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_odometer_draw);
meth->set_attr = set_std_osd_attr;
@@ -1264,12 +1275,17 @@ static struct osd_priv *osd_cmd_interface_new(struct navit *nav, struct osd_meth
struct attr *attr;
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 120;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 80;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_cmd_interface_draw);
opc->spec_set_attr_func = osd_cmd_interface_set_attr;
@@ -1419,12 +1435,17 @@ static struct osd_priv *osd_stopwatch_new(struct navit *nav, struct osd_methods
struct color orange_color= {0xffff,0xa5a5,0x0000,0xffff};
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 120;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 80;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_stopwatch_draw);
meth->set_attr = set_std_osd_attr;
@@ -1539,12 +1560,17 @@ static struct osd_priv *osd_compass_new(struct navit *nav, struct osd_methods *m
struct color red_color= {0xffff,0x0400,0x0400,0xffff};
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 20;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 80;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_compass_draw);
meth->set_attr = set_std_osd_attr;
osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
@@ -1587,9 +1613,9 @@ struct osd_button {
* @param img The image displayed by the item
*/
static void osd_button_adjust_sizes(struct osd_priv_common *opc, struct graphics_image *img) {
- if(opc->osd_item.rel_w==ATTR_REL_RELSHIFT)
+ if((opc->osd_item.rel_w.type == REL) && (opc->osd_item.rel_w.num == 0))
opc->osd_item.w=img->width;
- if(opc->osd_item.rel_h==ATTR_REL_RELSHIFT)
+ if((opc->osd_item.rel_h.type == REL) && (opc->osd_item.rel_h.num == 0))
opc->osd_item.h=img->height;
}
@@ -1648,7 +1674,7 @@ static void osd_button_init(struct osd_priv_common *opc, struct navit *nav) {
opc->osd_item.h = -1;
}
dbg(lvl_debug, "enter");
- dbg(lvl_debug, "Get: %s, %d, %d, %d, %d", this->src, opc->osd_item.rel_w, opc->osd_item.rel_h, opc->osd_item.w,
+ dbg(lvl_debug, "Get: %s, %f, %f, %d, %d", this->src, opc->osd_item.rel_w.num, opc->osd_item.rel_h.num, opc->osd_item.w,
opc->osd_item.h);
this->img = graphics_image_new_scaled(gra, this->src, opc->osd_item.w, opc->osd_item.h);
if (!this->img) {
@@ -1732,8 +1758,10 @@ static struct osd_priv *osd_button_new(struct navit *nav, struct osd_methods *me
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;
+ opc->osd_item.rel_w.type = REL;
+ opc->osd_item.rel_w.num = 0;
+ opc->osd_item.rel_h.type = REL;
+ opc->osd_item.rel_h.num = 0;
meth->set_attr = set_std_osd_attr;
opc->spec_set_attr_func = osd_button_set_attr;
@@ -1817,8 +1845,10 @@ static struct osd_priv *osd_image_new(struct navit *nav, struct osd_methods *met
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;
+ opc->osd_item.rel_w.type = REL;
+ opc->osd_item.rel_w.num = 0;
+ opc->osd_item.rel_h.type = REL;
+ opc->osd_item.rel_h.num = 0;
meth->set_attr = set_std_osd_attr;
opc->spec_set_attr_func = osd_button_set_attr;
@@ -2002,12 +2032,17 @@ static struct osd_priv *osd_navigation_status_new(struct navit *nav, struct osd_
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 70;
+ opc->osd_item.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 20;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = -80;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 70;
opc->osd_item.navit = nav;
- opc->osd_item.rel_h = 70;
- opc->osd_item.font_size = 200; // FIXME may not be needed
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 70;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200; // FIXME may not be needed
opc->osd_item.meth.draw = osd_draw_cast(osd_navigation_status_draw);
meth->set_attr = set_std_osd_attr;
osd_set_std_attr(attrs, &opc->osd_item, 0);
@@ -2146,12 +2181,17 @@ static struct osd_priv *osd_nav_next_turn_new(struct navit *nav, struct osd_meth
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 70;
+ opc->osd_item.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 20;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = -80;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 70;
opc->osd_item.navit = nav;
- opc->osd_item.rel_h = 70;
- opc->osd_item.font_size = 200;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 70;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_nav_next_turn_draw);
meth->set_attr = set_std_osd_attr;
@@ -2271,10 +2311,14 @@ static struct osd_priv *osd_nav_toggle_announcer_new(struct navit *nav, struct o
char *command = "announcer_toggle()";
opc->data = (void*)this;
- 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.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 48;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 48;
+ opc->osd_item.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = -64;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 76;
opc->osd_item.navit = nav;
opc->osd_item.meth.draw = osd_draw_cast(osd_nav_toggle_announcer_draw);
meth->set_attr = set_std_osd_attr;
@@ -2554,7 +2598,8 @@ static struct osd_priv *osd_speed_cam_new(struct navit *nav, struct osd_methods
opc->osd_item.w = 60;
opc->osd_item.h = 80;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_speed_cam_draw);
meth->set_attr = set_std_osd_attr;
@@ -2805,10 +2850,14 @@ static struct osd_priv *osd_speed_warner_new(struct navit *nav, struct osd_metho
struct attr *attr;
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num=-80;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num=20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num=60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num=60;
opc->osd_item.navit = nav;
this->active=-1;
opc->osd_item.meth.draw = osd_draw_cast(osd_speed_warner_draw);
@@ -2969,6 +3018,7 @@ static char *osd_text_format_attr(struct attr *attr, char *format, int imperial)
g_free(tmp);
return ret;
}
+ break;
case attr_position_time_iso8601:
if ((!format) || (!strcmp(format,"iso8601"))) {
break;
@@ -3060,7 +3110,7 @@ static void osd_text_draw(struct osd_priv_common *opc, struct navit *navit, stru
struct item *item;
struct osd_text_item *oti;
int offset,lines;
- int height=opc->osd_item.font_size*13/256;
+ int height=opc->osd_item.font_size.num*13/256;
int yspacing=height/2;
int xspacing=height/4;
int imperial=0;
@@ -3233,6 +3283,7 @@ static void osd_text_draw(struct osd_priv_common *opc, struct navit *navit, stru
if (do_draw) {
osd_std_resize(&opc->osd_item);
}
+ //fall through
default:
p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing)/2;
}
@@ -3434,12 +3485,17 @@ static struct osd_priv *osd_text_new(struct navit *nav, struct osd_methods *meth
struct attr *attr;
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = -80;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = 20;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 20;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_text_draw);
meth->set_attr = set_std_osd_attr;
opc->spec_set_attr_func = osd_text_set_attr;
@@ -3542,12 +3598,17 @@ static struct osd_priv *osd_gps_status_new(struct navit *nav, struct osd_methods
struct attr *attr;
opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 20;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = -80;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
opc->osd_item.navit = nav;
- opc->osd_item.rel_h = 40;
- opc->osd_item.font_size = 200;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 40;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_gps_status_draw);
meth->set_attr = set_std_osd_attr;
@@ -3646,12 +3707,17 @@ static struct osd_priv *osd_volume_new(struct navit *nav, struct osd_methods *me
struct attr *attr;
opc->data = (void*)this;
- 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.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 20;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = -80;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 40;
opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.meth.draw = osd_draw_cast(osd_volume_draw);
meth->set_attr = set_std_osd_attr;
@@ -3812,7 +3878,8 @@ static struct osd_priv *osd_scale_new(struct navit *nav, struct osd_methods *met
struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
opc->data = (void*)this;
- opc->osd_item.font_size = 200;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
opc->osd_item.navit = nav;
opc->osd_item.meth.draw = osd_draw_cast(osd_scale_draw);
meth->set_attr = set_std_osd_attr;
@@ -3849,7 +3916,7 @@ static void osd_auxmap_draw(struct osd_priv_common *opc) {
p.x=opc->osd_item.w/2;
p.y=opc->osd_item.h/2;
- if (opc->osd_item.rel_h || opc->osd_item.rel_w) {
+ if (opc->osd_item.rel_h.num || opc->osd_item.rel_w.num) {
struct map_selection sel;
memset(&sel, 0, sizeof(sel));
sel.u.p_rect.rl.x=opc->osd_item.w;
@@ -3917,11 +3984,16 @@ static struct osd_priv *osd_auxmap_new(struct navit *nav, struct osd_methods *me
struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
opc->data = (void*)this;
- 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;
+ opc->osd_item.rel_x.type = PIXELS;
+ opc->osd_item.rel_x.num = 20;
+ opc->osd_item.rel_y.type = PIXELS;
+ opc->osd_item.rel_y.num = -80;
+ opc->osd_item.rel_w.type = PIXELS;
+ opc->osd_item.rel_w.num = 60;
+ opc->osd_item.rel_h.type = PIXELS;
+ opc->osd_item.rel_h.num = 40;
+ opc->osd_item.font_size.type = PIXELS;
+ opc->osd_item.font_size.num = 200;
meth->set_attr = set_std_osd_attr;
osd_set_std_attr(attrs, &opc->osd_item, 0);