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



Author: scottp
Date: Thu Apr  3 06:52:45 2008
New Revision: 3654
URL: http://svn.gnome.org/viewvc/banshee?rev=3654&view=rev

Log:
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs:
Instantiate the CellContext on realization.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
Use one CellContext all the time, just changing properties when we
need to.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs: Made all
properties settable and got rid of fancy constructor.

* src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs: Made
slightly better.

Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs	Thu Apr  3 06:52:45 2008
@@ -43,44 +43,39 @@
         private Gdk.Rectangle clip;
         private bool text_as_foreground = false;
         
-        public CellContext (Cairo.Context context, Pango.Layout layout, Gtk.Widget widget,
-            Gdk.Drawable drawable, Theme theme, Gdk.Rectangle area, Gdk.Rectangle clip)
-        {
-            this.context = context;
-            this.layout = layout;
-            this.widget = widget;
-            this.drawable = drawable;
-            this.theme = theme;
-            this.area = area;
-            this.clip = clip;
-        }
-        
         public Cairo.Context Context {
             get { return context; }
+            set { context = value; }
         }
 
         public Pango.Layout Layout {
             get { return layout; }
+            set { layout = value; }
         }
 
         public Gtk.Widget Widget {
             get { return widget; }
+            set { widget = value; }
         }
 
         public Gdk.Drawable Drawable {
             get { return drawable; }
+            set { drawable = value; }
         }
 
         public Theme Theme {
             get { return theme; }
+            set { theme = value; }
         }
 
         public Gdk.Rectangle Area {
             get { return area; }
+            set { area = value; }
         }
         
         public Gdk.Rectangle Clip {
             get { return clip; }
+            set { clip = value; }
         }
         
         public bool TextAsForeground {

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	Thu Apr  3 06:52:45 2008
@@ -56,6 +56,7 @@
         private bool render_everything;
         
         private Cairo.Context cairo_context;
+        private CellContext cell_context;
         
         private Pango.Layout header_pango_layout;
         private Pango.Layout list_pango_layout;
@@ -120,6 +121,10 @@
             Rectangle cell_area = new Rectangle ();
             cell_area.Y = header_rendering_alloc.Y;
             cell_area.Height = header_rendering_alloc.Height;
+            
+            cell_context.Context = cairo_context;
+            cell_context.Drawable = GdkWindow;
+            cell_context.Layout = header_pango_layout;
 
             for (int ci = 0; ci < column_cache.Length; ci++) {
                 if (pressed_column_is_dragging && pressed_column_index == ci) {
@@ -163,8 +168,9 @@
             if (cell != null) {
                 cairo_context.Save ();
                 cairo_context.Translate (area.X, area.Y);
-                cell.Render (new CellContext (cairo_context, header_pango_layout, this, GdkWindow, 
-                    theme, area, clip), StateType.Normal, area.Width, area.Height);
+                cell_context.Area = area;
+                cell_context.Clip = clip;
+                cell.Render (cell_context, StateType.Normal, area.Width, area.Height);
                 cairo_context.Restore ();
             }
             
@@ -276,6 +282,11 @@
         
         private void PaintRows (int first_row, int last_row, int first_row_y)
         {
+            cell_context.Context = cairo_context;
+            cell_context.Drawable = canvas1;
+            cell_context.Layout = list_pango_layout;
+            cell_context.Clip = canvas_alloc;
+            
             Rectangle selected_focus_alloc = Rectangle.Zero;
             Rectangle single_list_alloc = new Rectangle ();
             
@@ -407,8 +418,8 @@
             
             cairo_context.Save ();
             cairo_context.Translate (area.X, area.Y);
-            cell.Render (new CellContext (cairo_context, list_pango_layout, this, canvas1, theme, area, canvas_alloc), 
-                dragging ? StateType.Normal : state, area.Width, area.Height);
+            cell_context.Area = area;
+            cell.Render (cell_context, dragging ? StateType.Normal : state, area.Width, area.Height);
             cairo_context.Restore ();
         }
         

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs	Thu Apr  3 06:52:45 2008
@@ -53,6 +53,9 @@
             
             GdkWindow = Parent.GdkWindow;
             theme = new GtkTheme (this);
+            cell_context = new CellContext ();
+            cell_context.Theme = theme;
+            cell_context.Widget = this;
             //graphics.RefreshColors ();
             
             WindowAttr attributes = new WindowAttr ();

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs	Thu Apr  3 06:52:45 2008
@@ -37,10 +37,6 @@
         private double target_value;
         private double velocity = 0;
         
-        protected virtual double MaxVelocity {
-            get { return Vadjustment.StepIncrement * 4; }
-        }
-        
         private double Accelerate (double velocity)
         {
             return AccelerateCore (velocity);
@@ -87,7 +83,14 @@
             int sign = Math.Sign (delta);
             delta = Math.Abs (delta);
             
-            velocity = TimeToDecelerate (delta) ? Decelerate (velocity) : Accelerate (velocity);
+            double hypothetical = delta;
+            double v = Accelerate (velocity);
+            while (v > 0 && hypothetical > 0) {
+                hypothetical -= v;
+                v = Decelerate (v);
+            }
+            
+            velocity = hypothetical <= 0 ? Decelerate (velocity) : Accelerate (velocity);
             
             value += Math.Max (velocity, 1) * sign;
             ignore_value_changed = true;
@@ -97,17 +100,6 @@
             return true;
         }
         
-        private bool TimeToDecelerate (double delta)
-        {
-            double hypothetical = delta;
-            double v = Accelerate (velocity);
-            while (v > 0) {
-                hypothetical -= v;
-                v = Decelerate (v);
-            }
-            return hypothetical <= 0;
-        }
-        
         protected override bool OnScrollEvent (Gdk.EventScroll evnt)
         {
             switch (evnt.Direction) {



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