#include "champlain.h"
#include "champlain-defines.h"
+#include "champlain-enum-types.h"
#include "champlain-map.h"
#include "champlain-marshal.h"
#include "champlain-private.h"
PROP_MAP_SOURCE,
PROP_OFFLINE,
PROP_DECEL_RATE,
+ PROP_SCROLL_MODE,
PROP_KEEP_CENTER_ON_RESIZE,
PROP_SHOW_LICENSE
};
ClutterActor *stage;
ChamplainMapSource map_source;
+ ChamplainScrollMode scroll_mode;
gint zoom_level; /* Only used when the zoom-level property is set before map
* is created */
case PROP_MAP_SOURCE:
g_value_set_int (value, priv->map_source);
break;
+ case PROP_SCROLL_MODE:
+ g_value_set_enum (value, priv->scroll_mode);
+ break;
case PROP_OFFLINE:
g_value_set_boolean (value, priv->offline);
break;
}
break;
}
+ case PROP_SCROLL_MODE:
+ priv->scroll_mode = g_value_get_enum (value);
+ g_object_set (G_OBJECT (priv->finger_scroll), "mode",
+ priv->scroll_mode, NULL);
+ break;
case PROP_OFFLINE:
priv->offline = g_value_get_boolean (value);
break;
"If viewer is in offline mode.",
FALSE, CHAMPLAIN_PARAM_READWRITE));
+ /**
+ * ChamplainView:scroll-mode:
+ *
+ * Determines the way the view reacts to scroll events.
+ *
+ * Since: 0.4
+ */
+ g_object_class_install_property (object_class,
+ PROP_SCROLL_MODE,
+ g_param_spec_enum ("scroll-mode",
+ "Scroll Mode",
+ "Determines the way the view reacts to scroll events.",
+ CHAMPLAIN_TYPE_SCROLL_MODE,
+ CHAMPLAIN_SCROLL_MODE_KINETIC,
+ CHAMPLAIN_PARAM_READWRITE));
+
/**
* ChamplainView:decel-rate:
*
priv->keep_center_on_resize = TRUE;
priv->show_license = TRUE;
priv->license_actor = NULL;
+ priv->stage = clutter_group_new ();
+ priv->scroll_mode = CHAMPLAIN_SCROLL_MODE_PUSH;
+
+ /* Setup viewport */
+ priv->viewport = tidy_viewport_new ();
+ g_object_set (G_OBJECT (priv->viewport), "sync-adjustments", FALSE, NULL);
+
+ g_signal_connect (priv->viewport,
+ "notify::x-origin",
+ G_CALLBACK (viewport_x_changed_cb),
+ view);
+
+ /* Setup finger scroll */
+ priv->finger_scroll = tidy_finger_scroll_new (priv->scroll_mode);
+
+ g_signal_connect (priv->finger_scroll,
+ "scroll-event",
+ G_CALLBACK (scroll_event),
+ view);
+
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->finger_scroll),
+ priv->viewport);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->stage),
+ priv->finger_scroll);
+ clutter_container_add_actor (CLUTTER_CONTAINER (view), priv->stage);
+
+ /* Map Layer */
+ priv->map_layer = clutter_group_new ();
+ clutter_actor_show (priv->map_layer);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport),
+ priv->map_layer);
+
+ g_signal_connect (priv->finger_scroll,
+ "button-press-event",
+ G_CALLBACK (finger_scroll_button_press_cb),
+ view);
+
+ /* Setup user_layers */
+ priv->user_layers = clutter_group_new ();
+ clutter_actor_show (priv->user_layers);
+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport),
+ priv->user_layers);
+ clutter_actor_raise (priv->user_layers, priv->map_layer);
}
static void
/**
* champlain_view_new:
- * @mode: a #ChamplainViewMode, the scrolling mode
* Returns a new #ChamplainView ready to be used as a #ClutterActor.
*
- * Since: 0.1
+ * Since: 0.4
*/
ClutterActor *
-champlain_view_new (ChamplainViewMode mode)
+champlain_view_new ()
{
- ChamplainView *view;
-
- view = CHAMPLAIN_VIEW (g_object_new (CHAMPLAIN_TYPE_VIEW, NULL));
- ChamplainViewPrivate *priv = GET_PRIVATE (view);
-
- priv->stage = clutter_group_new ();
-
-
- /* Setup viewport */
- priv->viewport = tidy_viewport_new ();
- g_object_set (G_OBJECT (priv->viewport), "sync-adjustments", FALSE, NULL);
-
- g_signal_connect (priv->viewport,
- "notify::x-origin",
- G_CALLBACK (viewport_x_changed_cb),
- view);
-
- /* Setup finger scroll */
- TidyFingerScrollMode tidy_mode;
- switch (mode)
- {
- case CHAMPLAIN_VIEW_MODE_PUSH:
- tidy_mode = TIDY_FINGER_SCROLL_MODE_PUSH;
- break;
- case CHAMPLAIN_VIEW_MODE_KINETIC:
- tidy_mode = TIDY_FINGER_SCROLL_MODE_KINETIC;
- break;
- }
-
- priv->finger_scroll = tidy_finger_scroll_new (mode);
-
- g_signal_connect (priv->finger_scroll,
- "scroll-event",
- G_CALLBACK (scroll_event),
- view);
-
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->finger_scroll),
- priv->viewport);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->stage),
- priv->finger_scroll);
- clutter_container_add_actor (CLUTTER_CONTAINER (view), priv->stage);
-
- /* Map Layer */
- priv->map_layer = clutter_group_new ();
- clutter_actor_show (priv->map_layer);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport),
- priv->map_layer);
-
- g_signal_connect (priv->finger_scroll,
- "button-press-event",
- G_CALLBACK (finger_scroll_button_press_cb),
- view);
-
- /* Setup user_layers */
- priv->user_layers = clutter_group_new ();
- clutter_actor_show (priv->user_layers);
- clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport),
- priv->user_layers);
- clutter_actor_raise (priv->user_layers, priv->map_layer);
-
- return CLUTTER_ACTOR (view);
+ return g_object_new (CHAMPLAIN_TYPE_VIEW, NULL);
}
/**
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 800, 600);
- actor = champlain_view_new (CHAMPLAIN_VIEW_MODE_KINETIC);
+ actor = champlain_view_new ();
+ g_object_set (G_OBJECT (actor), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+ "zoom-level", 12, NULL);
clutter_actor_set_reactive (actor, TRUE);
g_signal_connect_after (actor, "button-release-event",
G_CALLBACK (map_view_button_release_cb), actor);
champlain_view_add_layer(CHAMPLAIN_VIEW (actor), layer);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
- g_object_set (G_OBJECT (actor), "zoom-level", 12, NULL);
champlain_view_center_on (CHAMPLAIN_VIEW(actor), 45.466, -73.75);
clutter_actor_show (stage);