Exemple #1
0
        public ChildMover(DisplayObjectContainer from, DisplayObjectContainer to, int numberOfChildren)
        {
            _docFrom = from;
            _docTo = to;

            //_ctFrom = _docFrom as Container;
            //_ctTo = _docTo as Container;

            _numberOfChildrenToMove = numberOfChildren;
        }
Exemple #2
0
        /// <summary>
        /// This utility sorts the drawing list by request<br/>
        /// Takes the component as input and reads its child list internally<br/>
        /// Then it sorts it and saves into the drawing list<br/>
        /// Note: the original child list is never being modified (we want to stay robust here)
        /// </summary>
        /// <param name="doc"></param>
        public static void UpdateDrawingList(DisplayObjectContainer doc)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format("         DepthUtil -> UpdateDrawingList: {0} -> [orderList: {1}, depthList: {2}]", doc, doc.QNumberOfChildren, doc.QDrawingList.Count));
            }
#endif
            UpdateDrawingList(doc.QChildren, doc.QDrawingList);
        }
        public virtual DisplayListMember AddChildAt(DisplayListMember child, int index) // TODO: Do delayed version
        {
            //return QAddChildAt(index, child);
            DisplayObjectContainer formerParent = child.Parent;

            if (null != formerParent)
            {
                formerParent.RemoveChild(child);
            }

            QAddChildAt(child, index);

            return(child);
        }
        public virtual DisplayListMember AddChild(DisplayListMember child)
        {
            //Debug.Log("Parent: " + child.Parent);
            DisplayObjectContainer formerParent = child.Parent;

            if (null != formerParent)
            {
                formerParent.RemoveChild(child);
            }

            QAddChild(child);

            return(child);
        }
        /// <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();
        }
Exemple #6
0
        public override DisplayListMember AddChildAt(DisplayListMember child, int index)
        {
            DisplayObjectContainer formerParent = child.Parent;

            if (null != formerParent)
            {
                formerParent.RemoveChild(child);
            }

            AddingChild(child);

            QAddChildAt(child, index);

            ChildAdded(child);

            return(child);
        }
Exemple #7
0
        /**
         * Važno:
         * Ove overrideove sam ja dodao 20131105
         * Razlog je bio problem oko dinamičkog dodavanja itema u List kontrolu
         * Naime, iako su se liste inicijalno normalno inicijalizirale, prilikom dodavanja novog childa u kolekciju (dinamički)
         * događao se Exception u DataGroup metodi AddItemRendererToDisplayList ("ArgumentOutOfRangeException: Argument is out of range.")
         * Greška je bila ta da je linija base.AddChildAt(child, childIndex) naravno zvala base.AddChildAt od klase Component
         * a ta implementacija interno zove QAddChildAt (tj. ne radi razliku između toga da li postoji contentPane ili ne)
         * Tako da je child uvijek bio dodavan direktno na GroupBase, a ne na contentPane ukoliko je postojao
         * (GroupBase "laže" vanjskom svijetu i skriva činjenicu da postoji contentPane)
         * Zbog toga je bilo potrebno overridati ove 4 metode i ispraviti tu funkcionalnost
         * */

        public override DisplayListMember AddChild(DisplayListMember child)
        {
            DisplayObjectContainer formerParent = child.Parent;

            if (null != formerParent)
            {
                formerParent.RemoveChild(child);
            }

            // Do anything that needs to be done before the child is added.
            // When adding a child to Component, this will set the child's
            // virtual parent, its nestLevel, its document, etc.
            // When adding a child to a Container, the override will also
            // invalidate the container, adjust its content/chrome partitions,
            // etc.
            //base.AddingChild(child);

            if (null != _contentPane)
            {
                ContentPaneAddingChild(child);
            }
            else
            {
                base.AddingChild(child);
            }

            // Call a low-level player method in DisplayObjectContainer which
            // actually attaches the child to this component.
            // The player dispatches an "added" event from the child just after
            // it is attached, so all "added" handlers execute during this call.
            // Component registers an addedHandler() in its constructor,
            // which makes it runs before any other "added" handlers except
            // capture-phase ones; it sets up the child's styles.
            var retVal = null != _contentPane?_contentPane.QAddChild(child) : QAddChild(child);

            // Do anything that needs to be done after the child is added
            // and after all "added" handlers have executed.
            // This is where
            /*base.*/ ChildAdded(child);

            InvalidateDrawingList();
            //if (null != _contentPane)
            //    DepthUtil.UpdateDrawingList(_contentPane); // because AutoUpdateDrawingList is turned of on contentPane

            return(retVal);
        }
Exemple #8
0
        //private static void PushBranchToBack(Component leaf)
        //{
        //    if (null != leaf.Parent) //  && !(leaf.Owner is Stage)
        //    {
        //        //Debug.Log("Bringing to front: " + leaf);

        //        Container c = (Container)leaf.Parent;

        //        // If parent defined, trigger bringing to front this child
        //        c.PushChildToBack(leaf);
        //        // Do it recursivelly al the way up to Stage (which has no parent)
        //        //PushBranchToBack(leaf.Owner); // NONO
        //    }
        //}

        #endregion

        #region Parent - child

        ///<summary>
        /// Running when the parent is changed (used for setup the new parent and the stage)
        ///</summary>
        ///<param name="newParent"></param>
        public void ParentChanged(DisplayObjectContainer newParent)
        {
            //Debug.LogWarning("ParentChanged: " + this + "; Parent: " + newParent);

            if (null == newParent)
            {
                Parent = null;
                //Stage = null;
                NestLevel = 0;
            }
            else
            {
                Parent = newParent;
                Stage  = newParent.Stage; // 20130921 -> this line is very important, because this is the place where the Stage reference is added to a component
            }
//            Debug.Log(string.Format(@"Parent changed. Component: {0}
//Parent: {1}", this, newParent));
        }
        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();
        }
Exemple #10
0
        public override DisplayListMember AddChild(DisplayListMember child)
        {
            DisplayObjectContainer formerParent = child.Parent;

            if (null != formerParent)
            {
                formerParent.RemoveChild(child);
            }

            // If there is an overlay, place the child underneath it.
            int index = base.NumberOfChildren;

            // Do anything that needs to be done before the child is added.
            // When adding a child to Component, this will set the child's
            // virtual parent, its nestLevel, its document, etc.
            // When adding a child to a Container, the override will also
            // invalidate the container, adjust its content/chrome partitions,
            // etc.
            AddingChild(child);

            // Call a low-level player method in DisplayObjectContainer which
            // actually attaches the child to this component.
            // The player dispatches an "added" event from the child just after
            // it is attached, so all "added" handlers execute during this call.
            // Component registers an addedHandler() in its constructor,
            // which makes it runs before any other "added" handlers except
            // capture-phase ones; it sets up the child's styles.
            QAddChildAt(child, index);

            // Do anything that needs to be done after the child is added
            // and after all "added" handlers have executed.
            // This is where
            ChildAdded(child);

            return(child);
        }
Exemple #11
0
 /// <summary>
 /// Constructor
 /// It takes a target as an argument, and it holds the reference to that target
 /// </summary>
 /// <param name="target"></param>
 protected GuiTransformBase(DisplayListMember target)
 {
     _target = target;
     _doc    = target as DisplayObjectContainer;
 }
Exemple #12
0
 /// <summary>
 /// Adds a popup to popup stage
 /// </summary>
 /// <param name="popup">A popup to add</param>
 /// <param name="parent">Parent component (for position calculations)</param>
 /// <param name="modal">Is this a modal popup</param>
 public void AddPopup(DisplayListMember popup, DisplayObjectContainer parent, bool modal)
 {
     AddPopup(popup, parent ?? _stage, modal, true); // centered by default
 }
Exemple #13
0
 /// <summary>
 /// Adds a popup to popup stage
 /// </summary>
 /// <param name="popup">A popup to add</param>
 /// <param name="parent">Parent component (for position calculations)</param>
 /// <param name="modal">Is this a modal popup</param>
 /// <param name="centered">Should popup be centered</param>
 public void AddPopup(DisplayListMember popup, DisplayObjectContainer parent, bool modal, bool centered)
 {
     AddPopup(popup, parent ?? _stage, modal, centered, false);
 }
Exemple #14
0
        /// <summary>
        /// Adds a popup to popup stage
        /// </summary>
        /// <param name="popup">A popup to add</param>
        /// <param name="parent">Parent component (for position calculations)</param>
        /// <param name="modal">Is this a modal popup</param>
        /// <param name="centered">Should popup be centered</param>
        /// <param name="keepCenter">Should popup stay centered after the screen resize</param>
        public void AddPopup(DisplayListMember popup, DisplayObjectContainer parent, bool modal, bool centered, bool keepCenter)
        {
#if TRIAL
            /* HACK CHECK */
            Acme acme = (Acme) Framework.GetComponent<Acme>(true);
            if (null == acme || !acme.gameObject.activeInHierarchy/*active*/ || !acme.enabled)
                return;
#endif

            if (_popups.Contains(popup))
                return;
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("AddPopup");
            }
#endif
            List<PopupOption> options = new List<PopupOption>
                                            {
                                                new PopupOption(PopupOptionType.Parent, parent),
                                                new PopupOption(PopupOptionType.Modal, modal),
                                                new PopupOption(PopupOptionType.Centered, centered),
                                                new PopupOption(PopupOptionType.KeepCenter, keepCenter)
                                            };

            AddPopup(popup, options.ToArray());
        }
Exemple #15
0
 /// <summary>
 /// Creates the popup via factory/reflection
 /// </summary>
 /// <param name="parent">Parent component (for position calculations)</param>
 /// <param name="popupType">The popup class for instantiation</param>
 /// <returns></returns>
 public DisplayObject CreatePopup(Type popupType, DisplayObjectContainer parent)
 {
     return CreatePopup(popupType, parent, true);
 }
Exemple #16
0
 /// <summary>
 /// Creates the popup via factory/reflection
 /// </summary>
 /// <param name="parent">Parent component (for position calculations)</param>
 /// <param name="popupType">The popup class for instantiation</param>
 /// <param name="modal">Is this a modal popup</param>
 /// <param name="centered">Should popup be centered</param>
 /// <returns></returns>
 public DisplayObject CreatePopup(Type popupType, DisplayObjectContainer parent, bool modal, bool centered)
 {
     return CreatePopup(popupType, parent, modal, centered, false);
 }
Exemple #17
0
 /// <summary>
 /// Creates the popup via factory/reflection
 /// </summary>
 /// <param name="parent">Parent component (for position calculations)</param>
 /// <param name="popupType">The popup class for instantiation</param>
 /// <param name="modal">Is this a modal popup</param>
 /// <param name="centered">Should popup be centered</param>
 /// <param name="keepCenter">Should popup stay centered after the screen resize</param>
 /// <returns></returns>
 public DisplayObject CreatePopup(Type popupType, DisplayObjectContainer parent, bool modal, bool centered, bool keepCenter)
 {
     Component popup = (Component)Activator.CreateInstance(popupType);
     AddPopup(popup, parent, modal, centered, keepCenter);
     return popup;
 }
Exemple #18
0
        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;
        }
 /// <summary>
 /// Constructor
 /// It takes a target as an argument, and it holds the reference to that target
 /// </summary>
 /// <param name="target"></param>
 protected GuiTransformBase(DisplayListMember target)
 {
     _target = target;
     _doc = target as DisplayObjectContainer;
 }
Exemple #20
0
        //private static void PushBranchToBack(Component leaf)
        //{
        //    if (null != leaf.Parent) //  && !(leaf.Owner is Stage)
        //    {
        //        //Debug.Log("Bringing to front: " + leaf);

        //        Container c = (Container)leaf.Parent;

        //        // If parent defined, trigger bringing to front this child
        //        c.PushChildToBack(leaf);
        //        // Do it recursivelly al the way up to Stage (which has no parent)
        //        //PushBranchToBack(leaf.Owner); // NONO
        //    }
        //}
        
        #endregion

        #region Parent - child

        ///<summary>
        /// Running when the parent is changed (used for setup the new parent and the stage)
        ///</summary>
        ///<param name="newParent"></param>
        public void ParentChanged(DisplayObjectContainer newParent)
        {
            //Debug.LogWarning("ParentChanged: " + this + "; Parent: " + newParent);

            if (null == newParent)
            {
                Parent = null;
                //Stage = null;
                NestLevel = 0;
            }
            else
            {
                Parent = newParent;
                Stage = newParent.Stage; // 20130921 -> this line is very important, because this is the place where the Stage reference is added to a component
            }
//            Debug.Log(string.Format(@"Parent changed. Component: {0}
//Parent: {1}", this, newParent));
        }
 /// <summary>
 /// Constructor
 /// It takes a target as an argument, and it holds the reference to that target
 /// </summary>
 /// <param name="target"></param>
 public DisplayObjectTransform(DisplayListMember target) : base(target)
 {
     _doc = Target as DisplayObjectContainer;
 }
Exemple #22
0
        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;
        }