[chronojump] Encoder bars (grav and inertial) can be sel/deselecte clicking



commit 1bb660ed949ec54048d738a0367743849d989335
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jan 24 16:44:41 2020 +0000

    Encoder bars (grav and inertial) can be sel/deselecte clicking

 src/gui/encoder.cs             | 13 +++++++------
 src/gui/encoderGraphObjects.cs |  7 +++++--
 src/gui/encoderTreeviews.cs    | 14 +++++++++++---
 3 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 6058eb4c..c9027eab 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5366,18 +5366,19 @@ public partial class ChronoJumpWindow
 
        public void on_encoder_capture_curves_bars_drawingarea_button_press_event (object o, 
ButtonPressEventArgs args)
        {
-               LogB.Information(string.Format("Mouse X: {0}; Mouse Y: {1}", args.Event.X, args.Event.Y));
+               //LogB.Information(string.Format("Mouse X: {0}; Mouse Y: {1}", args.Event.X, args.Event.Y));
 
                //if list exists, select the repetition
                if(encoderGraphDoPlot != null)
                {
                        int repetition = encoderGraphDoPlot.FindBarInPixel(args.Event.X);
-                       LogB.Information("Repetition: " + repetition.ToString());
-                       if(repetition > 0)
+                       //LogB.Information("Repetition: " + repetition.ToString());
+                       if(repetition >= 0)
                        {
-                               //continue like: gui/encoderTreeview EncoderCaptureItemToggled
-                               //that manages if repetition should be discarded
-                               //also see if that method shold be divided on 2 depending on who calls it
+                               //this will be managed by: EncoderCaptureItemToggled()
+                               encoderCaptureItemToggledArgsPath = repetition.ToString();
+                               EncoderCaptureItemToggled(new object (), new ToggledArgs());
+                               encoderCaptureItemToggledArgsPath = "";
                        }
                }
        }
diff --git a/src/gui/encoderGraphObjects.cs b/src/gui/encoderGraphObjects.cs
index 73c87398..9a9a4a06 100644
--- a/src/gui/encoderGraphObjects.cs
+++ b/src/gui/encoderGraphObjects.cs
@@ -458,7 +458,9 @@ public class EncoderGraphDoPlot
                        rect = new Rectangle(0, 0, graphWidth, graphHeight);
                        pixmap.DrawRectangle(pen_colors_background_encoder_capture, true, rect);
                }
-               
+
+               int encoderBarsLimitsCount = 0;
+
                Gdk.Point dSecondaryPreviousPoint = new Gdk.Point(0,0);
                bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
                foreach(double dFor in data)
@@ -565,7 +567,7 @@ public class EncoderGraphDoPlot
                        rect = new Rectangle(dLeft, dTop, dWidth, dHeight);
                        pixmap.DrawRectangle(my_pen, true, rect);
 
-                       encoderBarsLimits.Add(count +1, dLeft, dLeft + dWidth); //first rep is 1
+                       encoderBarsLimits.Add(encoderBarsLimitsCount ++, dLeft, dLeft + dWidth); //first rep 
is 1
 
                        //paint diagonal line to distinguish eccentric-concentric
                        //line is painted before the black outline to fix graphical problems
@@ -810,6 +812,7 @@ public class EncoderBarsLimits
        {
                PointStartEnd p = new PointStartEnd(id, start, end);
                list.Add(p);
+               LogB.Information("Added: " + p.ToString());
        }
 
        public int FindBarInPixel (double pixel)
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 50356c8c..08f6630f 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -286,6 +286,7 @@ public partial class ChronoJumpWindow
                }
        }
 
+       private string encoderCaptureItemToggledArgsPath = "";
        void EncoderCaptureItemToggled(object o, ToggledArgs args)
        {
                //cannot toggle item while capturing or recalculating
@@ -302,11 +303,18 @@ public partial class ChronoJumpWindow
                                inertialStart = 2 * preferences.encoderCaptureInertialDiscardFirstN;
                }
 
+               string myArgsPath = "";
+               if(encoderCaptureItemToggledArgsPath != "")
+                       myArgsPath = encoderCaptureItemToggledArgsPath;
+               else
+                       myArgsPath = args.Path;
+
+               //LogB.Information("myArgsPath: " + myArgsPath);
                TreeIter iter;
                int column = 0;
-               if (encoderCaptureListStore.GetIterFromString (out iter, args.Path)) 
+               if (encoderCaptureListStore.GetIterFromString (out iter, myArgsPath))
                {
-                       int rowNum = Convert.ToInt32(args.Path); //starts at zero
+                       int rowNum = Convert.ToInt32(myArgsPath); //starts at zero
 
                        //do not allow to click a discarded repetition
                        if(rowNum < inertialStart)
@@ -314,7 +322,7 @@ public partial class ChronoJumpWindow
                        
                        //on "ecS" don't pass the 2nd row, pass always the first
                        //then need to move the iter to previous row
-                       TreePath path = new TreePath(args.Path);
+                       TreePath path = new TreePath(myArgsPath);
                        if(ecconLast != "c" && ! Util.IsEven(rowNum)) {
                                rowNum --;
                                path.Prev();


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