]> err.no Git - mapper/blob - src/map.h
Add redraw timer. Add zoom in/out helper for idle cb.
[mapper] / src / map.h
1 #include <config.h>
2
3 #define _GNU_SOURCE
4
5 #ifndef _MAPPER_MAP_H
6 #define _MAPPER_MAP_H
7
8 #include <unistd.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <strings.h>
12 #include <stddef.h>
13 #include <locale.h>
14 #include <math.h>
15 #include <errno.h>
16 #include <sys/wait.h>
17 #include <glib/gstdio.h>
18 #include <gtk/gtk.h>
19 #include <dbus/dbus-glib.h>
20
21 #include "utils.h"
22 #include "mapper-types.h"
23
24 typedef enum {
25         MAP_MODE_NORMAL=0,
26         MAP_MODE_DRAW_TRACK,
27         MAP_MODE_DRAW_ROUTE,
28         MAP_MODE_SET_ROUTE_FROM,
29         MAP_MODE_SET_ROUTE_POINT,
30         MAP_MODE_SET_ROUTE_TO,
31         MAP_MODES
32 } MapMode;
33
34 /** VARIABLES FOR MAINTAINING STATE OF THE CURRENT VIEW. */
35
36 /** The "zoom" level defines the resolution of a pixel, from 0 to MAX_ZOOM.
37  * Each pixel in the current view is exactly (1 << _zoom) "units" wide. */
38
39 Point _min_center;
40 Point _max_center;
41 Point _focus;
42
43 /** The "base tile" is the upper-left tile in the pixmap. */
44 guint _base_tilex;
45 guint _base_tiley;
46
47 guint _zoom;                    /* zoom level, from 0 to MAX_ZOOM. */
48 Point _center;                  /* current center location, X. */
49
50 /** The "offset" defines the upper-left corner of the visible portion of the
51  * 1024x768 pixmap. */
52 guint _offsetx;
53 guint _offsety;
54
55 /** CACHED SCREEN INFORMATION THAT IS DEPENDENT ON THE CURRENT VIEW. */
56 guint _screen_grids_halfwidth;
57 guint _screen_grids_halfheight;
58 guint _screen_width_pixels;
59 guint _screen_height_pixels;
60
61 guint _focus_unitwidth;
62 guint _focus_unitheight;
63 guint _world_size_tiles;
64
65 guint _key_zoom_new;
66 guint _key_zoom_timeout_sid;
67
68 gboolean _map_location_known;
69 gdouble _map_location_dist;
70
71 /** The widget that provides the visual display of the map. */
72 GtkWidget *_map_widget;
73
74 /** The backing pixmap of _map_widget. */
75 GdkPixmap *_map_pixmap;
76
77 GtkWidget *map_new(void);
78
79 gboolean map_key_zoom_timeout();
80
81 int map_zoom(gint zdir);
82 gboolean map_zoom_in(void);
83 gboolean map_zoom_out(void);
84 void map_set_autozoom(gboolean az);
85 void map_render_path(Path * path, GdkGC ** gc);
86 void map_pan(gint delta_unitx, gint delta_unity);
87 void map_move_mark(void);
88 void map_set_mark(void);
89 void map_render_data(void);
90
91 void map_render_tile(guint tilex, guint tiley, guint destx, guint desty, gboolean fast_fail);
92
93 void map_center_unit(guint new_center_unitx, guint new_center_unity);
94 void map_center_latlon(gdouble lat, gdouble lon);
95
96 gboolean map_goto_position(Position *pos);
97 gboolean map_update_location_from_center(void);
98
99 #endif