mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +01:00
Fixed auto-sized elements sometimes updating their location based on outdated parent positions
This commit is contained in:
parent
d7cda0d39b
commit
6a5e9a77ea
2 changed files with 12 additions and 9 deletions
|
@ -36,6 +36,7 @@ Improvements
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
|
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
|
||||||
- Fixed scroll bars doing unnecessary calculations when hidden
|
- Fixed scroll bars doing unnecessary calculations when hidden
|
||||||
|
- Fixed auto-sized elements sometimes updating their location based on outdated parent positions
|
||||||
|
|
||||||
## 6.3.1
|
## 6.3.1
|
||||||
|
|
||||||
|
|
|
@ -683,20 +683,22 @@ namespace MLEM.Ui.Elements {
|
||||||
return;
|
return;
|
||||||
this.stopwatch.Restart();
|
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;
|
var recursion = 0;
|
||||||
UpdateDisplayArea(actualSize);
|
UpdateDisplayArea();
|
||||||
|
|
||||||
this.stopwatch.Stop();
|
this.stopwatch.Stop();
|
||||||
this.System.Metrics.ForceAreaUpdateTime += this.stopwatch.Elapsed;
|
this.System.Metrics.ForceAreaUpdateTime += this.stopwatch.Elapsed;
|
||||||
this.System.Metrics.ForceAreaUpdates++;
|
this.System.Metrics.ForceAreaUpdates++;
|
||||||
|
|
||||||
void UpdateDisplayArea(Vector2 newSize) {
|
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;
|
||||||
var pos = new Vector2();
|
var pos = new Vector2();
|
||||||
|
|
||||||
switch (this.anchor) {
|
switch (this.anchor) {
|
||||||
case Anchor.TopLeft:
|
case Anchor.TopLeft:
|
||||||
case Anchor.AutoLeft:
|
case Anchor.AutoLeft:
|
||||||
|
@ -822,9 +824,9 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.TreatSizeAsMinimum) {
|
if (this.TreatSizeAsMinimum) {
|
||||||
autoSize = Vector2.Max(autoSize, actualSize);
|
autoSize = Vector2.Max(autoSize, intendedSize);
|
||||||
} else if (this.TreatSizeAsMaximum) {
|
} else if (this.TreatSizeAsMaximum) {
|
||||||
autoSize = Vector2.Min(autoSize, actualSize);
|
autoSize = Vector2.Min(autoSize, intendedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want to leave some leeway to prevent float rounding causing an infinite loop
|
// we want to leave some leeway to prevent float rounding causing an infinite loop
|
||||||
|
|
Loading…
Reference in a new issue