1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-25 22:18:34 +01:00

added line space to paragraph

This commit is contained in:
Ellpeck 2019-08-23 00:12:26 +02:00
parent 053f865a00
commit 74988921b1
2 changed files with 3 additions and 1 deletions

View file

@ -63,7 +63,7 @@ namespace Demos {
var root = new Panel(Anchor.Center, new Vector2(80, 100), Vector2.Zero, false, true, new Point(5, 10)); var root = new Panel(Anchor.Center, new Vector2(80, 100), Vector2.Zero, false, true, new Point(5, 10));
this.UiSystem.Add("Test", root); this.UiSystem.Add("Test", root);
root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is a small demo for MLEM.Ui, a user interface library that is part of (M)LEM (L)ibrary by (E)llpeck for (M)onoGame.")); root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is a small demo for MLEM.Ui, a user interface library that is part of (M)LEM (L)ibrary by (E)llpeck for (M)onoGame."){LineSpace = 1.5F});
var image = root.AddChild(new Image(Anchor.AutoCenter, new Vector2(50, 50), new TextureRegion(this.testTexture, 0, 0, 8, 8)) {IsHidden = true, Padding = new Point(3)}); var image = root.AddChild(new Image(Anchor.AutoCenter, new Vector2(50, 50), new TextureRegion(this.testTexture, 0, 0, 8, 8)) {IsHidden = true, Padding = new Point(3)});
// Setting their the x or y coordinate to 1 or a lower number causes the width or height to be a percentage of the parent's width or height // Setting their the x or y coordinate to 1 or a lower number causes the width or height to be a percentage of the parent's width or height
// (for example, setting the size's x to 0.75 would make the element's width be 0.75*parentWidth) // (for example, setting the size's x to 0.75 would make the element's width be 0.75*parentWidth)

View file

@ -34,6 +34,7 @@ namespace MLEM.Ui.Elements {
} }
public bool AutoAdjustWidth; public bool AutoAdjustWidth;
public TextCallback GetTextCallback; public TextCallback GetTextCallback;
public float LineSpace = 1;
public Paragraph(Anchor anchor, float width, TextCallback textCallback, bool centerText = false, IGenericFont font = null) public Paragraph(Anchor anchor, float width, TextCallback textCallback, bool centerText = false, IGenericFont font = null)
: this(anchor, width, "", centerText, font) { : this(anchor, width, "", centerText, font) {
@ -61,6 +62,7 @@ namespace MLEM.Ui.Elements {
if (strgScale.X > this.longestLineLength) if (strgScale.X > this.longestLineLength)
this.longestLineLength = strgScale.X; this.longestLineLength = strgScale.X;
} }
this.lineHeight *= this.LineSpace;
return new Point(this.AutoAdjustWidth ? this.longestLineLength.Ceil() + this.ScaledPadding.X * 2 : size.X, (this.lineHeight * this.splitText.Length).Ceil() + this.ScaledPadding.Y * 2); return new Point(this.AutoAdjustWidth ? this.longestLineLength.Ceil() + this.ScaledPadding.X * 2 : size.X, (this.lineHeight * this.splitText.Length).Ceil() + this.ScaledPadding.Y * 2);
} }