summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wildemann <gta04@metalstrolche.de>2019-07-21 13:07:20 +0200
committerStefan Wildemann <gta04@metalstrolche.de>2019-07-21 13:07:20 +0200
commit623e9b8b84a1351d62f6754e1e902f7ac111d63e (patch)
treec84e3eca3c4271072d9a131b8f5e97d671076a6a
parent61287a836fa02cce4d8dd442673e81541e0c5f4a (diff)
downloadnavit-623e9b8b84a1351d62f6754e1e902f7ac111d63e.tar.gz
add attr virtual_dpi and real_dpi
virtual_dpi gives the dpi value your config is designed against. real_dpi gives your screen resolution.
-rw-r--r--navit/attr_def.h2
-rw-r--r--navit/graphics.c14
2 files changed, 13 insertions, 3 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index 4d859d1fa..055936b4a 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -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.
diff --git a/navit/graphics.c b/navit/graphics.c
index 8216dc719..600392bef 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -330,7 +330,7 @@ static void graphics_dpi_patch (struct callback_list *l, enum attr_type type, in
*/
struct graphics * graphics_new(struct attr *parent, struct attr **attrs) {
struct graphics *this_;
- struct attr *type_attr, cbl_attr;
+ struct attr *type_attr, cbl_attr, *real_dpi_attr, *virtual_dpi_attr;
struct graphics_priv * (*graphicstype_new)(struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
struct callback_list *cbl);
@@ -344,10 +344,15 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs) {
dbg(lvl_error,"Failed to load graphics plugin %s.", type_attr->u.str);
return NULL;
}
+
+ virtual_dpi_attr=attr_search(attrs, NULL, attr_virtual_dpi);
+ real_dpi_attr=attr_search(attrs, NULL, attr_real_dpi);
+
this_=g_new0(struct graphics, 1);
this_->attrs=attr_list_dup(attrs);
- /*TODO: add attrs for virtual and real dpi */
this_->virtual_dpi = 96;
+ if(virtual_dpi_attr != NULL)
+ this_->virtual_dpi=virtual_dpi_attr->u.num;
this_->real_dpi = this_->virtual_dpi;
this_->cbl=callback_list_new();
cbl_attr.type=attr_callback_list;
@@ -360,7 +365,10 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs) {
this_->gamma=65536;
this_->font_size=20;
this_->image_cache_hash = g_hash_table_new_full(g_str_hash, g_str_equal,g_free,g_free);
- this_->real_dpi = graphics_get_dpi(this_);
+ if(real_dpi_attr != NULL)
+ this_->real_dpi=real_dpi_attr->u.num;
+ else
+ this_->real_dpi = graphics_get_dpi(this_);
dbg(lvl_error,"Using virtual dpi %f, real dpi %f", this_->virtual_dpi, this_->real_dpi);
if(this_->real_dpi != this_->virtual_dpi)
callback_list_call_attr_2(this_->cbl, attr_resize, GINT_TO_POINTER(navit_get_width(parent->u.navit)),