protected override void CommitProperties() { base.CommitProperties(); // Handle a deferred state change request. if (_currentStateDeferred != null) { var newState = _currentStateDeferred; _currentStateDeferred = null; CurrentState = newState; } // Typically state changes occur immediately, but during // component initialization we defer until commitProperties to // reduce a bit of the startup noise. if (_currentStateChanged && !Initialized) { _currentStateChanged = false; CommitCurrentState(); } if (_drawingListInvalidated) { //Debug.Log("Calling DepthUtil.UpdateDrawingList on " + this); _drawingListInvalidated = false; DepthUtil.UpdateDrawingList(this); } }
protected override void UpdateDisplayList(float width, float height) { //if (Id == "hbox") // Debug.Log("UpdateDisplayList: " + width + "; " + height); //if (Id == "contentGroup") // Debug.Log("GroupBase.UpdateDisplayList: " + width + ", " + height); base.UpdateDisplayList(width, height); if (_layoutInvalidateDisplayListFlag) { _layoutInvalidateDisplayListFlag = false; if (_autoLayout && null != _layout) { _layout.UpdateDisplayList(width, height); } if (null != _layout) { _layout.UpdateScrollRect(width, height); } } if (_drawingListInvalidated) { //Debug.Log("Calling DepthUtil.UpdateDrawingList on " + this); _drawingListInvalidated = false; //DepthUtil.UpdateDrawingList(this); DepthUtil.UpdateDrawingList(_contentPane ?? this); } }
///// <summary> ///// The list of components ordered by child Depth<br/> ///// Used for rendering<br/> ///// The rendering order might have different than layout order ///// </summary> //public virtual List<DisplayListMember> DrawingList //{ // get // { // return _drawingList; // } //} /// <summary> /// Updates the depth list which is used for rendering<br/> /// The depth list is based upon the Depth property of each child<br/> /// It is the same as the order list if no Depth is defined on each of the children /// </summary> internal virtual void InvalidateDrawingList() { // display object updates the list immediatelly (there are no invalidation methods) //if (this is Stage) // Debug.Log(string.Format(" DOC: Updating drawing list -> {0} [{1}, {2}]", this, _children.Count, _drawingList.Count)); if (AutoUpdateDrawingList) { DepthUtil.UpdateDrawingList(this); } }
private void CreateContentPane() { if (null != _contentPane) { return; } //Debug.Log("Creating content pane"); CreatingContentPane = true; var n = NumberOfChildren; // snapshot now //Debug.Log("CreateContentPane. Number of children: " + n); System.Collections.Generic.List <DisplayListMember> childrenToMove = new System.Collections.Generic.List <DisplayListMember>(); for (int i = 0; i < n; i++) { childrenToMove.Add(base.GetChildAt(i)); //Debug.Log("Will move: " + base.GetChildAt(i)); } /** * Content pane is a simple display object * NOTE: we have to use temp variable here * The reason is this line below: newPane.AddChild(child); * If the _contentPane is not null, this changed the flow: * we are expecting that AddChild() indirectly calls the RemoveChild() on parent (meaning: this container) * However, if _contentPane alsready set, it will try to remove the child from the pane itself! * */ #if DEBUG var newPane = new DisplayObjectContainer { Id = "content_pane", // for debugging purposes X = 0, Y = 0, AutoUpdateDrawingList = false, Visible = true }; #endif #if !DEBUG var newPane = new DisplayObjectContainer { X = 0, Y = 0, AutoUpdateDrawingList = false, Visible = true }; #endif /** * Add content pane as a last child * (cannot use AddChild(_contentPane) here, because it takes the number of * children internally depending of the pane existance) * Important: * Also cannot use AddChildAt, since it would then try to add content pane to the content pane itself * */ base.AddingChild(newPane); QAddChildAt(newPane, n); base.ChildAdded(newPane); //var mover = new ChildMover(this, _contentPane, numberOfChildren); //mover.Move(); foreach (DisplayListMember child in childrenToMove) { // set the container as a parent var cmp = child as Component; //RemoveChild(child); // TODO: remove newPane.AddChild(child); // AddChild interno zove RemoveChild na OVOM kontejneru. Zbog toga je potrebno da je _contentPane == null if (null != cmp) { cmp.ParentChanged(newPane); } //Debug.Log(" ... done"); } _contentPane = newPane; //Debug.Log("NumberOfChildren: " + NumberOfChildren); //Debug.Log("_contentPane.NumberOfChildren: " + _contentPane.NumberOfChildren); DepthUtil.UpdateDrawingList(this); // important! Cannot call the InvalidateDrawingList here because it will never update the display list of this //DepthUtil.UpdateDrawingList(_contentPane); // auto update is turned off on the content pane InvalidateDrawingList(); // same as DepthUtil.UpdateDrawingList(_contentPane) but delayed (so perhaps better for performance) CreatingContentPane = false; _contentPane.Visible = true; }