mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-23 05:08:34 +01:00
Allow overriding SetAreaAndUpdateChildren and switch to using it in some locations
This commit is contained in:
parent
103d7c7503
commit
55fae16768
3 changed files with 10 additions and 7 deletions
|
@ -646,7 +646,7 @@ namespace MLEM.Ui.Elements {
|
||||||
newSize.Y = parentArea.Bottom - pos.Y;
|
newSize.Y = parentArea.Bottom - pos.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.SetAreaDirectlyAndUpdateChildren(new RectangleF(pos, newSize));
|
this.SetAreaAndUpdateChildren(new RectangleF(pos, newSize));
|
||||||
|
|
||||||
if (this.SetWidthBasedOnChildren || this.SetHeightBasedOnChildren) {
|
if (this.SetWidthBasedOnChildren || this.SetHeightBasedOnChildren) {
|
||||||
Element foundChild = null;
|
Element foundChild = null;
|
||||||
|
@ -701,7 +701,7 @@ namespace MLEM.Ui.Elements {
|
||||||
/// Note that this method does not take into account any auto-sizing, anchoring or positioning, and so it should be used sparingly, if at all.
|
/// Note that this method does not take into account any auto-sizing, anchoring or positioning, and so it should be used sparingly, if at all.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="ForceUpdateArea"/>
|
/// <seealso cref="ForceUpdateArea"/>
|
||||||
public void SetAreaDirectlyAndUpdateChildren(RectangleF area) {
|
public virtual void SetAreaAndUpdateChildren(RectangleF area) {
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.System.InvokeOnElementAreaUpdated(this);
|
this.System.InvokeOnElementAreaUpdated(this);
|
||||||
foreach (var child in this.Children)
|
foreach (var child in this.Children)
|
||||||
|
|
|
@ -104,12 +104,15 @@ namespace MLEM.Ui.Elements {
|
||||||
throw new NotSupportedException($"A panel that scrolls overflow cannot contain another panel that scrolls overflow ({child})");
|
throw new NotSupportedException($"A panel that scrolls overflow cannot contain another panel that scrolls overflow ({child})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base.ForceUpdateArea();
|
base.ForceUpdateArea();
|
||||||
|
this.SetScrollBarStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void SetAreaAndUpdateChildren(RectangleF area) {
|
||||||
|
base.SetAreaAndUpdateChildren(area);
|
||||||
this.ScrollChildren();
|
this.ScrollChildren();
|
||||||
this.ScrollSetup();
|
this.ScrollSetup();
|
||||||
this.SetScrollBarStyle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollChildren() {
|
private void ScrollChildren() {
|
||||||
|
|
|
@ -20,13 +20,13 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ForceUpdateArea() {
|
public override void SetAreaAndUpdateChildren(RectangleF area) {
|
||||||
base.ForceUpdateArea();
|
base.SetAreaAndUpdateChildren(area);
|
||||||
// we squish children in order of priority, since auto-anchoring is based on addition order
|
// we squish children in order of priority, since auto-anchoring is based on addition order
|
||||||
for (var i = 0; i < this.SortedChildren.Count; i++) {
|
for (var i = 0; i < this.SortedChildren.Count; i++) {
|
||||||
var child = this.SortedChildren[i];
|
var child = this.SortedChildren[i];
|
||||||
if (SquishChild(child, out var squished))
|
if (SquishChild(child, out var squished))
|
||||||
child.SetAreaDirectlyAndUpdateChildren(squished);
|
child.SetAreaAndUpdateChildren(squished);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue