[hyena] [Hyena.Data.Gui] Add Fill property to Grid
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] [Hyena.Data.Gui] Add Fill property to Grid
- Date: Wed, 24 Nov 2010 03:32:02 +0000 (UTC)
commit d879ef99f80827cfd5cb6f0e38fd48149941a273
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Nov 23 21:31:13 2010 -0600
[Hyena.Data.Gui] Add Fill property to Grid
It will make the children evenly fill the grid's width instead of just
spacing them out evenly across it.
Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs b/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
index ef4b14d..6a310c0 100644
--- a/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
+++ b/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
@@ -38,6 +38,8 @@ namespace Hyena.Data.Gui
public int Rows { get; private set; }
public int Columns { get; private set; }
+ public bool Fill { get; set; }
+
public Func<CanvasItem> ChildAllocator { get; set; }
public event EventHandler<EventArgs<int>> ChildCountChanged;
@@ -96,12 +98,14 @@ namespace Hyena.Data.Gui
int view_row_index = 0;
int view_column_index = 0;
+ int flex_width = Fill ? 0 : (int)Math.Floor (Math.Max (0, child_span_width - ChildSize.Width) / (Columns + 1));
+
// Allocation of the first child in the layout, this
// will change as we iterate the layout children
var child_allocation = new Rect () {
- X = ActualAllocation.X,
+ X = ActualAllocation.X + flex_width,
Y = offset,
- Width = ChildSize.Width,
+ Width = Fill ? child_span_width : ChildSize.Width,
Height = ChildSize.Height
};
@@ -127,7 +131,7 @@ namespace Hyena.Data.Gui
view_column_index = 0;
child_allocation.Y += ChildSize.Height;
- child_allocation.X = ActualAllocation.X;
+ child_allocation.X = ActualAllocation.X + flex_width;
} else {
child_allocation.X += child_span_width;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]