mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 05:58:35 +01:00
Compare commits
No commits in common. "80a6c6b5e28080120965821fcf9a67194e53a476" and "68fc02b1708a6cb8d643b6fd5702d38905846260" have entirely different histories.
80a6c6b5e2
...
68fc02b170
5 changed files with 12 additions and 28 deletions
|
@ -24,8 +24,6 @@ Fixes
|
||||||
Improvements
|
Improvements
|
||||||
- Allow for checkboxes and radio buttons to be disabled
|
- Allow for checkboxes and radio buttons to be disabled
|
||||||
- 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
|
|
||||||
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
|
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -530,7 +530,7 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetAreaDirty() {
|
public void SetAreaDirty() {
|
||||||
this.AreaDirty = true;
|
this.AreaDirty = true;
|
||||||
this.Parent?.OnChildAreaDirty(this, false);
|
this.Parent?.OnChildAreaDirty(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1061,17 +1061,13 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A method that gets called by this element's <see cref="Children"/> or any of its grandchildren when their <see cref="SetAreaDirty"/> methods get called.
|
/// A method that gets called by this element's <see cref="Children"/> when their <see cref="SetAreaDirty"/> methods get called.
|
||||||
/// Note that the element's area might already be dirty, which will not stop this method from being called.
|
/// Note that the element's area might already be dirty, which will not stop this method from being called.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="child">The child whose area is being set dirty.</param>
|
/// <param name="child">The child whose area is being set dirty</param>
|
||||||
/// <param name="grandchild">Whether the <paramref name="child"/> is a grandchild of this element, rather than a direct child.</param>
|
protected virtual void OnChildAreaDirty(Element child) {
|
||||||
protected virtual void OnChildAreaDirty(Element child, bool grandchild) {
|
if (child.Anchor >= Anchor.AutoLeft || this.SetWidthBasedOnChildren || this.SetHeightBasedOnChildren)
|
||||||
if (!grandchild) {
|
this.SetAreaDirty();
|
||||||
if (child.Anchor >= Anchor.AutoLeft || this.SetWidthBasedOnChildren || this.SetHeightBasedOnChildren)
|
|
||||||
this.SetAreaDirty();
|
|
||||||
}
|
|
||||||
this.Parent?.OnChildAreaDirty(child, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace MLEM.Ui.Elements {
|
||||||
return;
|
return;
|
||||||
var offset = new Vector2(0, -this.ScrollBar.CurrentValue);
|
var offset = new Vector2(0, -this.ScrollBar.CurrentValue);
|
||||||
foreach (var child in this.GetChildren(c => c != this.ScrollBar, true)) {
|
foreach (var child in this.GetChildren(c => c != this.ScrollBar, true)) {
|
||||||
if (!child.ScrollOffset.Equals(offset, Epsilon)) {
|
if (child.ScrollOffset != offset) {
|
||||||
child.ScrollOffset = offset;
|
child.ScrollOffset = offset;
|
||||||
this.relevantChildrenDirty = true;
|
this.relevantChildrenDirty = true;
|
||||||
}
|
}
|
||||||
|
@ -157,15 +157,6 @@ namespace MLEM.Ui.Elements {
|
||||||
return relevant;
|
return relevant;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void OnChildAreaDirty(Element child, bool grandchild) {
|
|
||||||
base.OnChildAreaDirty(child, grandchild);
|
|
||||||
// we only need to scroll when a grandchild changes, since all of our children are forced
|
|
||||||
// to be auto-anchored and so will automatically propagate their changes up to us
|
|
||||||
if (grandchild)
|
|
||||||
this.ScrollChildren();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, Effect effect, Matrix matrix) {
|
public override void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, Effect effect, Matrix matrix) {
|
||||||
if (this.Texture.HasValue())
|
if (this.Texture.HasValue())
|
||||||
|
|
|
@ -191,8 +191,8 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void SetTextDirty() {
|
protected void SetTextDirty() {
|
||||||
this.TokenizedText = null;
|
this.TokenizedText = null;
|
||||||
// only set our area dirty if our size changed as a result of this action
|
// only set our area dirty if our size changed as a result of this action or if we have link children we need to update
|
||||||
if (!this.AreaDirty && !this.CalcActualSize(this.ParentArea).Equals(this.DisplayArea.Size, Epsilon))
|
if (!this.AreaDirty && (!this.CalcActualSize(this.ParentArea).Equals(this.DisplayArea.Size, Epsilon) || this.Children.Count > 0))
|
||||||
this.SetAreaDirty();
|
this.SetAreaDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,9 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OnChildAreaDirty(Element child, bool grandchild) {
|
protected override void OnChildAreaDirty(Element child) {
|
||||||
base.OnChildAreaDirty(child, grandchild);
|
base.OnChildAreaDirty(child);
|
||||||
if (!grandchild)
|
this.SetAreaDirty();
|
||||||
this.SetAreaDirty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool SquishChild(Element element, out RectangleF squishedArea) {
|
private static bool SquishChild(Element element, out RectangleF squishedArea) {
|
||||||
|
|
Loading…
Reference in a new issue