[chronojump] Added compujump buttons for encoder exercises
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Added compujump buttons for encoder exercises
- Date: Tue, 11 Jul 2017 07:25:43 +0000 (UTC)
commit 9323fa5c4cbb16881cacd70f94c4b6a8dfbd700b
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jul 11 09:23:54 2017 +0200
Added compujump buttons for encoder exercises
src/gui/chronopicRegister.cs | 17 +------------
src/gui/encoder.cs | 42 ++++++++++++++++++++++++++++++--
src/utilGtk.cs | 53 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 18 deletions(-)
---
diff --git a/src/gui/chronopicRegister.cs b/src/gui/chronopicRegister.cs
index dad5dc4..1d54b71 100644
--- a/src/gui/chronopicRegister.cs
+++ b/src/gui/chronopicRegister.cs
@@ -198,7 +198,7 @@ public class ChronopicRegisterWindow
label_port.Show();
Gtk.HBox hbox_type = new Gtk.HBox(false, 6);
- Button button_left = create_arrow_button(ArrowType.Left, ShadowType.In);
+ Button button_left = UtilGtk.CreateArrowButton(ArrowType.Left, ShadowType.In);
button_left.Sensitive = (listConnected[count-1].Type != TypePixList.l[0].Type);
button_left.CanFocus = false;
button_left.IsFocus = false;
@@ -211,7 +211,7 @@ public class ChronopicRegisterWindow
image.Pixbuf = pixbuf;
hbox_type.Add(image);
- Button button_right = create_arrow_button(ArrowType.Right, ShadowType.In);
+ Button button_right = UtilGtk.CreateArrowButton(ArrowType.Right, ShadowType.In);
button_right.CanFocus = false;
button_right.IsFocus = false;
button_right.Clicked += on_button_right_clicked;
@@ -233,19 +233,6 @@ public class ChronopicRegisterWindow
table_main.Show();
}
- static Button create_arrow_button(ArrowType arrow_type, ShadowType shadow_type )
- {
- Button button = new Button ();
- Arrow arrow = new Arrow (arrow_type, shadow_type);
-
- button.Add(arrow);
-
- button.Show();
- arrow.Show();
-
- return button;
- }
-
private void createContent(int connectedCount, int unknownCount)
{
//create top hbox
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 945fd1f..e201166 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -3346,7 +3346,10 @@ public partial class ChronoJumpWindow
// string [] encoderLateralityTranslation;
string [] encoderAnalyzeCrossTranslation;
string [] encoderAnalyze1RMTranslation;
-
+
+ Button button_combo_encoder_exercise_capture_left;
+ Button button_combo_encoder_exercise_capture_right;
+
protected void createEncoderCombos()
{
//create combo exercises
@@ -3397,7 +3400,23 @@ public partial class ChronoJumpWindow
//pack combos
- hbox_combo_encoder_exercise_capture.PackStart(combo_encoder_exercise_capture, true, true, 0);
+ if(configChronojump.Compujump)
+ {
+ button_combo_encoder_exercise_capture_left =
UtilGtk.CreateArrowButton(ArrowType.Left, ShadowType.In, 40, 40);
+ button_combo_encoder_exercise_capture_left.Sensitive = false;
+ button_combo_encoder_exercise_capture_left.Clicked +=
on_button_encoder_exercise_capture_left_clicked;
+
hbox_combo_encoder_exercise_capture.PackStart(button_combo_encoder_exercise_capture_left, true, true, 0);
+
+ hbox_combo_encoder_exercise_capture.PackStart(combo_encoder_exercise_capture, true,
true, 10);
+
+ button_combo_encoder_exercise_capture_right =
UtilGtk.CreateArrowButton(ArrowType.Right, ShadowType.In, 40, 40);
+ button_combo_encoder_exercise_capture_right.Sensitive = true;
+ button_combo_encoder_exercise_capture_right.Clicked +=
on_button_encoder_exercise_capture_right_clicked;
+
hbox_combo_encoder_exercise_capture.PackStart(button_combo_encoder_exercise_capture_right, true, true, 0);
+ } else {
+ hbox_combo_encoder_exercise_capture.PackStart(combo_encoder_exercise_capture, true,
true, 0);
+ }
+
hbox_combo_encoder_exercise_capture.ShowAll();
combo_encoder_exercise_capture.Sensitive = true;
@@ -3434,7 +3453,24 @@ public partial class ChronoJumpWindow
label_encoder_top_weights.Text = Catalog.GetString("Weights") + ": " +
entry_encoder_im_weights_n.Text;
label_encoder_top_im.Text = Catalog.GetString("Inertia M.") + ": " +
label_encoder_im_total.Text;
}
-
+
+ private void on_button_encoder_exercise_capture_left_clicked(object o, EventArgs args)
+ {
+ combo_encoder_exercise_capture = UtilGtk.ComboSelectPrevious(combo_encoder_exercise_capture);
+
+ button_combo_encoder_exercise_capture_left.Sensitive = (combo_encoder_exercise_capture.Active
0);
+ button_combo_encoder_exercise_capture_right.Sensitive = true;
+ }
+ private void on_button_encoder_exercise_capture_right_clicked(object o, EventArgs args)
+ {
+ bool isLast;
+ combo_encoder_exercise_capture = UtilGtk.ComboSelectNext(combo_encoder_exercise_capture, out
isLast);
+
+ button_combo_encoder_exercise_capture_left.Sensitive = true;
+ button_combo_encoder_exercise_capture_right.Sensitive = ! isLast;
+ }
+
+
//this is called also when an exercise is deleted to update the combo and the string []
protected void createEncoderComboExerciseAndAnalyze()
{
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 0bdb9c2..0702ea2 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -42,6 +42,36 @@ public class UtilGtk
*
*/
+ public static Gtk.ComboBox ComboSelectPrevious(ComboBox myCombo)
+ {
+ int newPosition = myCombo.Active -1;
+ if(newPosition >= 0)
+ myCombo.Active = newPosition;
+
+ return myCombo;
+ }
+ public static Gtk.ComboBox ComboSelectNext(ComboBox myCombo, out bool isLast)
+ {
+ TreeIter iter;
+ myCombo.Model.GetIterFirst(out iter);
+ int current = myCombo.Active;
+ int count = 0;
+ isLast = false;
+ do {
+ if(count > current)
+ {
+ myCombo.Active = count;
+ isLast = false;
+
+ return myCombo;
+ }
+ count ++;
+ } while (myCombo.Model.IterNext (ref iter));
+
+ isLast = true;
+ return myCombo;
+ }
+
public static string ComboGetActive(ComboBox myCombo) {
TreeIter iter;
@@ -591,6 +621,29 @@ public class UtilGtk
l.TooltipText = Util.RemoveMarkup(s);
}
+ public static Button CreateArrowButton(ArrowType arrow_type, ShadowType shadow_type)
+ {
+ return CreateArrowButton(arrow_type, shadow_type, -1, -1);
+ }
+ public static Button CreateArrowButton(ArrowType arrow_type, ShadowType shadow_type, int width, int
height)
+ {
+ Button button = new Button ();
+
+ if(width > 0)
+ button.WidthRequest = width;
+ if(height > 0)
+ button.HeightRequest = height;
+
+ Arrow arrow = new Arrow (arrow_type, shadow_type);
+
+ button.Add(arrow);
+
+ button.Show();
+ arrow.Show();
+
+ return button;
+ }
+
/*
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]