[longomatch] Automatic scrolling to latest empty field.



commit 3c1f8ae108647e4ac9ffeee9b85fe93e4df75ef5
Author: Julien Moutte <julien fluendo com>
Date:   Wed Mar 18 18:39:29 2015 +0100

    Automatic scrolling to latest empty field.

 .../Gui/Component/MediaFileSetSelection.cs         |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/MediaFileSetSelection.cs 
b/LongoMatch.GUI/Gui/Component/MediaFileSetSelection.cs
index 4e4345b..d34a54f 100644
--- a/LongoMatch.GUI/Gui/Component/MediaFileSetSelection.cs
+++ b/LongoMatch.GUI/Gui/Component/MediaFileSetSelection.cs
@@ -61,6 +61,22 @@ namespace LongoMatch.Gui.Component
                }
 
                /// <summary>
+               /// Forces a scroll to bottom of our scrolled window. This is useful for the user to access 
easily the latest entry field.
+               /// </summary>
+               void ScrollToBottom ()
+               {
+                       Adjustment adj = mfss_scrolledwindow.Vadjustment;
+
+                       adj.Value = adj.Upper - adj.PageSize;
+               }
+
+               void HandleChooserAllocated (object sender, EventArgs e)
+               {
+                       ScrollToBottom ();
+                       (sender as MediaFileChooser).SizeAllocated -= HandleChooserAllocated;
+               }
+
+               /// <summary>
                /// Add a media file chooser with given name. If name is null pick a name automatically 
avoiding duplicates.
                /// </summary>
                /// <param name="name">Name.</param>
@@ -82,6 +98,9 @@ namespace LongoMatch.Gui.Component
                        MediaFileChooser chooser = new MediaFileChooser (name);
 
                        chooser.ChangedEvent += HandleFileChangedEvent;
+                       // When the chooser is allocated we scroll to the bottom of the window.
+                       chooser.SizeAllocated += HandleChooserAllocated;
+
                        chooser.ShowAll ();
 
                        mfss_vbox.PackStart (chooser, true, true, 0);


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