adg: invalidate "scale" text directly in AdgCanvas
authorNicola Fontana <ntd@entidi.it>
Mon, 25 Mar 2013 19:37:19 +0000 (25 20:37 +0100)
committerNicola Fontana <ntd@entidi.it>
Mon, 25 Mar 2013 19:37:19 +0000 (25 20:37 +0100)
Handle the "scale" invalidation directly in the local-changed default
handler of AdgCanvas. Removed scale settings from adg-demo.

demo/adg-demo.c
src/adg/adg-canvas.c

index b657cf8..bfc6326 100644 (file)
@@ -172,7 +172,6 @@ _adg_part_define_title_block(DemoPart *part)
                  "drawing", part->DRAWING,
                  "logo", adg_logo_new(),
                  "projection", adg_projection_new(ADG_PROJECTION_SCHEME_FIRST_ANGLE),
-                 "scale", "---",
                  "size", "A4",
                  NULL);
 }
index bc31eea..5b43500 100644 (file)
@@ -640,7 +640,7 @@ adg_canvas_autoscale(AdgCanvas *canvas)
 
     data = canvas->data;
     entity = (AdgEntity *) canvas;
-    title_block = adg_canvas_get_title_block(canvas);
+    title_block = data->title_block;
 
     for (p_scale = data->scales; p_scale != NULL && *p_scale != NULL; ++p_scale) {
         const gchar *scale = *p_scale;
@@ -1244,12 +1244,24 @@ static void
 _adg_local_changed(AdgEntity *entity)
 {
     AdgCanvasPrivate *data = ((AdgCanvas *) entity)->data;
+    AdgTitleBlock *title_block = data->title_block;
 
     if (_ADG_OLD_ENTITY_CLASS->local_changed)
         _ADG_OLD_ENTITY_CLASS->local_changed(entity);
 
-    if (data->title_block)
-        adg_entity_local_changed((AdgEntity *) data->title_block);
+    if (title_block != NULL) {
+        const gchar *scale = adg_title_block_get_scale(title_block);
+
+        if (scale != NULL && scale[0] != '\0') {
+            const cairo_matrix_t *map = adg_entity_get_local_map(entity);
+            gdouble factor = adg_scale_factor(scale);
+
+            if (map->xx != factor || map->yy != factor)
+                adg_title_block_set_scale(title_block, "---");
+        }
+
+        adg_entity_local_changed((AdgEntity *) title_block);
+    }
 }
 
 static void