fixed child removal

fixed relayout on draw
refactored child remove/replace into ScrollPanelWidget
fixed scrolling on child remove
This commit is contained in:
Sascha Biedermann
2013-03-19 17:39:07 +01:00
parent 770d79da0b
commit b6d09b8829
3 changed files with 43 additions and 25 deletions

View File

@@ -50,6 +50,25 @@ namespace OpenRA.Widgets
base.AddChild(child);
}
public override void RemoveChild(Widget child)
{
base.RemoveChild(child);
Layout.AdjustChildren();
Scroll(0);
}
public void ReplaceChild(Widget oldChild, Widget newChild)
{
oldChild.Removed();
newChild.Parent = this;
Children[Children.IndexOf(oldChild)] = newChild;
Layout.AdjustChildren();
Scroll(0);
}
public override void DrawOuter()
{
if (!IsVisible())
@@ -95,8 +114,6 @@ namespace OpenRA.Widgets
Game.Renderer.EnableScissor(backgroundRect.X + 1, backgroundRect.Y + 1, backgroundRect.Width - 2, backgroundRect.Height - 2);
Layout.AdjustChildren();
foreach (var child in Children)
child.DrawOuter();