Core:Fix:Make use of layout_current and add layouts from xml to the menu
authorhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 12 Feb 2008 14:32:14 +0000 (14:32 +0000)
committerhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Tue, 12 Feb 2008 14:32:14 +0000 (14:32 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@859 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/attr_def.h
navit/src/graphics.c
navit/src/graphics.h
navit/src/navit.c

index c8714bf..a1538ae 100644 (file)
@@ -87,6 +87,7 @@ ATTR(name)
 ATTR(source)
 ATTR(description)
 ATTR(gc_type)
+ATTR(layout)
 ATTR2(0x0003ffff,type_string_end)
 ATTR(order_limit)
 ATTR2(0x00050000,type_double_start)
index 125b5c2..b262d79 100644 (file)
@@ -428,7 +428,7 @@ xdisplay_draw_layer(GHashTable *display_list, struct graphics *gra, struct layer
 }
 
 static void
-xdisplay_draw_layout(GHashTable *display_list, struct graphics *gra, struct layout *l, int order)
+xdisplay_draw(GHashTable *display_list, struct graphics *gra, struct layout *l, int order)
 {
        GList *lays;
        struct layer *lay;
@@ -441,19 +441,6 @@ xdisplay_draw_layout(GHashTable *display_list, struct graphics *gra, struct layo
        }
 }
 
-static void
-xdisplay_draw(GHashTable *display_list, struct graphics *gra, GList *layouts, int order)
-{
-       struct layout *l;
-
-       while (layouts) {
-               l=layouts->data;
-               xdisplay_draw_layout(display_list, gra, l, order);
-               return;
-               layouts=g_list_next(layouts);
-       }
-}
-
 extern void *route_selection;
 
 static void
@@ -545,15 +532,15 @@ graphics_ready(struct graphics *this_)
 }
 
 void
-graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, GList *layouts)
+graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l)
 {
        int order=transform_get_order(trans);
        // FIXME find a better place to set the background color
-       graphics_gc_set_background(gra->gc[0], ((struct layout *)layouts->data)->color);
-       graphics_gc_set_foreground(gra->gc[0], ((struct layout *)layouts->data)->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);
-       xdisplay_draw(displaylist->dl, gra, layouts, order);
+       xdisplay_draw(displaylist->dl, gra, l, order);
        gra->meth.draw_mode(gra->priv, draw_mode_end);
 }
 
@@ -576,7 +563,7 @@ graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy)
 
 
 void
-graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, GList *layouts)
+graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, struct layout *l)
 {
        int order=transform_get_order(trans);
 
@@ -598,7 +585,7 @@ graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *maps
        profile(0,NULL);
        do_draw(displaylist, trans, mapsets, order);
        profile(1,"do_draw");
-       graphics_displaylist_draw(gra, displaylist, trans, layouts);
+       graphics_displaylist_draw(gra, displaylist, trans, l);
        profile(1,"xdisplay_draw");
        profile(0,"end");
   
index 47fc321..ac59589 100644 (file)
@@ -96,6 +96,7 @@ struct graphics_gc;
 struct graphics_image;
 struct item;
 struct point;
+struct layout;
 struct graphics *graphics_new(const char *type, struct attr **attrs);
 struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h);
 void graphics_init(struct graphics *this_);
@@ -117,9 +118,9 @@ void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct
 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
 void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label);
 int graphics_ready(struct graphics *this_);
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, GList *layouts);
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l);
 void graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy);
-void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, GList *layouts);
+void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, struct layout *l);
 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
 void graphics_displaylist_close(struct displaylist_handle *dlh);
index 44be946..6725f71 100644 (file)
@@ -31,6 +31,7 @@
 #include "track.h"
 #include "vehicle.h"
 #include "color.h"
+#include "layout.h"
 
 #define _(STRING)    gettext(STRING)
 /**
@@ -130,6 +131,9 @@ 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
@@ -139,7 +143,7 @@ navit_draw(struct navit *this_)
        struct navit_vehicle *nv;
 
        transform_setup_source_rect(this_->trans);
-       graphics_draw(this_->gra, this_->displaylist, this_->mapsets, this_->trans, this_->layouts);
+       graphics_draw(this_->gra, this_->displaylist, this_->mapsets, this_->trans, this_->layout_current);
        l=this_->vehicles;
        while (l) {
                nv=l->data;
@@ -153,7 +157,7 @@ void
 navit_draw_displaylist(struct navit *this_)
 {
        if (this_->ready) 
-               graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layouts);
+               graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current);
 }
 
 static void
@@ -238,7 +242,7 @@ navit_motion_timeout(void *data)
        if (dx || dy) {
                this_->last=this_->current;
                graphics_displaylist_move(this_->displaylist, dx, dy);
-               graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layouts);
+               graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current);
                this_->moved=1;
        }
        this_->motion_timeout=0;
@@ -650,7 +654,15 @@ navit_debug(struct navit *this_)
 void
 navit_add_menu_layouts(struct navit *this_, struct menu *men)
 {
-       menu_add(men, "Test", menu_type_menu, NULL);
+       GList *layouts;
+       struct layout *l;
+
+       layouts = this_->layouts;
+       while (layouts) {
+               l=layouts->data;
+               menu_add(men, l->name, menu_type_menu, NULL);
+               layouts=g_list_next(layouts);
+       }
 }
 
 void
@@ -1193,6 +1205,8 @@ navit_set_center_screen(struct navit *this_, struct point *p)
 int
 navit_set_attr(struct navit *this_, struct attr *attr)
 {
+       GList *layouts;
+       struct layout *l;
        int dir=0, orient_old=0, attr_updated=0;
 
        switch (attr->type) {
@@ -1224,6 +1238,17 @@ navit_set_attr(struct navit *this_, struct attr *attr)
                        attr_updated=1;
                }
                break;
+       case attr_layout:
+               layouts = this_->layouts;
+               while (layouts) {
+                       l=layouts->data;
+                       if(!strcmp(attr->u.str,l->name) && this_->layout_current!=l) {
+                               this_->layout_current=l;
+                               attr_updated=1;
+                       }
+                       layouts=g_list_next(layouts);
+               }
+               break;
        default:
                return 0;
        }