Skip to content

Commit

Permalink
add:graphics:dpi scaling support (#813)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
metalstrolch committed Jul 28, 2019
1 parent b6c0c86 commit 6bc6c0c
Show file tree
Hide file tree
Showing 8 changed files with 390 additions and 131 deletions.
2 changes: 2 additions & 0 deletions navit/attr_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ ATTR(turn_around_penalty)
ATTR(turn_around_penalty2)
ATTR(autozoom_max)
ATTR(nav_status)
ATTR(virtual_dpi)
ATTR(real_dpi)
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.
Expand Down
12 changes: 12 additions & 0 deletions navit/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "debug.h"
#include "callback.h"


struct callback {
/* func has variable number of arguments, not (void),
* but we must declare something... */
Expand All @@ -34,6 +35,8 @@ struct callback {
};

struct callback_list {
callback_patch patch;
void * patch_context;
GList *list;
};

Expand Down Expand Up @@ -115,6 +118,13 @@ void callback_list_remove_destroy(struct callback_list *l, struct callback *cb)
g_free(cb);
}

void callback_list_add_patch_function (struct callback_list *l, callback_patch patch, void * context) {
if(!l)
return;
l->patch = patch;
l->patch_context = context;
}

void callback_call(struct callback *cb, int pcount, void **p) {
int i;
void *pf[8];
Expand Down Expand Up @@ -193,6 +203,8 @@ void callback_list_call_attr(struct callback_list *l, enum attr_type type, int p
if (!l) {
return;
}
if(l->patch != NULL)
l->patch(l, type, pcount, p, l->patch_context);

cbi=l->list;
while (cbi) {
Expand Down
2 changes: 2 additions & 0 deletions navit/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {
enum attr_type;
struct callback;
struct callback_list;
typedef void (*callback_patch) (struct callback_list *l, enum attr_type type, int pcount, void **p, void * context);
struct callback_list *callback_list_new(void);
struct callback *callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p);
struct callback *callback_new_attr_args(void (*func)(void), enum attr_type type, int count, ...);
Expand All @@ -41,6 +42,7 @@ void callback_list_add(struct callback_list *l, struct callback *cb);
struct callback *callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p);
void callback_list_remove(struct callback_list *l, struct callback *cb);
void callback_list_remove_destroy(struct callback_list *l, struct callback *cb);
void callback_list_add_patch_function (struct callback_list *l, callback_patch patch, void * context);
void callback_call(struct callback *cb, int pcount, void **p);
void callback_call_args(struct callback *cb, int count, ...);
void callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p);
Expand Down

0 comments on commit 6bc6c0c

Please sign in to comment.