mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +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;
|
||||
}
|
||||
|
||||
this.SetAreaDirectlyAndUpdateChildren(new RectangleF(pos, newSize));
|
||||
this.SetAreaAndUpdateChildren(new RectangleF(pos, newSize));
|
||||
|
||||
if (this.SetWidthBasedOnChildren || this.SetHeightBasedOnChildren) {
|
||||
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.
|
||||
/// </summary>
|
||||
/// <seealso cref="ForceUpdateArea"/>
|
||||
public void SetAreaDirectlyAndUpdateChildren(RectangleF area) {
|
||||
public virtual void SetAreaAndUpdateChildren(RectangleF area) {
|
||||
this.area = area;
|
||||
this.System.InvokeOnElementAreaUpdated(this);
|
||||
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})");
|
||||
}
|
||||
}
|
||||
|
||||
base.ForceUpdateArea();
|
||||
this.SetScrollBarStyle();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetAreaAndUpdateChildren(RectangleF area) {
|
||||
base.SetAreaAndUpdateChildren(area);
|
||||
this.ScrollChildren();
|
||||
this.ScrollSetup();
|
||||
this.SetScrollBarStyle();
|
||||
}
|
||||
|
||||
private void ScrollChildren() {
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceUpdateArea() {
|
||||
base.ForceUpdateArea();
|
||||
public override void SetAreaAndUpdateChildren(RectangleF area) {
|
||||
base.SetAreaAndUpdateChildren(area);
|
||||
// we squish children in order of priority, since auto-anchoring is based on addition order
|
||||
for (var i = 0; i < this.SortedChildren.Count; i++) {
|
||||
var child = this.SortedChildren[i];
|
||||
if (SquishChild(child, out var squished))
|
||||
child.SetAreaDirectlyAndUpdateChildren(squished);
|
||||
child.SetAreaAndUpdateChildren(squished);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue