Code

Patch from codedread. Prevents rendering of title/desc/metadata elements in text...
[inkscape.git] / src / display / canvas-grid.cpp
index 7aebe0095181fd80632c88f4adfac28d279bed1b..81e017f12792a048eb4095bd7e7f32007bc5ace3 100644 (file)
@@ -64,7 +64,7 @@ grid_canvasitem_get_type (void)
 
     if (!grid_canvasitem_type) {
         GtkTypeInfo grid_canvasitem_info = {
-            "GridCanvasItem",
+            (gchar *)"GridCanvasItem",
             sizeof (GridCanvasItem),
             sizeof (GridCanvasItemClass),
             (GtkClassInitFunc) grid_canvasitem_class_init,
@@ -826,12 +826,12 @@ grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba)
         a = NR_RGBA32_A (rgba);
         x0 = MAX (buf->rect.x0, xs);
         x1 = MIN (buf->rect.x1, xe + 1);
-        p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
+        p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4;
         for (x = x0; x < x1; x++) {
             p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
             p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
             p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
-            p += 3;
+            p += 4;
         }
     }
 }
@@ -849,7 +849,7 @@ grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
         a = NR_RGBA32_A (rgba);
         y0 = MAX (buf->rect.y0, ys);
         y1 = MIN (buf->rect.y1, ye + 1);
-        p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
+        p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4;
         for (y = y0; y < y1; y++) {
             p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
             p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
@@ -870,7 +870,7 @@ grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba)
         g = NR_RGBA32_G (rgba);
         b = NR_RGBA32_B (rgba);
         a = NR_RGBA32_A (rgba);
-        p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
+        p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4;
         p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
         p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
         p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
@@ -887,8 +887,8 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
 
     //set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
     guint32 _empcolor;
-    bool preference = prefs_get_int_attribute ("options.grids", "no_emphasize_when_zoomedout", 0) == 1;
-    if( (scaled[NR::X] || scaled[NR::Y]) && preference ) {
+    bool no_emp_when_zoomed_out = prefs_get_int_attribute ("options.grids", "no_emphasize_when_zoomedout", 0) == 1;
+    if( (scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out ) {
         _empcolor = color;
     } else {
         _empcolor = empcolor;
@@ -927,11 +927,19 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
             for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) {
                 gint const ix = (gint) Inkscape::round(x);
                 if ( (!scaled[NR::X] && (xlinenum % empspacing) != 0)
-                     || (!scaled[NR::Y] && (ylinenum % empspacing) != 0) )
+                     || (!scaled[NR::Y] && (ylinenum % empspacing) != 0)
+                     || ((scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out) )
                 {
                     grid_dot (buf, ix, iy, color | (guint32)0x000000FF); // put alpha to max value
                 } else {
+                    gint const pitch = 1;
+                    grid_dot (buf, ix-pitch, iy, _empcolor);
+                    grid_dot (buf, ix+pitch, iy, _empcolor);
+
                     grid_dot (buf, ix, iy, _empcolor | (guint32)0x000000FF);  // put alpha to max value
+
+                    grid_dot (buf, ix, iy-pitch, _empcolor);
+                    grid_dot (buf, ix, iy+pitch, _empcolor);
                 }
             }