/// <summary> /// Shows the mask /// </summary> /// <param name="component"></param> public void Mask(DisplayListMember component) { _component = component; #if DEBUG if (DebugMode) { Debug.Log("Masking component: " + component); } #endif if (null != _maskGraphics) { return; // already masking this component } _parent = _component.Parent ?? (_component is Stage ? _component as Stage : null); if (null == _parent) { return; // we are not on the display list, so we have nothing to mask indeed } var imc = _component as InvalidationManagerClient; _maskGraphics = new T { IncludeInLayout = false, X = _component.X, Y = _component.Y, Width = null != imc?imc.GetExplicitOrMeasuredWidth() : _component.Width, Height = null != imc?imc.GetExplicitOrMeasuredHeight() : _component.Height //Bounds = (Rectangle)_component.Bounds.Clone() // NOTE: BEWARE! This was the reference bug (without Clone())!!!!!!!!! }; _parent.AddChild(_maskGraphics); //_maskGraphics.ValidateNow(); // commented out 20130331 and moved to LoadingMaskAnimator // critical! //_maskGraphics.Transform.Apply(); // TODO: remove //_maskGraphics.Parent.Transform.ValidateChild(_maskGraphics); _maskGraphics.InvalidateTransform(); // subscribe to MOVE and RESIZE events of the component // we shall be levitating just over the component _component.AddEventListener(MoveEvent.MOVE, MoveHandler, EventPhase.Target); _component.AddEventListener(ResizeEvent.RESIZE, ResizeHandler, EventPhase.Target); _maskGraphics.Play(); }
private void StartHandler(Event e) { #if DEBUG if (DebugMode) { Debug.Log("StartHandler " + _component.Width + ", " + _component.Height); } #endif if (null != _maskGraphics) return; // already masking this component _parent = _component.Parent ?? (_component is Stage ? _component : null); if (null == _parent) return; // we are not on the display list, so we have nothing to mask indeed _maskGraphics = new LoadingMaskAnimator { IncludeInLayout = false, X = _component.X, Y = _component.Y, Width = _component.Width, Height = _component.Height, //Bounds = (Rectangle) _component.Bounds.Clone() // BEWARE! This was the reference bug (without Clone())!!!!!!!!! }; _parent.AddChild(_maskGraphics); LoadingEvent le = e as LoadingEvent; if (null != le) _maskGraphics.Message = le.Message; // critical! //_maskGraphics.Transform.Apply(); _maskGraphics.InvalidateTransform(); // subscribe to MOVE and RESIZE events of the component // we shall be levitating just over the component _component.AddEventListener(MoveEvent.MOVE, MoveHandler, EventPhase.Target); _component.AddEventListener(ResizeEvent.RESIZE, ResizeHandler, EventPhase.Target); _maskGraphics.Play(); }
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; }
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; }