banshee r3149 - in trunk/banshee: . src/Core/Hyena.Gui/Hyena.Data.Gui
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3149 - in trunk/banshee: . src/Core/Hyena.Gui/Hyena.Data.Gui
- Date: Tue, 5 Feb 2008 06:32:27 +0000 (GMT)
Author: scottp
Date: Tue Feb 5 06:32:27 2008
New Revision: 3149
URL: http://svn.gnome.org/viewvc/banshee?rev=3149&view=rev
Log:
* src/Core/Hyena.Gui/Hyena.Data.Gui/ListView.cs: A rework of PaintList
and PaintRows. Previously, all rows needed to be iterated over
three times: once to calculate the selection blocks, once to draw
the rule, and once to draw the content. Now it is only iterated
over once - rules, content for unselected rows, and selection
blocks are drawn during iteration while selected rows are put into
a list and their content is drawn at the end. This exploits the
fact that the most common numbers of visible selected rows are 0
and 1. The actual performance gains for this patch are rather
modest, but tangeble (a millisecond or two for the execution time
of PaintList acording to the profiler).
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView.cs
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView.cs Tue Feb 5 06:32:27 2008
@@ -868,63 +868,65 @@
private void PaintList(Gdk.EventExpose evnt, Gdk.Rectangle clip)
{
- if(model == null) {
+ if (model == null) {
return;
}
int rows = RowsInView;
int vadjustment_value = (int) vadjustment.Value;
int first_row = vadjustment_value / RowHeight;
- int last_row = Math.Min(model.Count, first_row + rows);
-
- // Compute a stack of Contiguous Selection Rectangles
- Stack<SelectionRectangle> cg_s_rects = new Stack<SelectionRectangle>();
-
- for(int ri = first_row; ri < last_row; ri++) {
- if(ri < 0 || !Selection.Contains(ri)) {
- continue;
- }
-
- if(Selection.Contains(ri - 1) && cg_s_rects.Count > 0) {
- cg_s_rects.Peek().Height += RowHeight;
- } else {
- cg_s_rects.Push(new SelectionRectangle(list_alloc.Y +
- (ri * RowHeight - vadjustment_value), RowHeight));
- }
- }
-
- if (rules_hint) {
- PaintRows (first_row, last_row, vadjustment_value, clip, false);
- }
-
- foreach(SelectionRectangle selection_rect in cg_s_rects) {
- graphics.DrawRowSelection(list_cr, list_alloc.X, selection_rect.Y, list_alloc.Width, selection_rect.Height);
- }
+ int last_row = Math.Min (model.Count, first_row + rows);
- PaintRows (first_row, last_row, vadjustment_value, clip, true);
+ PaintRows (first_row, last_row, vadjustment_value, clip);
}
- private void PaintRows (int first_row, int last_row, int vadjustment_value, Gdk.Rectangle clip, bool content)
+ private void PaintRows (int first_row, int last_row, int vadjustment_value, Gdk.Rectangle clip)
{
Gdk.Rectangle single_list_alloc = new Gdk.Rectangle ();
single_list_alloc.Width = list_alloc.Width;
single_list_alloc.Height = RowHeight;
single_list_alloc.X = list_alloc.X;
single_list_alloc.Y = list_alloc.Y - vadjustment_value + (first_row * single_list_alloc.Height);
+
+ int selection_height = 0;
+ int selection_y = 0;
+ List<int> selected_rows = new List<int> ();
for (int ri = first_row; ri < last_row; ri++) {
- if (content) {
- StateType row_state = Selection.Contains (ri) ? StateType.Selected : StateType.Normal;
+ if (Selection.Contains (ri)) {
+ if (selection_height == 0) {
+ selection_y = single_list_alloc.Y;
+ }
+ selection_height += single_list_alloc.Height;
+ selected_rows.Add (ri);
+ } else {
+ if (selection_height > 0) {
+ graphics.DrawRowSelection (
+ list_cr, list_alloc.X, list_alloc.Y + selection_y, list_alloc.Width, selection_height);
+ selection_height = 0;
+ selection_y = 0;
+ }
- //PaintRowFocus (ri, clip, single_list_alloc, row_state);
- PaintRow (ri, clip, single_list_alloc, row_state);
- } else if (ri % 2 != 0) {
- graphics.DrawRowRule (list_cr, single_list_alloc.X, single_list_alloc.Y,
- single_list_alloc.Width, single_list_alloc.Height);
+ if (rules_hint && ri % 2 != 0) {
+ graphics.DrawRowRule (list_cr, single_list_alloc.X, single_list_alloc.Y,
+ single_list_alloc.Width, single_list_alloc.Height);
+ }
+
+ PaintRow (ri, clip, single_list_alloc, StateType.Normal);
}
-
+
single_list_alloc.Y += single_list_alloc.Height;
}
+
+ if (selection_height > 0) {
+ graphics.DrawRowSelection(
+ list_cr, list_alloc.X, list_alloc.Y + selection_y, list_alloc.Width, selection_height);
+ }
+
+ foreach (int ri in selected_rows) {
+ single_list_alloc.Y = ri * single_list_alloc.Height - vadjustment_value;
+ PaintRow (ri, clip, single_list_alloc, StateType.Selected);
+ }
}
private void PaintRow(int row_index, Gdk.Rectangle clip, Gdk.Rectangle area, StateType state)
@@ -1246,4 +1248,4 @@
#endregion
}
-}
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]