mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +01:00
properly stop a panel's scroll bar from being removed
This commit is contained in:
parent
be9748e70e
commit
5f7956a7a3
2 changed files with 16 additions and 7 deletions
|
@ -423,7 +423,7 @@ namespace MLEM.Ui.Elements {
|
|||
/// <param name="index">The index to add the child at, or -1 to add it to the end of the <see cref="Children"/> list</param>
|
||||
/// <typeparam name="T">The type of child to add</typeparam>
|
||||
/// <returns>This element, for chaining</returns>
|
||||
public T AddChild<T>(T element, int index = -1) where T : Element {
|
||||
public virtual T AddChild<T>(T element, int index = -1) where T : Element {
|
||||
if (index < 0 || index > this.children.Count)
|
||||
index = this.children.Count;
|
||||
this.children.Insert(index, element);
|
||||
|
@ -443,7 +443,7 @@ namespace MLEM.Ui.Elements {
|
|||
/// Removes the given child from this element.
|
||||
/// </summary>
|
||||
/// <param name="element">The child element to remove</param>
|
||||
public void RemoveChild(Element element) {
|
||||
public virtual void RemoveChild(Element element) {
|
||||
this.children.Remove(element);
|
||||
// set area dirty here so that a dirty call is made
|
||||
// upwards to us if the element is auto-positioned
|
||||
|
@ -462,7 +462,7 @@ namespace MLEM.Ui.Elements {
|
|||
/// Removes all children from this element that match the given condition.
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition that determines if a child should be removed</param>
|
||||
public void RemoveChildren(Func<Element, bool> condition = null) {
|
||||
public virtual void RemoveChildren(Func<Element, bool> condition = null) {
|
||||
for (var i = this.Children.Count - 1; i >= 0; i--) {
|
||||
var child = this.Children[i];
|
||||
if (condition == null || condition(child)) {
|
||||
|
|
|
@ -108,11 +108,20 @@ namespace MLEM.Ui.Elements {
|
|||
/// <inheritdoc />
|
||||
public override void ForceUpdateSortedChildren() {
|
||||
base.ForceUpdateSortedChildren();
|
||||
if (this.scrollOverflow) {
|
||||
if (this.ScrollBar.Parent != this)
|
||||
throw new NotSupportedException("A panel that scrolls overflow cannot have its scroll bar removed from its list of children");
|
||||
if (this.scrollOverflow)
|
||||
this.relevantChildrenDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void RemoveChild(Element element) {
|
||||
if (element == this.ScrollBar)
|
||||
throw new NotSupportedException("A panel that scrolls overflow cannot have its scroll bar removed from its list of children");
|
||||
base.RemoveChild(element);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void RemoveChildren(Func<Element, bool> condition = null) {
|
||||
base.RemoveChildren(e => e != this.ScrollBar && (condition == null || condition(e)));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
Loading…
Reference in a new issue