* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * SECTION:champlainlayer
+ * @short_description: A container for #ChamplainMarker
+ *
+ * A ChamplainLayer is little more than a #ClutterContainer. It keeps the
+ * markers ordered so that they display correctly.
+ *
+ * Use #clutter_container_add to add markers to the layer and
+ * #clutter_container_remove to remove them.
+ */
+
#include "config.h"
#include "champlainlayer.h"
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * SECTION:champlainmarker
+ * @short_description: A marker to identify points of interest on a map
+ *
+ * Markers reprensent points of interest on a map. Markers need to be placed on
+ * a layer (a #ClutterGroup). Layers have to be added to a #ChamplainView for
+ * the markers to show on the map.
+ *
+ * A marker is nothing more than a regular #ClutterActor. You can draw on it
+ * what ever you want. Don't forget to set the anchor position in the marker
+ * using #champlain_marker_set_anchor. Set the markers position on the map
+ * using #champlain_marker_set_position.
+ *
+ * Champlain has a default type of markers with text. To create one,
+ * use #champlain_marker_new_with_label.
+ */
+
#include "config.h"
#include "champlaindefines.h"
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * SECTION:champlainview
+ * @short_description: A #ClutterActor to display maps
+ *
+ * The #ChamplainView is a ClutterActor to display maps. It supports two modes
+ * of scrolling:
+ * <itemizedlist>
+ * <listitem><para>Push: the normal behavior where the maps doesn't move
+ * after the user stopped scrolling;</para></listitem>
+ * <listitem><para>Kinetic: the iPhone-like behavior where the maps
+ * decelerate after the user stopped scrolling.</para></listitem>
+ * </itemizedlist>
+ *
+ * You can use the same #ChamplainView to display many types of maps. In
+ * Champlain they are called map sources. You can change the #map-source
+ * property at anytime to replace the current displayed map.
+ *
+ * The maps are downloaded from Internet from open maps sources (like
+ * <ulink role="online-location"
+ * url="http://www.openstreetmap.org">OpenStreetMap</ulink>). Maps are divided
+ * in tiles for each zoom level. When a tile is requested, #ChamplainView will
+ * first check if it is in cache (in the user's cache dir under champlain). If
+ * an error occurs during download, an error tile will be displayed (if not in
+ * offline mode).
+ *
+ * The button-press-event and button-release-event signals are emitted each
+ * time a mouse button is pressed on the @view. Coordinates can be converted with
+ * #champlain_view_get_coords_from_event.
+ */
+
#include "config.h"
#include "champlaindefines.h"
enum
{
/* normal signals */
- SIGNAL_TBD,
LAST_SIGNAL
};
};
#define PADDING 10
-// static guint champlain_view_signals[LAST_SIGNAL] = { 0, };
-
-#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate))
+//static guint signals[LAST_SIGNAL] = { 0, };
+#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate))
struct _ChamplainViewPrivate
{
ClutterActor *stage;
static void notify_marker_reposition_cb(ChamplainMarker *marker, GParamSpec *arg1, ChamplainView *view);
static void layer_add_marker_cb (ClutterGroup *layer, ChamplainMarker *marker, ChamplainView *view);
static void connect_marker_notify_cb (ChamplainMarker *marker, ChamplainView *view);
-static gboolean finger_scroll_clicked (ClutterActor *actor, ClutterButtonEvent *event, ChamplainView *view);
+static gboolean finger_scroll_button_press_cb (ClutterActor *actor,
+ ClutterButtonEvent *event, ChamplainView *view);
static void update_license (ChamplainView *view);
static void license_set_position (ChamplainView *view);
}
static gboolean
-finger_scroll_clicked (ClutterActor *actor,
- ClutterButtonEvent *event,
- ChamplainView *view)
+finger_scroll_button_press_cb (ClutterActor *actor,
+ ClutterButtonEvent *event,
+ ChamplainView *view)
{
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
g_signal_connect (priv->finger_scroll,
"button-press-event",
- G_CALLBACK (finger_scroll_clicked),
+ 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_foreach(CLUTTER_CONTAINER(layer), CLUTTER_CALLBACK(connect_marker_notify_cb), view);
}
-gboolean
-champlain_view_get_coords_from_event (ChamplainView *view, ClutterEvent *event, gdouble *lat, gdouble *lon)
+/**
+ * champlain_view_get_coords_from_event:
+ * @view: a #ChamplainView
+ * @event: a #ClutterEvent
+ * @latitude: a variable where to put the latitude of the event
+ * @longitude: a variable where to put the longitude of the event
+ *
+ * Returns a new #ChamplainView ready to be used as a #ClutterActor.
+ *
+ * Since: 0.2.8
+ */
+gboolean
+champlain_view_get_coords_from_event (ChamplainView *view,
+ ClutterEvent *event,
+ gdouble *latitude,
+ gdouble *longitude)
{
g_return_val_if_fail(CHAMPLAIN_IS_VIEW(view), FALSE);
g_return_val_if_fail(event, FALSE); // Apparently there isn't a more precise test
{
ClutterButtonEvent *e = (ClutterButtonEvent*) event;
x = e->x;
- y = e->y;
+ y = e->y;
}
break;
case CLUTTER_SCROLL:
{
ClutterScrollEvent *e = (ClutterScrollEvent*) event;
x = e->x;
- y = e->y;
+ y = e->y;
}
break;
case CLUTTER_MOTION:
{
ClutterMotionEvent *e = (ClutterMotionEvent*) event;
x = e->x;
- y = e->y;
+ y = e->y;
}
break;
case CLUTTER_ENTER:
{
ClutterCrossingEvent *e = (ClutterCrossingEvent*) event;
x = e->x;
- y = e->y;
+ y = e->y;
}
break;
default:
- return FALSE;
+ return FALSE;
}
- if (lat)
- *lat = viewport_get_latitude_at(priv, priv->viewport_size.y + y + priv->map->current_level->anchor.y);
- if (lon)
- *lon = viewport_get_longitude_at(priv, priv->viewport_size.x + x + priv->map->current_level->anchor.x);
+
+ if (latitude)
+ *latitude = viewport_get_latitude_at (priv,
+ priv->viewport_size.y + y + priv->map->current_level->anchor.y);
+ if (longitude)
+ *longitude = viewport_get_longitude_at (priv,
+ priv->viewport_size.x + x + priv->map->current_level->anchor.x);
+
return TRUE;
}
#include <champlain/champlain.h>
static gboolean
-montreal_click (ClutterActor *actor,
- ClutterButtonEvent *event,
- ChamplainView * view)
+map_view_button_release_cb (ClutterActor *actor,
+ ClutterButtonEvent *event,
+ ChamplainView * view)
{
gdouble lat, lon;
- g_print("Montreal was clicked!\n");
+ if (event->button != 1 || event->click_count > 1)
+ return;
+
+ g_print("Map was clicked at ");
if (champlain_view_get_coords_from_event (view, event, &lat, &lon))
g_print("%f, %f \n", lat, lon);
return TRUE;
}
+static gboolean
+montreal_click (ClutterActor *actor,
+ ClutterButtonEvent *event,
+ ChamplainView * view)
+{
+ if (event->button != 1 || event->click_count > 1)
+ return;
+
+ g_print("Montreal was clicked\n");
+
+ return TRUE;
+}
+
static ClutterActor*
create_marker_layer (ChamplainView *view)
{
clutter_actor_set_size (stage, 800, 600);
actor = champlain_view_new (CHAMPLAIN_VIEW_MODE_KINETIC);
+ clutter_actor_set_reactive (actor, TRUE);
+ g_signal_connect_after (actor, "button-release-event",
+ G_CALLBACK (map_view_button_release_cb), actor);
champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600);
# Extra options to supply to gtkdoc-fixref. Not normally needed.
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
-FIXXREF_OPTIONS=
+FIXXREF_OPTIONS= \
+ --extra-dir=$(PREFIX)/share/gtk-doc/html/gobject \
+ --extra-dir=$(PREFIX)/share/gtk-doc/html/glib \
+ --extra-dir=$(PREFIX)/share/gtk-doc/html/clutter
+
# Used for dependencies. The docs will be rebuilt if any of these change.
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
champlain_view_center_on
champlain_view_zoom_in
champlain_view_zoom_out
+champlain_view_get_coords_from_event
<SUBSECTION Standard>
CHAMPLAIN_VIEW
CHAMPLAIN_IS_VIEW
+++ /dev/null
-<!-- ##### SECTION Title ##### -->
-ChamplainMarker
-
-<!-- ##### SECTION Short_Description ##### -->
-A marker to identify points of interest on a map
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>Markers reprensent points of interest on a map. Markers need to be placed on a layer (a #ClutterGroup). Layers have to be added to a #ChamplainView for the markers to show on the map.</para>
-
-<para>A marker is nothing more than a regular #ClutterActor. You can draw on it what ever you want. Don't forget to set the anchor position in the marker using #champlain_marker_set_anchor. Set the markers position on the map using #champlain_marker_set_position.</para>
-
-<para>Champlain has a default type of markers with text. To create one, use #champlain_marker_new_with_label.</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
-
-</para>
-
-<!-- ##### SECTION Stability_Level ##### -->
-
-
-<!-- ##### STRUCT ChamplainMarker ##### -->
-<para>
-
-</para>
-
-@group:
-@priv:
-
-<!-- ##### FUNCTION champlain_marker_new ##### -->
-<para>
-
-</para>
-
-@Returns:
-
-
-<!-- ##### FUNCTION champlain_marker_new_with_label ##### -->
-<para>
-
-</para>
-
-@label:
-@font:
-@text_color:
-@marker_color:
-@Returns:
-
-
-<!-- ##### FUNCTION champlain_marker_new_with_image ##### -->
-<para>
-
-</para>
-
-@filename:
-@error:
-@Returns:
-
-
-<!-- ##### FUNCTION champlain_marker_new_with_image_full ##### -->
-<para>
-
-</para>
-
-@filename:
-@width:
-@height:
-@anchor_x:
-@anchor_y:
-@error:
-@Returns:
-
-
-<!-- ##### FUNCTION champlain_marker_set_position ##### -->
-<para>
-
-</para>
-
-@marker:
-@longitude:
-@latitude:
-
-
+++ /dev/null
-<!-- ##### SECTION Title ##### -->
-ChamplainView
-
-<!-- ##### SECTION Short_Description ##### -->
-A #ClutterActor to display maps
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>
-The #ChamplainView is a ClutterActor to display maps. It supports two modes of scrolling:
-<itemizedlist>
- <listitem><para>Push: the normal behavior where the maps doesn't move after the user stopped scrolling;</para></listitem>
- <listitem><para>Kinetic: the iPhone-like behavior where the maps decelerate after the user stopped scrolling.</para></listitem>
-</itemizedlist>
-</para>
-<para>
-You can use the same #ChamplainView to display many types of maps. In Champlain they are called map sources. You can change the #map-source property at anytime to replace the current displayed map.
-</para>
-<para>
-The maps are downloaded from Internet from open maps sources (like <ulink role="online-location" url="http://www.openstreetmap.org">OpenStreetMap</ulink>). Maps are divided in tiles for each zoom level. When a tile is requested, #ChamplainView will first check if it is in cache (in
-the user's cache dir under champlain). If an error occurs during download, an error tile will be displayed (if not in offline mode).
-</para>
-
-<para>
-
-</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
-
-</para>
-
-<!-- ##### SECTION Stability_Level ##### -->
-
-
-<!-- ##### ENUM ChamplainMapSource ##### -->
-<para>
-
-</para>
-
-@CHAMPLAIN_MAP_SOURCE_DEBUG:
-@CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP:
-@CHAMPLAIN_MAP_SOURCE_OPENARIALMAP:
-@CHAMPLAIN_MAP_SOURCE_MAPSFORFREE_RELIEF:
-@CHAMPLAIN_MAP_SOURCE_COUNT:
-
-<!-- ##### ENUM ChamplainViewMode ##### -->
-<para>
-
-</para>
-
-@CHAMPLAIN_VIEW_MODE_PUSH:
-@CHAMPLAIN_VIEW_MODE_KINETIC:
-
-<!-- ##### STRUCT ChamplainView ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### ARG ChamplainView:decel-rate ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:keep-center-on-resize ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:latitude ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:longitude ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:map-source ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:offline ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:show-license ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG ChamplainView:zoom-level ##### -->
-<para>
-
-</para>
-
-<!-- ##### FUNCTION champlain_view_new ##### -->
-<para>
-
-</para>
-
-@mode:
-@Returns:
-
-
-<!-- ##### FUNCTION champlain_view_center_on ##### -->
-<para>
-
-</para>
-
-@view:
-@latitude:
-@longitude:
-
-
-<!-- ##### FUNCTION champlain_view_zoom_in ##### -->
-<para>
-
-</para>
-
-@champlainView:
-
-
-<!-- ##### FUNCTION champlain_view_zoom_out ##### -->
-<para>
-
-</para>
-
-@champlainView:
-
-
TidyFingerScrollPrivate *priv = scroll->priv;
ClutterActor *child = tidy_scroll_view_get_child (TIDY_SCROLL_VIEW(scroll));
gboolean decelerating = FALSE;
+ gboolean moved = TRUE;
if (event->button != 1)
return FALSE;
}
/* Reset motion event buffer */
+ if (priv->last_motion <= 1)
+ moved = FALSE;
priv->last_motion = 0;
if (!decelerating)
/* Pass through events to children.
* FIXME: this probably breaks click-count.
*/
- clutter_event_put ((ClutterEvent *)event);
+ if (moved == FALSE)
+ clutter_event_put ((ClutterEvent *)event);
return TRUE;
}