banshee r3522 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3522 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView
- Date: Sun, 23 Mar 2008 00:04:56 +0000 (GMT)
Author: scottp
Date: Sun Mar 23 00:04:56 2008
New Revision: 3522
URL: http://svn.gnome.org/viewvc/banshee?rev=3522&view=rev
Log:
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs:
Moved the ColumnHeaderCellText.HasSort determination from
PaintHeaderCell into RegenerateColumnCache. This means we run that
code less often.
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
Fixed stupid bug in rendering which I can't believe I missed.
Better, faster, stronger.
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
Regenerate the column cache after the sort column changes so that
we re-assign the HasSort properties of the ColumnHeaderCellText
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs Sun Mar 23 00:04:56 2008
@@ -51,6 +51,7 @@
private static Gdk.Cursor resize_x_cursor = new Gdk.Cursor (Gdk.CursorType.SbHDoubleArrow);
private static Gdk.Cursor drag_cursor = new Gdk.Cursor (Gdk.CursorType.Fleur);
+ private int sort_column_index = -1;
private int resizing_column_index = -1;
private int pressed_column_index = -1;
private int pressed_column_x_start = -1;
@@ -108,7 +109,7 @@
private void RegenerateColumnCache ()
{
- if (!IsRealized || column_controller == null) {
+ if (column_controller == null) {
return;
}
@@ -116,6 +117,9 @@
GenerateColumnCache ();
}
+ ISortable sortable = Model as ISortable;
+ sort_column_index = -1;
+
for (int i = 0; i < column_cache.Length; i++) {
column_cache[i].Width = (int)Math.Round (((double)header_interaction_alloc.Width * column_cache[i].Column.Width));
column_cache[i].X1 = i == 0 ? 0 : column_cache[i - 1].X2;
@@ -123,6 +127,17 @@
column_cache[i].ResizeX1 = column_cache[i].X2;
column_cache[i].ResizeX2 = column_cache[i].ResizeX1 + 2;
column_cache[i].Index = i;
+
+ if (sortable != null) {
+ ColumnHeaderCellText column_cell = column_cache[i].Column.HeaderCell as ColumnHeaderCellText;
+ if (column_cell != null) {
+ ISortableColumn sort_column = column_cache[i].Column as ISortableColumn;
+ column_cell.HasSort = sort_column != null && sortable.SortColumn == sort_column;
+ if (column_cell.HasSort) {
+ sort_column_index = i;
+ }
+ }
+ }
}
}
@@ -209,10 +224,10 @@
return null;
}
- foreach (CachedColumn column in column_cache) {
- if (x >= column.ResizeX1 - 2 &&
- x <= column.ResizeX2 + 2) {
- return column.Column;
+ for (int i = 0; i < column_cache.Length - 1; i++) {
+ if (x >= column_cache[i].ResizeX1 - 2 &&
+ x <= column_cache[i].ResizeX2 + 2) {
+ return column_cache[i].Column;
}
}
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs Sun Mar 23 00:04:56 2008
@@ -342,6 +342,7 @@
if (column != null && Model is ISortable && column is ISortableColumn) {
((ISortable)Model).Sort ((ISortableColumn)column);
Model.Reload ();
+ RegenerateColumnCache ();
InvalidateHeader ();
}
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 Sun Mar 23 00:04:56 2008
@@ -60,8 +60,6 @@
private Pango.Layout header_pango_layout;
private Pango.Layout list_pango_layout;
- private int sort_column_index = -1;
-
private Theme theme;
protected Theme Theme {
get { return theme; }
@@ -117,8 +115,6 @@
header_pango_layout = PangoCairoHelper.CreateLayout (cairo_context);
Theme.DrawHeaderBackground (cairo_context, header_rendering_alloc);
- sort_column_index = -1;
-
Rectangle cell_area = new Rectangle ();
cell_area.Y = header_rendering_alloc.Y;
cell_area.Height = header_rendering_alloc.Height;
@@ -144,8 +140,6 @@
private void PaintHeaderCell (Rectangle area, Rectangle clip, int ci, bool dragging)
{
- ColumnCell cell = column_cache[ci].Column.HeaderCell;
-
if (dragging) {
Theme.DrawColumnHighlight (cairo_context, area,
CairoExtensions.ColorShade (Theme.Colors.GetWidgetColor (GtkColorClass.Dark, StateType.Normal), 0.9));
@@ -162,15 +156,7 @@
cairo_context.Stroke ();
}
- ColumnHeaderCellText column_cell = cell as ColumnHeaderCellText;
- ISortable sortable = Model as ISortable;
- if (column_cell != null && sortable != null) {
- ISortableColumn sort_column = column_cache[ci].Column as ISortableColumn;
- column_cell.HasSort = sort_column != null && sortable.SortColumn == sort_column;
- if (column_cell.HasSort) {
- sort_column_index = ci;
- }
- }
+ ColumnCell cell = column_cache[ci].Column.HeaderCell;
if (cell != null) {
cairo_context.Save ();
@@ -191,6 +177,7 @@
return;
}
+ // Render the sort effect to the GdkWindow.
if (sort_column_index != -1 && (!pressed_column_is_dragging || pressed_column_index != sort_column_index)) {
CachedColumn col = column_cache[sort_column_index];
Theme.DrawRowRule (cairo_context, list_rendering_alloc.X + col.X1, header_rendering_alloc.Bottom + Theme.BorderWidth,
@@ -224,6 +211,7 @@
// Render the background to the primary canvas.
Theme.DrawListBackground (cairo_context, canvas_alloc, true);
+ // Render the sort effect to the canvas.
if (sort_column_index != -1 && (!pressed_column_is_dragging || pressed_column_index != sort_column_index)) {
CachedColumn col = column_cache[sort_column_index];
Theme.DrawRowRule (cairo_context, col.X1, 0, col.Width, canvas_alloc.Height);
@@ -240,7 +228,7 @@
// render the new stuff in situ at the bottom.
int delta = (last_row - canvas_last_row) * RowHeight;
canvas1.DrawDrawable (Style.BaseGC (StateType.Normal), canvas2, 0, delta, 0, 0,
- list_rendering_alloc.Width, rows_in_view - delta);
+ list_rendering_alloc.Width, canvas_alloc.Height - delta);
// If the bottom of the stuff we're shifting up is part of a selection
// that continues down into the new stuff, be sure that we render the
@@ -256,7 +244,7 @@
// render the new stuff in situ at the top.
int delta = (canvas_first_row - first_row) * RowHeight;
canvas1.DrawDrawable (Style.BaseGC (StateType.Normal), canvas2, 0, 0, 0, delta,
- list_rendering_alloc.Width, rows_in_view - delta);
+ list_rendering_alloc.Width, canvas_alloc.Height - delta);
// If the top of the stuff we're shifting down is part of a selection
// that continues up into the new stuff, be sure that we render the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]