mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-28 07:18:35 +01:00
Compare commits
No commits in common. "fb3b586a3569a6ee15c8ae36a12d2db0c97bf072" and "d7cda0d39b1c8fbb558d366ce27b4b4e3e692e11" have entirely different histories.
fb3b586a35
...
d7cda0d39b
3 changed files with 10 additions and 34 deletions
|
@ -32,12 +32,10 @@ Additions
|
|||
Improvements
|
||||
- **Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn**
|
||||
- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum
|
||||
- Track element area update recursion count in UiMetrics
|
||||
|
||||
Fixes
|
||||
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
|
||||
- Fixed scroll bars doing unnecessary calculations when hidden
|
||||
- Fixed auto-sized elements sometimes updating their location based on outdated parent positions
|
||||
|
||||
## 6.3.1
|
||||
|
||||
|
|
|
@ -683,22 +683,20 @@ namespace MLEM.Ui.Elements {
|
|||
return;
|
||||
this.stopwatch.Restart();
|
||||
|
||||
var parentArea = this.ParentArea;
|
||||
var parentCenterX = parentArea.X + parentArea.Width / 2;
|
||||
var parentCenterY = parentArea.Y + parentArea.Height / 2;
|
||||
var actualSize = this.CalcActualSize(parentArea);
|
||||
|
||||
var recursion = 0;
|
||||
UpdateDisplayArea();
|
||||
UpdateDisplayArea(actualSize);
|
||||
|
||||
this.stopwatch.Stop();
|
||||
this.System.Metrics.ForceAreaUpdateTime += this.stopwatch.Elapsed;
|
||||
this.System.Metrics.ForceAreaUpdates++;
|
||||
|
||||
void UpdateDisplayArea(Vector2? overrideSize = null) {
|
||||
var parentArea = this.ParentArea;
|
||||
var parentCenterX = parentArea.X + parentArea.Width / 2;
|
||||
var parentCenterY = parentArea.Y + parentArea.Height / 2;
|
||||
|
||||
var intendedSize = this.CalcActualSize(parentArea);
|
||||
var newSize = overrideSize ?? intendedSize;
|
||||
void UpdateDisplayArea(Vector2 newSize) {
|
||||
var pos = new Vector2();
|
||||
|
||||
switch (this.anchor) {
|
||||
case Anchor.TopLeft:
|
||||
case Anchor.AutoLeft:
|
||||
|
@ -824,19 +822,14 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
|
||||
if (this.TreatSizeAsMinimum) {
|
||||
autoSize = Vector2.Max(autoSize, intendedSize);
|
||||
autoSize = Vector2.Max(autoSize, actualSize);
|
||||
} else if (this.TreatSizeAsMaximum) {
|
||||
autoSize = Vector2.Min(autoSize, intendedSize);
|
||||
autoSize = Vector2.Min(autoSize, actualSize);
|
||||
}
|
||||
|
||||
// we want to leave some leeway to prevent float rounding causing an infinite loop
|
||||
if (!autoSize.Equals(this.UnscrolledArea.Size, Element.Epsilon)) {
|
||||
recursion++;
|
||||
|
||||
this.System.Metrics.SummedRecursionDepth++;
|
||||
if (recursion > this.System.Metrics.MaxRecursionDepth)
|
||||
this.System.Metrics.MaxRecursionDepth = recursion;
|
||||
|
||||
if (recursion >= 64)
|
||||
throw new ArithmeticException($"The area of {this} has recursively updated too often. Does its child {foundChild} contain any conflicting auto-sizing settings?");
|
||||
UpdateDisplayArea(autoSize);
|
||||
|
|
|
@ -29,15 +29,6 @@ namespace MLEM.Ui {
|
|||
/// The amount of times that <see cref="Element.Update"/> was called.
|
||||
/// </summary>
|
||||
public uint Updates { get; internal set; }
|
||||
/// <summary>
|
||||
/// The total amount of recursions that <see cref="Element.ForceUpdateArea"/> went through.
|
||||
/// Can be divided by <see cref="ForceAreaUpdates"/> to get an average.
|
||||
/// </summary>
|
||||
public uint SummedRecursionDepth { get; internal set; }
|
||||
/// <summary>
|
||||
/// The maximum recursion depth that <see cref="Element.ForceUpdateArea"/> went through in a single call.
|
||||
/// </summary>
|
||||
public int MaxRecursionDepth { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of time that <see cref="Element.Draw(Microsoft.Xna.Framework.GameTime,Microsoft.Xna.Framework.Graphics.SpriteBatch,float,MLEM.Graphics.SpriteBatchContext)"/> took.
|
||||
|
@ -58,8 +49,6 @@ namespace MLEM.Ui {
|
|||
this.ForceAreaUpdates = 0;
|
||||
this.ActualAreaUpdates = 0;
|
||||
this.Updates = 0;
|
||||
this.SummedRecursionDepth = 0;
|
||||
this.MaxRecursionDepth = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -73,7 +62,7 @@ namespace MLEM.Ui {
|
|||
/// <summary>Returns the fully qualified type name of this instance.</summary>
|
||||
/// <returns>The fully qualified type name.</returns>
|
||||
public override string ToString() {
|
||||
return $"{nameof(this.ForceAreaUpdateTime)}: {this.ForceAreaUpdateTime}, {nameof(this.UpdateTime)}: {this.UpdateTime}, {nameof(this.ForceAreaUpdates)}: {this.ForceAreaUpdates}, {nameof(this.ActualAreaUpdates)}: {this.ActualAreaUpdates}, {nameof(this.Updates)}: {this.Updates}, {nameof(this.SummedRecursionDepth)}: {this.SummedRecursionDepth}, {nameof(this.MaxRecursionDepth)}: {this.MaxRecursionDepth}, {nameof(this.DrawTime)}: {this.DrawTime}, {nameof(this.Draws)}: {this.Draws}";
|
||||
return $"{nameof(this.ForceAreaUpdateTime)}: {this.ForceAreaUpdateTime}, {nameof(this.UpdateTime)}: {this.UpdateTime}, {nameof(this.ForceAreaUpdates)}: {this.ForceAreaUpdates}, {nameof(this.ActualAreaUpdates)}: {this.ActualAreaUpdates}, {nameof(this.Updates)}: {this.Updates}, {nameof(this.DrawTime)}: {this.DrawTime}, {nameof(this.Draws)}: {this.Draws}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -89,8 +78,6 @@ namespace MLEM.Ui {
|
|||
ForceAreaUpdates = left.ForceAreaUpdates + right.ForceAreaUpdates,
|
||||
ActualAreaUpdates = left.ActualAreaUpdates + right.ActualAreaUpdates,
|
||||
Updates = left.Updates + right.Updates,
|
||||
SummedRecursionDepth = left.SummedRecursionDepth + right.SummedRecursionDepth,
|
||||
MaxRecursionDepth = left.MaxRecursionDepth + right.MaxRecursionDepth,
|
||||
DrawTime = left.DrawTime + right.DrawTime,
|
||||
Draws = left.Draws + right.Draws
|
||||
};
|
||||
|
@ -109,8 +96,6 @@ namespace MLEM.Ui {
|
|||
ForceAreaUpdates = left.ForceAreaUpdates - right.ForceAreaUpdates,
|
||||
ActualAreaUpdates = left.ActualAreaUpdates - right.ActualAreaUpdates,
|
||||
Updates = left.Updates - right.Updates,
|
||||
SummedRecursionDepth = left.SummedRecursionDepth - right.SummedRecursionDepth,
|
||||
MaxRecursionDepth = left.MaxRecursionDepth - right.MaxRecursionDepth,
|
||||
DrawTime = left.DrawTime - right.DrawTime,
|
||||
Draws = left.Draws - right.Draws
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue