Browse Source

Part 9 of n

pull/2563/head
Jumar Macato 7 years ago
parent
commit
efdcd11952
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 1
      src/Avalonia.Controls/DefinitionBase.cs
  2. 27
      src/Avalonia.Controls/GridWPF.cs

1
src/Avalonia.Controls/DefinitionBase.cs

@ -21,6 +21,7 @@ namespace Avalonia.Controls
static DefinitionBase() static DefinitionBase()
{ {
SharedSizeGroupProperty.Changed.AddClassHandler<DefinitionBase>(OnSharedSizeGroupPropertyChanged); SharedSizeGroupProperty.Changed.AddClassHandler<DefinitionBase>(OnSharedSizeGroupPropertyChanged);
BoundsProperty.Changed.AddClassHandler<DefinitionBase>(OnUserSizePropertyChanged);
} }
/// <summary> /// <summary>

27
src/Avalonia.Controls/GridWPF.cs

@ -80,11 +80,10 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public bool ShowGridLines public bool ShowGridLines
{ {
get { return (CheckFlagsAnd(Flags.ShowGridLinesPropertyValue)); } get { return GetValue(ShowGridLinesProperty); }
set { SetValue(ShowGridLinesProperty, value); } set { SetValue(ShowGridLinesProperty, value); }
} }
/// <summary> /// <summary>
/// Gets the value of the Column attached property for a control. /// Gets the value of the Column attached property for a control.
/// </summary> /// </summary>
@ -186,7 +185,6 @@ namespace Avalonia.Controls
{ {
get get
{ {
if (_data == null) { _data = new ExtendedData(); }
if (_columnDefinitions == null) if (_columnDefinitions == null)
{ {
@ -204,6 +202,9 @@ namespace Avalonia.Controls
throw new NotSupportedException("Reassigning ColumnDefinitions not yet implemented."); throw new NotSupportedException("Reassigning ColumnDefinitions not yet implemented.");
} }
if (_data == null) { _data = new ExtendedData(); }
_columnDefinitions = value; _columnDefinitions = value;
_columnDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure()); _columnDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure());
_columnDefinitions.CollectionChanged += (_, __) => InvalidateMeasure(); _columnDefinitions.CollectionChanged += (_, __) => InvalidateMeasure();
@ -217,8 +218,6 @@ namespace Avalonia.Controls
{ {
get get
{ {
if (_data == null) { _data = new ExtendedData(); }
if (_rowDefinitions == null) if (_rowDefinitions == null)
{ {
RowDefinitions = new RowDefinitions(); RowDefinitions = new RowDefinitions();
@ -234,12 +233,17 @@ namespace Avalonia.Controls
throw new NotSupportedException("Reassigning RowDefinitions not yet implemented."); throw new NotSupportedException("Reassigning RowDefinitions not yet implemented.");
} }
if (_data == null) { _data = new ExtendedData(); }
_rowDefinitions = value; _rowDefinitions = value;
_rowDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure()); _rowDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure());
_rowDefinitions.CollectionChanged += (_, __) => InvalidateMeasure(); _rowDefinitions.CollectionChanged += (_, __) => InvalidateMeasure();
} }
} }
private bool rowColDefsEmpty => (RowDefinitions == null || RowDefinitions?.Count == 0 ) &&
(ColumnDefinitions == null || ColumnDefinitions?.Count == 0);
/// <summary> /// <summary>
/// Content measurement. /// Content measurement.
/// </summary> /// </summary>
@ -255,7 +259,7 @@ namespace Avalonia.Controls
ListenToNotifications = true; ListenToNotifications = true;
MeasureOverrideInProgress = true; MeasureOverrideInProgress = true;
if (extData == null) if (rowColDefsEmpty)
{ {
gridDesiredSize = new Size(); gridDesiredSize = new Size();
@ -400,7 +404,7 @@ namespace Avalonia.Controls
ArrangeOverrideInProgress = true; ArrangeOverrideInProgress = true;
if (_data == null) if (rowColDefsEmpty)
{ {
for (int i = 0, count = Children.Count; i < count; ++i) for (int i = 0, count = Children.Count; i < count; ++i)
{ {
@ -603,7 +607,7 @@ namespace Avalonia.Controls
// clamp to not exceed beyond bottom side of the grid // clamp to not exceed beyond bottom side of the grid
// row_span > 0 is guaranteed by property value validation callback // row_span > 0 is guaranteed by property value validation callback
cell.RowSpan = Math.Min(GetRowSpan(child), DefinitionsV.Length - cell.RowIndex); cell.RowSpan = Math.Min(GetRowSpan(child), DefinitionsV.Length - cell.RowIndex);
Debug.Assert(0 <= cell.ColumnIndex && cell.ColumnIndex < DefinitionsU.Length); Debug.Assert(0 <= cell.ColumnIndex && cell.ColumnIndex < DefinitionsU.Length);
Debug.Assert(0 <= cell.RowIndex && cell.RowIndex < DefinitionsV.Length); Debug.Assert(0 <= cell.RowIndex && cell.RowIndex < DefinitionsV.Length);
@ -2275,8 +2279,6 @@ namespace Avalonia.Controls
{ {
grid.InvalidateVisual(); grid.InvalidateVisual();
} }
grid.SetFlags((bool)e.NewValue, Flags.ShowGridLinesPropertyValue);
} }
private static void OnCellAttachedPropertyChanged(Visual child, AvaloniaPropertyChangedEventArgs e) private static void OnCellAttachedPropertyChanged(Visual child, AvaloniaPropertyChangedEventArgs e)
@ -2590,11 +2592,6 @@ namespace Avalonia.Controls
ValidDefinitionsVStructure = 0x00000002, ValidDefinitionsVStructure = 0x00000002,
ValidCellsStructure = 0x00000004, ValidCellsStructure = 0x00000004,
//
// boolean properties state
//
ShowGridLinesPropertyValue = 0x00000100, // show grid lines ?
// //
// boolean flags // boolean flags
// //

Loading…
Cancel
Save