[longomatch] Redesign zoom scale, add a VPaned.



commit a835d5564240db4f07c9433d9db98f20a626860d
Author: Julien Moutte <julien fluendo com>
Date:   Thu Mar 12 15:53:24 2015 +0100

    Redesign zoom scale, add a VPaned.

 LongoMatch.GUI/Gui/Component/ProjectPeriods.cs     |   67 ++++---
 .../LongoMatch.Gui.Component.ProjectPeriods.cs     |   40 +++--
 LongoMatch.GUI/gtk-gui/gui.stetic                  |  195 ++++++++++----------
 3 files changed, 163 insertions(+), 139 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
index a9ea78c..122218a 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
@@ -40,6 +40,7 @@ namespace LongoMatch.Gui.Component
                PeriodsMenu menu;
                Dictionary<Period, Period> periodsDict;
                bool projectHasPeriods;
+               double maxSecondsPerPixels;
 
                public ProjectPeriods ()
                {
@@ -47,34 +48,28 @@ namespace LongoMatch.Gui.Component
 
                        zoomscale.CanFocus = false;
                        zoomscale.Adjustment.Lower = 0;
-                       zoomscale.Adjustment.Upper = 12;
+                       zoomscale.Adjustment.Upper = 100;
                        zoomscale.ValueChanged += HandleZoomChanged;
 
-                       zoominimage.Pixbuf = LongoMatch.Gui.Helpers.Misc.LoadIcon ("longomatch-zoom-in", 14);
                        zoomoutimage.Pixbuf = LongoMatch.Gui.Helpers.Misc.LoadIcon ("longomatch-zoom-out", 
14);
-
-                       // Synchronize the zoom widget height with scrolledwindow's scrollbar's.
-                       scrolledwindow2.HScrollbar.SizeAllocated += (object o, SizeAllocatedArgs args) => {
-                               int spacing = (int)scrolledwindow2.StyleGetProperty ("scrollbar-spacing");
-                               zoomhbox.HeightRequest = args.Allocation.Height + spacing;
-                       };
+                       zoominimage.Pixbuf = LongoMatch.Gui.Helpers.Misc.LoadIcon ("longomatch-zoom-in", 14);
 
                        main_cam_playerbin.Tick += HandleTick;
                        main_cam_playerbin.ShowControls = false;
-                       //secondary_cam_playerbin.ShowControls = false;
+                       //sec_cam_playerbin.ShowControls = false;
 
                        timerule = new Timerule (new WidgetWrapper (timerulearea)) { ObjectsCanMove = false };
                        camerasTimeline = new CamerasTimeline (new WidgetWrapper (timelinearea));
                        camerasLabels = new CamerasLabels (new WidgetWrapper (labelsarea));
 
-                       /* Links Label size to the container */
+                       /* FIXME: Links Label size to the container */
                        labelsarea.SizeRequested += (o, args) => {
                                labels_vbox.WidthRequest = args.Requisition.Width;
                        };
 
                        // Set some sane defaults
                        labels_vbox.WidthRequest = StyleConf.TimelineLabelsWidth;
-                       // We need to aligne the timerule and the beginning of labels list
+                       // We need to align the timerule and the beginning of labels list
                        timerulearea.HeightRequest = StyleConf.TimelineCameraHeight;
 
                        camerasTimeline.TimeNodeChanged += HandleTimeNodeChanged;
@@ -84,6 +79,16 @@ namespace LongoMatch.Gui.Component
                        scrolledwindow2.Vadjustment.ValueChanged += HandleScrollEvent;
                        scrolledwindow2.Hadjustment.ValueChanged += HandleScrollEvent;
 
+                       // Adjust our zoom factors when the window is resized
+                       scrolledwindow2.SizeAllocated += (o, args) =>  {
+                               UpdateMaxSecondsPerPixel ();
+                       };
+                       // Synchronize the zoom widget height with scrolledwindow's scrollbar's.
+                       scrolledwindow2.HScrollbar.SizeAllocated += (object o, SizeAllocatedArgs args) => {
+                               int spacing = (int)scrolledwindow2.StyleGetProperty ("scrollbar-spacing");
+                               zoomhbox.HeightRequest = args.Allocation.Height + spacing;
+                       };
+
                        LongoMatch.Gui.Helpers.Misc.SetFocus (this, false);
 
                        menu = new PeriodsMenu ();
@@ -92,6 +97,7 @@ namespace LongoMatch.Gui.Component
                protected override void OnDestroyed ()
                {
                        main_cam_playerbin.Destroy ();
+                       //sec_cam_playerbin.Destroy ();
                        timerule.Dispose ();
                        camerasLabels.Dispose ();
                        camerasTimeline.Dispose ();
@@ -101,6 +107,7 @@ namespace LongoMatch.Gui.Component
                public void Pause ()
                {
                        main_cam_playerbin.Pause ();
+                       //sec_cam_playerbin.Pause ();
                }
 
                public void SaveChanges ()
@@ -132,7 +139,8 @@ namespace LongoMatch.Gui.Component
                                this.project = value;
                                gamePeriods = value.Dashboard.GamePeriods;
 
-                               file = value.Description.FileSet.FirstOrDefault ();
+                               MediaFileSet fileSet = project.Description.FileSet;
+                               file = fileSet.FirstOrDefault ();
                                start = new Time (0);
                                duration = file.Duration;
                                pDuration = new Time (duration.MSeconds / gamePeriods.Count);
@@ -159,14 +167,13 @@ namespace LongoMatch.Gui.Component
                                        periods = periodsDict.Values.ToList ();
                                }
 
-                               MediaFileSet fileSet = project.Description.FileSet;
-
                                camerasLabels.Load (fileSet);
                                camerasTimeline.Load (periods, fileSet, duration);
+
+                               UpdateMaxSecondsPerPixel ();
                                UpdateTimeLineSize (fileSet);
 
                                timerule.Duration = duration;
-                               zoomscale.Value = 6;
 
                                // Open media file
                                main_cam_playerbin.Open (value.Description.FileSet);
@@ -174,7 +181,18 @@ namespace LongoMatch.Gui.Component
                }
 
                /// <summary>
-               /// Adjusts the VPaned position to accomodate up to 8 cameras
+               /// Calculates the maximum number of seconds per pixel to accomodate the complete duration in 
available space.
+               /// </summary>
+               void UpdateMaxSecondsPerPixel () {
+                       if (duration != null) {
+                               // With 20 pixels of margin to properly see the whole segment
+                               maxSecondsPerPixels = (double)duration.TotalSeconds / 
(scrolledwindow2.Allocation.Width - 20);
+                               HandleZoomChanged (zoomscale, new EventArgs ());
+                       }
+               }
+
+               /// <summary>
+               /// Adjusts the VPaned position to accomodate up to 8 cameras.
                /// </summary>
                /// <param name="fileSet">File set.</param>
                void UpdateTimeLineSize (MediaFileSet fileSet)
@@ -222,18 +240,13 @@ namespace LongoMatch.Gui.Component
 
                void HandleZoomChanged (object sender, EventArgs e)
                {
-                       double secondsPer100Pixels, value;
-
-                       value = Math.Round (zoomscale.Value);
-                       if (value == 0) {
-                               secondsPer100Pixels = 1;
-                       } else if (value <= 6) {
-                               secondsPer100Pixels = value * 10;
-                       } else {
-                               secondsPer100Pixels = (value - 5) * 60;
-                       }
+                       // We zoom from our Maximum number of seconds per pixel to the minimum using the 0 to 
100 scale value
+                       double secondsPerPixel = 0, minSecondsPerPixels = 0.01;
+                       double value = Math.Round (zoomscale.Value);
+                       double diff = maxSecondsPerPixels - minSecondsPerPixels;
+
+                       secondsPerPixel = maxSecondsPerPixels - (diff * zoomscale.Value / 100);
 
-                       double secondsPerPixel = secondsPer100Pixels / 100;
                        timerule.SecondsPerPixel = secondsPerPixel;
                        camerasTimeline.SecondsPerPixel = secondsPerPixel;
                        QueueDraw ();
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
index 84d2748..7b4e965 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
@@ -4,6 +4,8 @@ namespace LongoMatch.Gui.Component
 {
        public partial class ProjectPeriods
        {
+               private global::Gtk.EventBox headereventbox;
+               
                private global::Gtk.VPaned vpaned2;
                
                private global::Gtk.VBox vbox2;
@@ -22,11 +24,11 @@ namespace LongoMatch.Gui.Component
                
                private global::Gtk.HBox zoomhbox;
                
-               private global::Gtk.Image zoominimage;
+               private global::Gtk.Image zoomoutimage;
                
                private global::Gtk.HScale zoomscale;
                
-               private global::Gtk.Image zoomoutimage;
+               private global::Gtk.Image zoominimage;
                
                private global::Gtk.VBox vbox7;
                
@@ -43,6 +45,9 @@ namespace LongoMatch.Gui.Component
                        global::Stetic.BinContainer.Attach (this);
                        this.Name = "LongoMatch.Gui.Component.ProjectPeriods";
                        // Container child 
LongoMatch.Gui.Component.ProjectPeriods.Gtk.Container+ContainerChild
+                       this.headereventbox = new global::Gtk.EventBox ();
+                       this.headereventbox.Name = "headereventbox";
+                       // Container child headereventbox.Gtk.Container+ContainerChild
                        this.vpaned2 = new global::Gtk.VPaned ();
                        this.vpaned2.CanFocus = true;
                        this.vpaned2.Name = "vpaned2";
@@ -79,7 +84,6 @@ namespace LongoMatch.Gui.Component
                        // Container child labels_alignment.Gtk.Container+ContainerChild
                        this.labels_vbox = new global::Gtk.VBox ();
                        this.labels_vbox.Name = "labels_vbox";
-                       this.labels_vbox.Spacing = 6;
                        // Container child labels_vbox.Gtk.Box+BoxChild
                        this.labelsarea = new global::Gtk.DrawingArea ();
                        this.labelsarea.Name = "labelsarea";
@@ -91,12 +95,12 @@ namespace LongoMatch.Gui.Component
                        this.zoomhbox.Name = "zoomhbox";
                        this.zoomhbox.Spacing = 6;
                        // Container child zoomhbox.Gtk.Box+BoxChild
-                       this.zoominimage = new global::Gtk.Image ();
-                       this.zoominimage.WidthRequest = 14;
-                       this.zoominimage.HeightRequest = 8;
-                       this.zoominimage.Name = "zoominimage";
-                       this.zoomhbox.Add (this.zoominimage);
-                       global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.zoomhbox 
[this.zoominimage]));
+                       this.zoomoutimage = new global::Gtk.Image ();
+                       this.zoomoutimage.WidthRequest = 14;
+                       this.zoomoutimage.HeightRequest = 8;
+                       this.zoomoutimage.Name = "zoomoutimage";
+                       this.zoomhbox.Add (this.zoomoutimage);
+                       global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.zoomhbox 
[this.zoomoutimage]));
                        w5.Position = 0;
                        w5.Expand = false;
                        w5.Fill = false;
@@ -104,7 +108,6 @@ namespace LongoMatch.Gui.Component
                        this.zoomscale = new global::Gtk.HScale (null);
                        this.zoomscale.CanFocus = true;
                        this.zoomscale.Name = "zoomscale";
-                       this.zoomscale.Inverted = true;
                        this.zoomscale.Adjustment.Upper = 100;
                        this.zoomscale.Adjustment.PageIncrement = 10;
                        this.zoomscale.Adjustment.StepIncrement = 1;
@@ -115,12 +118,12 @@ namespace LongoMatch.Gui.Component
                        global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.zoomhbox 
[this.zoomscale]));
                        w6.Position = 1;
                        // Container child zoomhbox.Gtk.Box+BoxChild
-                       this.zoomoutimage = new global::Gtk.Image ();
-                       this.zoomoutimage.WidthRequest = 14;
-                       this.zoomoutimage.HeightRequest = 8;
-                       this.zoomoutimage.Name = "zoomoutimage";
-                       this.zoomhbox.Add (this.zoomoutimage);
-                       global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.zoomhbox 
[this.zoomoutimage]));
+                       this.zoominimage = new global::Gtk.Image ();
+                       this.zoominimage.WidthRequest = 14;
+                       this.zoominimage.HeightRequest = 8;
+                       this.zoominimage.Name = "zoominimage";
+                       this.zoomhbox.Add (this.zoominimage);
+                       global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.zoomhbox 
[this.zoominimage]));
                        w7.Position = 2;
                        w7.Expand = false;
                        w7.Fill = false;
@@ -149,6 +152,8 @@ namespace LongoMatch.Gui.Component
                        this.scrolledwindow2.HeightRequest = 50;
                        this.scrolledwindow2.CanFocus = true;
                        this.scrolledwindow2.Name = "scrolledwindow2";
+                       this.scrolledwindow2.VscrollbarPolicy = ((global::Gtk.PolicyType)(0));
+                       this.scrolledwindow2.HscrollbarPolicy = ((global::Gtk.PolicyType)(0));
                        // Container child scrolledwindow2.Gtk.Container+ContainerChild
                        global::Gtk.Viewport w12 = new global::Gtk.Viewport ();
                        w12.ShadowType = ((global::Gtk.ShadowType)(0));
@@ -164,7 +169,8 @@ namespace LongoMatch.Gui.Component
                        global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.vbox7]));
                        w16.Position = 1;
                        this.vpaned2.Add (this.hbox3);
-                       this.Add (this.vpaned2);
+                       this.headereventbox.Add (this.vpaned2);
+                       this.Add (this.headereventbox);
                        if ((this.Child != null)) {
                                this.Child.ShowAll ();
                        }
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index d2674d5..04e5346 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -9660,134 +9660,122 @@ You can continue with the current capture, cancel it or save your project.
     <property name="MemberName" />
     <property name="Visible">False</property>
     <child>
-      <widget class="Gtk.VPaned" id="vpaned2">
+      <widget class="Gtk.EventBox" id="headereventbox">
         <property name="MemberName" />
-        <property name="CanFocus">True</property>
-        <property name="Position">400</property>
         <child>
-          <widget class="Gtk.VBox" id="vbox2">
+          <widget class="Gtk.VPaned" id="vpaned2">
             <property name="MemberName" />
+            <property name="CanFocus">True</property>
+            <property name="Position">400</property>
             <child>
-              <widget class="Gtk.HBox" id="playbins_hbox">
+              <widget class="Gtk.VBox" id="vbox2">
                 <property name="MemberName" />
-                <property name="Homogeneous">True</property>
-                <property name="Spacing">15</property>
-                <property name="BorderWidth">15</property>
                 <child>
-                  <widget class="LongoMatch.Gui.PlayerBin" id="main_cam_playerbin">
+                  <widget class="Gtk.HBox" id="playbins_hbox">
                     <property name="MemberName" />
-                    <property name="Events">ButtonPressMask</property>
-                    <property name="CloseAlwaysVisible">False</property>
+                    <property name="Homogeneous">True</property>
+                    <property name="Spacing">15</property>
+                    <property name="BorderWidth">15</property>
+                    <child>
+                      <widget class="LongoMatch.Gui.PlayerBin" id="main_cam_playerbin">
+                        <property name="MemberName" />
+                        <property name="Events">ButtonPressMask</property>
+                        <property name="CloseAlwaysVisible">False</property>
+                      </widget>
+                      <packing>
+                        <property name="Position">0</property>
+                        <property name="AutoSize">True</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder />
+                    </child>
                   </widget>
                   <packing>
                     <property name="Position">0</property>
                     <property name="AutoSize">True</property>
                   </packing>
                 </child>
-                <child>
-                  <placeholder />
-                </child>
               </widget>
               <packing>
-                <property name="Position">0</property>
-                <property name="AutoSize">True</property>
+                <property name="Resize">False</property>
               </packing>
             </child>
-          </widget>
-          <packing>
-            <property name="Resize">False</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="Gtk.HBox" id="hbox3">
-            <property name="MemberName" />
             <child>
-              <widget class="Gtk.Alignment" id="labels_alignment">
+              <widget class="Gtk.HBox" id="hbox3">
                 <property name="MemberName" />
                 <child>
-                  <widget class="Gtk.VBox" id="labels_vbox">
+                  <widget class="Gtk.Alignment" id="labels_alignment">
                     <property name="MemberName" />
-                    <property name="Spacing">6</property>
                     <child>
-                      <widget class="Gtk.DrawingArea" id="labelsarea">
+                      <widget class="Gtk.VBox" id="labels_vbox">
                         <property name="MemberName" />
-                      </widget>
-                      <packing>
-                        <property name="Position">0</property>
-                        <property name="AutoSize">True</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="Gtk.HBox" id="zoomhbox">
-                        <property name="MemberName" />
-                        <property name="Spacing">6</property>
                         <child>
-                          <widget class="Gtk.Image" id="zoominimage">
+                          <widget class="Gtk.DrawingArea" id="labelsarea">
                             <property name="MemberName" />
-                            <property name="WidthRequest">14</property>
-                            <property name="HeightRequest">8</property>
                           </widget>
                           <packing>
                             <property name="Position">0</property>
                             <property name="AutoSize">True</property>
-                            <property name="Expand">False</property>
-                            <property name="Fill">False</property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="Gtk.HScale" id="zoomscale">
+                          <widget class="Gtk.HBox" id="zoomhbox">
                             <property name="MemberName" />
-                            <property name="CanFocus">True</property>
-                            <property name="Inverted">True</property>
-                            <property name="Upper">100</property>
-                            <property name="PageIncrement">10</property>
-                            <property name="StepIncrement">1</property>
-                            <property name="DrawValue">False</property>
-                            <property name="Digits">0</property>
-                            <property name="ValuePos">Top</property>
+                            <property name="Spacing">6</property>
+                            <child>
+                              <widget class="Gtk.Image" id="zoomoutimage">
+                                <property name="MemberName" />
+                                <property name="WidthRequest">14</property>
+                                <property name="HeightRequest">8</property>
+                              </widget>
+                              <packing>
+                                <property name="Position">0</property>
+                                <property name="AutoSize">True</property>
+                                <property name="Expand">False</property>
+                                <property name="Fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="Gtk.HScale" id="zoomscale">
+                                <property name="MemberName" />
+                                <property name="CanFocus">True</property>
+                                <property name="Upper">100</property>
+                                <property name="PageIncrement">10</property>
+                                <property name="StepIncrement">1</property>
+                                <property name="DrawValue">False</property>
+                                <property name="Digits">0</property>
+                                <property name="ValuePos">Top</property>
+                              </widget>
+                              <packing>
+                                <property name="Position">1</property>
+                                <property name="AutoSize">True</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="Gtk.Image" id="zoominimage">
+                                <property name="MemberName" />
+                                <property name="WidthRequest">14</property>
+                                <property name="HeightRequest">8</property>
+                              </widget>
+                              <packing>
+                                <property name="Position">2</property>
+                                <property name="AutoSize">True</property>
+                                <property name="Expand">False</property>
+                                <property name="Fill">False</property>
+                              </packing>
+                            </child>
                           </widget>
                           <packing>
                             <property name="Position">1</property>
                             <property name="AutoSize">True</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <widget class="Gtk.Image" id="zoomoutimage">
-                            <property name="MemberName" />
-                            <property name="WidthRequest">14</property>
-                            <property name="HeightRequest">8</property>
-                          </widget>
-                          <packing>
-                            <property name="Position">2</property>
-                            <property name="AutoSize">True</property>
                             <property name="Expand">False</property>
                             <property name="Fill">False</property>
                           </packing>
                         </child>
                       </widget>
-                      <packing>
-                        <property name="Position">1</property>
-                        <property name="AutoSize">True</property>
-                        <property name="Expand">False</property>
-                        <property name="Fill">False</property>
-                      </packing>
                     </child>
                   </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="Position">0</property>
-                <property name="AutoSize">False</property>
-                <property name="Expand">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.VBox" id="vbox7">
-                <property name="MemberName" />
-                <child>
-                  <widget class="Gtk.DrawingArea" id="timerulearea">
-                    <property name="MemberName" />
-                  </widget>
                   <packing>
                     <property name="Position">0</property>
                     <property name="AutoSize">False</property>
@@ -9795,32 +9783,49 @@ You can continue with the current capture, cancel it or save your project.
                   </packing>
                 </child>
                 <child>
-                  <widget class="Gtk.ScrolledWindow" id="scrolledwindow2">
+                  <widget class="Gtk.VBox" id="vbox7">
                     <property name="MemberName" />
-                    <property name="HeightRequest">50</property>
-                    <property name="CanFocus">True</property>
                     <child>
-                      <widget class="Gtk.Viewport" id="GtkViewport">
+                      <widget class="Gtk.DrawingArea" id="timerulearea">
                         <property name="MemberName" />
-                        <property name="ShadowType">None</property>
+                      </widget>
+                      <packing>
+                        <property name="Position">0</property>
+                        <property name="AutoSize">False</property>
+                        <property name="Expand">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.ScrolledWindow" id="scrolledwindow2">
+                        <property name="MemberName" />
+                        <property name="HeightRequest">50</property>
+                        <property name="CanFocus">True</property>
+                        <property name="VscrollbarPolicy">Always</property>
+                        <property name="HscrollbarPolicy">Always</property>
                         <child>
-                          <widget class="Gtk.DrawingArea" id="timelinearea">
+                          <widget class="Gtk.Viewport" id="GtkViewport">
                             <property name="MemberName" />
+                            <property name="ShadowType">None</property>
+                            <child>
+                              <widget class="Gtk.DrawingArea" id="timelinearea">
+                                <property name="MemberName" />
+                              </widget>
+                            </child>
                           </widget>
                         </child>
                       </widget>
+                      <packing>
+                        <property name="Position">1</property>
+                        <property name="AutoSize">True</property>
+                      </packing>
                     </child>
                   </widget>
                   <packing>
                     <property name="Position">1</property>
-                    <property name="AutoSize">True</property>
+                    <property name="AutoSize">False</property>
                   </packing>
                 </child>
               </widget>
-              <packing>
-                <property name="Position">1</property>
-                <property name="AutoSize">False</property>
-              </packing>
             </child>
           </widget>
         </child>


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