[chronojump] Improvements on Bigger Buttons



commit c9020f1975e76612e73c3eed4c7a6e33f3052be0
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 31 13:33:10 2015 +0200

    Improvements on Bigger Buttons

 glade/chronojump.glade |  142 ++++++++++++++++++++++++++++++++++++++++++++----
 src/gui/encoder.cs     |   65 ++++++++++++++++++----
 src/gui/networks.cs    |    9 +++
 3 files changed, 195 insertions(+), 21 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index db4012e..82cd367 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7651,6 +7651,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -9056,6 +9059,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -10102,6 +10108,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -14205,7 +14214,7 @@ on current Chronojump version.</property>
                                                 </child>
                                                 <child>
                                                   <widget class="GtkButton" 
id="button_encoder_person_change">
-                                                    <property name="label" 
translatable="yes">Change</property>
+                                                    <property name="label" 
translatable="yes">Person</property>
                                                     <property name="width_request">80</property>
                                                     <property name="height_request">40</property>
                                                     <property name="visible">True</property>
@@ -15066,7 +15075,6 @@ on current Chronojump version.</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="invisible_char">●</property>
-                                                            <property name="width_chars">2</property>
                                                             <property 
name="primary_icon_activatable">False</property>
                                                             <property 
name="secondary_icon_activatable">False</property>
                                                             <property 
name="primary_icon_sensitive">True</property>
@@ -15079,11 +15087,75 @@ on current Chronojump version.</property>
                                                             <signal name="value_changed" 
handler="on_spin_encoder_im_weights_n_value_changed" swapped="no"/>
                                                             </widget>
                                                             <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_encoder_im_weights_n">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_encoder_im_weights_n_minus">
+                                                            <property name="label"> -1 </property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="has_tooltip">True</property>
+                                                            <signal name="clicked" 
handler="on_button_encoder_im_weights_n_minus_clicked" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkEntry" 
id="entry_encoder_im_weights_n">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="max_length">2</property>
+                                                            <property name="has_frame">False</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">2</property>
+                                                            <property name="text">0</property>
+                                                            <property name="shadow_type">none</property>
+                                                            <property 
name="invisible_char_set">True</property>
+                                                            <property 
name="primary_icon_activatable">False</property>
+                                                            <property 
name="secondary_icon_activatable">False</property>
+                                                            <property 
name="primary_icon_sensitive">True</property>
+                                                            <property 
name="secondary_icon_sensitive">True</property>
+                                                            <signal name="changed" 
handler="on_entry_encoder_im_weights_n_changed" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_encoder_im_weights_n_plus">
+                                                            <property name="label"> +1 </property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property name="has_tooltip">True</property>
+                                                            <signal name="clicked" 
handler="on_button_encoder_im_weights_n_plus_clicked" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -15193,20 +15265,19 @@ on current Chronojump version.</property>
                                                             <signal name="clicked" 
handler="on_button_encoder_capture_clicked" swapped="no"/>
                                                             <accelerator key="space" signal="clicked" 
modifiers="GDK_CONTROL_MASK"/>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox85">
+                                                            <widget class="GtkVBox" id="vbox8">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">1</property>
                                                             <child>
                                                             <widget class="GtkImage" id="image10">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="stock">gtk-apply</property>
-                                                            <property name="icon-size">2</property>
+                                                            <property name="icon-size">3</property>
                                                             </widget>
                                                             <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
                                                             <property name="position">0</property>
                                                             </packing>
                                                             </child>
@@ -21665,6 +21736,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22610,6 +22684,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -24047,6 +24124,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -24541,6 +24621,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -36113,6 +36196,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -37856,6 +37957,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -39211,9 +39324,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -40158,6 +40268,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -43890,6 +44003,9 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -44499,6 +44615,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -45123,6 +45242,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index ff89159..d92c418 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -37,11 +37,13 @@ public partial class ChronoJumpWindow
 
        [Widget] Gtk.Notebook notebook_encoder_capture_extra_mass;
 
+       [Widget] Gtk.Button button_encoder_select;
        [Widget] Gtk.SpinButton spin_encoder_extra_weight;
        [Widget] Gtk.Label label_encoder_displaced_weight;
        [Widget] Gtk.Label label_encoder_1RM_percent;
        [Widget] Gtk.Label label_encoder_im_total;
        [Widget] Gtk.SpinButton spin_encoder_im_weights_n;
+       [Widget] Gtk.Entry entry_encoder_im_weights_n;
        [Widget] Gtk.HBox hbox_combo_encoder_anchorage;
        [Widget] Gtk.ComboBox combo_encoder_anchorage;
        
@@ -420,11 +422,46 @@ public partial class ChronoJumpWindow
                        encoderConfigurationCurrent.d = Convert.ToDouble(selected);
        }
 
+
+       // ---- start of spin_encoder_im_weights_n ---->
+       /*
+        * when spin is seen the others (-1, entry, +1) are not seen
+        * -1, 1 change the entry
+        * entry changes de spin
+        * spin does not change anything
+        */
+       
+       void on_button_encoder_im_weights_n_minus_clicked (object o, EventArgs args) {
+               changeImWeights(-1);
+       }
+       void on_button_encoder_im_weights_n_plus_clicked (object o, EventArgs args) {
+               changeImWeights(+1);
+       }
+       private void changeImWeights(int change) {
+               int newValue = Convert.ToInt32(entry_encoder_im_weights_n.Text) + change;
+
+               double min, max;
+               spin_encoder_im_weights_n.GetRange(out min, out max);
+               if(newValue >= Convert.ToDouble(min) && newValue <= Convert.ToDouble(max))
+                       entry_encoder_im_weights_n.Text = newValue.ToString();
+       }
+
        void on_spin_encoder_im_weights_n_value_changed (object o, EventArgs args) {
                encoderConfigurationCurrent.extraWeightN = (int) spin_encoder_im_weights_n.Value; 
                encoderConfigurationCurrent.inertiaTotal = 
UtilEncoder.CalculeInertiaTotal(encoderConfigurationCurrent);
                label_encoder_im_total.Text = encoderConfigurationCurrent.inertiaTotal.ToString();
        }
+       void on_entry_encoder_im_weights_n_changed (object o, EventArgs args) 
+       {
+               if(entry_encoder_im_weights_n.Text == "" || entry_encoder_im_weights_n.Text == "00")
+                       entry_encoder_im_weights_n.Text = "0";
+               else if(Util.IsNumber(entry_encoder_im_weights_n.Text, false)) //cannot be decimal
+                       spin_encoder_im_weights_n.Value = Convert.ToInt32(entry_encoder_im_weights_n.Text);
+               else
+                       entry_encoder_im_weights_n.Text = spin_encoder_im_weights_n.Value.ToString();
+       }
+
+       // <---- end of spin_encoder_im_weights_n ----
        
 
        
@@ -517,6 +554,12 @@ public partial class ChronoJumpWindow
        }
 
        // ---- change extra weight start ----
+       /*
+        * when spin is seen the others (-10, -1, entry, +1, +10) are not seen
+        * -10, -1, 1, +10 change the entry
+        * entry changes de spin
+        * spin does not change anything
+        */
        
        void on_button_encoder_raspberry_extra_weight_minus_10_clicked (object o, EventArgs args) {
                rapsberryChangeExtraWeight(-10);
@@ -531,10 +574,18 @@ public partial class ChronoJumpWindow
                rapsberryChangeExtraWeight(+1);
        }
        void rapsberryChangeExtraWeight(int change) {
-               spin_encoder_extra_weight.Value += change;
-       }
+               /*
+                * don't change spin to avoid circular problems
+                * spin_encoder_extra_weight.Value += change;
+                * change the entry
+                * */
+               int newValue = Convert.ToInt32(entry_raspberry_extra_weight.Text) + change;
 
-       bool extra_weight_signals_on = true;
+               double min, max;
+               spin_encoder_extra_weight.GetRange(out min, out max);
+               if(newValue >= Convert.ToDouble(min) && newValue <= Convert.ToDouble(max))
+                       entry_raspberry_extra_weight.Text = newValue.ToString();
+       }
 
        void on_spin_encoder_extra_weight_value_changed (object o, EventArgs args) 
        {
@@ -542,18 +593,10 @@ public partial class ChronoJumpWindow
                //array1RMUpdate(false);
                //because then we will be calling SQL at each spinbutton increment
 
-               //change raspberry controls but taking care not get into circular changes
-               extra_weight_signals_on = false;
-               entry_raspberry_extra_weight.Text = spin_encoder_extra_weight.Value.ToString();
-               extra_weight_signals_on = true;
-
                encoder_change_displaced_weight_and_1RM ();
        }
        void on_entry_raspberry_extra_weight_changed (object o, EventArgs args) 
        {
-               if(! extra_weight_signals_on)
-                       return;
-
                if(entry_raspberry_extra_weight.Text == "" || entry_raspberry_extra_weight.Text == "00")
                        entry_raspberry_extra_weight.Text = "0";
                else if(Util.IsNumber(entry_raspberry_extra_weight.Text, false)) //cannot be decimal
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 10909da..ce2f659 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -38,6 +38,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Entry entry_raspberry_extra_weight;
        [Widget] Gtk.Box hbox_encoder_capture_extra_mass_no_raspberry;
        [Widget] Gtk.Box hbox_encoder_capture_extra_mass_raspberry;
+       [Widget] Gtk.HBox hbox_encoder_im_weights_n;
        
        //config.EncoderNameAndCapture
        [Widget] Gtk.Box hbox_encoder_person;
@@ -68,6 +69,14 @@ public partial class ChronoJumpWindow
                if(config.CustomButtons) {
                        hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
                        hbox_encoder_capture_extra_mass_raspberry.Visible = true;
+               
+                       button_encoder_select.HeightRequest = 40;
+                       //this will make all encoder capture controls taller    
+                       button_encoder_capture.SetSizeRequest(150,100);
+                       //button_encoder_capture.HeightRequest = 100;
+
+                       spin_encoder_im_weights_n.Visible = false;
+                       hbox_encoder_im_weights_n.Visible = true;
                }
                if(! config.UseVideo) {
                        useVideo = false;


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