/// <summary> /// Changes the node's Parent. This will automatically handle moving the widget /// into the new space and handling references such as `.Parent` and children. /// </summary> public virtual CogaNode SetParent(CogaNode parent) { if (Parent != null) { Parent.Children.Remove(this); Parent.OnChildRemoved?.Invoke(Parent, this); Parent.SetChildrenDirty(); Parent.SetDirty(); OnActiveChange = null; } Parent = parent; Parent.OnActiveChange += (node) => { OnActiveChange?.Invoke(this); }; Parent.SetChildrenDirty(); if (!Parent.Children.Contains(this)) { Parent.Children.Add(this); } if (Parent.Manager != null) { PropagateManager(this, Parent.Manager); } return(this); }
public CogaNode SetActive(bool active = true) { IsActive = active; SetDirty(); SetChildrenDirty(); // Turning inactive will stop a layout from being triggered, // so manually trigger it now for listeners that need to know its disabled. TriggerLayout(); OnActiveChange?.Invoke(this); return(this); }
public virtual void ActivationUpdate(ElementManagerLeaf elementManagerLeaf, bool isActive) { bool oldActive = Active; if (_activationExpression != null && _activationExpression.UsedIdentifiers.Contains(elementManagerLeaf.Identifier)) { Active = _activationExpression.Result; } if (oldActive != Active && OnActiveChange != null) { OnActiveChange.Invoke(Identifier, Active); } }
protected void InvokeActiveChange(string identifier, bool active) { OnActiveChange?.Invoke(identifier, active); }