banshee r3935 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena.Gui/Hyena.Gui src/Libraries/Hyena.Gui/Hyena.Widgets



Author: abock
Date: Tue May 20 15:12:12 2008
New Revision: 3935
URL: http://svn.gnome.org/viewvc/banshee?rev=3935&view=rev

Log:
2008-05-20  Aaron Bockover  <abock gnome org>

    * src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs: Tell the
    renderer what opacities we like

    * src/Libraries/Hyena.Gui/Hyena.Gui/RatingRenderer.cs: Take the color
    opacities from the argument stack instead of hard coding

    * src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs: Set desired
    opacities and added an AlwaysShowEmptyStars property; moved the motion
    event handler to an internal HandleMotionNotify method

    * src/Libraries/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs: Proxy the
    menu's motion notify event to the entry so we get the sweet preview;
    do not activate the menu when we set the rating so the menu stays visible
    and we can see the rating actually changed



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/RatingRenderer.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellRating.cs	Tue May 20 15:12:12 2008
@@ -54,7 +54,7 @@
             
             renderer.Value = Value;
             renderer.Render (context.Context, area, context.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state), 
-                hover_bound == BoundObjectParent && hover_bound != null, hover_value);
+                hover_bound == BoundObjectParent && hover_bound != null, hover_value, 0.8, 0.45, 0.35);
             
             // FIXME: Something is hosed in the view when computing cell dimensions
             // The cell width request is always smaller than the actual cell, so

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/RatingRenderer.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/RatingRenderer.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui/RatingRenderer.cs	Tue May 20 15:12:12 2008
@@ -52,18 +52,19 @@
         {
         }
         
-        public virtual void Render (Context cr, Gdk.Rectangle area, Color color, bool isHovering, int hoverValue)
+        public virtual void Render (Context cr, Gdk.Rectangle area, Color color, bool isHovering, int hoverValue, 
+            double fillOpacity, double hoverFillOpacity, double strokeOpacity)
         {
             if (!(Value > MinRating || (Value == MinRating && isHovering))) {
                 return;
             }
             
             Cairo.Color fill_color = color;
-            fill_color.A = 0.8;
+            fill_color.A = fillOpacity;
             Cairo.Color stroke_color = fill_color;
-            stroke_color.A = 0.35;
+            stroke_color.A = strokeOpacity;
             Cairo.Color hover_fill_color = fill_color;
-            hover_fill_color.A = 0.45;
+            hover_fill_color.A = hoverFillOpacity;
                 
             double x, y;
             ComputePosition (area, out x, out y);

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs	Tue May 20 15:12:12 2008
@@ -85,6 +85,12 @@
         
 #region Public Properties
 
+        private bool always_show_empty_stars = false;
+        public bool AlwaysShowEmptyStars {
+            get { return always_show_empty_stars; }
+            set { always_show_empty_stars = value; }
+        }
+
         private bool preview_on_hover = true;
         public bool PreviewOnHover {
             get { return preview_on_hover; }
@@ -247,8 +253,11 @@
             }
             
             Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow);
-            renderer.Render (cr, Allocation, CairoExtensions.GdkColorToCairoColor (
-                Style.Foreground (State)), PreviewOnHover && hover_value >= renderer.MinRating, hover_value);
+            renderer.Render (cr, Allocation, CairoExtensions.GdkColorToCairoColor (Style.Foreground (State)), 
+                AlwaysShowEmptyStars || (PreviewOnHover && hover_value >= renderer.MinRating), hover_value,
+                State == StateType.Insensitive ? 1 : 0.90, 
+                State == StateType.Insensitive ? 1 : 0.65, 
+                State == StateType.Insensitive ? 1 : 0.45);
             ((IDisposable)cr.Target).Dispose ();
             ((IDisposable)cr).Dispose ();
 
@@ -283,13 +292,7 @@
         
         protected override bool OnMotionNotifyEvent (Gdk.EventMotion motion)
         {
-            hover_value = renderer.RatingFromPosition (event_alloc, motion.X);
-            if ((motion.State & Gdk.ModifierType.Button1Mask) != 0) {
-                Value = hover_value;
-            }
-            
-            QueueDraw ();
-            return true;
+            return HandleMotionNotify (motion.State, motion.X);
         }
         
         protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
@@ -348,6 +351,17 @@
             return false;
         }
         
+        internal bool HandleMotionNotify (Gdk.ModifierType state, double x)
+        {
+            hover_value = renderer.RatingFromPosition (event_alloc, x);
+            if ((state & Gdk.ModifierType.Button1Mask) != 0) {
+                Value = hover_value;
+            }
+            
+            QueueDraw ();
+            return true;
+        }
+        
 #endregion
 
     }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingMenuItem.cs	Tue May 20 15:12:12 2008
@@ -52,7 +52,8 @@
             
             entry = new RatingEntry ();
             entry.HasFrame = false;
-            entry.PreviewOnHover = false;
+            entry.PreviewOnHover = true;
+            entry.AlwaysShowEmptyStars = true;
             entry.Changed += OnEntryChanged;
             box.PackStart (entry, false, false, 0);
             
@@ -89,7 +90,7 @@
         protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt)
         {
             if (!pressing) {
-                return false;
+                return entry.HandleMotionNotify (evnt.State, TransformX (evnt.X));
             }
 
             entry.SetValueFromPosition (TransformX (evnt.X));
@@ -114,9 +115,12 @@
         
         private void OnEntryChanged (object o, EventArgs args)
         {
-            if (can_activate) {
-                Activate ();
-            }
+            // TODO: See what's really better - hiding the menu when the
+            // value is set, or keeping it up; I like it staying up --Aaron
+            //
+            // if (can_activate) {
+            //    Activate ();
+            // }
         }
         
         public void Reset (int value)



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