[chronojump] CairoBars clickable. Implemented on encoder: can select/deselect reps
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] CairoBars clickable. Implemented on encoder: can select/deselect reps
- Date: Fri, 18 Mar 2022 17:44:37 +0000 (UTC)
commit 606368e265de6ba28ef169912fdc423964afe246
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Mar 18 18:44:04 2022 +0100
CairoBars clickable. Implemented on encoder: can select/deselect reps
glade/app1.glade | 31 +++++++++++++++++++------------
src/gui/app1/encoder.cs | 19 +++++++++++++++++++
src/gui/cairo/bars.cs | 30 ++++++++++++++++++++++++++++++
src/gui/eventExecute.cs | 15 +++++++++------
src/gui/usefulObjects.cs | 10 +++++++++-
5 files changed, 86 insertions(+), 19 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index f42e221f7..58a4b5c0b 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -26264,6 +26264,9 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -32672,18 +32675,6 @@ Concentric</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Tests
will be filmed</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<widget class="GtkHBox"
id="hbox_video_encoder_capturing">
<property name="can_focus">False</property>
<property name="spacing">4</property>
@@ -32720,6 +32711,18 @@ Concentric</property>
</packing>
</child>
<child>
+ <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Tests
will be filmed</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox"
id="hbox_video_encoder_no_capturing">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -33731,6 +33734,7 @@ Concentric</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="expose_event"
handler="on_encoder_capture_curves_bars_drawingarea_cairo_expose_event" swapped="no"/>
+ <signal name="button_press_event"
handler="on_encoder_capture_curves_bars_drawingarea_cairo_button_press_event" swapped="no"/>
</widget>
<packing>
<property name="expand">True</property>
@@ -42381,6 +42385,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index bd5190b2f..b3985a0c3 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -5936,6 +5936,7 @@ public partial class ChronoJumpWindow
//needed to have mouse clicks button_press_event ()
// encoder_capture_curves_bars_drawingarea.AddEvents((int) (Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask));
encoder_capture_curves_bars_drawingarea.AddEvents((int) Gdk.EventMask.ButtonPressMask);
+ encoder_capture_curves_bars_drawingarea_cairo.AddEvents((int) Gdk.EventMask.ButtonPressMask);
Gdk.Rectangle allocation = encoder_capture_curves_bars_drawingarea.Allocation;
if(encoder_capture_curves_bars_pixmap == null || encoder_capture_curves_sizeChanged ||
@@ -5998,6 +5999,24 @@ public partial class ChronoJumpWindow
}
}
}
+ public void on_encoder_capture_curves_bars_drawingarea_cairo_button_press_event (object o,
ButtonPressEventArgs args)
+ {
+ LogB.Information("on_encoder_capture_curves_bars_drawingarea_cairo_button_press_event 0");
+ if(cairoPaintBarsPre == null) //TODO: check also that is the encoder graph and not jumps or
whatever
+ return;
+
+ LogB.Information("on_encoder_capture_curves_bars_drawingarea_cairo_button_press_event 1");
+ int repetition = cairoPaintBarsPre.FindBarInPixel(args.Event.X);
+ //LogB.Information("Repetition: " + repetition.ToString());
+ if(repetition >= 0)
+ {
+ LogB.Information("on_encoder_capture_curves_bars_drawingarea_cairo_button_press_event 2");
+ //this will be managed by: EncoderCaptureItemToggled()
+ encoderCaptureItemToggledArgsPath = repetition.ToString();
+ EncoderCaptureItemToggled(new object (), new ToggledArgs());
+ encoderCaptureItemToggledArgsPath = "";
+ }
+ }
public void on_encoder_capture_curves_bars_drawingarea_cairo_expose_event (object o, ExposeEventArgs
args)
{
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index fa6ab96f0..6ed486df5 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -55,6 +55,8 @@ public abstract class CairoBars : CairoGeneric
protected Cairo.Color bluePlots;
protected Cairo.Color yellow;
+ protected RepetitionMouseLimits mouseLimits;
+
// ---- values can be passed from outside via accessors ---->
protected string xVariable = "";
protected string yVariable = "Height";
@@ -298,6 +300,8 @@ public abstract class CairoBars : CairoGeneric
rightMargin = 70;
bottomMargin = 9;
topMarginSet ();
+
+ mouseLimits = new RepetitionMouseLimits();
}
//will be overwritten by graphs with legend
@@ -674,6 +678,16 @@ public abstract class CairoBars : CairoGeneric
paintGridInt (g, minX, maxX, minY, maxY, 1, gridType, textHeight -2);
}
+ public int FindBarInPixel (double pixel)
+ {
+ LogB.Information("cairo bars FindBarInPixel 0");
+ if(mouseLimits == null)
+ return -1;
+
+ LogB.Information("cairo bars FindBarInPixel 1");
+ return mouseLimits.FindBarInPixel(pixel);
+ }
+
public string YVariable {
set { yVariable = value; }
}
@@ -764,6 +778,7 @@ public class CairoBars1Series : CairoBars
drawRoundedRectangle (true, x, y, barWidth, graphHeight -y -bottomMargin, 4, g,
barColor);
plotResultOnBar(x + barWidth/2, y, graphHeight -bottomMargin, p.Y, resultFontHeight,
barWidth, -1);
+ mouseLimits.AddInPos (pointMain_l.Count -1 -i, x, x+barWidth);
//print the type at bottom
//printTextMultiline (x + barWidth/2, graphHeight -bottomMargin +
fontHeightForBottomNames/2, 0, fontHeightForBottomNames,
@@ -1005,6 +1020,15 @@ public class CairoBarsNHSeries : CairoBars
int resultFontHeight = getBarsResultFontHeight (barWidth*1.5);
List<Point3F> resultOnBars_l = new List<Point3F>();
+
+ /* mouseLimits
+ if there are 6 bars, 6+6 bars should be 0..11,
+ one bar will go from 11 to 1 and the other from 10 to 0
+ note that this can be reversed according to mainAtLeft
+ */
+ int mouseLimitsPos1stBar = pointMain_l.Count *2 -2;
+ int mouseLimitsPos2ndBar = pointMain_l.Count *2 -1;
+
for(int i = 0; i < pointMain_l.Count; i ++)
{
/*
@@ -1034,6 +1058,9 @@ public class CairoBarsNHSeries : CairoBars
drawRoundedRectangle (true, x + adjustX, y, barWidth, graphHeight -y
-bottomMargin, 4, g, barColor);
resultOnBarsThisIteration_l.Add(new Point3F(x + adjustX + barWidth/2,
y-4, pS.Y));
+ //add for the secondary and for the main bar, no problem both will
work
+ mouseLimits.AddInPos (mouseLimitsPos1stBar, x+adjustX,
x+adjustX+barWidth);
+ mouseLimitsPos1stBar -= 2;
if(labelBarMain != "")
{
@@ -1072,6 +1099,9 @@ public class CairoBarsNHSeries : CairoBars
drawRoundedRectangle (true, x+adjustX, y, barWidth, graphHeight -y
-bottomMargin, 4, g, barColor);
resultOnBarsThisIteration_l.Add(new Point3F(x + adjustX + barWidth/2, y,
pB.Y));
+ //add for the secondary and for the main bar, no problem both will work
+ mouseLimits.AddInPos (mouseLimitsPos2ndBar, x+adjustX, x+adjustX+barWidth);
+ mouseLimitsPos2ndBar -= 2;
if(labelBarMain != "")
{
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index c0a04f375..ce7b11c85 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -2137,6 +2137,7 @@ public abstract class CairoPaintBarsPre
//encoder
public PrepareEventGraphBarplotEncoder eventGraphEncoderBarplotStored;
+ protected CairoBars cb;
protected DrawingArea darea;
protected string fontStr;
protected Constants.Modes mode;
@@ -2482,6 +2483,11 @@ public abstract class CairoPaintBarsPre
return str;
}
+
+ public int FindBarInPixel (double pixel)
+ {
+ return cb.FindBarInPixel(pixel);
+ }
}
public class CairoPaintBarsPreJumpSimple : CairoPaintBarsPre
@@ -2530,7 +2536,6 @@ public class CairoPaintBarsPreJumpSimple : CairoPaintBarsPre
if(showBarA && ! showBarB)
UseHeights = false;
- CairoBars cb;
if(showBarA && showBarB) //Dja, Djna
cb = new CairoBarsNHSeries (darea);
else if (showBarA) //takeOff, takeOffWeight
@@ -2674,7 +2679,7 @@ public class CairoPaintBarsPreJumpReactive : CairoPaintBarsPre
protected override void paintSpecific()
{
- CairoBars cb = new CairoBarsNHSeries (darea);
+ cb = new CairoBarsNHSeries (darea);
cb.YVariable = Catalog.GetString("Time");
cb.YUnits = "s";
@@ -3059,7 +3064,7 @@ public class CairoPaintBarsPreJumpReactiveRealtimeCapture : CairoPaintBarsPre
if(tv_l.Count != tc_l.Count)
return;
- CairoBars cb = new CairoBarsNHSeries (darea);
+ cb = new CairoBarsNHSeries (darea);
cb.YVariable = Catalog.GetString("Time");
cb.YUnits = "s";
@@ -3225,7 +3230,7 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
//if(ifRSAstartRest)
// return;
- CairoBars cb = new CairoBars1Series (darea);
+ cb = new CairoBars1Series (darea);
cb.YVariable = Catalog.GetString("Speed");
cb.YUnits = "m/s";
@@ -3552,8 +3557,6 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
private void paintSpecificDo ()
{
- CairoBars cb;
-
if(pegbe.eccon == "c")
cb = new CairoBars1Series (darea);
else
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index bfdaf05df..4a0e44bb1 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -708,7 +708,15 @@ public class RepetitionMouseLimits
{
PointStartEnd p = new PointStartEnd(current ++, start, end);
list.Add(p);
- LogB.Information("Added: " + p.ToString());
+ LogB.Information("Mouse added: " + p.ToString());
+ }
+
+ //used on CairoBars because bars go from right to left, so we force the pos here
+ public void AddInPos (int pos, double start, double end)
+ {
+ PointStartEnd p = new PointStartEnd(pos, start, end);
+ list.Add(p);
+ LogB.Information("Mouse added: " + p.ToString());
}
public int FindBarInPixel (double pixel)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]