public NeoGuiContext(INeoGuiDelegate del) { rootStateDomain = new StateDomain(this); Delegate = del; Input = new InputContext(this); }
public static Element Create(Element parent, object key = null, StateDomain domain = null) => parent.Context.CreateElement(parent, key, domain);
internal Element CreateElement(Element parent, object key, StateDomain domain) { if (ElementCount == AttrStateId.Length) { var newLength = AttrStateId.Length * 2; Array.Resize(ref AttrStateId, newLength); Array.Resize(ref AttrStateKey, newLength); Array.Resize(ref AttrStateDomain, newLength); Array.Resize(ref AttrName, newLength); Array.Resize(ref AttrParent, newLength); Array.Resize(ref AttrFirstChild, newLength); Array.Resize(ref AttrNextSibling, newLength); Array.Resize(ref AttrLevel, newLength); Array.Resize(ref AttrZIndex, newLength); Array.Resize(ref AttrFlags, newLength); Array.Resize(ref AttrTransform, newLength); Array.Resize(ref AttrWorldTransform, newLength); Array.Resize(ref AttrRect, newLength); Array.Resize(ref AttrBoundingRect, newLength); Array.Resize(ref AttrClipRect, newLength); Array.Resize(ref AttrDrawFunc, newLength); Array.Resize(ref AttrMeasureFunc, newLength); Array.Resize(ref AttrLayoutFunc, newLength); } if (domain == null) { domain = AttrStateDomain[parent.Index]; } long id; if (key == null) { key = AttrStateKey[parent.Index]; id = domain.GetStateIdForInheritedKey(key); } else { id = domain.GetStateIdForOwnKey(key); } currStateIds[id] = domain; AttrStateId[ElementCount] = id; AttrStateKey[ElementCount] = key; AttrStateDomain[ElementCount] = domain; AttrName[ElementCount] = ""; AttrParent[ElementCount] = parent.Index; AttrFirstChild[ElementCount] = -1; // we have no children yet AttrNextSibling[ElementCount] = AttrFirstChild[parent.Index]; // set parent's first child as next sibling AttrFirstChild[parent.Index] = ElementCount; // set this element as parent's first child AttrLevel[ElementCount] = AttrLevel[parent.Index] + 1; AttrZIndex[ElementCount] = 0; AttrFlags[ElementCount] = 0; AttrTransform[ElementCount].MakeIdentity(); AttrWorldTransform[ElementCount].MakeIdentity(); AttrRect[ElementCount] = new Rect(); AttrBoundingRect[ElementCount] = new Rect(); AttrDrawFunc[ElementCount] = null; AttrMeasureFunc[ElementCount] = null; AttrLayoutFunc[ElementCount] = null; return(new Element(this, ElementCount++)); }