Add:map_binfile:Feedback during map download
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 24 Dec 2010 13:37:41 +0000 (13:37 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 24 Dec 2010 13:37:41 +0000 (13:37 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3824 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/attr_def.h
navit/navit/graphics.c
navit/navit/graphics.h
navit/navit/map.c
navit/navit/navit.c
navit/navit/plugin_def.h

index 211b8a0..7a44fd0 100644 (file)
@@ -333,6 +333,7 @@ ATTR(map_release)
 ATTR(accesskey)
 ATTR(http_method)
 ATTR(http_header)
+ATTR(progress)
 ATTR2(0x0003ffff,type_string_end)
 ATTR2(0x00040000,type_special_begin)
 ATTR(order)
index 2ecf00a..4e4cd53 100644 (file)
@@ -678,6 +678,7 @@ void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct
        this_->meth.draw_text(this_->priv, gc1->priv, gc2 ? gc2->priv : NULL, font->priv, text, p, dx, dy);
 }
 
+
 /**
  * FIXME
  * @param <>
@@ -1583,6 +1584,21 @@ get_font(struct graphics *gra, int size)
        return gra->font[size];
 }
 
+void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p)
+{
+       struct graphics_font *font=get_font(this_, text_size);
+       struct point bbox[4];
+       int i;
+
+       graphics_get_text_bbox(this_, font, text, 0x10000, 0, bbox, 0);
+       for (i = 0 ; i < 4 ; i++) {
+               bbox[i].x+=p->x;
+               bbox[i].y+=p->y;
+       }
+       graphics_draw_rectangle(this_, this_->gc[2], &bbox[1], bbox[2].x-bbox[0].x, bbox[0].y-bbox[1].y+5);
+       graphics_draw_text(this_, this_->gc[1], this_->gc[2], font, text, p, 0x10000, 0);
+}
+
 char *
 graphics_icon_path(char *icon)
 {
@@ -1852,6 +1868,7 @@ static void xdisplay_draw_layer(struct displaylist *display_list, struct graphic
 
 
 
+
 /**
  * FIXME
  * @param <>
@@ -1951,7 +1968,14 @@ do_draw(struct displaylist *displaylist, int cancel, int flags)
                        while ((item=map_rect_get_item(displaylist->mr))) {
                                int label_count=0;
                                char *labels[2];
-                               struct hash_entry *entry=get_hash_entry(displaylist, item->type);
+                               struct hash_entry *entry;
+                               if (item == &busy_item) {
+                                       if (displaylist->workload)
+                                               return;
+                                       else
+                                               continue;
+                               }
+                               entry=get_hash_entry(displaylist, item->type);
                                if (!entry) 
                                        continue;
                                count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, displaylist->sel);
index f3581d6..255e9f2 100644 (file)
@@ -116,8 +116,8 @@ struct graphics_data_image {
 
 /* prototypes */
 enum attr_type;
-enum item_type;
 enum draw_mode_num;
+enum item_type;
 struct attr;
 struct attr_iter;
 struct callback;
@@ -171,6 +171,7 @@ void graphics_overlay_disable(struct graphics *this_, int disable);
 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
 int graphics_draw_drag(struct graphics *this_, struct point *p);
 void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
+void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p);
 char *graphics_icon_path(char *icon);
 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t);
 void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags);
index bd404bd..a991bdf 100644 (file)
@@ -91,7 +91,7 @@ struct map *
 map_new(struct attr *parent, struct attr **attrs)
 {
        struct map *m;
-       struct map_priv *(*maptype_new)(struct map_methods *meth, struct attr **attrs);
+       struct map_priv *(*maptype_new)(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl);
        struct attr *type=attr_search(attrs, NULL, attr_type);
 
        if (! type) {
@@ -106,14 +106,12 @@ map_new(struct attr *parent, struct attr **attrs)
 
        m=g_new0(struct map, 1);
        m->attrs=attr_list_dup(attrs);
-       m->priv=maptype_new(&m->meth, attrs);
+       m->attr_cbl=callback_list_new();
+       m->priv=maptype_new(&m->meth, attrs, m->attr_cbl);
        if (! m->priv) {
-               attr_list_free(m->attrs);
-               g_free(m);
+               map_destroy(m);
                m=NULL;
        }
-       if (m)
-               m->attr_cbl=callback_list_new();
        return m;
 }
 
@@ -257,7 +255,8 @@ map_set_projection(struct map *this_, enum projection pro)
 void
 map_destroy(struct map *m)
 {
-       m->meth.map_destroy(m->priv);
+       if (m->priv)
+               m->meth.map_destroy(m->priv);
        attr_list_free(m->attrs);
        callback_list_destroy(m->attr_cbl);
        g_free(m);
index 04aed44..32d3bbb 100644 (file)
@@ -57,6 +57,7 @@
 #include "profile.h"
 #include "command.h"
 #include "navit_nls.h"
+#include "map.h"
 #include "util.h"
 #include "messages.h"
 #include "vehicleprofile.h"
@@ -108,7 +109,7 @@ struct navit {
        GList *windows_items;
        struct navit_vehicle *vehicle;
        struct callback_list *attr_cbl;
-       struct callback *nav_speech_cb, *roadbook_callback, *popup_callback, *route_cb;
+       struct callback *nav_speech_cb, *roadbook_callback, *popup_callback, *route_cb, *progress_cb;
        struct datawindow *roadbook_window;
        struct map *former_destination;
        struct point pressed, last, current;
@@ -250,6 +251,31 @@ navit_draw_displaylist(struct navit *this_)
 }
 
 static void
+navit_map_progress(struct navit *this_)
+{
+       struct map *map;
+       struct mapset *ms;
+       struct mapset_handle *msh;
+       struct attr attr;
+       struct point p;
+       p.x=10;
+       p.y=32;
+
+       ms=this_->mapsets->data;
+       msh=mapset_open(ms);
+       while (msh && (map=mapset_next(msh, 0))) {
+               if (map_get_attr(map, attr_progress, &attr, NULL)) {
+                       char *str=g_strdup_printf("%s       ",attr.u.str);
+                       graphics_draw_text_std(this_->gra, 32, str, &p);
+                       g_free(str);
+                       p.y+=32;
+                       graphics_draw_mode(this_->gra, draw_mode_end);
+               }
+       }
+       mapset_close(msh);
+}
+
+static void
 navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr)
 {
        int updated;
@@ -286,7 +312,7 @@ navit_handle_resize(struct navit *this_, int w, int h)
        if (callback) 
                callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
        if (this_->ready == 3)
-               navit_draw(this_);
+               navit_draw_async(this_, 1);
 }
 
 static void
@@ -1401,7 +1427,15 @@ navit_init(struct navit *this_)
        navit_set_vehicle(this_, this_->vehicle);
        dbg(2,"Adding dynamic maps to mapset %p\n",this_->mapsets);
        if (this_->mapsets) {
+               struct mapset_handle *msh;
                ms=this_->mapsets->data;
+               this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_);
+               msh=mapset_open(ms);
+               while (msh && (map=mapset_next(msh, 0))) {
+                       map_add_callback(map, this_->progress_cb);
+               }
+               mapset_close(msh);
+               
                if (this_->route) {
                        if ((map=route_get_map(this_->route)))
                                mapset_add_attr(ms, &(struct attr){attr_map,.u.map=map});
index 682ca59..01acea7 100644 (file)
@@ -25,7 +25,7 @@ PLUGIN_FUNC1(draw, struct container *, co)
 PLUGIN_FUNC3(popup, struct container *, map, struct popup *, p, struct popup_item **, list)
 PLUGIN_TYPE(graphics, (struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)) 
 PLUGIN_TYPE(gui, (struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)) 
-PLUGIN_TYPE(map, (struct map_methods *meth, struct attr **attrs)) 
+PLUGIN_TYPE(map, (struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)) 
 PLUGIN_TYPE(osd, (struct navit *nav, struct osd_methods *meth, struct attr **attrs))
 PLUGIN_TYPE(speech, (struct speech_methods *meth, struct attr **attrs, struct attr *parent)) 
 PLUGIN_TYPE(vehicle, (struct vehicle_methods *meth, struct callback_list *cbl, struct attr **attrs))