summaryrefslogtreecommitdiff
path: root/navit/graphics.h
diff options
context:
space:
mode:
authorStefan Wildemann <metalstrolch@users.noreply.github.com>2019-07-28 12:29:58 +0200
committerGitHub <noreply@github.com>2019-07-28 12:29:58 +0200
commit6bc6c0cca6c105450f7cc6f080c72d99f87c173f (patch)
treea8165965f15b9de8f38355101d6ab9717ab353f5 /navit/graphics.h
parentb6c0c8685f802091e2c37d88960266137d0fb6f2 (diff)
downloadnavit-6bc6c0cca6c105450f7cc6f080c72d99f87c173f.tar.gz
add:graphics:dpi scaling support (#813)
This commit adds calculating a scaling factor out of the virtual_dpi assumed when the layout was created, and the real_dpi value of the hardware. It is activated if "virtual_dpi" tag is set into the "graphics" tag on navit.xml. Currently only qt5 graphics implment returning the hardware dpi. But this can be simulated and overwritten by setting "real_dpi" tag to "graphics" tag on navit.xm on all available graphics.l
Diffstat (limited to 'navit/graphics.h')
-rw-r--r--navit/graphics.h181
1 files changed, 99 insertions, 82 deletions
diff --git a/navit/graphics.h b/navit/graphics.h
index befeb8e2b..eec44ae14 100644
--- a/navit/graphics.h
+++ b/navit/graphics.h
@@ -24,6 +24,7 @@
#ifndef NAVIT_GRAPHICS_H
#define NAVIT_GRAPHICS_H
+#include "coord.h"
#ifdef __cplusplus
extern "C" {
@@ -42,7 +43,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 +55,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 +71,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 +109,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);
+ navit_float (*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 +186,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 +259,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 +273,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 +290,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);
+navit_float graphics_get_dpi(struct graphics *gra);
/* end of prototypes */
#ifdef __cplusplus