public virtual void finalize() { if (buttons.Keys.Count < 1) { throw new FutileException("You need to add more states to your toggle first!"); } isFinalized = true; //kind of arbitrary... just pick one of the button states to offset the others by... offsetX = -1; offsetY = -1; int lowestChild = -1; FContainer parent = null; foreach (FButton button in buttons.Values) { if (offsetX == -1f) { offsetX = button.x; } if (offsetY == -1f) { offsetY = button.y; } if (button.container != null) { if (parent == null) { parent = button.container; } if (lowestChild == -1 || parent.IndexOf(button) < lowestChild) { lowestChild = parent.IndexOf(button); } } AddChild(button); button.x -= offsetX; button.y -= offsetY; } //place us back in the parent display tree parent.AddChildAtIndex(this, lowestChild); x = offsetX; y = offsetY; }