mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
Fixed ee62554
not working when the padding or scale changes
This commit is contained in:
parent
ee62554fee
commit
f5ff96d348
1 changed files with 10 additions and 5 deletions
|
@ -107,7 +107,8 @@ namespace MLEM.Ui.Elements {
|
||||||
private StyleProp<TextAlignment> alignment;
|
private StyleProp<TextAlignment> alignment;
|
||||||
private StyleProp<GenericFont> regularFont;
|
private StyleProp<GenericFont> regularFont;
|
||||||
private TokenizedString tokenizedText;
|
private TokenizedString tokenizedText;
|
||||||
private Vector2? lastAlignSplitSize;
|
private float? lastAlignSplitWidth;
|
||||||
|
private float? lastAlignSplitScale;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new paragraph with the given settings.
|
/// Creates a new paragraph with the given settings.
|
||||||
|
@ -195,7 +196,8 @@ namespace MLEM.Ui.Elements {
|
||||||
|
|
||||||
// tokenize the text
|
// tokenize the text
|
||||||
this.tokenizedText = this.System.TextFormatter.Tokenize(this.RegularFont, this.Text, this.Alignment);
|
this.tokenizedText = this.System.TextFormatter.Tokenize(this.RegularFont, this.Text, this.Alignment);
|
||||||
this.lastAlignSplitSize = null;
|
this.lastAlignSplitWidth = null;
|
||||||
|
this.lastAlignSplitScale = null;
|
||||||
|
|
||||||
// add links to the paragraph
|
// add links to the paragraph
|
||||||
this.RemoveChildren(c => c is Link);
|
this.RemoveChildren(c => c is Link);
|
||||||
|
@ -204,11 +206,14 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AlignAndSplitIfNecessary(Vector2 size) {
|
private void AlignAndSplitIfNecessary(Vector2 size) {
|
||||||
if (size == this.lastAlignSplitSize)
|
|
||||||
return;
|
|
||||||
this.lastAlignSplitSize = size;
|
|
||||||
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)
|
||||||
|
return;
|
||||||
|
this.lastAlignSplitWidth = width;
|
||||||
|
this.lastAlignSplitScale = scale;
|
||||||
|
|
||||||
if (this.TruncateIfLong) {
|
if (this.TruncateIfLong) {
|
||||||
this.tokenizedText.Truncate(this.RegularFont, width, scale, this.Ellipsis, this.Alignment);
|
this.tokenizedText.Truncate(this.RegularFont, width, scale, this.Ellipsis, this.Alignment);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue