Browse Source

Merge branch 'master' into fixes/dont-create-virtualizer-before-panel

pull/1727/head
danwalmsley 8 years ago
committed by GitHub
parent
commit
b77050efe3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/Avalonia.Controls/Grid.cs
  2. 11
      src/Avalonia.Styling/Styling/Setter.cs

20
src/Avalonia.Controls/Grid.cs

@ -194,6 +194,16 @@ namespace Avalonia.Controls
/// </summary>
private GridLayout.MeasureResult _rowMeasureCache;
/// <summary>
/// Gets the row layout as of the last measure.
/// </summary>
private GridLayout _rowLayoutCache;
/// <summary>
/// Gets the column layout as of the last measure.
/// </summary>
private GridLayout _columnLayoutCache;
/// <summary>
/// Measures the grid.
/// </summary>
@ -253,6 +263,9 @@ namespace Avalonia.Controls
// Cache the measure result and return the desired size.
_columnMeasureCache = columnResult;
_rowMeasureCache = rowResult;
_rowLayoutCache = rowLayout;
_columnLayoutCache = columnLayout;
return new Size(columnResult.DesiredLength, rowResult.DesiredLength);
// Measure each child only once.
@ -299,13 +312,11 @@ namespace Avalonia.Controls
// arrow back to any statements and re-run them without any side-effect.
var (safeColumns, safeRows) = GetSafeColumnRows();
var columnLayout = new GridLayout(ColumnDefinitions);
var rowLayout = new GridLayout(RowDefinitions);
var columnLayout = _columnLayoutCache;
var rowLayout = _rowLayoutCache;
// Calculate for arrange result.
var columnResult = columnLayout.Arrange(finalSize.Width, _columnMeasureCache);
var rowResult = rowLayout.Arrange(finalSize.Height, _rowMeasureCache);
// Arrange the children.
foreach (var child in Children.OfType<Control>())
{
@ -315,7 +326,6 @@ namespace Avalonia.Controls
var y = Enumerable.Range(0, row).Sum(r => rowResult.LengthList[r]);
var width = Enumerable.Range(column, columnSpan).Sum(c => columnResult.LengthList[c]);
var height = Enumerable.Range(row, rowSpan).Sum(r => rowResult.LengthList[r]);
child.Arrange(new Rect(x, y, width, height));
}

11
src/Avalonia.Styling/Styling/Setter.cs

@ -158,18 +158,11 @@ namespace Avalonia.Styling
var activated = new ActivatedObservable(activator, sourceInstance.Observable, description);
return InstancedBinding.OneWay(activated, BindingPriority.StyleTrigger);
}
case BindingMode.OneWayToSource:
{
var activated = new ActivatedSubject(activator, sourceInstance.Subject, description);
return InstancedBinding.OneWayToSource(activated, BindingPriority.StyleTrigger);
}
case BindingMode.TwoWay:
default:
{
var activated = new ActivatedSubject(activator, sourceInstance.Subject, description);
return InstancedBinding.TwoWay(activated, BindingPriority.StyleTrigger);
return new InstancedBinding(activated, sourceInstance.Mode, BindingPriority.StyleTrigger);
}
default:
throw new NotSupportedException("Unsupported BindingMode.");
}
}

Loading…
Cancel
Save