banshee r3519 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3519 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView
- Date: Sat, 22 Mar 2008 06:59:26 +0000 (GMT)
Author: scottp
Date: Sat Mar 22 06:59:26 2008
New Revision: 3519
URL: http://svn.gnome.org/viewvc/banshee?rev=3519&view=rev
Log:
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/Column.cs: Added MaxWidth
property (currently not used anywhere).
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs:
Began reworking the column layout code. Columns will now resize
themselves to take up the header width. No logic yet for min or max
column widths: that's tommorrow!
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Column.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Column.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Column.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/Column.cs Sat Mar 22 06:59:26 2008
@@ -41,7 +41,8 @@
private ColumnCell header_cell;
private List<ColumnCell> cells = new List<ColumnCell> ();
- private int minWidth = 0;
+ private int minWidth = 0;
+ private int maxWidth = Int32.MaxValue;
private double minRelativeWidth = 0;
private double relativeWidth = 0;
private bool isVisible = true;
@@ -114,6 +115,11 @@
{
get { return minRelativeWidth; }
set { minRelativeWidth = value; }
+ }
+
+ public int MaxWidth {
+ get { return maxWidth; }
+ set { maxWidth = value; }
}
public double RelativeWidth
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 Sat Mar 22 06:59:26 2008
@@ -42,6 +42,7 @@
public int X1;
public int X2;
public int Width;
+ public int MinWidth;
public int ResizeX1;
public int ResizeX2;
public int Index;
@@ -65,31 +66,16 @@
private void InvalidateColumnCache ()
{
- if (column_cache == null) {
- return;
- }
-
- for (int i = 0; i < column_cache.Length; i++) {
- column_cache[i] = CachedColumn.Zero;
- }
-
column_cache = null;
}
- private void RegenerateColumnCache ()
+ private void GenerateColumnCache ()
{
- if (!IsRealized) {
- return;
- }
-
- InvalidateColumnCache ();
-
- if (column_controller == null) {
- return;
- }
+ column_cache = new CachedColumn[column_controller.Count];
int i = 0;
- column_cache = new CachedColumn[column_controller.Count];
+ int min_header_width = 0;
+ double total = 0.0;
foreach (Column column in column_controller) {
if (!column.Visible) {
@@ -99,21 +85,50 @@
column_cache[i] = new CachedColumn ();
column_cache[i].Column = column;
- column_cache[i].Width = (int)Math.Round (((double)header_interaction_alloc.Width * column.Width));
+ // TODO can this be done in the constructor? Will the title change?
+ int w;
+ int h;
+ column_layout.SetText (column.Title);
+ column_layout.GetPixelSize (out w, out h);
+ // 10 is arbitrary. Should we have a good way of getting the arrow width?
+ min_header_width += column_cache[i].MinWidth = Math.Max (column.MinWidth, w + 10);
+
+ total += column.Width;
+ i++;
+ }
+
+ Array.Resize (ref column_cache, i);
+
+ double scale_factor = 1.0 / total;
+
+ for (i = 0; i < column_cache.Length; i++) {
+ column_cache[i].Column.Width *= scale_factor;
+ }
+ }
+
+ private void RegenerateColumnCache ()
+ {
+ if (!IsRealized || column_controller == null) {
+ return;
+ }
+
+ if (column_cache == null) {
+ GenerateColumnCache ();
+ }
+
+ 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;
column_cache[i].X2 = column_cache[i].X1 + column_cache[i].Width;
column_cache[i].ResizeX1 = column_cache[i].X2;
column_cache[i].ResizeX2 = column_cache[i].ResizeX1 + 2;
column_cache[i].Index = i;
-
- i++;
}
-
- Array.Resize (ref column_cache, i);
}
protected virtual void OnColumnControllerUpdated ()
{
+ InvalidateColumnCache ();
RegenerateColumnCache ();
InvalidateListView ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]