mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
Allow setting a default text alignment for paragraphs in UiStyle
This commit is contained in:
parent
58a0f8915a
commit
dbf370c968
3 changed files with 9 additions and 3 deletions
|
@ -27,6 +27,7 @@ Improvements
|
||||||
- Only set a paragraph's area dirty when a text change would cause it to change size
|
- Only set a paragraph's area dirty when a text change would cause it to change size
|
||||||
- Ensure that a panel gets notified of all relevant changes by calling OnChildAreaDirty for all grandchildren
|
- Ensure that a panel gets notified of all relevant changes by calling OnChildAreaDirty for all grandchildren
|
||||||
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
|
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
|
||||||
|
- Allow setting a default text alignment for paragraphs in UiStyle
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed paragraph links having incorrect hover locations when using special text alignments
|
- Fixed paragraph links having incorrect hover locations when using special text alignments
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace MLEM.Ui.Elements {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="TextAlignment"/> that this paragraph's text should be rendered with
|
/// The <see cref="TextAlignment"/> that this paragraph's text should be rendered with
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TextAlignment Alignment {
|
public StyleProp<TextAlignment> Alignment {
|
||||||
get => this.alignment;
|
get => this.alignment;
|
||||||
set {
|
set {
|
||||||
this.alignment = value;
|
this.alignment = value;
|
||||||
|
@ -99,7 +99,7 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
private string text;
|
private string text;
|
||||||
private TextAlignment alignment;
|
private StyleProp<TextAlignment> alignment;
|
||||||
private StyleProp<GenericFont> regularFont;
|
private StyleProp<GenericFont> regularFont;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -158,6 +158,7 @@ namespace MLEM.Ui.Elements {
|
||||||
this.RegularFont = this.RegularFont.OrStyle(style.Font ?? throw new NotSupportedException("Paragraphs cannot use ui styles that don't have a font. Please supply a custom font by setting UiStyle.Font."));
|
this.RegularFont = this.RegularFont.OrStyle(style.Font ?? throw new NotSupportedException("Paragraphs cannot use ui styles that don't have a font. Please supply a custom font by setting UiStyle.Font."));
|
||||||
this.TextScale = this.TextScale.OrStyle(style.TextScale);
|
this.TextScale = this.TextScale.OrStyle(style.TextScale);
|
||||||
this.TextColor = this.TextColor.OrStyle(style.TextColor);
|
this.TextColor = this.TextColor.OrStyle(style.TextColor);
|
||||||
|
this.Alignment = this.Alignment.OrStyle(style.TextAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -202,7 +203,7 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetAlignmentOffset() {
|
private float GetAlignmentOffset() {
|
||||||
switch (this.Alignment) {
|
switch (this.Alignment.Value) {
|
||||||
case TextAlignment.Center:
|
case TextAlignment.Center:
|
||||||
return this.DisplayArea.Width / 2;
|
return this.DisplayArea.Width / 2;
|
||||||
case TextAlignment.Right:
|
case TextAlignment.Right:
|
||||||
|
|
|
@ -199,6 +199,10 @@ namespace MLEM.Ui.Style {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color TextColor = Color.White;
|
public Color TextColor = Color.White;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The <see cref="TextAlignment"/> that a <see cref="Paragraph"/> should use by default.
|
||||||
|
/// </summary>
|
||||||
|
public TextAlignment TextAlignment;
|
||||||
|
/// <summary>
|
||||||
/// The <see cref="SoundEffectInfo"/> that should be played when an element's <see cref="Element.OnPressed"/> and <see cref="Element.OnSecondaryPressed"/> events are called.
|
/// The <see cref="SoundEffectInfo"/> that should be played when an element's <see cref="Element.OnPressed"/> and <see cref="Element.OnSecondaryPressed"/> events are called.
|
||||||
/// Note that this sound is only played if the callbacks have any subscribers.
|
/// Note that this sound is only played if the callbacks have any subscribers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue