Code

Add preference so people can choose which behaviour they want. (bug 167422)
authorjohanengelen <johanengelen@users.sourceforge.net>
Mon, 14 Jan 2008 23:30:00 +0000 (23:30 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Mon, 14 Jan 2008 23:30:00 +0000 (23:30 +0000)
src/display/canvas-grid.cpp
src/preferences-skeleton.h
src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h

index 0edcbd0ab0653480c2953016c44af1f51f514b7c..b6897ae4821b412311e6a9c5b25dfa06a407c46c 100644 (file)
@@ -833,16 +833,24 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
     gdouble const syg = floor ((buf->rect.y0 - ow[NR::Y]) / sw[NR::Y]) * sw[NR::Y] + ow[NR::Y];
     gint const  ylinestart = (gint) Inkscape::round((syg - ow[NR::Y]) / sw[NR::Y]);
 
+    //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 ) {
+        _empcolor = color;
+    } else {
+        _empcolor = empcolor;
+    }
+
     if (!render_dotted) {
         gint ylinenum;
         gdouble y;
         for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) {
             gint const y0 = (gint) Inkscape::round(y);
-
             if (!scaled[NR::Y] && (ylinenum % empspacing) != 0) {
                 grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color);
             } else {
-                grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, empcolor);
+                grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, _empcolor);
             }
         }
 
@@ -853,7 +861,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
             if (!scaled[NR::X] && (xlinenum % empspacing) != 0) {
                 grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color);
             } else {
-                grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, empcolor);
+                grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, _empcolor);
             }
         }
     } else {
@@ -869,7 +877,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
                 if ( (!scaled[NR::X] && (xlinenum % empspacing) == 0)
                      || (!scaled[NR::Y] && (ylinenum % empspacing) == 0) )
                 {
-                    grid_dot (buf, ix, iy, empcolor | (guint32)0x000000FF); // put alpha to max value
+                    grid_dot (buf, ix, iy, _empcolor | (guint32)0x000000FF); // put alpha to max value
                 } else {
                     grid_dot (buf, ix, iy, color | (guint32)0x000000FF);  // put alpha to max value
                 }
index 825bf37bdefaa8b06edb97a5835fdf574f509d1c..f2b217fd43ff1fe654bde2ac63be529bd4a329b8 100644 (file)
@@ -246,7 +246,8 @@ static char const preferences_skeleton[] =
 "           masks=\"65535\"/>\n" // 0x0000ffff
 "    <group id=\"svgoutput\" usenamedcolors=\"0\" numericprecision=\"8\" minimumexponent=\"-8\" inlineattrs=\"0\" indent=\"2\"/>\n"
 "    <group id=\"forkgradientvectors\" value=\"1\"/>\n"
-"    <group id=\"grids\">"
+"    <group id=\"grids\""
+"      no_emphasize_when_zoomedout=\"0\">\n"
 "      <group id=\"xy\" "
 "             units=\"px\"\n"
 "             origin_x=\"0.0\"\n"
index b0791426564a78f5eef7fc4e6c6ea184837bc01b..d0fb56f976aead073fb7acac1a87dca756fe0899 100644 (file)
@@ -807,6 +807,8 @@ void InkscapePreferences::initPageGrids()
 {
     _page_grids.add_group_header( _("Default grid settings"));
 
+    _grids_no_emphasize_on_zoom.init( _("Don't emphasize gridlines when zoomed out"), "options.grids", "no_emphasize_when_zoomedout", false);
+    _page_grids.add_line( false, "", _grids_no_emphasize_on_zoom, "", _("If set and zoomed out, the gridlines will be shown in normal color instead of major grid line color."), false);
     _page_grids.add_line( false, "", _grids_notebook, "", "", false);
     _grids_notebook.append_page(_grids_xy,     CanvasGrid::getName( GRID_RECTANGULAR ));
     _grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));
index fd340769ee2c5a5f138f66753141b31b982badde..607953802afd18466312cf02963de8a1fade55b0 100644 (file)
@@ -177,6 +177,7 @@ protected:
     PrefCheckButton     _cms_proof_preserveblack;
 
     Gtk::Notebook       _grids_notebook;
+    PrefCheckButton     _grids_no_emphasize_on_zoom;
     DialogPage          _grids_xy, _grids_axonom;
     // CanvasXYGrid properties:
         PrefUnit            _grids_xy_units;