Skip to content

Commit

Permalink
Add GridColumn.DisplayIndex and Grid.ColumnOrderChanged
Browse files Browse the repository at this point in the history
Gtk: Improve performance of TreeGridView drastically.
Mac: Fix alignment of some controls on CustomCell
Updated GridViewSection to allow saving/restoring
Fixes picoe#1868
  • Loading branch information
cwensley committed Mar 14, 2022
1 parent 29c211e commit 97c49d2
Show file tree
Hide file tree
Showing 33 changed files with 981 additions and 554 deletions.
36 changes: 24 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
// "targetArchitecture": "x86_64", // uncomment to test intel on M1
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.Mac64 - mono",
Expand All @@ -22,7 +23,8 @@
"passDebugOptionsViaEnvironmentVariable": true,
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.XamMac2",
Expand All @@ -32,7 +34,8 @@
"program": "${workspaceFolder}/artifacts/test/${config:var.configuration}/net6.0-macos/Eto.Test.XamMac2.app/Contents/MacOS/Eto.Test.XamMac2",
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.XamMac2 - mono",
Expand All @@ -44,7 +47,8 @@
"passDebugOptionsViaEnvironmentVariable": true,
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.Gtk",
Expand All @@ -60,7 +64,8 @@
},
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false,
},
{
"name": "Eto.Test.Gtk - mono",
Expand All @@ -76,7 +81,8 @@
}
},
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.Gtk2",
Expand All @@ -87,7 +93,8 @@
"passDebugOptionsViaEnvironmentVariable": true,
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.Wpf",
Expand All @@ -98,7 +105,8 @@
"targetArchitecture": "x86_64",
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.Wpf - .NET 4.8",
Expand All @@ -108,7 +116,8 @@
"program": "${workspaceFolder}/artifacts/test/${config:var.configuration}/net48/Eto.Test.Wpf.exe",
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.WinForms",
Expand All @@ -118,7 +127,8 @@
"program": "${workspaceFolder}/artifacts/test/${config:var.configuration}/net6.0-windows/Eto.Test.WinForms.exe",
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.WinForms - .NET 4.8",
Expand All @@ -128,7 +138,8 @@
"program": "${workspaceFolder}/artifacts/test/${config:var.configuration}/net48/Eto.Test.WinForms.exe",
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Test.Direct2D",
Expand All @@ -138,7 +149,8 @@
"program": "${workspaceFolder}/artifacts/test/${config:var.configuration}/net6.0-windows/Eto.Test.Direct2D.exe",
"args": [],
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"justMyCode": false
},
{
"name": "Eto.Addin.VisualStudio.Mac",
Expand Down
2 changes: 1 addition & 1 deletion lib/monomac
4 changes: 2 additions & 2 deletions src/Eto.Gtk/Forms/Cells/CellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace Eto.GtkSharp.Forms.Cells
{
public interface ICellDataSource
{
object GetItem(int row);

object GetItem(Gtk.TreePath path);

void EndCellEditing(Gtk.TreePath path, int column);
Expand All @@ -22,6 +20,7 @@ public interface ICellDataSource
void OnCellFormatting(GridCellFormatEventArgs args);

int RowDataColumn { get; }
int ItemDataColumn { get; }
}

public interface IEtoCellRenderer
Expand Down Expand Up @@ -102,6 +101,7 @@ protected virtual void BindCell(ref int dataIndex)
//if (FormattingEnabled)
{
Column.Control.AddAttribute(Control, "row", Source.RowDataColumn);
Column.Control.AddAttribute(Control, "item", Source.ItemDataColumn);
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/Eto.Gtk/Forms/Cells/CheckBoxCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ public int Row
get { return row; }
set {
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set {
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/Eto.Gtk/Forms/Cells/ComboBoxCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ public int Row
get { return row; }
set {
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkTextCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}


#if GTK2
public override void GetSize(Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
Expand Down
21 changes: 16 additions & 5 deletions src/Eto.Gtk/Forms/Cells/CustomCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,25 @@ public int Row
set
{
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}

IGtkCellEditable CreateEditable(Gdk.Rectangle cellArea)
{
var item = Handler.Source.GetItem(Row);
var item = Item;
int column = -1;
var args = new CellEventArgs(null, Handler.Widget, Row, column, item, CellStates.Editing, null);

Expand Down Expand Up @@ -149,7 +160,7 @@ protected override void Render(Gdk.Drawable window, Gtk.Widget widget, Gdk.Recta
}
using (var graphics = new Graphics(new GraphicsHandler(widget, window)))
{
var item = h.Source.GetItem(Row);
var item = Item;
var args = new CellPaintEventArgs(graphics, cell_area.ToEto(), flags.ToEto(), item);
h.Callback.OnPaint(h.Widget, args);
}
Expand All @@ -170,7 +181,7 @@ protected override void OnGetPreferredWidth(Gtk.Widget widget, out int minimum_s
var h = Handler;
if (h == null)
return;
var item = h.Source?.GetItem(Row);
var item = Item;
int column = -1;
var args = new CellEventArgs(null, h.Widget, Row, column, item, CellStates.Editing, null);

Expand Down Expand Up @@ -215,7 +226,7 @@ protected override unsafe void OnRender(Cairo.Context cr, Gtk.Widget widget, Gdk
}
using (var graphics = new Graphics(new GraphicsHandler(widget, cr)))
{
var item = Handler.Source.GetItem(Row);
var item = Item;
var args = new CellPaintEventArgs(graphics, cell_area.ToEto(), flags.ToEto(), item);
Handler.Callback.OnPaint(Handler.Widget, args);
}
Expand Down
17 changes: 14 additions & 3 deletions src/Eto.Gtk/Forms/Cells/DrawableCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ public int Row
get { return row; }
set {
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}

Expand All @@ -36,7 +47,7 @@ protected override void Render(Gdk.Drawable window, Gtk.Widget widget, Gdk.Recta
{
using (var graphics = new Graphics(new GraphicsHandler(widget, window)))
{
var item = Handler.Source.GetItem(Row);
var item = Item;
#pragma warning disable 618
var args = new DrawableCellPaintEventArgs(graphics, cell_area.ToEto(), flags.ToEto(), item);
Handler.Callback.OnPaint(Handler.Widget, args);
Expand All @@ -54,7 +65,7 @@ protected override void OnRender (Cairo.Context cr, Gtk.Widget widget, Gdk.Recta
{
using (var graphics = new Graphics(new GraphicsHandler(cr, null, false)))
{
var item = Handler.Source.GetItem(Row);
var item = Item;
#pragma warning disable 618
var args = new DrawableCellPaintEventArgs(graphics, cell_area.ToEto(), flags.ToEto(), item);
Handler.Callback.OnPaint(Handler.Widget, args);
Expand Down
16 changes: 13 additions & 3 deletions src/Eto.Gtk/Forms/Cells/ImageTextCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class ImageRenderer : Gtk.CellRendererPixbuf
{
public ImageTextCellHandler Handler { get; set; }

[GLib.Property("item")]
public object Item { get; set; }

int row;
[GLib.Property("row")]
Expand All @@ -25,8 +23,19 @@ public int Row
get { return row; }
set {
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkGridCellFormatEventArgs<ImageRenderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<ImageRenderer>(this, Handler.Column.Widget, item, Row));
}
}
}
Expand Down Expand Up @@ -108,6 +117,7 @@ protected override void BindCell(ref int dataIndex)
if (FormattingEnabled)
{
Column.Control.AddAttribute(imageCell, "row", Source.RowDataColumn);
Column.Control.AddAttribute(imageCell, "item", Source.ItemDataColumn);
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/Eto.Gtk/Forms/Cells/ImageViewCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ public int Row
get { return row; }
set {
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/Eto.Gtk/Forms/Cells/ProgressCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@ public int Row
get { return row; }
set {
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}


#if GTK2
public override void GetSize(Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
Expand Down
13 changes: 12 additions & 1 deletion src/Eto.Gtk/Forms/Cells/TextBoxCellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ public int Row
set
{
row = value;
}
}

object item;
[GLib.Property("item")]
public object Item
{
get { return item; }
set
{
item = value;
if (Handler.FormattingEnabled)
Handler.Format(new GtkTextCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, Handler.Source.GetItem(Row), Row));
Handler.Format(new GtkGridCellFormatEventArgs<Renderer>(this, Handler.Column.Widget, item, Row));
}
}

Expand Down
Loading

0 comments on commit 97c49d2

Please sign in to comment.