gfloat units_conv;
gchar *units_str;
- gfloat speed;
+ /* Current speed, set from outside */
+ gfloat speed;
+ gboolean speed_oc;
/* Buffer offset */
gint offsetx;
gboolean button_down;
gint mouse_x;
gint mouse_y;
+ gint drag_x;
+ gint drag_y;
gdouble mouse_lat;
gdouble mouse_lon;
PROP_SHOW_VELVEC,
PROP_SHOW_SCALE,
PROP_SHOW_SPEED,
+ PROP_SPEED,
+ PROP_SPEED_OC,
PROP_LAST
};
pspec=g_param_spec_boolean("show-speed","Show speed","Display current speed on map", TRUE, G_PARAM_READWRITE);
g_object_class_install_property(object_class, PROP_SHOW_SPEED, pspec);
+pspec=g_param_spec_boolean("over-speed","Over speed","Are we speeding", FALSE, G_PARAM_READWRITE);
+g_object_class_install_property(object_class, PROP_SPEED_OC, pspec);
+
+pspec=g_param_spec_double("speed","Current speed","Speed value to display on map, if show-peed is TRUE", 0, 999, 0, G_PARAM_READWRITE);
+g_object_class_install_property(object_class, PROP_SPEED, pspec);
+
gtk_map_signals[MAP_ZOOM_CHANGED]=g_signal_new("zoom-changed", G_OBJECT_CLASS_TYPE(object_class),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(GtkMapClass, zoom_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
case PROP_SHOW_SPEED:
priv->show_speed=g_value_get_boolean(value);
break;
+ case PROP_SPEED:
+ priv->speed=g_value_get_float(value);
+ break;
+ case PROP_SPEED_OC:
+ priv->speed_oc=g_value_get_boolean(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_SHOW_SCALE:
g_value_set_boolean(value, priv->show_scale);
break;
+ case PROP_SPEED:
+ g_value_set_float(value, priv->speed);
+ break;
+ case PROP_SPEED_OC:
+ g_value_set_boolean(value, priv->speed_oc);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
gtk_map_information_text(widget, 10, 10, priv->speed_gc, buffer);
}
-void
-gtk_map_set_speed(GtkWidget *widget, gfloat speed, gboolean overspeed)
-{
-GtkMap *map;
-GtkMapPriv *priv;
-
-g_return_if_fail(GTK_IS_MAP(widget));
-map=GTK_MAP(widget);
-priv=GTK_MAP_GET_PRIVATE(map);
-
-priv->speed_gc=(overspeed) ? priv->speed_gc1 : priv->speed_gc2;
-priv->speed=speed;
-}
-
/******************************************************************************/
static gboolean
{
GtkMap *map;
GtkMapPriv *priv;
+GdkModifierType mask;
+gint x,y;
g_return_val_if_fail(GTK_IS_MAP(widget), FALSE);
map=GTK_MAP(widget);
priv=GTK_MAP_GET_PRIVATE(map);
-priv->mouse_x=(gint)event->x;
-priv->mouse_y=(gint)event->y;
+if (event->is_hint) {
+ gdk_window_get_pointer (event->window, &x, &y, &mask);
+} else {
+ x=(gint)event->x;
+ y=(gint)event->y;
+ mask=event->state;
+}
+
+priv->mouse_x=x;
+priv->mouse_y=y;
unit2latlon(x2unit(priv->mouse_x), y2unit(priv->mouse_y), &priv->mouse_lat, &priv->mouse_lon);
-g_debug("MOUSE(%d): %d,%d (%f,%f)", priv->button_down, priv->mouse_x, priv->mouse_y, priv->mouse_lat, priv->mouse_lon);
+if ((mask & GDK_BUTTON1_MASK)) {
+ gint dx, dy;
+
+ dx=(event->x-priv->drag_x)+priv->screen_width_pixels/2;
+ dy=(event->y-priv->drag_y)+priv->screen_height_pixels/2;
+ gtk_map_set_center(widget, x2unit((gint)dx), y2unit((gint)dy));
+} else {
+ /* XXX: check if pointer is near a marker perhaps ? */
+}
+
+g_debug("MOUSE(%d): %d,%d [%d] (%f,%f)", priv->button_down, priv->mouse_x, priv->mouse_y, mask, priv->mouse_lat, priv->mouse_lon);
return FALSE;
}
switch (event->button) {
case 1:
priv->button_down=TRUE;
+ priv->drag_x=(gint)event->x;
+ priv->drag_y=(gint)event->y;
if (priv->click_to_center) {
gtk_map_set_center(widget, x2unit((gint) (event->x+0.5)), y2unit((gint) (event->y+0.5)));
return FALSE;
switch (event->button) {
case 1:
priv->button_down=FALSE;
+ priv->drag_x=-1;
+ priv->drag_y=-1;
/* Check if a marker was clicked, if they are shown and if there is something to show */
if (priv->show_markers && priv->marker_store) {
/* XXX */