Add:Core:Incomplete support for attributes instead of toggle flags
authorhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 2 Jan 2008 00:16:25 +0000 (00:16 +0000)
committerhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 2 Jan 2008 00:16:25 +0000 (00:16 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@687 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/attr_def.h
navit/src/navit.c
navit/src/navit.h
navit/src/navit.xml

index 4295d20..5010ce1 100644 (file)
@@ -40,6 +40,9 @@ ATTR2(0x00028000,type_boolean_begin)
 /* boolean */
 ATTR(overwrite)
 ATTR(active)
+ATTR(cursor)
+ATTR(orientation)
+ATTR(tracking)
 ATTR2(0x0002ffff,type_int_end)
 ATTR2(0x00030000,type_string_begin)
 ATTR(type)
index f9f3379..0518868 100644 (file)
@@ -336,28 +336,37 @@ navit_new(struct attr **attrs)
 
        this_->bookmarks_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
-       
+       this_->cursor_flag=1;
+       this_->orient_north_flag=0;
+       this_->tracking_flag=1;
+
        for (;*attrs; attrs++) {
-           switch((*attrs)->type) {
+               switch((*attrs)->type) {
                case attr_zoom:
-                   zoom = (*attrs)->u.num;
-                   break;
+                       zoom=(*attrs)->u.num;
+                       break;
                case attr_center:
-                   g=*((*attrs)->u.coord_geo);
-                   break;
+                       g=*((*attrs)->u.coord_geo);
+                       break;
+               case attr_cursor:
+                       this_->cursor_flag=!!(*attrs)->u.num;
+                       break;
+               case attr_orientation:
+                       this_->orient_north_flag=!!(*attrs)->u.num;
+                       break;
+               case attr_tracking:
+                       this_->tracking_flag=!!(*attrs)->u.num;
+                       break;
                default:
-                   dbg(0, "Unexpected attribute %x\n",(*attrs)->type);
-                   break;
-           }
+                       dbg(0, "Unexpected attribute %x\n",(*attrs)->type);
+                       break;
+               }
        }
        transform_from_geo(pro, &g, &co);
        center.x=co.x;
        center.y=co.y;
        center.pro = pro;
 
-       dbg(0,"zoom=%d, coords x=%d, y=%d\n",zoom, center.x, center.y);
-       this_->cursor_flag=1;
-       this_->tracking_flag=1;
        this_->trans=transform_new();
        transform_setup(this_->trans, &center, zoom, 0);
        this_->displaylist=graphics_displaylist_new();
@@ -1176,6 +1185,56 @@ navit_toggle_orient_north(struct navit *this_)
        navit_draw(this_);
 }
 
+int
+navit_set_attr(struct navit *this_, struct attr *attr)
+{
+       int dir = 0;
+
+       switch (attr->type) {
+       case attr_cursor:
+               this_->cursor_flag=!!attr->u.num;
+               break;
+       case attr_tracking:
+               this_->tracking_flag=!!attr->u.num;
+               break;
+       case attr_orientation:
+               this_->orient_north_flag=!!attr->u.num;
+               if (this_->orient_north_flag) {
+                       dir = 0;
+               } else {
+                       if (this_->vehicle) {
+                               dir = this_->vehicle->dir;
+                       }
+               }
+               transform_set_angle(this_->trans, dir);
+               navit_draw(this_);
+               break;
+       default:
+               return 0;
+       }
+       return 1;
+}
+
+int
+navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr)
+{
+       switch (type) {
+       case attr_cursor:
+               attr->u.num=this_->cursor_flag;
+               break;
+       case attr_tracking:
+               attr->u.num=this_->tracking_flag;
+               break;
+       case attr_orientation:
+               attr->u.num=this_->orient_north_flag;
+               break;
+       default:
+               return 0;
+       }
+       attr->type=type;
+       return 1;
+}
+
 /**
  * Toggle the cursor update : refresh the map each time the cursor has moved (instead of only when it reaches a border)
  *
index a116e92..f4d7740 100644 (file)
@@ -7,6 +7,7 @@ extern "C" {
 extern struct gui *main_loop_gui;
 /* prototypes */
 enum item_type;
+enum attr_type;
 struct attr;
 struct callback;
 struct coord;
@@ -63,6 +64,8 @@ void navit_set_center_screen(struct navit *this_, struct point *p);
 void navit_toggle_cursor(struct navit *this_);
 void navit_toggle_tracking(struct navit *this_);
 void navit_toggle_orient_north(struct navit *this_);
+int navit_set_attr(struct navit *this_, struct attr *attr);
+int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr);
 void navit_set_position(struct navit *this_, struct pcoord *c);
 struct navit_vehicle *navit_add_vehicle(struct navit *this_, struct vehicle *v, struct attr **attrs);
 void navit_add_vehicle_cb(struct navit *this_, struct callback *cb);
index 5191aad..4769cb3 100644 (file)
@@ -12,7 +12,7 @@ Center coordinates format:
 [-]0xX [-]0xX 
 Change to your home coordinates.
 -->
-<navit center="4808 N 1134 E" zoom="256" >
+<navit center="4808 N 1134 E" zoom="256" tracking="1" cursor="1" orientation="0">
        <gui type="gtk" />
        <graphics type="gtk_drawing_area" />
 <!-- For SDL, use rather the following lines