]> err.no Git - libchamplain/commitdiff
decel-rate and mode var
authorPierre-Luc Beaudoin <pierre-luc@squidy.info>
Fri, 29 Aug 2008 17:45:39 +0000 (13:45 -0400)
committerPierre-Luc Beaudoin <pierlux@carbon.(none)>
Fri, 29 Aug 2008 17:45:39 +0000 (13:45 -0400)
champlain/champlainview.c
champlain/champlainview.h
champlain/launcher.c
champlain/tile.c

index 698a358186f96e2f613d6b18f4003f5b45177146..d65c461a2c0ebf779ce56ecadeff54be2cbe2563 100644 (file)
@@ -40,6 +40,7 @@
 enum
 {
   /* normal signals */
+  SIGNAL_TBD,
   LAST_SIGNAL
 };
 
@@ -50,7 +51,8 @@ enum
   PROP_LATITUDE,
   PROP_ZOOM_LEVEL,
   PROP_MAP_SOURCE,
-  PROP_OFFLINE
+  PROP_OFFLINE,
+  PROP_DECEL_RATE,
 };
 
 static guint champlain_view_signals[LAST_SIGNAL] = { 0, };
@@ -167,6 +169,13 @@ champlain_view_get_property(GObject* object, guint prop_id, GValue* value, GPara
         case PROP_OFFLINE:
           g_value_set_boolean(value, priv->offline);
           break;
+        case PROP_DECEL_RATE:
+          {
+            gdouble decel;
+            g_object_get (priv->fingerScroll, "decel-rate", decel, NULL);
+            g_value_set_double(value, decel);
+            break;
+          }
         default:
           G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
       }
@@ -248,6 +257,12 @@ champlain_view_set_property(GObject* object, guint prop_id, const GValue* value,
       case PROP_OFFLINE:
         priv->offline = g_value_get_boolean(value);
         break;
+      case PROP_DECEL_RATE:
+        {
+          gdouble decel = g_value_get_double(value);
+          g_object_set (priv->fingerScroll, "decel-rate", decel, NULL);
+          break;
+        }
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     }
@@ -267,10 +282,10 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
 {
   g_type_class_add_private (champlainViewClass, sizeof (ChamplainViewPrivate));
 
-  GObjectClass *objectClass = G_OBJECT_CLASS (champlainViewClass);
-  objectClass->finalize = champlain_view_finalize;
-  objectClass->get_property = champlain_view_get_property;
-  objectClass->set_property = champlain_view_set_property;
+  GObjectClass *object_class = G_OBJECT_CLASS (champlainViewClass);
+  object_class->finalize = champlain_view_finalize;
+  object_class->get_property = champlain_view_get_property;
+  object_class->set_property = champlain_view_set_property;
   
   /**
   * ChamplainView:longitude:
@@ -279,7 +294,7 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
   *
   * Since: 0.1
   */
-  g_object_class_install_property(objectClass, PROP_LONGITUDE,
+  g_object_class_install_property(object_class, PROP_LONGITUDE,
                                   g_param_spec_float("longitude",
                                                      "Longitude",
                                                      "The longitude coordonate of the map",
@@ -295,7 +310,7 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
   *
   * Since: 0.1
   */
-  g_object_class_install_property(objectClass, PROP_LATITUDE,
+  g_object_class_install_property(object_class, PROP_LATITUDE,
                                   g_param_spec_float("latitude",
                                                      "Latitude",
                                                      "The latitude coordonate of the map",
@@ -311,7 +326,7 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
   *
   * Since: 0.1
   */
-  g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL,
+  g_object_class_install_property(object_class, PROP_ZOOM_LEVEL,
                                   g_param_spec_int("zoom-level",
                                                    "Zoom level",
                                                    "The level of zoom of the map",
@@ -328,7 +343,7 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
   *
   * Since: 0.1
   */
-   g_object_class_install_property(objectClass, PROP_MAP_SOURCE,
+  g_object_class_install_property(object_class, PROP_MAP_SOURCE,
                                   g_param_spec_int("map-source",
                                                    "Map source",
                                                    "The map source being displayed",
@@ -344,12 +359,31 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
   *
   * Since: 0.2
   */
-   g_object_class_install_property(objectClass, PROP_OFFLINE,
+  g_object_class_install_property(object_class, PROP_OFFLINE,
                                   g_param_spec_boolean("offline",
                                                        "Offline Mode",
                                                        "If viewer is in offline mode.",
                                                        FALSE,
                                                        CHAMPLAIN_PARAM_READWRITE)); 
+
+  /**
+  * ChamplainView:offline:
+  *
+  * If true, will fetch tiles from the Internet, otherwise, will only use cached content.
+  *
+  * Since: 0.2
+  */
+  g_object_class_install_property (object_class,
+                                   PROP_DECEL_RATE,
+                                   g_param_spec_double ("decel-rate",
+                                                        "Deceleration rate",
+                                                        "Rate at which the view "
+                                                        "will decelerate in "
+                                                        "kinetic mode.",
+                                                        CLUTTER_FIXED_TO_FLOAT (CFX_ONE + CFX_MIN),
+                                                        CLUTTER_FIXED_TO_FLOAT (CFX_MAX),
+                                                        1.1,
+                                                        G_PARAM_READWRITE));
 }
 
 static void
@@ -405,7 +439,7 @@ view_size_allocated_cb (GtkWidget *view, GtkAllocation *allocation, ChamplainVie
  * Since: 0.1
  */
 GtkWidget *
-champlain_view_new ()
+champlain_view_new (ChamplainViewMode mode)
 {
   ClutterColor stage_color = { 0x34, 0x39, 0x39, 0xff };
   ChamplainView *view;
@@ -435,8 +469,19 @@ champlain_view_new ()
                     view);
 
   // Setup finger scroll
-  priv->fingerScroll = tidy_finger_scroll_new(TIDY_FINGER_SCROLL_MODE_KINETIC);
-  g_object_set (priv->fingerScroll, "decel-rate", 1.25, NULL);
+  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->fingerScroll = tidy_finger_scroll_new(mode);
+
   clutter_container_add_actor (CLUTTER_CONTAINER (priv->fingerScroll), priv->viewport);
   clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->fingerScroll);
 
index 2abb279e7f836ca774b331d328d4fe0f745c2997..f9d1a0b6c0e20e7f2c8a094188ef9aa4c3ba8185 100644 (file)
@@ -46,6 +46,18 @@ typedef enum
 
 typedef struct _ChamplainViewPrivate ChamplainViewPrivate;
 
+/**
+ * ChamplainViewMode:
+ * @CHAMPLAIN_VIEW_MODE_PUSH: Non-kinetic scrolling
+ * @CHAMPLAIN_VIEW_MODE_KINETIC: Kinetic scrolling
+ *
+ * Type of scrolling.
+ */
+typedef enum {
+  CHAMPLAIN_VIEW_MODE_PUSH,
+  CHAMPLAIN_VIEW_MODE_KINETIC
+} ChamplainViewMode;
+
 struct _ChamplainView
 {
   GtkAlignment bin;
@@ -61,7 +73,7 @@ struct _ChamplainViewClass
 
 CHAMPLAIN_API GType champlain_view_get_type (void);
 
-CHAMPLAIN_API GtkWidget *champlain_view_new ();
+CHAMPLAIN_API GtkWidget *champlain_view_new (ChamplainViewMode mode);
 
 CHAMPLAIN_API void champlain_view_center_on (ChamplainView *view, gdouble longitude, gdouble latitude);
 
index b4b6af0dca2ac8b890508d24643862a03f2fd421..2bab2f5f46affc686fa23700fba821064edd74d0 100644 (file)
@@ -114,8 +114,10 @@ main (int argc, char *argv[])
 
   vbox = gtk_vbox_new(FALSE, 10);
   
-  widget = champlain_view_new ();
+  widget = champlain_view_new (CHAMPLAIN_VIEW_MODE_KINETIC);
   g_object_set(G_OBJECT(widget), "zoom-level", 5, NULL);
+//  g_object_set(G_OBJECT(widget), "decel-rate", 1.1, NULL);
+//  g_object_set(G_OBJECT(widget), "offline", TRUE, NULL);
   
   gtk_widget_set_size_request(widget, 640, 480);
   
index fd4deb49e4ac2ce8488105c6838696b6de24386b..6fc2de572eadbabac67cc9fc28e387ea1e918267 100644 (file)
@@ -41,6 +41,7 @@ tile_set(Tile* tile)
   clutter_actor_set_size (tile->actor, tile->size, tile->size);
   clutter_actor_show (tile->actor);
 }
+
 static void 
 create_error_tile(Map* map, Tile* tile)
 {