[chronojump] cairo grids using topMargin and bottomMargin instead of outerMargins



commit b619c828cfc3bf025e5806154cba553546c9d350
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Aug 25 14:04:20 2021 +0200

    cairo grids using topMargin and bottomMargin instead of outerMargins

 src/gui/cairo/generic.cs              | 13 ++++++++-----
 src/gui/cairo/jumpsWeightFVProfile.cs |  3 +++
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/gui/cairo/generic.cs b/src/gui/cairo/generic.cs
index 63ad2e5c8..156a38f4e 100644
--- a/src/gui/cairo/generic.cs
+++ b/src/gui/cairo/generic.cs
@@ -32,6 +32,9 @@ public abstract class CairoGeneric
        protected int outerMargins = 40; //blank space outside the axis.
        protected int innerMargins = 30; //space between the axis and the real coordinates.
 
+       protected int topMargin = 20; //outerMargins/2;
+       protected int bottomMargin = 20; //outerMargins/2;
+
        protected string font;
        protected int textHeight = 12;
 
@@ -110,7 +113,7 @@ public abstract class CairoGeneric
                        for(double i = gridYTuple.Item1; i <= gridYTuple.Item2 ; i += gridYTuple.Item3)
                        {
                                int ytemp = Convert.ToInt32(calculatePaintY(i));
-                               if(ytemp <= outerMargins || ytemp >= graphHeight - outerMargins)
+                               if(ytemp <= topMargin + bottomMargin || ytemp >= graphHeight - (topMargin + 
bottomMargin))
                                        continue;
 
                                paintHorizontalGridLine(g, ytemp, Util.TrimDecimals(i, 2));
@@ -138,7 +141,7 @@ public abstract class CairoGeneric
                        for(double i = Math.Floor(minX); i <= Math.Ceiling(maxY) ; i += by)
                        {
                                int ytemp = Convert.ToInt32(calculatePaintY(i));
-                               if(ytemp <= outerMargins || ytemp >= graphHeight - outerMargins)
+                               if(ytemp <= topMargin + bottomMargin || ytemp >= graphHeight - (topMargin + 
bottomMargin))
                                        continue;
 
                                paintHorizontalGridLine(g, ytemp, Util.TrimDecimals(i, 2));
@@ -156,9 +159,9 @@ public abstract class CairoGeneric
        //this combined with printXAxisText is different on RaceAnalyzer
        protected virtual void paintVerticalGridLine(Cairo.Context g, int xtemp, string text)
        {
-               g.MoveTo(xtemp, graphHeight - outerMargins);
-               g.LineTo(xtemp, outerMargins);
-               printText(xtemp, graphHeight - Convert.ToInt32(outerMargins/2), 0, textHeight, text, g, 
alignTypes.CENTER);
+               g.MoveTo(xtemp, graphHeight - (topMargin + bottomMargin));
+               g.LineTo(xtemp, (topMargin + bottomMargin));
+               printText(xtemp, graphHeight - bottomMargin, 0, textHeight, text, g, alignTypes.CENTER);
        }
 
        /*
diff --git a/src/gui/cairo/jumpsWeightFVProfile.cs b/src/gui/cairo/jumpsWeightFVProfile.cs
index 6f0426fe8..1c23b0be1 100644
--- a/src/gui/cairo/jumpsWeightFVProfile.cs
+++ b/src/gui/cairo/jumpsWeightFVProfile.cs
@@ -76,6 +76,9 @@ public class JumpsWeightFVProfileGraph : CairoXY
                this.colorBackground = colorFromGdk(Config.ColorBackground); //but note if we are using 
system colors, this will not match
 
                outerMargins = 50; //blank space outside the axis
+               topMargin = outerMargins/2;
+               bottomMargin = outerMargins/2;
+
                if(showFullGraph)
                        innerMargins = 0;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]