]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikaggregatelayer.c
Add Terraserver
[andy/viking.git] / src / vikaggregatelayer.c
index 426aa0bc830f5f4e4eae4761810b77e6b76453b9..884340f787ca5dc20fd362e58092869817e05346 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include "viking.h"
  */
 
 #include "viking.h"
-#include "vikaggregatelayer_pixmap.h"
+#include "icons/icons.h"
 
 #include <string.h>
 
 
 #include <string.h>
 
@@ -33,7 +33,7 @@ static void aggregate_layer_drag_drop_request ( VikAggregateLayer *val_src, VikA
 
 VikLayerInterface vik_aggregate_layer_interface = {
   "Aggregate",
 
 VikLayerInterface vik_aggregate_layer_interface = {
   "Aggregate",
-  &aggregatelayer_pixbuf,
+  &vikaggregatelayer_pixbuf,
 
   NULL,
   0,
 
   NULL,
   0,
@@ -165,7 +165,7 @@ static VikAggregateLayer *aggregate_layer_unmarshall( guint8 *data, gint len, Vi
     child_layer = vik_layer_unmarshall ( data + sizeof(gint), alm_size, vvp );
     if (child_layer) {
       rv->children = g_list_append ( rv->children, child_layer );
     child_layer = vik_layer_unmarshall ( data + sizeof(gint), alm_size, vvp );
     if (child_layer) {
       rv->children = g_list_append ( rv->children, child_layer );
-      g_signal_connect_swapped ( G_OBJECT(child_layer), "update", G_CALLBACK(vik_layer_emit_update), rv );
+      g_signal_connect_swapped ( G_OBJECT(child_layer), "update", G_CALLBACK(vik_layer_emit_update_secondary), rv );
     }
     alm_next;
   }
     }
     alm_next;
   }
@@ -204,7 +204,7 @@ void vik_aggregate_layer_insert_layer ( VikAggregateLayer *val, VikLayer *l, Gtk
   } else {
     val->children = g_list_append ( val->children, l );
   }
   } else {
     val->children = g_list_append ( val->children, l );
   }
-  g_signal_connect_swapped ( G_OBJECT(l), "update", G_CALLBACK(vik_layer_emit_update), val );
+  g_signal_connect_swapped ( G_OBJECT(l), "update", G_CALLBACK(vik_layer_emit_update_secondary), val );
 }
 
 void vik_aggregate_layer_add_layer ( VikAggregateLayer *val, VikLayer *l )
 }
 
 void vik_aggregate_layer_add_layer ( VikAggregateLayer *val, VikLayer *l )
@@ -223,7 +223,7 @@ void vik_aggregate_layer_add_layer ( VikAggregateLayer *val, VikLayer *l )
   }
 
   val->children = g_list_append ( val->children, l );
   }
 
   val->children = g_list_append ( val->children, l );
-  g_signal_connect_swapped ( G_OBJECT(l), "update", G_CALLBACK(vik_layer_emit_update), val );
+  g_signal_connect_swapped ( G_OBJECT(l), "update", G_CALLBACK(vik_layer_emit_update_secondary), val );
 }
 
 void vik_aggregate_layer_move_layer ( VikAggregateLayer *val, GtkTreeIter *child_iter, gboolean up )
 }
 
 void vik_aggregate_layer_move_layer ( VikAggregateLayer *val, GtkTreeIter *child_iter, gboolean up )
@@ -265,9 +265,34 @@ void vik_aggregate_layer_move_layer ( VikAggregateLayer *val, GtkTreeIter *child
     val->children = second;
 }
 
     val->children = second;
 }
 
+/* Draw the aggregate layer. If vik viewport is in half_drawn mode, this means we are only
+ * to draw the layers above and including the trigger layer.
+ * To do this we don't draw any layers if in half drawn mode, unless we find the
+ * trigger layer, in which case we pull up the saved pixmap, turn off half drawn mode and
+ * start drawing layers.
+ * Also, if we were never in half drawn mode, we save a snapshot
+ * of the pixmap before drawing the trigger layer so we can use it again
+ * later.
+ */
 void vik_aggregate_layer_draw ( VikAggregateLayer *val, gpointer data )
 {
 void vik_aggregate_layer_draw ( VikAggregateLayer *val, gpointer data )
 {
-  g_list_foreach ( val->children, (GFunc)(vik_layer_draw), data );
+  GList *iter = val->children;
+  VikLayer *vl;
+  VikLayer *trigger = VIK_LAYER(vik_viewport_get_trigger( VIK_VIEWPORT(data) ));
+  while ( iter ) {
+    vl = VIK_LAYER(iter->data);
+    if ( vl == trigger ) {
+      if ( vik_viewport_get_half_drawn ( VIK_VIEWPORT(data) ) ) {
+        vik_viewport_set_half_drawn ( VIK_VIEWPORT(data), FALSE );
+        vik_viewport_snapshot_load( VIK_VIEWPORT(data) );
+      } else {
+        vik_viewport_snapshot_save( VIK_VIEWPORT(data) );
+      }
+    }
+    if ( vl->type == VIK_LAYER_AGGREGATE || vl->type == VIK_LAYER_GPS || ! vik_viewport_get_half_drawn( VIK_VIEWPORT(data) ) )
+      vik_layer_draw ( vl, data );
+    iter = iter->next;
+  }
 }
 
 static void aggregate_layer_change_coord_mode ( VikAggregateLayer *val, VikCoordMode mode )
 }
 
 static void aggregate_layer_change_coord_mode ( VikAggregateLayer *val, VikCoordMode mode )