banshee r3177 - in trunk/banshee: . src/Core/Hyena.Gui/Hyena.Data.Gui src/Core/Hyena.Gui/Hyena.Data.Gui/ListView
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3177 - in trunk/banshee: . src/Core/Hyena.Gui/Hyena.Data.Gui src/Core/Hyena.Gui/Hyena.Data.Gui/ListView
- Date: Sat, 9 Feb 2008 00:45:11 +0000 (GMT)
Author: abock
Date: Sat Feb 9 00:45:10 2008
New Revision: 3177
URL: http://svn.gnome.org/viewvc/banshee?rev=3177&view=rev
Log:
2008-02-08 Aaron Bockover <abock gnome org>
* src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs:
* src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
* src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
Implemented most of what is required for column reordering, but not
100% complete yet
* src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs: DrawColumnHighlight
now can have an override color
* src/Core/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs: Added Reorder
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ColumnController.cs Sat Feb 9 00:45:10 2008
@@ -100,6 +100,17 @@
OnUpdated ();
}
+ public void Reorder (int index, int newIndex)
+ {
+ lock (this) {
+ Column column = columns[index];
+ columns.RemoveAt (index);
+ columns.Insert (newIndex, column);
+ }
+
+ OnUpdated ();
+ }
+
IEnumerator IEnumerable.GetEnumerator ()
{
return columns.GetEnumerator ();
@@ -111,7 +122,7 @@
}
public Column this[int index] {
- get { return columns[index] as Column; }
+ get { return columns[index]; }
}
public int Count {
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs Sat Feb 9 00:45:10 2008
@@ -48,10 +48,16 @@
private const int COLUMN_PADDING = 1;
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 column_text_y;
private int column_text_height;
private int resizing_column_index = -1;
+ private int pressed_column_index = -1;
+ private int pressed_column_x_start = -1;
+ private int pressed_column_x_drag = -1;
+ private bool pressed_column_is_dragging = false;
+
private Pango.Layout column_layout;
private CachedColumn [] column_cache;
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs Sat Feb 9 00:45:10 2008
@@ -199,65 +199,78 @@
if (press.Window == header_window) {
Gtk.Drag.SourceUnset (this);
- Column column = GetColumnForResizeHandle ((int) press.X);
+
+ Column column = GetColumnForResizeHandle ((int)press.X);
if (column != null) {
resizing_column_index = GetCachedColumnForColumn (column).Index;
- }
- } else if (press.Window == list_window && model != null) {
- GrabFocus ();
-
- int row_index = GetRowAtY ((int) press.Y);
-
- if (press.Button == 1 && (press.State & Gdk.ModifierType.ControlMask) == 0 &&
- Selection.Contains (row_index)) {
- return true;
+ } else {
+ column = GetColumnAt ((int)press.X);
+ if (column != null) {
+ pressed_column_index = GetCachedColumnForColumn (column).Index;
+ pressed_column_x_start = (int)press.X;
+ }
}
- object item = model[row_index];
- if (item == null) {
- return true;
- }
+ return true;
+ }
+
+ if (press.Window != list_window || model == null) {
+ return true;
+ }
+
+ GrabFocus ();
+
+ int row_index = GetRowAtY ((int) press.Y);
+
+ if (press.Button == 1 && (press.State & Gdk.ModifierType.ControlMask) == 0 &&
+ Selection.Contains (row_index)) {
+ return true;
+ }
+
+ object item = model[row_index];
+ if (item == null) {
+ return true;
+ }
- if (press.Button == 1 && press.Type == Gdk.EventType.TwoButtonPress &&
- row_index == last_click_row_index) {
- OnRowActivated ();
- last_click_row_index = -1;
- } else {
- if ((press.State & Gdk.ModifierType.ControlMask) != 0) {
- if (press.Button == 3) {
- if (!Selection.Contains (row_index)) {
- Selection.Select (row_index);
- }
- } else {
- Selection.ToggleSelect(row_index);
+ if (press.Button == 1 && press.Type == Gdk.EventType.TwoButtonPress &&
+ row_index == last_click_row_index) {
+ OnRowActivated ();
+ last_click_row_index = -1;
+ } else {
+ if ((press.State & Gdk.ModifierType.ControlMask) != 0) {
+ if (press.Button == 3) {
+ if (!Selection.Contains (row_index)) {
+ Selection.Select (row_index);
}
- } else if ((press.State & Gdk.ModifierType.ShiftMask) != 0) {
- Selection.SelectFromFirst (row_index, true);
} else {
- if (press.Button == 3) {
- if (!Selection.Contains (row_index)) {
- Selection.Clear (false);
- Selection.Select (row_index);
- }
- } else {
+ Selection.ToggleSelect(row_index);
+ }
+ } else if ((press.State & Gdk.ModifierType.ShiftMask) != 0) {
+ Selection.SelectFromFirst (row_index, true);
+ } else {
+ if (press.Button == 3) {
+ if (!Selection.Contains (row_index)) {
Selection.Clear (false);
Selection.Select (row_index);
}
+ } else {
+ Selection.Clear (false);
+ Selection.Select (row_index);
}
+ }
- FocusRow (row_index);
+ FocusRow (row_index);
- if (press.Button == 3) {
- last_click_row_index = -1;
- OnPopupMenu ();
- } else {
- last_click_row_index = row_index;
- }
+ if (press.Button == 3) {
+ last_click_row_index = -1;
+ OnPopupMenu ();
+ } else {
+ last_click_row_index = row_index;
}
-
- InvalidateListWindow ();
}
+ InvalidateListWindow ();
+
return true;
}
@@ -267,17 +280,29 @@
OnDragSourceSet ();
if (resizing_column_index >= 0) {
+ pressed_column_index = -1;
resizing_column_index = -1;
header_window.Cursor = null;
return true;
}
+
+ if (pressed_column_index >= 0 && pressed_column_is_dragging) {
+ pressed_column_is_dragging = false;
+ pressed_column_index = -1;
+ header_window.Cursor = null;
+ InvalidateHeaderWindow ();
+ InvalidateListWindow ();
+ return true;
+ }
- Column column = GetColumnAt ((int)evnt.X);
+ Column column = column_cache[pressed_column_index].Column;
if (column != null && Model is ISortable && column is ISortableColumn) {
((ISortable)Model).Sort ((ISortableColumn)column);
Model.Reload ();
InvalidateHeaderWindow ();
}
+
+ pressed_column_index = -1;
} else if (evnt.Window == list_window && model != null &&
(evnt.State & (Gdk.ModifierType.ShiftMask | Gdk.ModifierType.ControlMask)) == 0) {
GrabFocus ();
@@ -302,10 +327,26 @@
protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt)
{
if (evnt.Window == header_window) {
+ if (pressed_column_index >= 0 && !pressed_column_is_dragging &&
+ Gtk.Drag.CheckThreshold (this, pressed_column_x_start, 0, (int)evnt.X, 0)) {
+ pressed_column_is_dragging = true;
+ InvalidateHeaderWindow ();
+ InvalidateListWindow ();
+ }
+
+ if (pressed_column_is_dragging) {
+ header_window.Cursor = drag_cursor;
+ pressed_column_x_drag = (int)evnt.X - pressed_column_x_start +
+ column_cache[pressed_column_index].X1;
+ InvalidateHeaderWindow ();
+ InvalidateListWindow ();
+ return true;
+ }
+
header_window.Cursor = resizing_column_index >= 0 || GetColumnForResizeHandle ((int)evnt.X) != null
? resize_x_cursor
: null;
-
+
if (resizing_column_index >= 0) {
ResizeColumn (evnt.X);
}
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs Sat Feb 9 00:45:10 2008
@@ -115,33 +115,71 @@
cell_area.Y = column_text_y;
cell_area.Height = HeaderHeight - column_text_y;
- for (int ci = 0; ci < column_cache.Length; ci++) {
- cell_area.X = column_cache[ci].X1 + left_border_alloc.Width;
- cell_area.Width = column_cache[ci].Width - COLUMN_PADDING;
-
- ColumnCell cell = column_cache[ci].Column.HeaderCell;
-
- if (cell is ColumnHeaderCellText && Model is ISortable) {
- bool has_sort = ((ISortable)Model).SortColumn == column_cache[ci].Column as ISortableColumn
- && column_cache[ci].Column is ISortableColumn;
- ((ColumnHeaderCellText)cell).HasSort = has_sort;
- if (has_sort) {
- graphics.DrawColumnHighlight (header_cr, cell_area, 3);
- }
- }
-
- if (cell != null) {
- header_cr.Save ();
- header_cr.Translate (cell_area.X, cell_area.Y);
- cell.Render (new CellContext (header_cr, header_pango_layout, this, header_window,
- graphics, cell_area), StateType.Normal, cell_area.Width, cell_area.Height);
- header_cr.Restore ();
+ for (int ci = 0; ci < column_cache.Length; ci++) {
+ if (pressed_column_is_dragging && pressed_column_index == ci) {
+ continue;
}
+ cell_area.X = column_cache[ci].X1 + left_border_alloc.Width;
+ cell_area.Width = column_cache[ci].Width - COLUMN_PADDING;
+ PaintHeaderCell (cell_area, clip, ci, false);
+ }
+
+ if (pressed_column_is_dragging && pressed_column_index >= 0) {
+ cell_area.X = pressed_column_x_drag + left_border_alloc.Width;
+ cell_area.Width = column_cache[pressed_column_index].Width - COLUMN_PADDING;
+ PaintHeaderCell (cell_area, clip, pressed_column_index, true);
+ }
+ }
+
+ private void PaintHeaderCell (Gdk.Rectangle area, Gdk.Rectangle clip, int ci, bool dragging)
+ {
+ ColumnCell cell = column_cache[ci].Column.HeaderCell;
+
+ if (dragging) {
if (ci < column_cache.Length - 1) {
graphics.DrawHeaderSeparator (header_cr, header_alloc,
column_cache[ci].ResizeX1 - 1 + left_border_alloc.Width, 2);
}
+
+ graphics.DrawColumnHighlight (header_cr, area, 3,
+ CairoExtensions.ColorShade (graphics.GetWidgetColor (GtkColorClass.Dark, StateType.Normal), 0.9));
+
+ Cairo.Color stroke_color = CairoExtensions.ColorShade (graphics.GetWidgetColor (
+ GtkColorClass.Base, StateType.Normal), 0.0);
+ stroke_color.A = 0.5;
+
+ header_cr.Color = stroke_color;
+
+ header_cr.MoveTo (area.X - 1, area.Y + 1);
+ header_cr.LineTo (area.X - 1, area.Y + area.Height - 1);
+ header_cr.Stroke ();
+
+ header_cr.MoveTo (area.X + area.Width, area.Y + 1);
+ header_cr.LineTo (area.X + area.Width, area.Y + area.Height - 1);
+ header_cr.Stroke ();
+ }
+
+ if (cell is ColumnHeaderCellText && Model is ISortable) {
+ bool has_sort = ((ISortable)Model).SortColumn == column_cache[ci].Column as ISortableColumn
+ && column_cache[ci].Column is ISortableColumn;
+ ((ColumnHeaderCellText)cell).HasSort = has_sort;
+ if (has_sort) {
+ graphics.DrawColumnHighlight (header_cr, area, 3);
+ }
+ }
+
+ if (cell != null) {
+ header_cr.Save ();
+ header_cr.Translate (area.X, area.Y);
+ cell.Render (new CellContext (header_cr, header_pango_layout, this, header_window,
+ graphics, area), StateType.Normal, area.Width, area.Height);
+ header_cr.Restore ();
+ }
+
+ if (!dragging && ci < column_cache.Length - 1) {
+ graphics.DrawHeaderSeparator (header_cr, header_alloc,
+ column_cache[ci].ResizeX1 - 1 + left_border_alloc.Width, 2);
}
}
@@ -228,6 +266,8 @@
single_list_alloc.Y = ri * single_list_alloc.Height - vadjustment_value;
PaintRow (ri, clip, single_list_alloc, StateType.Selected);
}
+
+ PaintDraggingColumn (evnt, clip);
}
private void PaintRow (int row_index, Gdk.Rectangle clip, Gdk.Rectangle area, StateType state)
@@ -241,28 +281,77 @@
Gdk.Rectangle cell_area = new Gdk.Rectangle ();
cell_area.Height = RowHeight;
cell_area.Y = area.Y;
-
+
for (int ci = 0; ci < column_cache.Length; ci++) {
+ if (pressed_column_is_dragging && pressed_column_index == ci) {
+ continue;
+ }
+
cell_area.Width = column_cache[ci].Width;
cell_area.X = column_cache[ci].X1;
-
- PaintCell (item, ci, row_index, cell_area, cell_area, state);
+ PaintCell (item, ci, row_index, cell_area, cell_area, state, false);
+ }
+
+ if (pressed_column_is_dragging && pressed_column_index >= 0) {
+ cell_area.Width = column_cache[pressed_column_index].Width;
+ cell_area.X = pressed_column_x_drag;
+ PaintCell (item, pressed_column_index, row_index, cell_area, cell_area, state, true);
}
}
private void PaintCell (object item, int column_index, int row_index, Gdk.Rectangle area,
- Gdk.Rectangle clip, StateType state)
+ Gdk.Rectangle clip, StateType state, bool dragging)
{
ColumnCell cell = column_cache[column_index].Column.GetCell (0);
cell.BindListItem (item);
+ if (dragging) {
+ Cairo.Color fill_color = graphics.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
+ fill_color.A = 0.5;
+ list_cr.Color = fill_color;
+ list_cr.Rectangle (area.X, area.Y, area.Width, area.Height);
+ list_cr.Fill ();
+ }
+
list_cr.Save ();
list_cr.Translate (clip.X, clip.Y);
cell.Render (new CellContext (list_cr, list_pango_layout, this, list_window, graphics, area),
- state, area.Width, area.Height);
+ dragging? StateType.Normal : state, area.Width, area.Height);
list_cr.Restore ();
}
+ private void PaintDraggingColumn (Gdk.EventExpose evnt, Gdk.Rectangle clip)
+ {
+ if (!pressed_column_is_dragging || pressed_column_index < 0) {
+ return;
+ }
+
+ CachedColumn column = column_cache[pressed_column_index];
+
+ int x = pressed_column_x_drag;
+
+ Cairo.Color fill_color = graphics.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
+ fill_color.A = 0.6;
+
+ Cairo.Color stroke_color = CairoExtensions.ColorShade (graphics.GetWidgetColor (
+ GtkColorClass.Base, StateType.Normal), 0.0);
+ stroke_color.A = 0.4;
+
+ list_cr.Rectangle (x, list_alloc.Y, column.Width, list_alloc.Height);
+ list_cr.Color = fill_color;
+ list_cr.Fill ();
+
+ list_cr.MoveTo (x, list_alloc.Y);
+ list_cr.LineTo (x, list_alloc.Y + list_alloc.Height);
+ list_cr.MoveTo (x + column.Width, list_alloc.Y);
+ list_cr.LineTo (x + column.Width, list_alloc.Y + list_alloc.Height);
+
+ list_cr.Color = stroke_color;
+ list_cr.Antialias = Cairo.Antialias.None;
+ list_cr.LineWidth = 1.0;
+ list_cr.Stroke ();
+ }
+
private void PaintLeftBorder (Gdk.EventExpose evnt, Gdk.Rectangle clip)
{
graphics.DrawLeftBorder (left_border_cr, left_border_alloc);
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs Sat Feb 9 00:45:10 2008
@@ -222,9 +222,13 @@
public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset)
{
- Cairo.Color gtk_selection_color = GetWidgetColor(GtkColorClass.Background, StateType.Selected);
- Cairo.Color light_color = CairoExtensions.ColorShade(gtk_selection_color, 1.6);
- Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_selection_color, 1.3);
+ DrawColumnHighlight(cr, alloc, bottom_offset, GetWidgetColor(GtkColorClass.Background, StateType.Selected));
+ }
+
+ public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset, Cairo.Color color)
+ {
+ Cairo.Color light_color = CairoExtensions.ColorShade(color, 1.6);
+ Cairo.Color dark_color = CairoExtensions.ColorShade(color, 1.3);
LinearGradient grad = new LinearGradient(alloc.X, alloc.Y + 2, alloc.X, alloc.Y + alloc.Height - 3 - bottom_offset);
grad.AddColorStop(0, light_color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]