[chronojump] CairoBarsEncoder has lower space on top of bars (like old gtk graph)



commit 7950378b4c49e67ab540e2a56e2925564a755f70
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Mar 29 13:24:24 2022 +0200

    CairoBarsEncoder has lower space on top of bars (like old gtk graph)

 src/gui/cairo/bars.cs   | 37 ++++++++++++++++++++++++++-----------
 src/gui/eventExecute.cs | 24 ++++++++++++------------
 2 files changed, 38 insertions(+), 23 deletions(-)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index e1a19d6b1..c1276f218 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -26,6 +26,9 @@ using Cairo;
 
 public abstract class CairoBars : CairoGeneric
 {
+       public enum Type { NORMAL, ENCODER };
+       protected Type type;
+
        protected DrawingArea area;
        protected ImageSurface surface;
 
@@ -352,12 +355,7 @@ public abstract class CairoBars : CairoGeneric
                mouseLimits = new RepetitionMouseLimits();
        }
 
-       //will be overwritten by graphs with legend
-       protected virtual void topMarginSet ()
-       {
-               topMargin = 40;
-       }
-
+       protected abstract void topMarginSet ();
        protected abstract void findMaximums(); //includes point and guides
 
        protected void paintAxisDo (int width)
@@ -929,9 +927,10 @@ public class CairoBars1Series : CairoBars
        private List<string> names_l;
 
        //constructor when there are no points
-       public CairoBars1Series (DrawingArea area, string font, string testsNotFoundMessage)
+       public CairoBars1Series (DrawingArea area, Type type, string font, string testsNotFoundMessage)
        {
                this.area = area;
+               this.type = type;
 
                LogB.Information("constructor without points, area is null:" + (area == null).ToString());
                LogB.Information("constructor without points, area.GdkWindow is null:" + (area.GdkWindow == 
null).ToString());
@@ -944,9 +943,10 @@ public class CairoBars1Series : CairoBars
        }
 
        //regular constructor
-       public CairoBars1Series (DrawingArea area, bool clickable, bool paintAxis, bool paintGrid)
+       public CairoBars1Series (DrawingArea area, Type type, bool clickable, bool paintAxis, bool paintGrid)
        {
                this.area = area;
+               this.type = type;
                this.clickable = clickable;
                this.paintAxis = paintAxis;
                this.paintGrid = paintGrid;
@@ -954,6 +954,14 @@ public class CairoBars1Series : CairoBars
                this.colorSerieA = colorFromGdk(Config.ColorBackground); //but note if we are using system 
colors, this will not match
        }
 
+       protected override void topMarginSet ()
+       {
+               if(type == Type.ENCODER)
+                       topMargin = 20;
+               else
+                       topMargin = 40;
+       }
+
        protected override void findMaximums()
        {
                foreach(PointF p in barMain_l)
@@ -1085,9 +1093,10 @@ public class CairoBarsNHSeries : CairoBars
        private int boxWidth = 10; //px. Same as boxHeight. box - text sep is .5 boxWidth. 1st text - 2nd box 
sep is 2*boxWidth
 
        //constructor when there are no points
-       public CairoBarsNHSeries (DrawingArea area, string font)
+       public CairoBarsNHSeries (DrawingArea area, Type type, string font)
        {
                this.area = area;
+               this.type = type;
 
                LogB.Information("constructor without points, area is null:" + (area == null).ToString());
                LogB.Information("constructor without points, area.GdkWindow is null:" + (area.GdkWindow == 
null).ToString());
@@ -1097,9 +1106,10 @@ public class CairoBarsNHSeries : CairoBars
        }
 
        //regular constructor
-       public CairoBarsNHSeries (DrawingArea area, bool showLegend, bool clickable, bool paintAxis, bool 
paintGrid)
+       public CairoBarsNHSeries (DrawingArea area, Type type, bool showLegend, bool clickable, bool 
paintAxis, bool paintGrid)
        {
                this.area = area;
+               this.type = type;
                this.showLegend = showLegend;
                this.clickable = clickable;
                this.paintAxis = paintAxis;
@@ -1112,11 +1122,16 @@ public class CairoBarsNHSeries : CairoBars
 
        protected override void topMarginSet ()
        {
-               topMargin = 50; //to accomodate legend under title
+               if(type == Type.ENCODER)
+               {
+                       topMargin = 20;
+                       return;
+               }
 
                if(! showLegend)
                        return;
 
+               topMargin = 50; //to accomodate legend under title
                oneRowLegend = true;
                calculateOneRowLegendWidth();
 
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index fc8dc2a60..b120a8f41 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -2192,7 +2192,7 @@ public abstract class CairoPaintBarsPre
        protected void blankScreen (DrawingArea darea, string fontStr)
        {
                try {
-                       new CairoBars1Series (darea, fontStr, "");
+                       new CairoBars1Series (darea, CairoBars.Type.NORMAL, fontStr, "");
                } catch {
                        LogB.Information("saved crash at with cairo paint (blank screen)");
                }
@@ -2209,7 +2209,7 @@ public abstract class CairoPaintBarsPre
                if(! haveDataToPlot())
                {
                        try {
-                               new CairoBars1Series (darea, fontStr, testsNotFound());
+                               new CairoBars1Series (darea, CairoBars.Type.NORMAL, fontStr, testsNotFound());
                        } catch {
                                LogB.Information("saved crash at with cairo paint");
                        }
@@ -2540,11 +2540,11 @@ public class CairoPaintBarsPreJumpSimple : CairoPaintBarsPre
                        UseHeights = false;
 
                if(showBarA && showBarB) //Dja, Djna
-                       cb = new CairoBarsNHSeries (darea, true, false, true, true);
+                       cb = new CairoBarsNHSeries (darea, CairoBars.Type.NORMAL, true, false, true, true);
                else if (showBarA) //takeOff, takeOffWeight
-                       cb = new CairoBars1Series (darea, false, true, true);
+                       cb = new CairoBars1Series (darea, CairoBars.Type.NORMAL, false, true, true);
                else //rest of the jumps: sj, cmj, ..
-                       cb = new CairoBars1Series (darea, false, true, true);
+                       cb = new CairoBars1Series (darea, CairoBars.Type.NORMAL, false, true, true);
 
                if(UseHeights) {
                        cb.YVariable = Catalog.GetString("Height");
@@ -2682,7 +2682,7 @@ public class CairoPaintBarsPreJumpReactive : CairoPaintBarsPre
 
        protected override void paintSpecific()
        {
-               cb = new CairoBarsNHSeries (darea, true, false, true, true);
+               cb = new CairoBarsNHSeries (darea, CairoBars.Type.NORMAL, true, false, true, true);
 
                cb.YVariable = Catalog.GetString("Time");
                cb.YUnits = "s";
@@ -2812,7 +2812,7 @@ public class CairoPaintBarsPreRunSimple : CairoPaintBarsPre
 
        protected override void paintSpecific()
        {
-               CairoBars1Series cb = new CairoBars1Series (darea, false, true, true);
+               CairoBars1Series cb = new CairoBars1Series (darea, CairoBars.Type.NORMAL, false, true, true);
 
                cb.YVariable = Catalog.GetString("Speed");
                cb.YUnits = "m/s";
@@ -2913,7 +2913,7 @@ public class CairoPaintBarsPreRunInterval : CairoPaintBarsPre
 
        protected override void paintSpecific()
        {
-               CairoBars1Series cb = new CairoBars1Series (darea, false, true, true);
+               CairoBars1Series cb = new CairoBars1Series (darea, CairoBars.Type.NORMAL, false, true, true);
 
                cb.YVariable = Catalog.GetString("Speed");
                cb.YUnits = "m/s";
@@ -3068,7 +3068,7 @@ public class CairoPaintBarsPreJumpReactiveRealtimeCapture : CairoPaintBarsPre
                if(tv_l.Count != tc_l.Count)
                        return;
 
-               cb = new CairoBarsNHSeries (darea, true, false, true, true);
+               cb = new CairoBarsNHSeries (darea, CairoBars.Type.NORMAL, true, false, true, true);
 
                cb.YVariable = Catalog.GetString("Time");
                cb.YUnits = "s";
@@ -3235,7 +3235,7 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
                //if(ifRSAstartRest)
                //      return;
 
-               cb = new CairoBars1Series (darea, false, true, true);
+               cb = new CairoBars1Series (darea, CairoBars.Type.NORMAL, false, true, true);
 
                cb.YVariable = Catalog.GetString("Speed");
                cb.YUnits = "m/s";
@@ -3889,9 +3889,9 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
        private void paintSpecificDo ()
        {
                if(pegbe.eccon == "c")
-                       cb = new CairoBars1Series (darea, ! pegbe.capturing, false, false);
+                       cb = new CairoBars1Series (darea, CairoBars.Type.ENCODER, ! pegbe.capturing, false, 
false);
                else
-                       cb = new CairoBarsNHSeries (darea, false, ! pegbe.capturing, false, false);
+                       cb = new CairoBarsNHSeries (darea, CairoBars.Type.ENCODER, false, ! pegbe.capturing, 
false, false);
 
                //LogB.Information("data_l.Count: " + data_l.Count.ToString());
                //cb.GraphInit(fontStr, true, false); //usePersonGuides, useGroupGuides


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