diff --git a/src/Avalonia.Controls/ColumnDefinition.cs b/src/Avalonia.Controls/ColumnDefinition.cs index 8c9f6323a9..015484dbcc 100644 --- a/src/Avalonia.Controls/ColumnDefinition.cs +++ b/src/Avalonia.Controls/ColumnDefinition.cs @@ -29,7 +29,7 @@ namespace Avalonia.Controls /// /// Initializes a new instance of the class. /// - public ColumnDefinition() : base(true) + public ColumnDefinition() { } @@ -38,7 +38,7 @@ namespace Avalonia.Controls /// /// The width of the column. /// The width unit of the column. - public ColumnDefinition(double value, GridUnitType type): base(true) + public ColumnDefinition(double value, GridUnitType type) { Width = new GridLength(value, type); } @@ -47,7 +47,7 @@ namespace Avalonia.Controls /// Initializes a new instance of the class. /// /// The width of the column. - public ColumnDefinition(GridLength width): base(true) + public ColumnDefinition(GridLength width) { Width = width; } @@ -87,5 +87,11 @@ namespace Avalonia.Controls get { return GetValue(WidthProperty); } set { SetValue(WidthProperty, value); } } + + internal override GridLength UserSizeValueCache => this.Width; + + internal override double UserMinSizeValueCache => this.MinWidth; + + internal override double UserMaxSizeValueCache => this.MaxWidth; } } diff --git a/src/Avalonia.Controls/DefinitionBase.cs b/src/Avalonia.Controls/DefinitionBase.cs index f9a7fc648d..643d9da751 100644 --- a/src/Avalonia.Controls/DefinitionBase.cs +++ b/src/Avalonia.Controls/DefinitionBase.cs @@ -13,7 +13,7 @@ namespace Avalonia.Controls /// /// Base class for and . /// - public class DefinitionBase : ContentControl + public abstract class DefinitionBase : ContentControl { /// /// Static ctor. Used for static registration of properties. @@ -21,8 +21,9 @@ namespace Avalonia.Controls static DefinitionBase() { SharedSizeGroupProperty.Changed.AddClassHandler(OnSharedSizeGroupPropertyChanged); - BoundsProperty.Changed.AddClassHandler(OnUserSizePropertyChanged); + // BoundsProperty.Changed.AddClassHandler(OnUserSizePropertyChanged); } + /// /// Defines the property. @@ -38,63 +39,6 @@ namespace Avalonia.Controls get { return GetValue(SharedSizeGroupProperty); } set { SetValue(SharedSizeGroupProperty, value); } } - //------------------------------------------------------ - // - // Constructors - // - //------------------------------------------------------ - - - internal DefinitionBase(bool isColumnDefinition) - { - _isColumnDefinition = isColumnDefinition; - _parentIndex = -1; - } - - - - //------------------------------------------------------ - // - // Internal Methods - // - //------------------------------------------------------ - - #region Internal Methods - - /// - /// Callback to notify about entering model tree. - /// - internal void OnEnterParentTree() - { - // if (_sharedState == null) - // { - // // start with getting SharedSizeGroup value. - // // this property is NOT inhereted which should result in better overall perf. - // string sharedSizeGroupId = SharedSizeGroup; - // if (sharedSizeGroupId != null) - // { - // SharedSizeScope privateSharedSizeScope = PrivateSharedSizeScope; - // if (privateSharedSizeScope != null) - // { - // _sharedState = privateSharedSizeScope.EnsureSharedState(sharedSizeGroupId); - // _sharedState.AddMember(this); - // } - // } - // } - } - - /// - /// Callback to notify about exitting model tree. - /// - internal void OnExitParentTree() - { - _offset = 0; - if (_sharedState != null) - { - _sharedState.RemoveMember(this); - _sharedState = null; - } - } /// /// Performs action preparing definition to enter layout calculation mode. @@ -109,161 +53,6 @@ namespace Avalonia.Controls if (_sharedState != null) { _sharedState.EnsureDeferredValidation(grid); } } - /// - /// Updates min size. - /// - /// New size. - internal void UpdateMinSize(double minSize) - { - _minSize = Math.Max(_minSize, minSize); - } - - /// - /// Sets min size. - /// - /// New size. - internal void SetMinSize(double minSize) - { - _minSize = minSize; - } - - /// - /// - /// - /// - /// This method needs to be internal to be accessable from derived classes. - /// - internal static void OnUserSizePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e) - { - DefinitionBase definition = (DefinitionBase)d; - - if (definition.InParentLogicalTree) - { - if (definition._sharedState != null) - { - definition._sharedState.Invalidate(); - } - else - { - Grid parentGrid = (Grid)definition.Parent; - - if (((GridLength)e.OldValue).GridUnitType != ((GridLength)e.NewValue).GridUnitType) - { - parentGrid.Invalidate(); - } - else - { - parentGrid.InvalidateMeasure(); - } - } - } - } - - /// - /// - /// - /// - /// This method needs to be internal to be accessable from derived classes. - /// - internal static bool IsUserSizePropertyValueValid(object value) - { - return (((GridLength)value).Value >= 0); - } - - /// - /// - /// - /// - /// This method needs to be internal to be accessable from derived classes. - /// - internal static void OnUserMinSizePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e) - { - DefinitionBase definition = (DefinitionBase)d; - - if (definition.InParentLogicalTree) - { - Grid parentGrid = (Grid)definition.Parent; - parentGrid.InvalidateMeasure(); - } - } - - /// - /// - /// - /// - /// This method needs to be internal to be accessable from derived classes. - /// - internal static bool IsUserMinSizePropertyValueValid(object value) - { - double v = (double)value; - return (!Double.IsNaN(v) && v >= 0.0d && !Double.IsPositiveInfinity(v)); - } - - /// - /// - /// - /// - /// This method needs to be internal to be accessable from derived classes. - /// - internal static void OnUserMaxSizePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e) - { - DefinitionBase definition = (DefinitionBase)d; - - if (definition.InParentLogicalTree) - { - Grid parentGrid = (Grid)definition.Parent; - parentGrid.InvalidateMeasure(); - } - } - - /// - /// - /// - /// - /// This method needs to be internal to be accessable from derived classes. - /// - internal static bool IsUserMaxSizePropertyValueValid(object value) - { - double v = (double)value; - return (!Double.IsNaN(v) && v >= 0.0d); - } - - /// - /// - /// - /// - /// This method reflects Grid.SharedScopeProperty state by setting / clearing - /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty - /// is a collection of SharedSizeState objects for the scope. - /// Also PrivateSharedSizeScopeProperty is FrameworkPropertyMetadataOptions.Inherits property. So that all children - /// elements belonging to a certain scope can easily access SharedSizeState collection. As well - /// as been norified about enter / exit a scope. - /// - internal static void OnIsSharedSizeScopePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e) - { - // is it possible to optimize here something like this: - // if ((bool)d.GetValue(Grid.IsSharedSizeScopeProperty) == (d.GetLocalValue(PrivateSharedSizeScopeProperty) != null) - // { /* do nothing */ } - if ((bool)e.NewValue) - { - SharedSizeScope sharedStatesCollection = new SharedSizeScope(); - // d.SetValue(PrivateSharedSizeScopeProperty, sharedStatesCollection); - } - else - { - // d.ClearValue(PrivateSharedSizeScopeProperty); - } - } - - #endregion Internal Methods - - //------------------------------------------------------ - // - // Internal Properties - // - //------------------------------------------------------ - - #region Internal Properties /// /// Returns true if this definition is a part of shared group. @@ -376,6 +165,25 @@ namespace Avalonia.Controls } return (minSize); } + + } + + /// + /// Updates min size. + /// + /// New size. + internal void UpdateMinSize(double minSize) + { + _minSize = Math.Max(_minSize, minSize); + } + + /// + /// Sets min size. + /// + /// New size. + internal void SetMinSize(double minSize) + { + _minSize = minSize; } /// @@ -408,44 +216,18 @@ namespace Avalonia.Controls /// /// Internal helper to access up-to-date UserSize property value. /// - internal GridLength UserSizeValueCache - { - get - { - return (GridLength)GetValue( - _isColumnDefinition ? - ColumnDefinition.WidthProperty : - RowDefinition.HeightProperty); - } - } + internal abstract GridLength UserSizeValueCache { get; } /// /// Internal helper to access up-to-date UserMinSize property value. /// - internal double UserMinSizeValueCache - { - get - { - return (double)GetValue( - _isColumnDefinition ? - ColumnDefinition.MinWidthProperty : - RowDefinition.MinHeightProperty); - } - } + internal abstract double UserMinSizeValueCache { get; } /// /// Internal helper to access up-to-date UserMaxSize property value. /// - internal double UserMaxSizeValueCache - { - get - { - return (double)GetValue( - _isColumnDefinition ? - ColumnDefinition.MaxWidthProperty : - RowDefinition.MaxHeightProperty); - } - } + internal abstract double UserMaxSizeValueCache { get; } + /// /// Protected. Returns true if this DefinitionBase instance is in parent's logical tree. @@ -455,37 +237,6 @@ namespace Avalonia.Controls get { return (_parentIndex != -1); } } - #endregion Internal Properties - - //------------------------------------------------------ - // - // Private Methods - // - //------------------------------------------------------ - - #region Private Methods - - /// - /// SetFlags is used to set or unset one or multiple - /// flags on the object. - /// - private void SetFlags(bool value, Flags flags) - { - _flags = value ? (_flags | flags) : (_flags & (~flags)); - } - - /// - /// CheckFlagsAnd returns true if all the flags in the - /// given bitmask are set on the object. - /// - private bool CheckFlagsAnd(Flags flags) - { - return ((_flags & flags) == flags); - } - - /// - /// - /// private static void OnSharedSizeGroupPropertyChanged(DefinitionBase definition, AvaloniaPropertyChangedEventArgs e) { if (definition.InParentLogicalTree) @@ -593,31 +344,13 @@ namespace Avalonia.Controls } } - #endregion Private Methods - - //------------------------------------------------------ - // - // Private Properties - // - //------------------------------------------------------ - - #region Private Properties - - // /// - // /// Private getter of shared state collection dynamic property. - // /// - // private SharedSizeScope PrivateSharedSizeScope - // { - // get { return (SharedSizeScope)GetValue(PrivateSharedSizeScopeProperty); } - // } - /// /// Convenience accessor to UseSharedMinimum flag /// private bool UseSharedMinimum { - get { return (CheckFlagsAnd(Flags.UseSharedMinimum)); } - set { SetFlags(value, Flags.UseSharedMinimum); } + get { return _useSharedMinimum; } + set { _useSharedMinimum = value; } } /// @@ -625,22 +358,11 @@ namespace Avalonia.Controls /// private bool LayoutWasUpdated { - get { return (CheckFlagsAnd(Flags.LayoutWasUpdated)); } - set { SetFlags(value, Flags.LayoutWasUpdated); } + get { return _layoutWasUpdated; } + set { _layoutWasUpdated = value; } } - #endregion Private Properties - - //------------------------------------------------------ - // - // Private Fields - // - //------------------------------------------------------ - - #region Private Fields - private readonly bool _isColumnDefinition; // when "true", this is a ColumnDefinition; when "false" this is a RowDefinition (faster than a type check) - private Flags _flags; // flags reflecting various aspects of internal state - private int _parentIndex; // this instance's index in parent's children collection + private int _parentIndex = -1; // this instance's index in parent's children collection private Grid.LayoutTimeSizeType _sizeType; // layout-time user size type. it may differ from _userSizeValueCache.UnitType when calculating "to-content" @@ -650,29 +372,10 @@ namespace Avalonia.Controls private double _offset; // offset of the DefinitionBase from left / top corner (assuming LTR case) private SharedSizeState _sharedState; // reference to shared state object this instance is registered with + private bool _layoutWasUpdated; + private bool _useSharedMinimum; - internal const bool ThisIsColumnDefinition = true; - internal const bool ThisIsRowDefinition = false; - - #endregion Private Fields - //------------------------------------------------------ - // - // Private Structures / Classes - // - //------------------------------------------------------ - - #region Private Structures Classes - - [System.Flags] - private enum Flags : byte - { - // - // bool flags - // - UseSharedMinimum = 0x00000020, // when "1", definition will take into account shared state's minimum - LayoutWasUpdated = 0x00000040, // set to "1" every time the parent grid is measured - } /// /// Collection of shared states objects for a single scope @@ -908,10 +611,5 @@ namespace Avalonia.Controls private GridLength _userSize; // shared state private double _minSize; // shared state } - - - #endregion Properties } -} - - +} \ No newline at end of file diff --git a/src/Avalonia.Controls/GridWPF.cs b/src/Avalonia.Controls/GridWPF.cs index 89ae5c6bf5..d049f9fd4b 100644 --- a/src/Avalonia.Controls/GridWPF.cs +++ b/src/Avalonia.Controls/GridWPF.cs @@ -186,6 +186,7 @@ namespace Avalonia.Controls get { + if (_columnDefinitions == null) { ColumnDefinitions = new ColumnDefinitions(); @@ -207,9 +208,13 @@ namespace Avalonia.Controls _columnDefinitions = value; _columnDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure()); - _columnDefinitions.CollectionChanged += (_, __) => + ColumnDefinitionsDirty = true; + DefinitionsU = _columnDefinitions.Cast().ToArray(); + + _columnDefinitions.CollectionChanged += (_, e) => { - _data.DefinitionsU = _columnDefinitions.Select(p => (DefinitionBase)p).ToArray(); + DefinitionsU = e.NewItems.Cast().ToArray(); + ColumnDefinitionsDirty = true; InvalidateMeasure(); }; @@ -242,16 +247,21 @@ namespace Avalonia.Controls _rowDefinitions = value; _rowDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure()); - _rowDefinitions.CollectionChanged += (_, __) => + RowDefinitionsDirty = true; + + DefinitionsV = _rowDefinitions.Cast().ToArray(); + + _rowDefinitions.CollectionChanged += (_, e) => { - _data.DefinitionsV = _rowDefinitions.Select(p => (DefinitionBase)p).ToArray(); + DefinitionsV = e.NewItems.Cast().ToArray(); + RowDefinitionsDirty = true; InvalidateMeasure(); }; } } - private bool rowColDefsEmpty => (RowDefinitions == null || RowDefinitions?.Count == 0) && - (ColumnDefinitions == null || ColumnDefinitions?.Count == 0); + private bool rowColDefsEmpty => (DefinitionsU.Length == 0) && + (DefinitionsV.Length == 0); /// /// Content measurement. @@ -309,10 +319,10 @@ namespace Avalonia.Controls } } - ValidateDefinitionsUStructure(); + // ValidateColumnDefinitionsStructure(); ValidateDefinitionsLayout(DefinitionsU, sizeToContentU); - ValidateDefinitionsVStructure(); + // ValidateRowDefinitionsStructure(); ValidateDefinitionsLayout(DefinitionsV, sizeToContentV); CellsStructureDirty |= (SizeToContentU != sizeToContentU) || (SizeToContentV != sizeToContentV); @@ -453,12 +463,12 @@ namespace Avalonia.Controls cell.Arrange(cellRect); } - // update render bound on grid lines renderer visual - var gridLinesRenderer = EnsureGridLinesRenderer(); - if (gridLinesRenderer != null) - { - gridLinesRenderer.UpdateRenderBounds(arrangeSize); - } + // // update render bound on grid lines renderer visual + // var gridLinesRenderer = EnsureGridLinesRenderer(); + // if (gridLinesRenderer != null) + // { + // gridLinesRenderer.UpdateRenderBounds(arrangeSize); + // } } } finally @@ -493,7 +503,7 @@ namespace Avalonia.Controls // actual value calculations require structure to be up-to-date if (!ColumnDefinitionsDirty) { - DefinitionBase[] definitions = DefinitionsU; + var definitions = DefinitionsU; value = definitions[(columnIndex + 1) % definitions.Length].FinalOffset; if (columnIndex != 0) { value -= definitions[columnIndex].FinalOffset; } } @@ -515,7 +525,7 @@ namespace Avalonia.Controls // actual value calculations require structure to be up-to-date if (!RowDefinitionsDirty) { - DefinitionBase[] definitions = DefinitionsV; + var definitions = DefinitionsV; value = definitions[(rowIndex + 1) % definitions.Length].FinalOffset; if (rowIndex != 0) { value -= definitions[rowIndex].FinalOffset; } } @@ -525,38 +535,20 @@ namespace Avalonia.Controls /// /// Convenience accessor to MeasureOverrideInProgress bit flag. /// - internal bool MeasureOverrideInProgress - { - get { return (CheckFlagsAnd(Flags.MeasureOverrideInProgress)); } - set { SetFlags(value, Flags.MeasureOverrideInProgress); } - } - + internal bool MeasureOverrideInProgress { get; set; } /// /// Convenience accessor to ArrangeOverrideInProgress bit flag. /// - internal bool ArrangeOverrideInProgress - { - get { return (CheckFlagsAnd(Flags.ArrangeOverrideInProgress)); } - set { SetFlags(value, Flags.ArrangeOverrideInProgress); } - } - + internal bool ArrangeOverrideInProgress { get; set; } /// - /// Convenience accessor to ValidDefinitionsUStructure bit flag. + /// Convenience accessor to ValidColumnDefinitionsStructure bit flag. /// - internal bool ColumnDefinitionsDirty - { - get { return (!CheckFlagsAnd(Flags.ValidDefinitionsUStructure)); } - set { SetFlags(!value, Flags.ValidDefinitionsUStructure); } - } + internal bool ColumnDefinitionsDirty { get; set; } /// - /// Convenience accessor to ValidDefinitionsVStructure bit flag. + /// Convenience accessor to ValidRowDefinitionsStructure bit flag. /// - internal bool RowDefinitionsDirty - { - get { return (!CheckFlagsAnd(Flags.ValidDefinitionsVStructure)); } - set { SetFlags(!value, Flags.ValidDefinitionsVStructure); } - } + internal bool RowDefinitionsDirty { get; set; } /// /// Lays out cells according to rows and columns, and creates lookup grids. @@ -674,92 +666,6 @@ namespace Avalonia.Controls HasGroup3CellsInAutoRows = hasGroup3CellsInAutoRows; } - /// - /// Initializes DefinitionsU memeber either to user supplied ColumnDefinitions collection - /// or to a default single element collection. DefinitionsU gets trimmed to size. - /// - /// - /// This is one of two methods, where ColumnDefinitions and DefinitionsU are directly accessed. - /// All the rest measure / arrange / render code must use DefinitionsU. - /// - private void ValidateDefinitionsUStructure() - { - if (ColumnDefinitionsDirty) - { - ExtendedData extData = ExtData; - - if (extData.ColumnDefinitions == null) - { - if (extData.DefinitionsU == null) - { - extData.DefinitionsU = new DefinitionBase[] { new ColumnDefinition() }; - } - } - else - { - // extData.ColumnDefinitions.InternalTrimToSize(); - - if (extData.ColumnDefinitions.Count == 0) - { - // if column definitions collection is empty - // mockup array with one column - extData.DefinitionsU = new DefinitionBase[] { new ColumnDefinition() }; - } - else - { - extData.DefinitionsU = extData.ColumnDefinitions.ToArray(); - } - } - - ColumnDefinitionsDirty = false; - } - - Debug.Assert(ExtData.DefinitionsU != null && ExtData.DefinitionsU.Length > 0); - } - - /// - /// Initializes DefinitionsV memeber either to user supplied RowDefinitions collection - /// or to a default single element collection. DefinitionsV gets trimmed to size. - /// - /// - /// This is one of two methods, where RowDefinitions and DefinitionsV are directly accessed. - /// All the rest measure / arrange / render code must use DefinitionsV. - /// - private void ValidateDefinitionsVStructure() - { - if (RowDefinitionsDirty) - { - ExtendedData extData = ExtData; - - if (extData.RowDefinitions == null) - { - if (extData.DefinitionsV == null) - { - extData.DefinitionsV = new DefinitionBase[] { new RowDefinition() }; - } - } - else - { - // extData.RowDefinitions.InternalTrimToSize(); - - if (extData.RowDefinitions.Count == 0) - { - // if row definitions collection is empty - // mockup array with one row - extData.DefinitionsV = new DefinitionBase[] { new RowDefinition() }; - } - else - { - extData.DefinitionsV = extData.RowDefinitions.ToArray(); - } - } - - RowDefinitionsDirty = false; - } - - Debug.Assert(ExtData.DefinitionsV != null && ExtData.DefinitionsV.Length > 0); - } - /// /// Validates layout time size type information on given array of definitions. /// Sets MinSize and MeasureSizes. @@ -1607,7 +1513,7 @@ namespace Avalonia.Controls /// Array of definitions to use for calculations. /// Desired size. private double CalculateDesiredSize( - DefinitionBase[] definitions) + DefinitionBase[] definitions) { double desiredSize = 0; @@ -1762,9 +1668,9 @@ namespace Avalonia.Controls double remainingAvailableSize = finalSize - takenSize; double remainingStarWeight = totalStarWeight - takenStarWeight; - MinRatioIndexComparer minRatioIndexComparer = new MinRatioIndexComparer(definitions); + MinRatioIndexComparer minRatioIndexComparer = new MinRatioIndexComparer((DefinitionBase[])definitions); Array.Sort(definitionIndices, 0, minCount, minRatioIndexComparer); - MaxRatioIndexComparer maxRatioIndexComparer = new MaxRatioIndexComparer(definitions); + MaxRatioIndexComparer maxRatioIndexComparer = new MaxRatioIndexComparer((DefinitionBase[])definitions); Array.Sort(definitionIndices, defCount, maxCount, maxRatioIndexComparer); while (minCount + maxCount > 0 && remainingAvailableSize > 0.0) @@ -2147,7 +2053,7 @@ namespace Avalonia.Controls /// Number of items in the range. /// Final size. private double GetFinalSizeForRange( - DefinitionBase[] definitions, + DefinitionBase[] definitions, int start, int count) { @@ -2338,22 +2244,6 @@ namespace Avalonia.Controls return (result != 2); } - /// - /// Private version returning array of column definitions. - /// - private DefinitionBase[] DefinitionsU - { - get { return (ExtData.DefinitionsU); } - } - - /// - /// Private version returning array of row definitions. - /// - private DefinitionBase[] DefinitionsV - { - get { return (ExtData.DefinitionsV); } - } - /// /// Helper accessor to layout time array of definitions. /// @@ -2545,7 +2435,7 @@ namespace Avalonia.Controls } } - private ExtendedData _data; // extended data instantiated on demand, for non-trivial case handling only + private ExtendedData _data = new ExtendedData(); // extended data instantiated on demand, for non-trivial case handling only private Flags _flags; // grid validity / property caches dirtiness flags private GridLinesRenderer _gridLinesRenderer; @@ -2554,7 +2444,8 @@ namespace Avalonia.Controls // Stores unrounded values and rounding errors during layout rounding. double[] _roundingErrors; - + private DefinitionBase[] DefinitionsU = new DefinitionBase[1] { new ColumnDefinition() }; + private DefinitionBase[] DefinitionsV = new DefinitionBase[1] { new RowDefinition() }; private const double c_epsilon = 1e-5; // used in fp calculations private const double c_starClip = 1e298; // used as maximum for clipping star values during normalization private const int c_layoutLoopMaxCount = 5; // 5 is an arbitrary constant chosen to end the measure loop @@ -2572,17 +2463,13 @@ namespace Avalonia.Controls /// private class ExtendedData { - internal ColumnDefinitions ColumnDefinitions; // collection of column definitions (logical tree support) - internal RowDefinitions RowDefinitions; // collection of row definitions (logical tree support) - internal DefinitionBase[] DefinitionsU; // collection of column definitions used during calc - internal DefinitionBase[] DefinitionsV; // collection of row definitions used during calc internal CellCache[] CellCachesCollection; // backing store for logical Children internal int CellGroup1; // index of the first cell in first cell group internal int CellGroup2; // index of the first cell in second cell group internal int CellGroup3; // index of the first cell in third cell group internal int CellGroup4; // index of the first cell in forth cell group internal DefinitionBase[] TempDefinitions; // temporary array used during layout for various purposes - // TempDefinitions.Length == Max(definitionsU.Length, definitionsV.Length) + // TempDefinitions.Length == Max(DefinitionsU.Length, DefinitionsV.Length) } /// @@ -2597,8 +2484,8 @@ namespace Avalonia.Controls // * Valid???Layout flags indicate that layout time portion of the information // stored on the objects should be updated. // - ValidDefinitionsUStructure = 0x00000001, - ValidDefinitionsVStructure = 0x00000002, + ValidColumnDefinitionsStructure = 0x00000001, + ValidRowDefinitionsStructure = 0x00000002, ValidCellsStructure = 0x00000004, // @@ -3188,20 +3075,20 @@ namespace Avalonia.Controls return; } - for (int i = 1; i < grid.DefinitionsU.Length; ++i) + for (int i = 1; i < grid.ColumnDefinitions.Count; ++i) { DrawGridLine( drawingContext, - grid.DefinitionsU[i].FinalOffset, 0.0, - grid.DefinitionsU[i].FinalOffset, lastArrangeSize.Height); + grid.ColumnDefinitions[i].FinalOffset, 0.0, + grid.ColumnDefinitions[i].FinalOffset, lastArrangeSize.Height); } - for (int i = 1; i < grid.DefinitionsV.Length; ++i) + for (int i = 1; i < grid.RowDefinitions.Count; ++i) { DrawGridLine( drawingContext, - 0.0, grid.DefinitionsV[i].FinalOffset, - lastArrangeSize.Width, grid.DefinitionsV[i].FinalOffset); + 0.0, grid.RowDefinitions[i].FinalOffset, + lastArrangeSize.Width, grid.RowDefinitions[i].FinalOffset); } } diff --git a/src/Avalonia.Controls/RowDefinition.cs b/src/Avalonia.Controls/RowDefinition.cs index d42ffdfc28..1cb09e16e9 100644 --- a/src/Avalonia.Controls/RowDefinition.cs +++ b/src/Avalonia.Controls/RowDefinition.cs @@ -29,7 +29,7 @@ namespace Avalonia.Controls /// /// Initializes a new instance of the class. /// - public RowDefinition() : base(false) + public RowDefinition() { } @@ -38,7 +38,7 @@ namespace Avalonia.Controls /// /// The height of the row. /// The height unit of the column. - public RowDefinition(double value, GridUnitType type): base(false) + public RowDefinition(double value, GridUnitType type) { Height = new GridLength(value, type); } @@ -47,7 +47,7 @@ namespace Avalonia.Controls /// Initializes a new instance of the class. /// /// The height of the column. - public RowDefinition(GridLength height): base(false) + public RowDefinition(GridLength height) { Height = height; } @@ -87,5 +87,12 @@ namespace Avalonia.Controls get { return GetValue(HeightProperty); } set { SetValue(HeightProperty, value); } } + + + internal override GridLength UserSizeValueCache => this.Height; + + internal override double UserMinSizeValueCache => this.MinHeight; + + internal override double UserMaxSizeValueCache => this.MaxHeight; } } \ No newline at end of file