[libchamplain] Make sure that viewport is redrawn even when it stops moving
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Make sure that viewport is redrawn even when it stops moving
- Date: Fri, 19 Apr 2013 19:42:46 +0000 (UTC)
commit 44f487e4e2a4698de9598f6cf3da1ab5d07f3362
Author: Jiří Techet <techet gmail com>
Date: Fri Apr 19 19:36:01 2013 +0200
Make sure that viewport is redrawn even when it stops moving
champlain/champlain-view.c | 62 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 13 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 48add5b..a241678 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -182,6 +182,8 @@ struct _ChamplainViewPrivate
gint tiles_loading;
+ guint redraw_timeout;
+
ClutterActor *zoom_container_actor;
gboolean animating_zoom;
guint anim_start_zoom_level;
@@ -235,6 +237,7 @@ static void champlain_view_go_to_with_duration (ChamplainView *view,
gdouble longitude,
guint duration);
static gboolean fill_tile_cb (FillTileCallbackData *data);
+static gboolean redraw_timeout_cb(gpointer view);
/* Updates the internals after the viewport changed */
@@ -556,6 +559,12 @@ champlain_view_dispose (GObject *object)
g_object_unref (priv->background_content);
priv->background_content = NULL;
}
+
+ if (priv->redraw_timeout != 0)
+ {
+ g_source_remove (priv->redraw_timeout);
+ priv->redraw_timeout = 0;
+ }
priv->map_layer = NULL;
priv->license_actor = NULL;
@@ -1008,6 +1017,8 @@ champlain_view_init (ChamplainView *view)
priv->background_content = NULL;
priv->zoom_container_actor = NULL;
+ priv->redraw_timeout = g_timeout_add (350, redraw_timeout_cb, view);
+
g_signal_connect (view, "notify::width", G_CALLBACK (view_size_changed_cb), NULL);
g_signal_connect (view, "notify::height", G_CALLBACK (view_size_changed_cb), NULL);
@@ -1066,30 +1077,55 @@ champlain_view_init (ChamplainView *view)
static void
-viewport_pos_changed_cb (G_GNUC_UNUSED GObject *gobject,
- G_GNUC_UNUSED GParamSpec *arg1,
- ChamplainView *view)
+prepare_update (ChamplainView *view,
+ gfloat x,
+ gfloat y)
+{
+ ChamplainViewPrivate *priv = view->priv;
+ gdouble absolute_x, absolute_y;
+
+ absolute_x = x + priv->anchor_x + priv->viewport_width / 2.0;
+ absolute_y = y + priv->anchor_y + priv->viewport_height / 2.0;
+
+ update_viewport (view, absolute_x, absolute_y, FALSE, TRUE);
+
+ g_timer_start (priv->update_viewport_timer);
+}
+
+
+static gboolean
+redraw_timeout_cb (gpointer data)
{
DEBUG_LOG ()
+ ChamplainView *view = data;
ChamplainViewPrivate *priv = view->priv;
gfloat x, y;
champlain_viewport_get_origin (CHAMPLAIN_VIEWPORT (priv->viewport), &x, &y);
- if (fabs (x - priv->viewport_x) > 100 ||
- fabs (y - priv->viewport_y) > 100 ||
- g_timer_elapsed (priv->update_viewport_timer, NULL) > 0.25)
- {
- gdouble absolute_x, absolute_y;
+ if ((fabs (x - priv->viewport_x) > 0 || fabs (y - priv->viewport_y) > 0) &&
+ g_timer_elapsed (priv->update_viewport_timer, NULL) > 0.30)
+ prepare_update (view, x, y);
+
+ return TRUE;
+}
+
+
+static void
+viewport_pos_changed_cb (G_GNUC_UNUSED GObject *gobject,
+ G_GNUC_UNUSED GParamSpec *arg1,
+ ChamplainView *view)
+{
+ DEBUG_LOG ()
- absolute_x = x + priv->anchor_x + priv->viewport_width / 2.0;
- absolute_y = y + priv->anchor_y + priv->viewport_height / 2.0;
+ ChamplainViewPrivate *priv = view->priv;
+ gfloat x, y;
- update_viewport (view, absolute_x, absolute_y, FALSE, TRUE);
+ champlain_viewport_get_origin (CHAMPLAIN_VIEWPORT (priv->viewport), &x, &y);
- g_timer_start (priv->update_viewport_timer);
- }
+ if (fabs (x - priv->viewport_x) > 100 || fabs (y - priv->viewport_y) > 100)
+ prepare_update (view, x, y);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]