[chronojump] DB: 1.47 font size of encoder capture graph can be changed



commit 96fc2b9658036ddf8e340e9b3647acda524e152e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jun 14 05:42:18 2017 -0300

    DB: 1.47 font size of encoder capture graph can be changed

 glade/preferences_win.glade |  234 ++++++++++++++++++++++++++++++++-----------
 src/gui/encoder.cs          |   36 +++++--
 src/gui/preferences.cs      |    9 ++-
 src/preferences.cs          |    1 +
 src/sqlite/main.cs          |   11 ++-
 src/sqlite/preferences.cs   |    3 +
 6 files changed, 220 insertions(+), 74 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index 2a500ba..c7298b8 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -118,64 +118,6 @@
                                 <property name="position">3</property>
                               </packing>
                             </child>
-                            <child>
-                              <widget class="GtkCheckButton" id="check_appearance_encoder_only_bars">
-                                <property name="label" translatable="yes">On encoder capture show only 
bars</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="draw_indicator">True</property>
-                                <signal name="toggled" 
handler="on_check_appearance_encoder_only_bars_toggled" swapped="no"/>
-                              </widget>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">4</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkAlignment" id="alignment_restart">
-                                <property name="can_focus">False</property>
-                                <property name="top_padding">20</property>
-                                <child>
-                                  <widget class="GtkHBox" id="hbox25">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">12</property>
-                                    <child>
-                                      <widget class="GtkLabel" id="label73">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="xalign">0</property>
-                                        <property name="label" translatable="yes">This change needs 
restarting Chronojump</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkImage" id="image2">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-dialog-warning</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </widget>
-                                </child>
-                              </widget>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">5</property>
-                              </packing>
-                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -2197,6 +2139,176 @@ It starts before and arrives there with some speed.</property>
                           </packing>
                         </child>
                         <child>
+                          <widget class="GtkFrame" id="frame14">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label_xalign">0</property>
+                            <property name="label_yalign">0.69999998807907104</property>
+                            <property name="shadow_type">out</property>
+                            <child>
+                              <widget class="GtkAlignment" id="alignment17">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="border_width">8</property>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <widget class="GtkVBox" id="vbox32">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">8</property>
+                                    <child>
+                                      <widget class="GtkVBox" id="vbox33">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">4</property>
+                                        <child>
+                                          <widget class="GtkCheckButton" 
id="check_appearance_encoder_only_bars">
+                                            <property name="label" translatable="yes">On encoder capture 
show only bars</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" 
handler="on_check_appearance_encoder_only_bars_toggled" swapped="no"/>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkAlignment" id="alignment_restart">
+                                            <property name="can_focus">False</property>
+                                            <property name="top_padding">4</property>
+                                            <child>
+                                              <widget class="GtkHBox" id="hbox25">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="spacing">12</property>
+                                                <child>
+                                                  <widget class="GtkLabel" id="label73">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="xalign">0</property>
+                                                    <property name="label" translatable="yes">This change 
needs restarting Chronojump</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">0</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <widget class="GtkImage" id="image2">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="stock">gtk-dialog-warning</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">1</property>
+                                                  </packing>
+                                                </child>
+                                              </widget>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkHBox" id="hbox36">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">20</property>
+                                        <child>
+                                          <widget class="GtkLabel" id="label108">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Font size at 
capture</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkHBox" 
id="hbox_encoder_capture_barplot_font_size">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="spacing">4</property>
+                                            <child>
+                                              <widget class="GtkSpinButton" 
id="spin_encoder_capture_barplot_font_size">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="has_tooltip">True</property>
+                                                <property name="invisible_char">●</property>
+                                                <property name="width_chars">3</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>
+                                                <property name="adjustment">14 8 25 1 10 0</property>
+                                                <property name="climb_rate">1</property>
+                                                <property name="snap_to_ticks">True</property>
+                                                <property name="numeric">True</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                </child>
+                              </widget>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label111">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Appearance</property>
+                                <property name="use_markup">True</property>
+                              </widget>
+                              <packing>
+                                <property name="type">label_item</property>
+                              </packing>
+                            </child>
+                          </widget>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
                           <widget class="GtkFrame" id="frame6">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
@@ -2435,7 +2547,7 @@ It starts before and arrives there with some speed.</property>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="position">3</property>
+                            <property name="position">4</property>
                           </packing>
                         </child>
                         <child>
@@ -2449,7 +2561,7 @@ It starts before and arrives there with some speed.</property>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="position">4</property>
+                            <property name="position">5</property>
                           </packing>
                         </child>
                         <child>
@@ -2495,7 +2607,7 @@ It starts before and arrives there with some speed.</property>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">5</property>
+                            <property name="position">6</property>
                           </packing>
                         </child>
                       </widget>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index fcbef33..f71b4b2 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4494,8 +4494,8 @@ public partial class ChronoJumpWindow
 
                int left_margin = 10;
                int right_margin = 0;
-               int top_margin = 35;
-               int bottom_margin = 20;
+               int top_margin = 20 + 3 * preferences.encoderCaptureBarplotFontSize;
+               int bottom_margin = 8 + preferences.encoderCaptureBarplotFontSize;
                //bars will be plotted here
                int graphHeightSafe = graphHeight - (top_margin + bottom_margin);
        
@@ -4503,16 +4503,20 @@ public partial class ChronoJumpWindow
 
                //plot bars
                int sep = 20;   //between reps
+
                if (data.Count >= 10 && data.Count < 20) {
                        sep = 10;
-                       layout_encoder_capture_curves_bars.FontDescription = Pango.FontDescription.FromString 
("Courier 9");
-               } else  if (data.Count >= 20) {
+                       layout_encoder_capture_curves_bars.FontDescription =
+                               Pango.FontDescription.FromString ("Courier " + 
(preferences.encoderCaptureBarplotFontSize -2).ToString());
+               } else if (data.Count >= 20) {
                        sep = 2;
-                       layout_encoder_capture_curves_bars.FontDescription = Pango.FontDescription.FromString 
("Courier 7");
+                       layout_encoder_capture_curves_bars.FontDescription =
+                               Pango.FontDescription.FromString ("Courier " + 
(preferences.encoderCaptureBarplotFontSize -4).ToString());
                        left_margin = 2;
                }
-                       
-               layout_encoder_capture_curves_bars_text.FontDescription = Pango.FontDescription.FromString 
("Courier 11");
+
+               layout_encoder_capture_curves_bars_text.FontDescription =
+                       Pango.FontDescription.FromString ("Courier " + 
preferences.encoderCaptureBarplotFontSize.ToString());
                layout_encoder_capture_curves_bars_text.FontDescription.Weight = Pango.Weight.Bold;
                
                string eccon = findEccon(true);
@@ -4537,7 +4541,8 @@ public partial class ChronoJumpWindow
                //draw line for person max intersession
                if(mainVariable == Constants.MeanPower && maxIntersession > 0)
                {
-                       layout_encoder_capture_curves_bars_text.SetMarkup("Person's best: (" + 
Util.TrimDecimals(maxIntersession, 1) + "W)");
+                       //layout_encoder_capture_curves_bars_text.SetMarkup("Person's best: (" + 
Util.TrimDecimals(maxIntersession, 1) + "W)");
+                       layout_encoder_capture_curves_bars_text.SetMarkup("Person's best:");
                        layout_encoder_capture_curves_bars_text.GetPixelSize(out textWidth, out textHeight);
                        encoder_capture_curves_bars_pixmap.DrawLayout (pen_yellow_encoder_capture,
                                                left_margin, top_margin - textHeight,
@@ -4546,6 +4551,13 @@ public partial class ChronoJumpWindow
                        encoder_capture_curves_bars_pixmap.DrawLine(pen_yellow_encoder_capture,
                                        left_margin, top_margin,
                                        graphWidth - right_margin, top_margin);
+
+                       layout_encoder_capture_curves_bars_text.SetMarkup(Util.TrimDecimals(maxIntersession, 
1) + "W");
+                       layout_encoder_capture_curves_bars_text.GetPixelSize(out textWidth, out textHeight);
+                       encoder_capture_curves_bars_pixmap.DrawLayout (pen_yellow_encoder_capture,
+                                               graphWidth - (right_margin + textWidth),
+                                               top_margin - textHeight,
+                                               layout_encoder_capture_curves_bars_text);
                }
                
                bool iterOk = encoderCaptureListStore.GetIterFirst(out iter);
@@ -4657,7 +4669,8 @@ public partial class ChronoJumpWindow
                        textHeight = 1;
                        layout_encoder_capture_curves_bars.GetPixelSize(out textWidth, out textHeight); 
                        encoder_capture_curves_bars_pixmap.DrawLayout (pen_black_encoder_capture, 
-                                       Convert.ToInt32( (dLeft + dWidth/2) - textWidth/2), dTop - 15, //x, y 
+                                       Convert.ToInt32( (dLeft + dWidth/2) - textWidth/2),     //x
+                                       dTop - (5 + preferences.encoderCaptureBarplotFontSize), //y
                                        layout_encoder_capture_curves_bars);
                        //end of: write the result
 
@@ -4740,7 +4753,7 @@ public partial class ChronoJumpWindow
                                Util.TrimDecimals( (sumSaved / countSaved), decimals) + 
                                " " + units;
 
-               title += "; Loss: " + Util.TrimDecimals(100.0 * (maxThisSet - minThisSet) / maxThisSet, 
decimals) + " %]";
+               title += "; Loss: " + Util.TrimDecimals(100.0 * (maxThisSet - minThisSet) / maxThisSet, 
decimals) + "%]";
 
                layout_encoder_capture_curves_bars_text.SetMarkup(title);
                textWidth = 1;
@@ -5183,7 +5196,8 @@ public partial class ChronoJumpWindow
                layout_encoder_capture_signal.FontDescription = Pango.FontDescription.FromString ("Courier 
10");
 
                layout_encoder_capture_curves_bars = new Pango.Layout 
(encoder_capture_curves_bars_drawingarea.PangoContext);
-               layout_encoder_capture_curves_bars.FontDescription = Pango.FontDescription.FromString 
("Courier 10");
+               layout_encoder_capture_curves_bars.FontDescription =
+                       Pango.FontDescription.FromString ("Courier " + 
preferences.encoderCaptureBarplotFontSize.ToString());
                
                layout_encoder_capture_curves_bars_text = new Pango.Layout 
(encoder_capture_curves_bars_drawingarea.PangoContext);
                layout_encoder_capture_curves_bars_text.FontDescription = Pango.FontDescription.FromString 
("Courier 10");
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 5cf9984..4dc5735 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -115,6 +115,7 @@ public class PreferencesWindow
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_4top;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_all;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_none;
+       [Widget] Gtk.SpinButton spin_encoder_capture_barplot_font_size;
        [Widget] Gtk.CheckButton check_show_start_and_duration;
        [Widget] Gtk.CheckButton check_encoder_capture_cut_by_triggers;
        [Widget] Gtk.Image image_encoder_capture_cut_by_triggers_help;
@@ -450,7 +451,8 @@ public class PreferencesWindow
                        PreferencesWindowBox.radio_encoder_auto_save_curve_all.Active = true;
                else
                        PreferencesWindowBox.radio_encoder_auto_save_curve_none.Active = true;
-       
+
+               PreferencesWindowBox.spin_encoder_capture_barplot_font_size.Value = 
preferences.encoderCaptureBarplotFontSize;
                PreferencesWindowBox.check_show_start_and_duration.Active = 
preferences.encoderShowStartAndDuration;
                PreferencesWindowBox.check_encoder_capture_cut_by_triggers.Active = 
preferences.encoderCaptureCutByTriggers;
 
@@ -1579,6 +1581,11 @@ public class PreferencesWindow
                        preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.NONE;
                }
 
+               preferences.encoderCaptureBarplotFontSize = preferencesChange(
+                               "encoderCaptureBarplotFontSize",
+                               preferences.encoderCaptureBarplotFontSize,
+                               (int) PreferencesWindowBox.spin_encoder_capture_barplot_font_size.Value);
+
                preferences.encoderShowStartAndDuration = preferencesChange(
                                "encoderShowStartAndDuration",
                                preferences.encoderShowStartAndDuration,
diff --git a/src/preferences.cs b/src/preferences.cs
index 6f2eb31..5b2a335 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -62,6 +62,7 @@ public class Preferences
        public bool encoderCaptureCheckFullyExtended;
        public int encoderCaptureCheckFullyExtendedValue;
        public Constants.EncoderAutoSaveCurve encoderAutoSaveCurve;
+       public int encoderCaptureBarplotFontSize;
        public bool encoderShowStartAndDuration;
        public bool encoderCaptureCutByTriggers;
        
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index a11732c..cc7aa9a 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -125,7 +125,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.46";
+       static string lastChronojumpDatabaseVersion = "1.47";
 
        public Sqlite() {
        }
@@ -2234,6 +2234,14 @@ class Sqlite
 
                                currentVersion = updateVersion("1.46");
                        }
+                       if(currentVersion == "1.46")
+                       {
+                               LogB.SQL("Added encoderCaptureBarplotFontSize at preferences");
+
+                               SqlitePreferences.Insert ("encoderCaptureBarplotFontSize", "14");
+
+                               currentVersion = updateVersion("1.47");
+                       }
 
 
                        // --- add more updates here
@@ -2415,6 +2423,7 @@ class Sqlite
                SqlitePreferences.initializeTable(lastChronojumpDatabaseVersion, creatingBlankDatabase);
 
                //changes [from - to - desc]
+               //1.46 - 1.47 Converted DB to 1.47 Added encoderCaptureBarplotFontSize at preferences
                //1.45 - 1.46 Converted DB to 1.46 Added muteLogs at preferences
                //1.44 - 1.45 Converted DB to 1.45 Added ForceSensorImpulse value
                //1.43 - 1.44 Converted DB to 1.44 Added encoderCaptureCutByTriggers to preferences
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 94e0ccf..0476bd8 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -109,6 +109,7 @@ class SqlitePreferences : Sqlite
                                Insert ("encoderCaptureMinHeightInertial", "5", dbcmdTr);
                                Insert ("encoderCaptureCheckFullyExtended", "True", dbcmdTr);
                                Insert ("encoderCaptureCheckFullyExtendedValue", "4", dbcmdTr);
+                               Insert ("encoderCaptureBarplotFontSize", "14", dbcmdTr);
                                Insert ("encoderShowStartAndDuration", "False", dbcmdTr);
                                Insert ("encoderCaptureCutByTriggers", "False", dbcmdTr);
                                Insert ("encoderPropulsive", "True", dbcmdTr);
@@ -280,6 +281,8 @@ class SqlitePreferences : Sqlite
                        else if(reader[0].ToString() == "encoderAutoSaveCurve")
                                preferences.encoderAutoSaveCurve = (Constants.EncoderAutoSaveCurve) 
                                        Enum.Parse(typeof(Constants.EncoderAutoSaveCurve), 
reader[1].ToString()); 
+                       else if(reader[0].ToString() == "encoderCaptureBarplotFontSize")
+                               preferences.encoderCaptureBarplotFontSize = 
Convert.ToInt32(reader[1].ToString());
                        else if(reader[0].ToString() == "encoderShowStartAndDuration")
                                preferences.encoderShowStartAndDuration = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "encoderCaptureCutByTriggers")


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