SUBDIRS = tidy src
+
+pcfiles = champlain-1.0.pc
+
+champlain-1.0.pc: champlain.pc
+ @cp -f $< $@
+
+pkgconfig_DATA = $(pcfiles)
+pkgconfigdir = $(libdir)/pkgconfig
PACKAGE_STRING='champlain 0.1'
PACKAGE_BUGREPORT='pierre-luc@squidy.info'
-ac_unique_file="src/champlain_widget.h"
+ac_unique_file="src/champlainview.h"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
\"") >&5
($PKG_CONFIG --exists --print-errors " glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
" 2>/dev/null`
else
pkg_failed=yes
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
\"") >&5
($PKG_CONFIG --exists --print-errors " glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
" 2>/dev/null`
else
pkg_failed=yes
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
"`
else
DEPS_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors " glib-2.0 >= 2.2,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
"`
fi
# Put the nasty error message in config.log where it belongs
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
) were not met:
$DEPS_PKG_ERRORS
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
) were not met:
$DEPS_PKG_ERRORS
# Checks for library functions.
-ac_config_files="$ac_config_files Makefile src/Makefile tidy/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile tidy/Makefile champlain.pc"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"tidy/Makefile") CONFIG_FILES="$CONFIG_FILES tidy/Makefile" ;;
+ "champlain.pc") CONFIG_FILES="$CONFIG_FILES champlain.pc" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
$ac_cs_success || { (exit 1); exit 1; }
fi
+
+
+echo ""
+echo " Champlain $VERSION"
+echo ""
+echo " Prefix: ${prefix}"
+echo " Compiler flags: ${CPPFLAGS}"
+echo ""
PACKAGE_STRING='champlain 0.1'
PACKAGE_BUGREPORT='pierre-luc@squidy.info'
-ac_unique_file="src/champlain_widget.h"
+ac_unique_file="src/champlainview.h"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
\"") >&5
($PKG_CONFIG --exists --print-errors " glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
" 2>/dev/null`
else
pkg_failed=yes
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
\"") >&5
($PKG_CONFIG --exists --print-errors " glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
" 2>/dev/null`
else
pkg_failed=yes
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
"`
else
DEPS_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors " glib-2.0 >= 2.2,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
"`
fi
# Put the nasty error message in config.log where it belongs
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
) were not met:
$DEPS_PKG_ERRORS
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
) were not met:
$DEPS_PKG_ERRORS
# Checks for library functions.
-ac_config_files="$ac_config_files Makefile src/Makefile tidy/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile tidy/Makefile champlain.pc"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"tidy/Makefile") CONFIG_FILES="$CONFIG_FILES tidy/Makefile" ;;
+ "champlain.pc") CONFIG_FILES="$CONFIG_FILES champlain.pc" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
$ac_cs_success || { (exit 1); exit 1; }
fi
+
+
+echo ""
+echo " Champlain $VERSION"
+echo ""
+echo " Prefix: ${prefix}"
+echo " Compiler flags: ${CPPFLAGS}"
+echo ""
m4trace:configure.ac:23: -1- m4_pattern_allow([^DEPS_LIBS$])
m4trace:configure.ac:38: -1- AC_CONFIG_FILES([Makefile
src/Makefile
- tidy/Makefile])
-m4trace:configure.ac:41: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([LIB@&t@OBJS])
-m4trace:configure.ac:41: -1- m4_pattern_allow([^LIB@&t@OBJS$])
-m4trace:configure.ac:41: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([LTLIBOBJS])
-m4trace:configure.ac:41: -1- m4_pattern_allow([^LTLIBOBJS$])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([top_builddir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([srcdir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([abs_srcdir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([top_srcdir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([abs_top_srcdir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([builddir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([abs_builddir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([abs_top_builddir])
-m4trace:configure.ac:41: -1- AC_SUBST_TRACE([INSTALL])
+ tidy/Makefile
+ champlain.pc])
+m4trace:configure.ac:42: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([LIB@&t@OBJS])
+m4trace:configure.ac:42: -1- m4_pattern_allow([^LIB@&t@OBJS$])
+m4trace:configure.ac:42: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([LTLIBOBJS])
+m4trace:configure.ac:42: -1- m4_pattern_allow([^LTLIBOBJS$])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([top_builddir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([srcdir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([abs_srcdir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([top_srcdir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([abs_top_srcdir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([builddir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([abs_builddir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([abs_top_builddir])
+m4trace:configure.ac:42: -1- AC_SUBST_TRACE([INSTALL])
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
])
m4trace:configure.ac:23: -1- PKG_PROG_PKG_CONFIG
m4trace:configure.ac:23: -1- m4_pattern_forbid([^_?PKG_[A-Z_]+$])
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
], [pkg_cv_[]DEPS_CFLAGS=`$PKG_CONFIG --[]cflags " glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
" 2>/dev/null`], [pkg_failed=yes])
m4trace:configure.ac:23: -1- PKG_CHECK_EXISTS([ glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
], [pkg_cv_[]DEPS_LIBS=`$PKG_CONFIG --[]libs " glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
-
+
" 2>/dev/null`], [pkg_failed=yes])
m4trace:configure.ac:23: -1- _PKG_SHORT_ERRORS_SUPPORTED
-m4trace:configure.ac:41: -1- m4_pattern_allow([^LIB@&t@OBJS$])
-m4trace:configure.ac:41: -1- m4_pattern_allow([^LTLIBOBJS$])
-m4trace:configure.ac:41: -1- _AC_AM_CONFIG_HEADER_HOOK([$ac_file])
-m4trace:configure.ac:41: -1- _AM_OUTPUT_DEPENDENCY_COMMANDS
+m4trace:configure.ac:42: -1- m4_pattern_allow([^LIB@&t@OBJS$])
+m4trace:configure.ac:42: -1- m4_pattern_allow([^LTLIBOBJS$])
+m4trace:configure.ac:42: -1- _AC_AM_CONFIG_HEADER_HOOK([$ac_file])
+m4trace:configure.ac:42: -1- _AM_OUTPUT_DEPENDENCY_COMMANDS
--- /dev/null
+prefix=/usr/local
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${exec_prefix}/include
+
+Name: Champlain
+Description: Map View for Gtk+
+Version: 0.1
+Libs: -L${libdir} -lchamplain-1.0
+Cflags: -I${includedir}/champlain-1.0
+Requires: gobject-2.0 clutter-0.8 gtk+-2.10
--- /dev/null
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${exec_prefix}/include
+
+Name: Champlain
+Description: Map View for Gtk+
+Version: @VERSION@
+Libs: -L${libdir} -lchamplain-1.0
+Cflags: -I${includedir}/champlain-1.0
+Requires: gobject-2.0 clutter-0.8 gtk+-2.10
AC_PREREQ(2.61)
AC_INIT(champlain, 0.1, pierre-luc@squidy.info)
-AC_CONFIG_SRCDIR([src/champlain_widget.h])
+AC_CONFIG_SRCDIR([src/champlainview.h])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
AC_SUBST(DEPS_LIBS)
PKG_CHECK_MODULES(DEPS,
- [ glib-2.0 >= 2.2,
+ [ glib-2.0 >= 2.2,
gobject-2.0 >= 2.10,
gtk+-2.0 >= 2.2,
clutter-0.8 >= 0.8,
clutter-gtk-0.8 >= 0.8
- ]
+ ]
)
# Checks for header files.
AC_CONFIG_FILES([Makefile
src/Makefile
- tidy/Makefile])
+ tidy/Makefile
+ champlain.pc])
AC_OUTPUT
+
+
+echo ""
+echo " Champlain $VERSION"
+echo ""
+echo " Prefix: ${prefix}"
+echo " Compiler flags: ${CPPFLAGS}"
+echo ""
CHAMPLAIN_MARSHAL = champlain-marshal
CHAMPLAIN_MARSHAL_LIST = champlain-marshal.list
-bin_PROGRAMS = champlain
+lib_LTLIBRARIES = libchamplain-1.0.la
-nodist_champlain_SOURCES = \
+bin_PROGRAMS = launcher
+
+nodist_libchamplain_1_0_la_SOURCES = \
$(BUILT_SOURCES)
-champlain_SOURCES = $(CHAMPLAIN_MARSHAL_LIST) \
- champlain_widget.c \
- champlain_map.c \
- champlain_map_zoom_level.c \
- champlain_map_tile.c \
- map_source/openstreetmap.c \
- map_source/debugmap.c \
- launcher.c
+launcher_SOURCES = launcher.c
+launcher_LDADD = $(DEPS_LIBS) libchamplain-1.0.la
+
+libchamplain_1_0_la_SOURCES = $(CHAMPLAIN_MARSHAL_LIST) \
+ champlainview.c \
+ map.c \
+ zoomlevel.c \
+ tile.c \
+ sources/openstreetmap.c \
+ sources/debugmap.c
-champlain_LDADD = $(DEPS_LIBS) ../tidy/libtidy-1.0.la
+libchamplain_1_0_la_LIBADD = $(DEPS_LIBS) ../tidy/libtidy-1.0.la
AM_CPPFLAGS = $(DEPS_CFLAGS) -I../tidy
+++ /dev/null
-/*
- * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <champlain_map_zoom_level.h>
-#include <champlain_map_tile.h>
-#include <champlain_map.h>
-#include <champlain_private.h>
-#include <clutter/clutter.h>
-
-ChamplainMapZoomLevel*
-champlain_map_zoom_level_new(gint zoom_level, gint row, gint column, gint tile_size)
-{
- ChamplainMapZoomLevel* level = g_new0(ChamplainMapZoomLevel, 1);
-
- level->level = zoom_level;
- level->row_count = row;
- level->column_count = column;
- level->tile_size = tile_size;
- level->tiles = g_ptr_array_sized_new (row * column);
- level->group = clutter_group_new ();
-
- return level;
-}
-
-void
-champlain_map_zoom_level_create(ChamplainMap* map, gint zoom_level)
-{
- int i;
- for (i = 0; i < map->current_level->row_count * map->current_level->column_count; i++)
- {
- int x = i % map->current_level->column_count;
- int y = i / map->current_level->column_count;
-
- ChamplainMapTile* tile = map->get_tile(map, zoom_level, x, y);
-
- clutter_container_add (CLUTTER_CONTAINER (map->current_level->group), tile->actor, NULL);
- g_ptr_array_add (map->current_level->tiles, tile);
- }
-}
-
-guint
-champlain_map_zoom_level_get_width(ChamplainMapZoomLevel* level)
-{
- return (level->column_count + 1) * level->tile_size;
-}
-
-guint
-champlain_map_zoom_level_get_height(ChamplainMapZoomLevel* level)
-{
- return (level->row_count + 1) * level->tile_size;
-}
#include "config.h"
#include "champlain_defines.h"
-#include "champlain_map_tile.h"
-#include "champlain_map.h"
-#include "champlain_map_zoom_level.h"
-#include "champlain_widget.h"
+#include "champlain_view.h"
+#include "map_tile.h"
+#include "map.h"
+#include "map_zoom_level.h"
#include "champlain-marshal.h"
#include <tidy-finger-scroll.h>
PROP_TBD
};
-static guint champlain_widget_signals[LAST_SIGNAL] = { 0, };
+static guint champlain_view_signals[LAST_SIGNAL] = { 0, };
-#define CHAMPLAIN_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_WIDGET, ChamplainWidgetPrivate))
+#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate))
typedef struct
{
ClutterUnit y;
} ChamplainPoint;
-struct _ChamplainWidgetPrivate
+struct _ChamplainViewPrivate
{
GtkWidget *clutterEmbed;
ClutterActor *viewport;
ChamplainPoint viewportSize;
ClutterActor *fingerScroll;
- ChamplainMap *map;
+ Map *map;
};
-G_DEFINE_TYPE (ChamplainWidget, champlain_widget, GTK_TYPE_ALIGNMENT);
+G_DEFINE_TYPE (ChamplainView, champlain_view, GTK_TYPE_ALIGNMENT);
static void
-champlain_widget_finalize (GObject * object)
+champlain_view_finalize (GObject * object)
{
- ChamplainWidget *widget = CHAMPLAIN_WIDGET (object);
- ChamplainWidgetPrivate *priv = CHAMPLAIN_WIDGET_GET_PRIVATE (widget);
+ ChamplainView *view = CHAMPLAIN_VIEW (object);
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
- G_OBJECT_CLASS (champlain_widget_parent_class)->finalize (object);
+ G_OBJECT_CLASS (champlain_view_parent_class)->finalize (object);
}
static void
-champlain_widget_class_init (ChamplainWidgetClass *champlainWidgetClass)
+champlain_view_class_init (ChamplainViewClass *champlainViewClass)
{
- g_type_class_add_private (champlainWidgetClass, sizeof (ChamplainWidgetPrivate));
+ g_type_class_add_private (champlainViewClass, sizeof (ChamplainViewPrivate));
- GObjectClass *objectClass = G_OBJECT_CLASS (champlainWidgetClass);
- objectClass->finalize = champlain_widget_finalize;
+ GObjectClass *objectClass = G_OBJECT_CLASS (champlainViewClass);
+ objectClass->finalize = champlain_view_finalize;
}
static void
-champlain_widget_init (ChamplainWidget *champlainWidget)
+champlain_view_init (ChamplainView *champlainView)
{
- ChamplainWidgetPrivate *priv = CHAMPLAIN_WIDGET_GET_PRIVATE (champlainWidget);
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
}
static void
-widget_size_allocated_cb (GtkWidget *widget, GtkAllocation *allocation, ChamplainWidget *champlainWidget)
+view_size_allocated_cb (GtkWidget *view, GtkAllocation *allocation, ChamplainView *champlainView)
{
gdouble lower, upper;
TidyAdjustment *hadjust, *vadjust;
- ChamplainWidgetPrivate *priv = CHAMPLAIN_WIDGET_GET_PRIVATE (champlainWidget);
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
priv->viewportSize.x = allocation->width;
priv->viewportSize.y = allocation->height;
clutter_actor_set_size (priv->fingerScroll, priv->viewportSize.x, priv->viewportSize.y);
tidy_adjustment_get_values (hadjust, NULL, &lower, &upper, NULL, NULL, NULL);
lower = 0;
- upper = champlain_map_zoom_level_get_width(priv->map->current_level) - priv->viewportSize.x;
+ upper = map_zoom_level_get_width(priv->map->current_level) - priv->viewportSize.x;
g_object_set (hadjust, "lower", lower, "upper", upper,
"step-increment", 1.0, "elastic", TRUE, NULL);
tidy_adjustment_get_values (vadjust, NULL, &lower, &upper, NULL, NULL, NULL);
lower = 0;
- upper = champlain_map_zoom_level_get_height(priv->map->current_level) - priv->viewportSize.y;
+ upper = map_zoom_level_get_height(priv->map->current_level) - priv->viewportSize.y;
g_object_set (vadjust, "lower", lower, "upper", upper,
"step-increment", 1.0, "elastic", TRUE, NULL);
+
}
GtkWidget *
-champlain_widget_new ()
+champlain_view_new ()
{
ClutterColor stage_color = { 0x34, 0x39, 0x39, 0xff };
- ChamplainWidget *widget;
+ ChamplainView *view;
ClutterActor *stage;
- widget = CHAMPLAIN_WIDGET (g_object_new (CHAMPLAIN_TYPE_WIDGET, NULL));
- ChamplainWidgetPrivate *priv = CHAMPLAIN_WIDGET_GET_PRIVATE (widget);
+ view = CHAMPLAIN_VIEW (g_object_new (CHAMPLAIN_TYPE_VIEW, NULL));
+ ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
priv->viewportSize.x = 640;
priv->viewportSize.y = 480;
priv->clutterEmbed = gtk_clutter_embed_new ();
g_signal_connect (priv->clutterEmbed,
"size-allocate",
- G_CALLBACK (widget_size_allocated_cb),
- widget);
+ G_CALLBACK (view_size_allocated_cb),
+ view);
// Setup stage
stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutterEmbed));
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
- gtk_container_add (GTK_CONTAINER (widget), priv->clutterEmbed);
+ gtk_container_add (GTK_CONTAINER (view), priv->clutterEmbed);
// Setup viewport
priv->viewport = tidy_viewport_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (priv->fingerScroll), priv->viewport);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->fingerScroll);
- priv->map = champlain_map_new(CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP);//OPENSTREETMAP
- champlain_map_load(priv->map, 4);
+ priv->map = map_new(CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP);//OPENSTREETMAP
+ map_load(priv->map, 4);
clutter_container_add_actor (CLUTTER_CONTAINER (group), priv->map->current_level->group);
- return GTK_WIDGET (widget);
+ return GTK_WIDGET (view);
}
* Boston, MA 02110-1301, USA.
*/
-#ifndef CHAMPLAIN_WIDGET_H
-#define CHAMPLAIN_WIDGET_H
+#ifndef CHAMPLAIN_VIEW_H
+#define CHAMPLAIN_VIEW_H
#include <champlain_defines.h>
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
-G_BEGIN_DECLS
-#define CHAMPLAIN_TYPE_WIDGET (champlain_widget_get_type())
-#define CHAMPLAIN_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_WIDGET, ChamplainWidget))
-#define CHAMPLAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CHAMPLAIN_TYPE_WIDGET, ChamplainWidgetClass))
-#define CHAMPLAIN_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHAMPLAIN_TYPE_WIDGET))
-#define CHAMPLAIN_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CHAMPLAIN_TYPE_WIDGET))
-#define CHAMPLAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHAMPLAIN_TYPE_WIDGET, ChamplainWidgetClass))
-typedef struct _ChamplainWidgetPrivate ChamplainWidgetPrivate;
+typedef enum
+{
+ CHAMPLAIN_MAP_SOURCE_DEBUG,
+ CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP,
+ CHAMPLAIN_MAP_SOURCE_GOOGLE
+} ChamplainMapSource;
+
+#define CHAMPLAIN_TYPE_VIEW (champlain_view_get_type())
+#define CHAMPLAIN_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CHAMPLAIN_TYPE_VIEW, ChamplainView))
+#define CHAMPLAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CHAMPLAIN_TYPE_VIEW, ChamplainViewClass))
+#define CHAMPLAIN_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CHAMPLAIN_TYPE_VIEW))
+#define CHAMPLAIN_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CHAMPLAIN_TYPE_VIEW))
+#define CHAMPLAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewClass))
+
+typedef struct _ChamplainViewPrivate ChamplainViewPrivate;
-struct _ChamplainWidget
+struct _ChamplainView
{
GtkAlignment bin;
- ChamplainWidgetPrivate *priv;
+ ChamplainViewPrivate *priv;
};
-struct _ChamplainWidgetClass
+struct _ChamplainViewClass
{
GtkBinClass parent_class;
- ChamplainWidget *(*create_widget) (ChamplainWidget * widget);
-
- void (*set_scroll_adjustments) (ChamplainWidget * widget, GtkAdjustment * hadjustment, GtkAdjustment * vadjustment);
-
};
-CHAMPLAIN_API GType champlain_widget_get_type (void);
-
-CHAMPLAIN_API GtkWidget *champlain_widget_new (void);
+CHAMPLAIN_API GType champlain_view_get_type (void);
-#define TILE_SIZE 100
-#define ROW_SIZE 5
+CHAMPLAIN_API GtkWidget *champlain_view_new (void);
#endif
*/
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy), NULL);
- widget = champlain_widget_new ();
+ widget = champlain_view_new ();
/* and insert it into the main window */
gtk_container_add (GTK_CONTAINER (window), widget);
* Boston, MA 02110-1301, USA.
*/
-#include <champlain_map.h>
-#include <champlain_map_zoom_level.h>
+#include <map.h>
+#include <zoomlevel.h>
-ChamplainMap*
-champlain_map_new (ChamplainMapSourceId source)
+Map*
+map_new (ChamplainMapSource source)
{
- ChamplainMap* map = g_new0(ChamplainMap, 1);
+ Map* map = g_new0(Map, 1);
- switch(source)
- {
- case CHAMPLAIN_MAP_SOURCE_DEBUG:
- debugmap_init(map);
- break;
- case CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP:
- osm_init(map);
- break;
- }
-
- return map;
+ switch(source)
+ {
+ case CHAMPLAIN_MAP_SOURCE_DEBUG:
+ debugmap_init(map);
+ break;
+ case CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP:
+ osm_init(map);
+ break;
+ }
+
+ return map;
}
void
-champlain_map_load(ChamplainMap* map, gint zoom_level)
+map_load(Map* map, gint zoom_level)
{
- guint row_count = map->get_row_count(map, zoom_level);
- guint column_count = map->get_column_count(map, zoom_level);
-
- map->current_level = champlain_map_zoom_level_new(zoom_level, row_count, column_count, map->tile_size);
- champlain_map_zoom_level_create(map, zoom_level);
+ guint row_count = map->get_row_count(map, zoom_level);
+ guint column_count = map->get_column_count(map, zoom_level);
+
+ map->current_level = zoom_level_new(zoom_level, row_count, column_count, map->tile_size);
+ zoom_level_create(map, zoom_level);
}
* Boston, MA 02110-1301, USA.
*/
-#ifndef CHAMPLAIN_MAP_H
-#define CHAMPLAIN_MAP_H
+#ifndef MAP_H
+#define MAP_H
+#include "champlainview.h"
#include "champlain_defines.h"
-#include "champlain_map_zoom_level.h"
-#include "champlain_map_tile.h"
+#include "zoomlevel.h"
+#include "tile.h"
+
#include <glib.h>
#include <clutter/clutter.h>
-struct _ChamplainMap
+struct _Map
{
int zoom_levels;
const gchar* name;
- ChamplainMapZoomLevel* current_level;
+ ZoomLevel* current_level;
int tile_size;
- ChamplainMapTile* (* get_tile) (ChamplainMap* map, guint zoom_level, guint x, guint y);
- guint (* get_row_count) (ChamplainMap* map, guint zoom_level);
- guint (* get_column_count) (ChamplainMap* map, guint zoom_level);
+ Tile* (* get_tile) (Map* map, guint zoom_level, guint x, guint y);
+ guint (* get_row_count) (Map* map, guint zoom_level);
+ guint (* get_column_count) (Map* map, guint zoom_level);
-} ;
+};
-CHAMPLAIN_API ChamplainMap* champlain_map_new (ChamplainMapSourceId source);
+CHAMPLAIN_API Map* champlain_map_new (ChamplainMapSource source);
#endif
+++ /dev/null
-/*
- * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "map_source/debugmap.h"
-#include <math.h>
-
-guint debugmap_row_count(ChamplainMap* map, guint zoom_level);
-guint debugmap_column_count(ChamplainMap* map, guint zoom_level);
-ChamplainMapTile* debugmap_get_tile (ChamplainMap* map, guint zoom_level, guint x, guint y);
-
-void
-debugmap_init(ChamplainMap* map)
-{
- map->name = "Debug";
- map->zoom_levels = 1;
- map->tile_size = 256;
-
- map->get_row_count = debugmap_row_count;
- map->get_column_count = debugmap_column_count;
- map->get_tile = debugmap_get_tile;
-}
-
-guint debugmap_row_count(ChamplainMap* map, guint zoom_level)
-{
- return pow (2, zoom_level);
-}
-
-guint debugmap_column_count(ChamplainMap* map, guint zoom_level)
-{
- return pow (2, zoom_level);
-}
-
-ChamplainMapTile* debugmap_get_tile (ChamplainMap* map, guint zoom_level, guint x, guint y)
-{
-
- ChamplainMapTile* tile = g_new0(ChamplainMapTile, 1);
-
- ClutterColor white;
- clutter_color_parse ("white", &white);
- ClutterColor blue;
- clutter_color_parse ("blue", &blue);
-
- ClutterColor * color, * textColor;
- if ((y + x) % 2)
- {
- color = &blue;
- textColor = &white;
- }
- else
- {
- color = &white;
- textColor = &blue;
- }
-
-
- tile->x = x;
- tile->y = y;
- tile->visible = FALSE;
- tile->actor = clutter_group_new();
-
- ClutterActor* actor = clutter_rectangle_new_with_color (color);
- clutter_actor_set_position (actor, x * map->tile_size, y * map->tile_size);
- clutter_actor_set_size (actor, map->tile_size, map->tile_size);
- clutter_actor_show (actor);
- clutter_container_add_actor (CLUTTER_CONTAINER (tile->actor), actor);
-
- actor = clutter_label_new_full ("Arial", g_strdup_printf("%d, %d", x, y), textColor);
- clutter_actor_set_position (actor, x * map->tile_size + map->tile_size/2.25, y * map->tile_size + map->tile_size/2.25);
- clutter_container_add_actor (CLUTTER_CONTAINER (tile->actor), actor);
-
- g_object_ref(tile->actor); // to prevent actors to be destroyed when they are removed from groups
-
- return tile;
-}
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "sources/debugmap.h"
+#include <math.h>
+
+guint debugmap_row_count(Map* map, guint zoom_level);
+guint debugmap_column_count(Map* map, guint zoom_level);
+Tile* debugmap_get_tile (Map* map, guint zoom_level, guint x, guint y);
+
+void
+debugmap_init(Map* map)
+{
+ map->name = "Debug";
+ map->zoom_levels = 1;
+ map->tile_size = 256;
+
+ map->get_row_count = debugmap_row_count;
+ map->get_column_count = debugmap_column_count;
+ map->get_tile = debugmap_get_tile;
+}
+
+guint debugmap_row_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+guint debugmap_column_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+Tile* debugmap_get_tile (Map* map, guint zoom_level, guint x, guint y)
+{
+
+ Tile* tile = g_new0(Tile, 1);
+
+ ClutterColor white;
+ clutter_color_parse ("white", &white);
+ ClutterColor blue;
+ clutter_color_parse ("blue", &blue);
+
+ ClutterColor * color, * textColor;
+ if ((y + x) % 2)
+ {
+ color = &blue;
+ textColor = &white;
+ }
+ else
+ {
+ color = &white;
+ textColor = &blue;
+ }
+
+ tile->x = x;
+ tile->y = y;
+ tile->visible = FALSE;
+ tile->actor = clutter_group_new();
+
+ ClutterActor* actor = clutter_rectangle_new_with_color (color);
+ clutter_actor_set_position (actor, x * map->tile_size, y * map->tile_size);
+ clutter_actor_set_size (actor, map->tile_size, map->tile_size);
+ clutter_actor_show (actor);
+ clutter_container_add_actor (CLUTTER_CONTAINER (tile->actor), actor);
+
+ actor = clutter_label_new_full ("Arial", g_strdup_printf("%d, %d", x, y), textColor);
+ clutter_actor_set_position (actor, x * map->tile_size + map->tile_size/2.25, y * map->tile_size + map->tile_size/2.25);
+ clutter_container_add_actor (CLUTTER_CONTAINER (tile->actor), actor);
+
+ g_object_ref(tile->actor); // to prevent actors to be destroyed when they are removed from groups
+
+ return tile;
+}
#ifndef OPENSTREETMAP_H
#define OPENSTREETMAP_H
-#include <champlain_map.h>
+#include <map.h>
-void debugmap_init(ChamplainMap* map);
+void debugmap_init(Map* map);
#endif
* Boston, MA 02110-1301, USA.
*/
-#include "map_source/openstreetmap.h"
-#include <champlain_map.h>
+#include "sources/openstreetmap.h"
+#include <map.h>
#include <math.h>
//http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames#C.2FC.2B.2B
-guint osm_row_count(ChamplainMap* map, guint zoom_level);
-guint osm_column_count(ChamplainMap* map, guint zoom_level);
-ChamplainMapTile* osm_get_tile (ChamplainMap* map, guint zoom_level, guint x, guint y);
+guint osm_row_count(Map* map, guint zoom_level);
+guint osm_column_count(Map* map, guint zoom_level);
+Tile* osm_get_tile (Map* map, guint zoom_level, guint x, guint y);
void
-osm_init(ChamplainMap* map)
+osm_init(Map* map)
{
- map->name = "OpenStreetMap";
- map->zoom_levels = 17;
+ map->name = "OpenStreetMap";
+ map->zoom_levels = 17;
map->tile_size = 256;
map->get_row_count = osm_row_count;
map->get_tile = osm_get_tile;
}
-guint osm_row_count(ChamplainMap* map, guint zoom_level)
+guint osm_row_count(Map* map, guint zoom_level)
{
- return pow (2, zoom_level);
+ return pow (2, zoom_level);
}
-guint osm_column_count(ChamplainMap* map, guint zoom_level)
+guint osm_column_count(Map* map, guint zoom_level)
{
- return pow (2, zoom_level);
+ return pow (2, zoom_level);
}
-ChamplainMapTile* osm_get_tile (ChamplainMap* map, guint zoom_level, guint x, guint y)
+Tile* osm_get_tile (Map* map, guint zoom_level, guint x, guint y)
{
- ChamplainMapTile* tile = g_new0(ChamplainMapTile, 1);
-
- tile->x = x;
- tile->y = y;
- tile->visible = FALSE;
+ Tile* tile = g_new0(Tile, 1);
+
+ tile->x = x;
+ tile->y = y;
+ tile->visible = FALSE;
// For no apparent reason, the group is necessary even if
// it contains only one actor... if missing, the viewport will break
- tile->actor = clutter_group_new();
-
- ClutterActor* actor = clutter_texture_new_from_file(g_strdup_printf("/home/plbeaudoin/champlain/tiles/%d/%d/%d.png", zoom_level, x, y), NULL);
- clutter_actor_set_position (actor, x * map->tile_size, y * map->tile_size);
- clutter_actor_set_size (actor, map->tile_size, map->tile_size);
- clutter_actor_show (actor);
+ tile->actor = clutter_group_new();
+
+ ClutterActor* actor = clutter_texture_new_from_file(g_strdup_printf("/home/plbeaudoin/champlain/tiles/%d/%d/%d.png", zoom_level, x, y), NULL);
+ clutter_actor_set_position (actor, x * map->tile_size, y * map->tile_size);
+ clutter_actor_set_size (actor, map->tile_size, map->tile_size);
+ clutter_actor_show (actor);
clutter_container_add_actor (CLUTTER_CONTAINER (tile->actor), actor);
- g_object_ref(tile->actor); // to prevent actors to be destroyed when they are removed from groups
-
- return tile;
-
+ g_object_ref(tile->actor); // to prevent actors to be destroyed when they are removed from groups
+
+ return tile;
+
}
#ifndef OPENSTREETMAP_H
#define OPENSTREETMAP_H
-#include <champlain_map.h>
+#include <map.h>
-void osm_init(ChamplainMap* map);
+void osm_init(Map* map);
#endif
*/
-#include "champlain_map_tile.h"
+#include "tile.h"
/*
gboolean
-tile_is_visible(ClutterUnit viewport_w, ClutterUnit viewport_h, ChamplainPoint position, ChamplainMapTile* tile)
+tile_is_visible(ClutterUnit viewport_w, ClutterUnit viewport_h, ChamplainPoint position, MapTile* tile)
{
- ClutterUnit size = CLUTTER_UNITS_FROM_INT(tile->size);
+ ClutterUnit size = CLUTTER_UNITS_FROM_INT(tile->size);
-
- if( ((tile->x + 1)* size + position.x < 0 || tile->x* size + position.x > viewport_w) ||
- ((tile->y + 1)* size + position.y < 0 || tile->y* size + position.y > viewport_h))
- {
- g_print ("Tile I: %d, %d\t p: %d, %d \n",
- tile->x, tile->y,
- CLUTTER_UNITS_TO_INT (position.x),
- CLUTTER_UNITS_TO_INT (position.y));
- return FALSE;
- }
- //g_print ("Tile V: %d, %d\t p: %d, %d \n",
- //tile->x, tile->y,
- //CLUTTER_UNITS_TO_INT (position.x),
- //CLUTTER_UNITS_TO_INT (position.y));
- return TRUE;
+ if( ((tile->x + 1)* size + position.x < 0 || tile->x* size + position.x > viewport_w) ||
+ ((tile->y + 1)* size + position.y < 0 || tile->y* size + position.y > viewport_h))
+ {
+ g_print ("Tile I: %d, %d\t p: %d, %d \n",
+ tile->x, tile->y,
+ CLUTTER_UNITS_TO_INT (position.x),
+ CLUTTER_UNITS_TO_INT (position.y));
+ return FALSE;
+ }
+ //g_print ("Tile V: %d, %d\t p: %d, %d \n",
+ //tile->x, tile->y,
+ //CLUTTER_UNITS_TO_INT (position.x),
+ //CLUTTER_UNITS_TO_INT (position.y));
+ return TRUE;
}*/
int size;
gboolean visible; // Wether the tile is visible in the viewport
-} ChamplainMapTile;
+} Tile;
#endif
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <zoomlevel.h>
+#include <tile.h>
+#include "map.h"
+#include <champlain_private.h>
+#include <clutter/clutter.h>
+
+ZoomLevel*
+zoom_level_new(gint zoom_level, gint row, gint column, gint tile_size)
+{
+ ZoomLevel* level = g_new0(ZoomLevel, 1);
+
+ level->level = zoom_level;
+ level->row_count = row;
+ level->column_count = column;
+ level->tile_size = tile_size;
+ level->tiles = g_ptr_array_sized_new (row * column);
+ level->group = clutter_group_new ();
+
+ return level;
+}
+
+void
+zoom_level_create(Map* map, gint zoom_level)
+{
+ int i;
+ for (i = 0; i < map->current_level->row_count * map->current_level->column_count; i++)
+ {
+ int x = i % map->current_level->column_count;
+ int y = i / map->current_level->column_count;
+
+ Tile* tile = map->get_tile(map, zoom_level, x, y);
+
+ clutter_container_add (CLUTTER_CONTAINER (map->current_level->group), tile->actor, NULL);
+ g_ptr_array_add (map->current_level->tiles, tile);
+ }
+}
+
+guint
+zoom_level_get_width(ZoomLevel* level)
+{
+ return (level->column_count + 1) * level->tile_size;
+}
+
+guint
+zoom_level_get_height(ZoomLevel* level)
+{
+ return (level->row_count + 1) * level->tile_size;
+}
GPtrArray *tiles;
ClutterActor* group;
-} ChamplainMapZoomLevel;
+} ZoomLevel;
-guint champlain_map_zoom_level_get_width(ChamplainMapZoomLevel* level);
+guint zoom_level_get_width(ZoomLevel* level);
-guint champlain_map_zoom_level_get_height(ChamplainMapZoomLevel* level);
+guint zoom_level_get_height(ZoomLevel* level);
-ChamplainMapZoomLevel* champlain_map_zoom_level_new(gint zoom_level, gint row, gint column, gint tile_size);
+ZoomLevel* zoom_level_new(gint zoom_level, gint row, gint column, gint tile_size);
#endif