[chronojump] ForceSensoAnalyzeInstant: Better code for repetition display



commit 85f0f1da47414087d481ee8e0d44f94231d6506e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Feb 15 18:47:10 2020 +0100

    ForceSensoAnalyzeInstant: Better code for repetition display

 src/gui/app1/forceSensorAnalyze.cs | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index 65472a38..74b29b25 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -1105,12 +1105,7 @@ public partial class ChronoJumpWindow
                        //if(j > 0) // write repetition count and store MouseLimits
                        if(sampleEnd >= 0)
                        {
-                               layout_force_ai_text.SetMarkup((j+1).ToString());
-                               textWidth = 1; textHeight = 1;
-                               layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
-                               force_sensor_ai_pixmap.DrawLayout (pen_green_force_ai,
-                                               Convert.ToInt32((xposRepStart + xposRepEnd)/2 - textWidth/2), 
0,
-                                               layout_force_ai_text);
+                               forceSensorWriteRepetitionNumber(j, xposRepStart, xposRepEnd, true);
 
                                if(! forceSensorZoomApplied)
                                        fsAIRepetitionMouseLimits.Add(xposRepStart, xposRepEnd);
@@ -1119,14 +1114,7 @@ public partial class ChronoJumpWindow
                //show the number of last repetition (when obviously no new rep will make writting it)
                //but only if zoomed and that repetition exists (has an end)
                if(forceSensorZoomApplied && j >= 0 && j < reps_l.Count) // write last repetition count
-               {
-                       layout_force_ai_text.SetMarkup((j+1).ToString());
-                       textWidth = 1; textHeight = 1;
-                       layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
-                       force_sensor_ai_pixmap.DrawLayout (pen_green_force_ai,
-                                       Convert.ToInt32((xposRepEnd + allocation.Width)/2 - textWidth/2), 0,
-                                       layout_force_ai_text);
-               }
+                       forceSensorWriteRepetitionNumber(j, xposRepStart, xposRepEnd, false);
 
 
                /*
@@ -1184,6 +1172,22 @@ public partial class ChronoJumpWindow
                LogB.Information("forceSensorAnalyzeManualGraphDo() END");
        }
 
+       private void forceSensorWriteRepetitionNumber(int rep, int xposRepStart, int xposRepEnd, bool 
repetitionHasEnded)
+       {
+               layout_force_ai_text.SetMarkup((rep+1).ToString());
+               int textWidth = 1; int textHeight = 1;
+               layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
+
+               if(repetitionHasEnded)
+                       force_sensor_ai_pixmap.DrawLayout (pen_green_force_ai,
+                                       Convert.ToInt32((xposRepStart + xposRepEnd)/2 - textWidth/2), 0,
+                                       layout_force_ai_text);
+               else // on zooming a rep
+                       force_sensor_ai_pixmap.DrawLayout (pen_green_force_ai,
+                                       Convert.ToInt32((xposRepEnd + 
force_sensor_ai_drawingarea.Allocation.Width)/2 - textWidth/2), 0,
+                                       layout_force_ai_text);
+       }
+
        private int fsAIFindBarInPixel (double pixel)
        {
                if(fsAIRepetitionMouseLimits == null)


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