Hi everybody, I've added a feature to my copy of tangoGPS, and thought that others might be interested: it allows the *details* in the map (e.g.: text, icons) to be scaled up (to show fewer details, but make the shown details bigger) or scaled down (to render the details smaller, but show more of them).
This has made tangoGPS *much* more usable for me on my FreeRunner, because I can actually read the labels for streets, etc. without holding the screen very close to my face :) (I guess that the OpenStreetMap tiles are rasterised expecting something like 96 DPI, but the FreeRunner's display runs at ~280 DPI, so text and icons used in OSM tiles is *very* small when displayed on the FreeRunner without any upsampling; `zooming the details' by 1 level makes everything legible at arm's length, and zooming the details by 2 levels makes the text easy to read even at a glance while driving). I've attached 2 separate patches: one patch that adds the `back end' of the feature (a new `global_detail_zoom' variable with the corresponding gconf hooks, and some minor-changes to the tile-loading code), and another patch that adds the front-end GUI for the feature (an additional submenu in the map screen, and a couple of new callbacks to accompany the new menu-items). I added the submenu and menu-items manually in interface.c--it looks like Marcus is using Glade to maintain the GUI, but I'm not entirely sure (I didn't see glade-file in the tarball...); if he still *is* using Glade, then it may make more sense to defined these submenus via Glade. -- Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr)))).
=== modified file 'src/globals.c' --- src/globals.c 2009-09-26 02:35:15 +0000 +++ src/globals.c 2009-10-24 19:13:54 +0000 @@ -22,6 +22,7 @@ int global_x = 890; int global_y = 515; int global_zoom = 3; int global_zoom_max = 20; +int global_detail_zoom = 0; int mouse_dx = 0; int mouse_dy = 0; === modified file 'src/globals.h' --- src/globals.h 2009-09-26 02:35:15 +0000 +++ src/globals.h 2009-10-24 19:13:54 +0000 @@ -104,6 +104,7 @@ extern int global_x; extern int global_y; extern int global_zoom; extern int global_zoom_max; +extern int global_detail_zoom; extern int mouse_dx; // for mouse move pixmap extern int mouse_dy; === modified file 'src/init.c' --- src/init.c 2009-09-26 02:35:15 +0000 +++ src/init.c 2009-10-24 19:13:54 +0000 @@ -686,7 +686,10 @@ pre_init() global_gconfclient, GCONF"/global_zoom", err); - + global_detail_zoom = gconf_client_get_int ( + global_gconfclient, + GCONF"/global_detail_zoom", + err); === modified file 'src/map_management.c' --- src/map_management.c 2009-10-04 17:46:35 +0000 +++ src/map_management.c 2009-10-26 01:07:04 +0000 @@ -35,6 +35,8 @@ load_tile( gchar *dir, int offset_x, int offset_y) { + int detail_zoom=global_detail_zoom; /* round (dpi/96.0)? */ + int detail_scale=(int) pow (2.0, (float) detail_zoom); int overzoom=0; int upscale=1; gboolean tile_found = FALSE; @@ -55,7 +57,10 @@ load_tile( gchar *dir, } else printf("no drawable -> NULL\n"); - + + upscale = detail_scale; + zoom -= detail_zoom; + for(overzoom=0; overzoom<=3; overzoom++) { g_sprintf(filename, "%s/%u/%u/%u.png", dir, zoom-overzoom, x/upscale, y/upscale); @@ -72,7 +77,7 @@ load_tile( gchar *dir, upscale *= 2; } - if(pixbuf && overzoom) + if(pixbuf && upscale > 1) { GdkPixbuf *pixbuf_scaled = NULL; @@ -154,7 +159,7 @@ load_tile( gchar *dir, if (global_auto_download) { repo = global_curr_repo->data; - download_tile(repo,zoom,x,y); + download_tile(repo,zoom,x/detail_scale,y/detail_scale); } else {
=== modified file 'src/callbacks.c' --- src/callbacks.c 2009-09-26 02:35:15 +0000 +++ src/callbacks.c 2009-10-25 23:52:52 +0000 @@ -3910,3 +3910,52 @@ on_item18_button_release_event ( repaint_all(); return FALSE; } + +void +activate_more_map_details (GtkMenuItem *menu_item, gpointer user_data) +{ + GError *error = NULL; + gboolean success = FALSE; + + printf ("enlarge details\n"); + + if (global_detail_zoom > 0) { + global_detail_zoom--; + + } + + if (global_detail_zoom == 0) { + gtk_widget_set_sensitive (GTK_WIDGET (menu_item), FALSE); + } + + success = gconf_client_set_int( + global_gconfclient, + GCONF"/global_detail_zoom", + global_detail_zoom, + &error); + + repaint_all (); +} + +void +activate_larger_map_details (GtkMenuItem *larger_item, GtkMenuItem *more_item) +{ + GError *error = NULL; + gboolean success = FALSE; + + printf ("shrink details\n"); + + global_detail_zoom++; + + if (global_detail_zoom > 0) { + gtk_widget_set_sensitive (GTK_WIDGET (more_item), TRUE); + } + + success = gconf_client_set_int( + global_gconfclient, + GCONF"/global_detail_zoom", + global_detail_zoom, + &error); + + repaint_all (); +} === modified file 'src/callbacks.h' --- src/callbacks.h 2009-09-26 02:35:15 +0000 +++ src/callbacks.h 2009-10-25 23:53:55 +0000 @@ -774,3 +774,9 @@ gboolean on_item18_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); + +void +activate_more_map_details (GtkMenuItem *menu_item, gpointer user_data); + +void +activate_larger_map_details (GtkMenuItem *larger_item, GtkMenuItem *more_item); === modified file 'src/interface.c' --- src/interface.c 2009-09-26 02:35:15 +0000 +++ src/interface.c 2009-10-26 02:39:40 +0000 @@ -16,6 +16,7 @@ #include "callbacks.h" #include "interface.h" #include "support.h" +#include "globals.h" #define GLADE_HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ @@ -1955,6 +1956,11 @@ create_menu1 (void) GtkWidget *item7; GtkWidget *item8; + GtkWidget *details_item; + GtkWidget *details_menu; + GtkWidget *details_item_more; + GtkWidget *details_item_bigger; + menu1 = gtk_menu_new (); item4 = gtk_menu_item_new_with_mnemonic (_("this point")); @@ -2033,6 +2039,25 @@ create_menu1 (void) gtk_widget_show (item8); gtk_container_add (GTK_CONTAINER (menu1), item8); + + details_item = gtk_menu_item_new_with_mnemonic (_("map detail")); + gtk_container_add (GTK_CONTAINER (menu1), details_item); + + details_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (details_item), details_menu); + + details_item_bigger = gtk_menu_item_new_with_mnemonic (_("fewer/larger details")); + gtk_container_add (GTK_CONTAINER (details_menu), details_item_bigger); + + details_item_more = gtk_menu_item_new_with_mnemonic (_("more/smaller details")); + if (global_detail_zoom == 0) { + gtk_widget_set_sensitive (details_item_more, FALSE); + } + gtk_container_add (GTK_CONTAINER (details_menu), details_item_more); + + gtk_widget_show_all (details_item); + + g_signal_connect ((gpointer) item4, "activate", G_CALLBACK (on_item4_activate), NULL); @@ -2076,6 +2101,12 @@ create_menu1 (void) G_CALLBACK (on_item8_activate), NULL); + g_signal_connect ((gpointer) details_item_more, "activate", + G_CALLBACK (activate_more_map_details), + NULL); + g_signal_connect ((gpointer) details_item_bigger, "activate", + G_CALLBACK (activate_larger_map_details), + details_item_more); GLADE_HOOKUP_OBJECT_NO_REF (menu1, menu1, "menu1"); GLADE_HOOKUP_OBJECT (menu1, item4, "item4");
_______________________________________________ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community