mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Fixed Paragraph and Checkbox not reacting to SquishingGroup sizing properly
This commit is contained in:
parent
4994bb3d5d
commit
1a7cb65cf2
3 changed files with 16 additions and 6 deletions
|
@ -39,6 +39,7 @@ Additions
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed images not updating their hidden state properly when the displayed texture changes
|
- Fixed images not updating their hidden state properly when the displayed texture changes
|
||||||
- Fixed AutoInline elements overflowing into their parent if it's taller
|
- Fixed AutoInline elements overflowing into their parent if it's taller
|
||||||
|
- Fixed Paragraph and Checkbox not reacting to SquishingGroup sizing properly
|
||||||
|
|
||||||
Improvements
|
Improvements
|
||||||
- Increased Element area calculation recursion limit to 64
|
- Increased Element area calculation recursion limit to 64
|
||||||
|
|
|
@ -106,13 +106,12 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override Vector2 CalcActualSize(RectangleF parentArea) {
|
public override void SetAreaAndUpdateChildren(RectangleF area) {
|
||||||
var size = base.CalcActualSize(parentArea);
|
base.SetAreaAndUpdateChildren(area);
|
||||||
if (this.Label != null) {
|
if (this.Label != null) {
|
||||||
this.Label.Size = new Vector2((size.X - size.Y) / this.Scale - this.TextOffsetX, 1);
|
this.Label.Size = new Vector2((area.Width - area.Height) / this.Scale - this.TextOffsetX, 1);
|
||||||
this.Label.PositionOffset = new Vector2(size.Y / this.Scale + this.TextOffsetX, 0);
|
this.Label.PositionOffset = new Vector2(area.Height / this.Scale + this.TextOffsetX, 0);
|
||||||
}
|
}
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -175,6 +175,13 @@ namespace MLEM.Ui.Elements {
|
||||||
this.CanBeMoused = false;
|
this.CanBeMoused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void SetAreaAndUpdateChildren(RectangleF area) {
|
||||||
|
base.SetAreaAndUpdateChildren(area);
|
||||||
|
// in case an outside source sets our area, we still want to display our text correctly
|
||||||
|
this.AlignAndSplitIfNecessary(area.Size);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override Vector2 CalcActualSize(RectangleF parentArea) {
|
protected override Vector2 CalcActualSize(RectangleF parentArea) {
|
||||||
var size = base.CalcActualSize(parentArea);
|
var size = base.CalcActualSize(parentArea);
|
||||||
|
@ -182,6 +189,9 @@ namespace MLEM.Ui.Elements {
|
||||||
this.TokenizeIfNecessary();
|
this.TokenizeIfNecessary();
|
||||||
this.AlignAndSplitIfNecessary(size);
|
this.AlignAndSplitIfNecessary(size);
|
||||||
var textSize = this.tokenizedText.GetArea(Vector2.Zero, this.TextScale * this.TextScaleMultiplier * this.Scale).Size;
|
var textSize = this.tokenizedText.GetArea(Vector2.Zero, this.TextScale * this.TextScaleMultiplier * this.Scale).Size;
|
||||||
|
// if we auto-adjust our width, then we would also split the same way with our adjusted width, so cache that
|
||||||
|
if (this.AutoAdjustWidth)
|
||||||
|
this.lastAlignSplitWidth = textSize.X;
|
||||||
return new Vector2(this.AutoAdjustWidth ? textSize.X + this.ScaledPadding.Width : size.X, textSize.Y + this.ScaledPadding.Height);
|
return new Vector2(this.AutoAdjustWidth ? textSize.X + this.ScaledPadding.Width : size.X, textSize.Y + this.ScaledPadding.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +265,7 @@ namespace MLEM.Ui.Elements {
|
||||||
var width = size.X - this.ScaledPadding.Width;
|
var width = size.X - this.ScaledPadding.Width;
|
||||||
var scale = this.TextScale * this.TextScaleMultiplier * this.Scale;
|
var scale = this.TextScale * this.TextScaleMultiplier * this.Scale;
|
||||||
|
|
||||||
if (this.lastAlignSplitWidth == width && this.lastAlignSplitScale == scale)
|
if (this.lastAlignSplitWidth?.Equals(width, Element.Epsilon) == true && this.lastAlignSplitScale?.Equals(scale, Element.Epsilon) == true)
|
||||||
return;
|
return;
|
||||||
this.lastAlignSplitWidth = width;
|
this.lastAlignSplitWidth = width;
|
||||||
this.lastAlignSplitScale = scale;
|
this.lastAlignSplitScale = scale;
|
||||||
|
|
Loading…
Reference in a new issue