From 8b0ff0a25c4df9950f3c781f97f9f233606c4de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Wed, 19 Apr 2017 11:19:45 -0700 Subject: [PATCH] Add methods for easy adding/removing children Summary: Adds two methods ```AddChild``` and ```RemoveChild``` to be able to add/remove children without the need to know there position. Closes https://github.com/facebook/yoga/pull/513 Reviewed By: emilsjolander Differential Revision: D4914242 Pulled By: splhack fbshipit-source-id: df187ba71a1bae0b3b0649624f3c29401d5f8804 --- csharp/Facebook.Yoga/YogaNode.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index df6d2f0f..2ca4a61e 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -576,6 +576,20 @@ namespace Facebook.Yoga Native.YGNodeRemoveChild(_ygNode, child._ygNode); } + public void AddChild(YogaNode child) + { + Insert(Count, child); + } + + public void RemoveChild(YogaNode child) + { + int index = IndexOf(child); + if (index >= 0) + { + RemoveAt(IndexOf(child)); + } + } + public void Clear() { if (_children != null)