Skip to content

Commit

Permalink
Fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Oct 22, 2023
1 parent fab81ac commit d6cd08e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Myra.Tests/MMLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public void LoadMMLWithExternalAssets()

var project = Project.LoadFromXml(mml, assetManager);

var imageButton1 = (ImageButton)project.Root.FindWidgetById("spawnUnit1");
var imageButton1 = (ImageButton)project.Root.FindChildById("spawnUnit1");
Assert.IsNotNull(imageButton1);
Assert.IsNotNull(imageButton1.Image);
Assert.AreEqual(imageButton1.Image.Size, new Point(64, 64));

var label = (Label)project.Root.FindWidgetById("label");
var label = (Label)project.Root.FindChildById("label");
Assert.IsNotNull(label);
Assert.IsNotNull(label.Font);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Myra.Tests/StackPanelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public void AddRemove()
var label2 = new Label();
var label3 = new Label();

stackPanel.AddChild(label1);
stackPanel.AddChild(label2);
stackPanel.AddChild(label3);
stackPanel.Widgets.Add(label1);
stackPanel.Widgets.Add(label2);
stackPanel.Widgets.Add(label3);

stackPanel.RemoveChild(label2);
stackPanel.Widgets.Remove(label2);

Assert.AreEqual(2, stackPanel.Widgets.Count);
Assert.AreEqual(label1, stackPanel.Widgets[0]);
Expand Down
14 changes: 14 additions & 0 deletions src/Myra/Graphics2D/UI/Containers/MultipleItemsContainerBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Myra.Attributes;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;

Expand Down Expand Up @@ -29,5 +30,18 @@ public MultipleItemsContainerBase()
HorizontalAlignment = HorizontalAlignment.Stretch;
VerticalAlignment = VerticalAlignment.Stretch;
}

[Obsolete("Use Widgets.Add")]
public void AddChild(Widget child)
{
Widgets.Add(child);
}

[Obsolete("Use Widgets.Remove")]
public void RemoveChild(Widget child)
{
Widgets.Remove(child);
}

}
}
File renamed without changes.
9 changes: 9 additions & 0 deletions src/Myra/Graphics2D/UI/Widget.Children.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,14 @@ internal static Widget FindChild(Widget Widget, Func<Widget, bool> predicate = n

return null;
}

/// <summary>
/// Finds the first widget with matching <paramref name="Id"/>
/// </summary>
/// <param name="Id">Id to match on</param>
/// <returns>Widget instance if found otherwise null</returns>

[Obsolete("Use FindChildById")]
public Widget FindWidgetById(string Id) => FindChildById(Id);
}
}

0 comments on commit d6cd08e

Please sign in to comment.