Add:Core:Made detail level for layouts configurable
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 26 Jul 2008 20:36:27 +0000 (20:36 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 26 Jul 2008 20:36:27 +0000 (20:36 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1231 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/attr_def.h
navit/graphics.c
navit/layout.c
navit/layout.h
navit/navit.c
navit/osm2navit.c
navit/xmlconfig.c

index d7ffaed..91c4043 100644 (file)
@@ -63,6 +63,7 @@ ATTR(vocabulary_name_systematic)
 ATTR(vocabulary_distances)
 ATTR(announce_name_systematic_first)
 ATTR(antialias)
+ATTR(order_delta)
 ATTR2(0x00028000,type_boolean_begin)
 /* boolean */
 ATTR(overwrite)
@@ -130,7 +131,7 @@ ATTR(command)
 ATTR(src)
 ATTR(path)
 ATTR2(0x0003ffff,type_string_end)
-ATTR(order_limit)
+ATTR(order)
 ATTR2(0x00050000,type_double_start)
 ATTR(position_height)
 ATTR(position_speed)
index 42c2172..ee7929e 100644 (file)
@@ -835,12 +835,12 @@ void graphics_displaylist_draw(struct graphics *gra, struct displaylist *display
        p.x=0;
        p.y=0;
        // FIXME find a better place to set the background color
-       graphics_gc_set_background(gra->gc[0], l->color);
-       graphics_gc_set_foreground(gra->gc[0], l->color);
+       graphics_gc_set_background(gra->gc[0], &l->color);
+       graphics_gc_set_foreground(gra->gc[0], &l->color);
        gra->meth.background_gc(gra->priv, gra->gc[0]->priv);
        gra->meth.draw_mode(gra->priv, draw_mode_begin);
        gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &p, 32767, 32767);
-       xdisplay_draw(displaylist->dl, gra, l, order);
+       xdisplay_draw(displaylist->dl, gra, l, order+l->order_delta);
        if (callback)
                callback_list_call_attr_0(gra->cbl, attr_postdraw);
        gra->meth.draw_mode(gra->priv, draw_mode_end);
@@ -892,6 +892,8 @@ void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList
        }
 #endif
        profile(0,NULL);
+       dbg(0,"delta=%d\n", l->order_delta);
+       order+=l->order_delta;
        do_draw(displaylist, trans, mapsets, order);
 //     profile(1,"do_draw");
        graphics_displaylist_draw(gra, displaylist, trans, l, 1);
index 8e2cb0e..653d2b5 100644 (file)
 
 #include <glib.h>
 #include <string.h>
+#include "item.h"
 #include "layout.h"
 
-struct layout * layout_new(const char *name, struct color *color)
+struct layout * layout_new(struct attr *parent, struct attr **attrs)
 {
        struct layout *l;
+       struct color def_color = {0xffff, 0xefef, 0xb7b7, 0xffff};
+       struct attr *name_attr,*color_attr,*order_delta_attr;
 
+
+       if (! (name_attr=attr_search(attrs, NULL, attr_name)))
+               return NULL;
        l = g_new0(struct layout, 1);
-       l->name = g_strdup(name);
-       l->color = g_new0(struct color,1);
-       *(l->color) = *color;
+       l->name = g_strdup(name_attr->u.str);
+       if ((color_attr=attr_search(attrs, NULL, attr_color)))
+               l->color = *color_attr->u.color;
+       else
+               l->color = def_color;
+       if ((order_delta_attr=attr_search(attrs, NULL, attr_order_delta)))
+               l->order_delta=order_delta_attr->u.num;
        return l;
 }
 
index 401e6fa..5d97052 100644 (file)
@@ -62,7 +62,7 @@ struct color;
 
 struct layer { char *name; int details; GList *itemtypes; };
 
-struct layout { char *name; struct color *color; GList *layers; };
+struct layout { char *name; struct color color; GList *layers; int order_delta; };
 
 /* prototypes */
 enum item_type;
@@ -70,7 +70,7 @@ struct element;
 struct itemtype;
 struct layer;
 struct layout;
-struct layout *layout_new(const char *name, struct color *color);
+struct layout *layout_new(struct attr *parent, struct attr **attrs);
 struct layer *layer_new(const char *name, int details);
 void layout_add_layer(struct layout *layout, struct layer *layer);
 struct itemtype *itemtype_new(int order_min, int order_max);
index beb7baf..6af9f4c 100644 (file)
@@ -161,15 +161,6 @@ navit_get_tracking(struct navit *this_)
 }
 
 void
-navit_add_layout(struct navit *this_, struct layout *lay)
-{
-       this_->layouts = g_list_append(this_->layouts, lay);
-       if(!this_->layout_current) {
-               this_->layout_current=lay;
-       }
-}
-
-void
 navit_draw(struct navit *this_)
 {
        GList *l;
@@ -1434,6 +1425,11 @@ navit_add_attr(struct navit *this_, struct attr *attr)
                return navit_set_gui(this_, attr->u.gui);
        case attr_graphics:
                return navit_set_graphics(this_, attr->u.graphics);
+       case attr_layout:
+               this_->layouts = g_list_append(this_->layouts, attr->u.layout);
+               if(!this_->layout_current) 
+                       this_->layout_current=attr->u.layout;
+               return 1;
        case attr_route:
                this_->route=attr->u.route;
                route_set_projection(this_->route, transform_get_projection(this_->trans));
index b49664f..d6db7fb 100644 (file)
@@ -1808,7 +1808,7 @@ phase34_process_file(int phase, FILE *in)
 struct index_item {
        struct item_bin item;
        struct rect r;
-       struct attr_bin attr_order_limit;
+       struct attr_bin attr_order;
        short min;
        short max;
        struct attr_bin attr_zipfile_ref;
@@ -1836,8 +1836,8 @@ index_submap_add(int phase, struct tile_head *th, GList **tiles_list)
        ii.item.type=type_submap;
        ii.item.clen=4;
 
-       ii.attr_order_limit.len=2;
-       ii.attr_order_limit.type=attr_order_limit;
+       ii.attr_order.len=2;
+       ii.attr_order.type=attr_order;
 
        ii.attr_zipfile_ref.len=2;
        ii.attr_zipfile_ref.type=attr_zipfile_ref;
index 84756b2..c8da7f1 100644 (file)
@@ -463,22 +463,6 @@ xmlconfig_map(struct xmlstate *state)
 }
 
 static int
-xmlconfig_layout(struct xmlstate *state)
-{
-       const char *name=find_attribute(state, "name", 1);
-       struct color color = {0xffff, 0xefef, 0xb7b7, 0xffff};
-
-       if (! name)
-               return 0;
-       find_color(state, 0, &color);
-       state->element_attr.u.data = layout_new(name, &color);
-       if (! state->element_attr.u.data)
-               return 0;
-       navit_add_layout(state->parent->element_attr.u.data, state->element_attr.u.data);
-       return 1;
-}
-
-static int
 xmlconfig_layer(struct xmlstate *state)
 {
        const char *name=find_attribute(state, "name", 1);
@@ -648,7 +632,7 @@ struct element_func {
        { "navit", "config", NULL, NEW(navit_new), ADD(navit_add_attr), INIT(navit_init), DESTROY(navit_destroy)},
        { "graphics", "navit", NULL, NEW(graphics_new), NULL, NULL, NULL},
        { "gui", "navit", NULL, NEW(gui_new), NULL, NULL, NULL},
-       { "layout", "navit", xmlconfig_layout},
+       { "layout", "navit", NULL, NEW(layout_new), NULL, NULL, NULL},
        { "layer", "layout", xmlconfig_layer},
        { "item", "layer", xmlconfig_item},
        { "circle", "item", xmlconfig_circle},