banshee r3799 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Core/Banshee.Widgets/Banshee.Widgets src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying src/Libraries/Hyena.Gui/Hyena.Widgets



Author: abock
Date: Sat Apr 19 22:18:52 2008
New Revision: 3799
URL: http://svn.gnome.org/viewvc/banshee?rev=3799&view=rev

Log:
2008-04-19  Aaron Bockover  <abock gnome org>

    * src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedSeekSlider.cs:
    Added new horizontal layout mode that is nice for fullscreen

    * src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs:
    Rebuild the layouts when the format string changes

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenControls.cs:
    Allow the seek slider to fill any remaining space in the window and
    make sure the window takes 85% of the screen width

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs:
    Fixed the popup auto-hide when the mouse was over the controls

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs:
    Added better sizing to allow the window to adapt to the screen size

    * src/Libraries/Hyena.Gui/Hyena.Widgets/MenuButton.cs:
    Implemented two empty method overrides to avoid GtkContainer's bitching



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedSeekSlider.cs
   trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenControls.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/MenuButton.cs

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedSeekSlider.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedSeekSlider.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedSeekSlider.cs	Sat Apr 19 22:18:52 2008
@@ -35,17 +35,26 @@
 
 namespace Banshee.Gui.Widgets
 {
+    public enum SeekSliderLayout {
+        Horizontal,
+        Vertical
+    }   
+
     public class ConnectedSeekSlider : Alignment
     {
         private SeekSlider seek_slider;
         private StreamPositionLabel stream_position_label;
     
-        public ConnectedSeekSlider () : base (0.0f, 0.0f, 1.0f, 1.0f)
+        public ConnectedSeekSlider () : this (SeekSliderLayout.Vertical)
+        {
+        }
+    
+        public ConnectedSeekSlider (SeekSliderLayout layout) : base (0.0f, 0.0f, 1.0f, 1.0f)
         {
             RightPadding = 10;
             LeftPadding = 10;
             
-            BuildSeekSlider ();
+            BuildSeekSlider (layout);
             
             ServiceManager.PlayerEngine.EventChanged += OnPlayerEngineEventChanged;
             ServiceManager.PlayerEngine.StateChanged += OnPlayerEngineStateChanged;
@@ -56,20 +65,33 @@
             get { return stream_position_label; }
         }
         
-        private void BuildSeekSlider ()
-        {
-            VBox box = new VBox ();
-            Add (box);
-            
+        public SeekSlider SeekSlider {
+            get { return seek_slider; }
+        }
+        
+        private void BuildSeekSlider (SeekSliderLayout layout)
+        {            
             seek_slider = new SeekSlider ();
             stream_position_label = new StreamPositionLabel (seek_slider);
+         
+            Box box;
             
-            seek_slider.SetSizeRequest (125, -1);
+            if (layout == SeekSliderLayout.Horizontal) {
+                box = new HBox ();
+                box.Spacing = 5;
+                stream_position_label.FormatString = "<b>{0}</b>";
+            } else {
+                box = new VBox ();
+            }
             
+            seek_slider.SetSizeRequest (125, -1);
+                     
             box.PackStart (seek_slider, true, true, 0);
-            box.PackStart (stream_position_label, true, true, 0);
+            box.PackStart (stream_position_label, false, false, 0);
             
             box.ShowAll ();
+            
+            Add (box);
         }
         
         private void OnPlayerEngineStateChanged (object o, PlayerEngineStateArgs args)

Modified: trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs	Sat Apr 19 22:18:52 2008
@@ -48,13 +48,21 @@
             this.seekRange = seekRange;
             this.seekRange.ValueChanged += OnSliderUpdated;
             this.seekRange.DurationChanged += OnSliderUpdated;
-
+        }
+        
+        protected override void OnRealized ()
+        {
+            base.OnRealized ();
+            
             BuildLayouts ();
             UpdateLabel ();
         }
         
         private void BuildLayouts ()
         {
+            if (layout != null) {
+                layout.Dispose ();
+            }
             layout = new Pango.Layout (PangoContext);
             layout.FontDescription = PangoContext.FontDescription.Copy ();
             layout.Ellipsize = Pango.EllipsizeMode.None;
@@ -181,6 +189,7 @@
         public string FormatString {
             set { 
                 format_string = value;
+                BuildLayouts ();
                 UpdateLabel ();
             }
         }

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenControls.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenControls.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenControls.cs	Sat Apr 19 22:18:52 2008
@@ -39,10 +39,10 @@
     {
         private InterfaceActionService action_service;
         
-        public FullscreenControls (Window toplevel) : base (toplevel)
+        public FullscreenControls (Window toplevel) : base (toplevel, 0.85)
         {
             action_service = ServiceManager.Get<InterfaceActionService> ();
-            BorderWidth = 2;
+            BorderWidth = 1;
             BuildInterface ();
         }
         
@@ -50,10 +50,10 @@
         {
             HBox box = new HBox ();
             
-            box.PackStart (action_service.PlaybackActions["PreviousAction"].CreateToolItem ());
-            box.PackStart (action_service.PlaybackActions["PlayPauseAction"].CreateToolItem ());
+            box.PackStart (action_service.PlaybackActions["PreviousAction"].CreateToolItem (), false, false, 0);
+            box.PackStart (action_service.PlaybackActions["PlayPauseAction"].CreateToolItem (), false, false, 0);
             box.PackStart (new NextButton (action_service), false, false, 0);
-            box.PackStart (new ConnectedSeekSlider (), false, false, 10);
+            box.PackStart (new ConnectedSeekSlider (SeekSliderLayout.Horizontal), true, true, 0);
             box.PackStart (new ConnectedVolumeButton (), false, false, 0);
             
             Button exit = new Button (Stock.LeaveFullscreen);

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	Sat Apr 19 22:18:52 2008
@@ -56,7 +56,8 @@
         
         protected override void OnRealized ()
         {
-            Events |= Gdk.EventMask.PointerMotionMask | Gdk.EventMask.PointerMotionHintMask;
+            Events |= Gdk.EventMask.PointerMotionMask;
+            
             base.OnRealized ();
             
             Screen.SizeChanged += OnScreenSizeChanged;
@@ -84,10 +85,7 @@
         protected override void OnHidden ()
         {
             base.OnHidden ();
-            if (controls != null) {
-                controls.Destroy ();
-                controls = null;
-            }
+            DestroyControls ();
             parent.RemoveNotification ("is-active", ParentActiveNotification);
         }
         
@@ -138,10 +136,37 @@
                 controls.Hide ();
             }
         }
-
+        
+        private void DestroyControls ()
+        {
+            if (controls != null) {
+                controls.Destroy ();
+                controls = null;
+            }
+        }
+        
+        private bool ControlsActive {
+            get {
+                if (controls == null || !controls.Visible) {
+                    return false;
+                }
+                
+                int cursor_x, cursor_y;
+                int window_x, window_y;
+                
+                controls.GdkWindow.Screen.Display.GetPointer (out cursor_x, out cursor_y);
+                controls.GetPosition (out window_x, out window_y);
+                
+                Gdk.Rectangle box = new Gdk.Rectangle (window_x, window_y, 
+                    controls.Allocation.Width, controls.Allocation.Height);
+                
+                return box.Contains (cursor_x, cursor_y);
+            }
+        }
+     
 #endregion
         
-#region Mouse Cursor Polish
+#region Mouse Cursor Logic
 
         private const int CursorUpdatePositionDelay = 500;   // How long (ms) before the cursor position is updated
         private const int CursorHideDelay = 2500;            // How long (ms) to remain stationary before it hides
@@ -168,7 +193,7 @@
                     cursor_update_position_timeout_id = GLib.Timeout.Add (CursorUpdatePositionDelay, 
                         OnCursorUpdatePositionTimeout);
                 }        
-            } else if (controls.CanHide) {
+            } else if (!ControlsActive) {
                 if (hide_cursor_timeout_id > 0) {
                     GLib.Source.Remove (hide_cursor_timeout_id);
                 }
@@ -188,8 +213,11 @@
         
         private bool OnHideCursorTimeout ()
         {
-            HideCursor ();
-            HideControls ();
+            if (!ControlsActive) {
+                HideCursor ();
+                HideControls ();
+            }
+            
             hide_cursor_timeout_id = 0;
             return false;
         }

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/OverlayWindow.cs	Sat Apr 19 22:18:52 2008
@@ -38,10 +38,24 @@
         
         private double x_align = 0.5;
         private double y_align = 0.90;
+        private double width_scale;
         
-        public OverlayWindow (Window toplevel) : base (WindowType.Popup)
+        public OverlayWindow (Window toplevel) : this (toplevel, 0.0)
         {
+        }
+        
+        public OverlayWindow (Window toplevel, double widthScale) : base (WindowType.Popup)
+        {
+            if (toplevel == null) {
+                throw new ArgumentNullException ("toplevel", "An overlay must have a parent window");
+            }
+            
+            if (width_scale < 0 || width_scale > 1) {
+                throw new ArgumentOutOfRangeException ("widthScale", "Must be between 0 and 1 inclusive");
+            }
+        
             this.toplevel = toplevel;
+            this.width_scale = widthScale;
             
             Decorated = false;
             DestroyWithParent = true;
@@ -63,10 +77,6 @@
             // composited = CompositeUtils.IsComposited (Screen) && CompositeUtils.SetRgbaColormap (this);
             // AppPaintable = composited;
             
-            Events |= (Gdk.EventMask.EnterNotifyMask | 
-                Gdk.EventMask.LeaveNotifyMask |
-                Gdk.EventMask.PointerMotionMask);
-
             base.OnRealized ();
             
             // ShapeWindow ();
@@ -78,27 +88,27 @@
             base.OnMapped ();
             Relocate ();
         }
-        
-        protected override bool OnEnterNotifyEvent (Gdk.EventCrossing evnt)
-        {
-            can_hide = false;
-            return base.OnEnterNotifyEvent (evnt);
-        }
 
-        protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing evnt)
+        protected override bool OnConfigureEvent (Gdk.EventConfigure evnt)
         {
-            can_hide = true;
-            return base.OnLeaveNotifyEvent (evnt);
+            return base.OnConfigureEvent (evnt);
         }
         
-        protected override bool OnConfigureEvent (Gdk.EventConfigure evnt)
+        protected override void OnSizeRequested (ref Requisition requisition)
         {
-            return base.OnConfigureEvent (evnt);
+            if (Child != null) {
+                requisition = Child.SizeRequest ();
+            }
+            
+            if (width_scale > 0 && width_scale <= 1 && TransientFor != null) {
+                requisition.Width = (int)(TransientFor.Allocation.Width * width_scale);
+            }
         }
         
         protected override void OnSizeAllocated (Gdk.Rectangle allocation)
         {
             base.OnSizeAllocated (allocation);
+            
             Relocate ();
             // ShapeWindow ();
             QueueDraw ();
@@ -111,6 +121,7 @@
         
         private void OnToplevelSizeAllocated (object o, SizeAllocatedArgs args)
         {
+            QueueResize ();
             Relocate ();
         }
         

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/MenuButton.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/MenuButton.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/MenuButton.cs	Sat Apr 19 22:18:52 2008
@@ -107,6 +107,14 @@
             callback (box);
         }
         
+        protected override void OnAdded (Widget widget)
+        {
+        }
+        
+        protected override void OnRemoved (Widget widget)
+        {
+        }
+        
         protected void ShowMenu ()
         {
             menu.Popup (null, null, PositionMenu, 1, Gtk.Global.CurrentEventTime);



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