コード例 #1
0
 private void AnimationFinished(object sender, EventArgs e)
 {
     // Iterate list of LayoutItem that were set for removal.
     // Now the core animation has finished their Views can be removed.
     if (itemRemovalQueue != null)
     {
         foreach (LayoutItem item in itemRemovalQueue)
         {
             // Check incase the parent was already removed and the Owner was
             // removed already.
             if (item.Owner)
             {
                 // Check again incase the parent has already been removed.
                 ILayoutParent layoutParent = item.GetParent();
                 LayoutGroup   layoutGroup  = layoutParent as LayoutGroup;
                 if (layoutGroup != null)
                 {
                     layoutGroup.Owner?.RemoveChild(item.Owner);
                 }
             }
         }
         itemRemovalQueue.Clear();
         // If LayoutItems added to stack whilst the core animation is playing
         // they would have been cleared here.
         // Could have another stack to be added to whilst the animation is running.
         // After the running stack is cleared it can be populated with the content
         // of the other stack.  Then the main removal stack iterated when AnimationFinished
         // occurs again.
     }
     NUILog.Debug("LayoutController AnimationFinished");
     coreAnimation?.Clear();
 }
コード例 #2
0
 public ILayoutParent GetParent()
 {
     global::System.IntPtr cPtr = LayoutPINVOKE.LayoutItemWrapperImpl_GetParent(swigCPtr);
     //ILayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new ILayoutParent(cPtr, false);
     ILayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutItemWrapperImpl(cPtr, false);
     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
コード例 #3
0
 /// <summary>
 /// Request relayout of a LayoutItem and it's parent tree.
 /// </summary>
 /// <param name="layoutItem">LayoutItem that is required to be laid out again.</param>
 public void RequestLayout(LayoutItem layoutItem)
 {
     // Go up the tree and mark all parents to relayout
     ILayoutParent layoutParent = layoutItem.GetParent();
     if (layoutParent != null)
     {
          LayoutGroup layoutGroup =  layoutParent as LayoutGroup;
          if(! layoutGroup.LayoutRequested)
          {
             layoutGroup.RequestLayout();
          }
     }
 }
コード例 #4
0
ファイル: LayoutItem.cs プロジェクト: hyotaekshim/TizenFX
        /// <summary>
        /// Unparent this layout from it's owner, and remove any layout children in derived types. <br />
        /// </summary>
        internal void Unparent()
        {
            // Enable directly derived types to first remove children
            OnUnparent();

            // Remove myself from parent
            Parent?.Remove(this);

            // Remove parent reference
            Parent = null;

            // Lastly, clear layout from owning View.
            Owner?.ResetLayout();
        }
コード例 #5
0
        /// <summary>
        /// Sets up the main animation with the animators for each item (each layoutPositionData structure)
        /// </summary>
        private void AddAnimatorsToAnimation(LayoutData layoutPositionData)
        {
            LayoutTransition    positionTransition    = new LayoutTransition();
            LayoutTransition    sizeTransition        = new LayoutTransition();
            TransitionCondition conditionForAnimators = layoutPositionData.ConditionForAnimation;

            // LayoutChanged transitions overrides ChangeOnAdd and ChangeOnRemove as siblings will
            // reposition to the new layout not to the insertion/removal of a sibling.
            if (layoutPositionData.ConditionForAnimation.HasFlag(TransitionCondition.LayoutChanged))
            {
                conditionForAnimators = TransitionCondition.LayoutChanged;
            }

            // Set up a default transitions, will be overwritten if inherited from parent or set explicitly.
            TransitionComponents positionTransitionComponents = CreateDefaultTransitionComponent(0, 300);
            TransitionComponents sizeTransitionComponents     = CreateDefaultTransitionComponent(0, 300);

            bool matchedCustomTransitions = false;


            TransitionList transitionsForCurrentCondition = new TransitionList();

            // Note, Transitions set on View rather than LayoutItem so if the Layout changes the transition persist.

            // Check if item to animate has it's own Transitions for this condition.
            // If a key exists then a List of at least 1 transition exists.
            if (layoutPositionData.Item.Owner.LayoutTransitions.ContainsKey(conditionForAnimators))
            {
                // Child has transitions for the condition
                matchedCustomTransitions = layoutPositionData.Item.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out transitionsForCurrentCondition);
            }

            if (!matchedCustomTransitions)
            {
                // Inherit parent transitions as none already set on View for the condition.
                ILayoutParent layoutParent = layoutPositionData.Item.GetParent();
                if (layoutParent != null)
                {
                    // Item doesn't have it's own transitions for this condition so copy parents if
                    // has a parent with transitions.
                    LayoutGroup    layoutGroup = layoutParent as LayoutGroup;
                    TransitionList parentTransitionList;
                    // Note TryGetValue returns null if key not matched.
                    if (layoutGroup != null && layoutGroup.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out parentTransitionList))
                    {
                        // Copy parent transitions to temporary TransitionList. List contains transitions for the current condition.
                        LayoutTransitionsHelper.CopyTransitions(parentTransitionList,
                                                                transitionsForCurrentCondition);
                    }
                }
            }


            // Position/Size transitions can be displayed for a layout changing to another layout or an item being added or removed.

            // There can only be one position transition and one size position, they will be replaced if set multiple times.
            // transitionsForCurrentCondition represent all non position (custom) properties that should be animated.

            // Search for Position property in the transitionsForCurrentCondition list of custom transitions,
            // and only use the particular parts of the animator as custom transitions should not effect all parameters of Position.
            // Typically Delay, Duration and Alphafunction can be custom.
            FindAndReplaceAnimatorComponentsForProperty(transitionsForCurrentCondition,
                                                        AnimatableProperties.Position,
                                                        ref positionTransitionComponents);

            // Size
            FindAndReplaceAnimatorComponentsForProperty(transitionsForCurrentCondition,
                                                        AnimatableProperties.Size,
                                                        ref sizeTransitionComponents);

            // Add animators to the core Animation,

            SetupAnimationForCustomTransitions(transitionsForCurrentCondition, layoutPositionData.Item.Owner);

            SetupAnimationForPosition(layoutPositionData, positionTransitionComponents);

            SetupAnimationForSize(layoutPositionData, sizeTransitionComponents);

            // Dispose components
            positionTransitionComponents.Dispose();
            sizeTransitionComponents.Dispose();
        }
コード例 #6
0
ファイル: LayoutItem.cs プロジェクト: hyotaekshim/TizenFX
 /// <summary>
 /// [Draft] Set parent to this layout.
 /// </summary>
 /// <param name="parent">Parent to set on this Layout.</param>
 internal void SetParent(ILayoutParent parent)
 {
     Parent = parent as LayoutGroup;
 }
コード例 #7
0
ファイル: LayoutItem.cs プロジェクト: vincent-kwon/TizenFX
 /// <summary>
 /// [Draft] Set parent to this layout.
 /// </summary>
 /// <param name="parent">Parent to set on this Layout.</param>
 public void SetParent(ILayoutParent parent)
 {
     Parent = parent as LayoutGroup;
 }
コード例 #8
0
        /// <summary>
        /// Sets up the main animation with the animators for each item (each layoutPositionData structure)
        /// </summary>
        private void AddAnimatorsToAnimation(LayoutData layoutPositionData)
        {
            LayoutTransition    positionTransition    = new LayoutTransition();
            TransitionCondition conditionForAnimators = layoutPositionData.ConditionForAnimation;

            // LayoutChanged transitions overrides ChangeOnAdd and ChangeOnRemove as siblings will
            // reposition to the new layout not to the insertion/removal of a sibling.
            if (layoutPositionData.ConditionForAnimation.HasFlag(TransitionCondition.LayoutChanged))
            {
                conditionForAnimators = TransitionCondition.LayoutChanged;
            }

            // Set up a default transition, will be overwritten if inherited from parent or set explicitly.
            const int     START_TIME    = 0;
            const int     END_TIME      = 100;
            AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            // positionTransitionComponents will be overwritten if set explicitly
            TransitionComponents positionTransitionComponents = new TransitionComponents(START_TIME, END_TIME, alphaFunction);
            bool matchedCustomTransitions = false;

            // Inherit parent transitions if none already set on View for the condition.
            // Transitions set on View rather than LayoutItem so if the Layout changes the transition persist.
            // Still need to inherit Position animator from parent but not other animatable properties if already set.

            TransitionList transitionsForCurrentCondition;

            ILayoutParent layoutParent = layoutPositionData.Item.GetParent();

            if (layoutParent != null)
            {
                // Check if item to aninmate has it's own Transitions for this condition.
                if (layoutPositionData.Item.Owner.LayoutTransitions.ContainsKey(conditionForAnimators))
                {
                    matchedCustomTransitions = true; // If a key exists then a List of atleast 1 transition exists.
                }
                else
                {
                    // Item doesn't have it's own transitions for this condition so copy parents if
                    // has a parent with transitions.
                    transitionsForCurrentCondition = new TransitionList();
                    LayoutGroup    layoutGroup = layoutParent as LayoutGroup;
                    TransitionList parentTransitionList;
                    // Note TryGetValue returns null if key not matched.
                    if (layoutGroup.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out parentTransitionList))
                    {
                        // Copy parent transitions for this condition to temporary TransitionList.
                        LayoutTransitionsHelper.CopyTransitions(parentTransitionList,
                                                                transitionsForCurrentCondition);

                        SetupAnimationForCustomTransitions(transitionsForCurrentCondition, layoutPositionData.Item.Owner);
                        matchedCustomTransitions = false;
                    }
                }
            }

            // SetupAnimationXXXX functions add Animators to the core Animation, these can be custom or set by the
            // layout system in the case of Positioning.

            if (matchedCustomTransitions)
            {
                // Position transition can be for a layout changing to another layout or an item being added or removed.
                // There can only be one position transition, it will be replaced if set multiple times.
                // transitionsForCurrentCondition represent all non position (custom) properties that should be animated.
                // There can be multiple properties hence returned as a list.
                if (layoutPositionData.Item.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out transitionsForCurrentCondition))
                {
                    // Search for Position property in the transitionsForCurrentCondition list of custom transitions,
                    // and only use the particular parts of the animator as custom transitions should not effect all parameters of Position.
                    // Typically Delay, Duration and Alphafunction can be custom.
                    FindAndReplaceAnimatorComponentsForProperty(transitionsForCurrentCondition,
                                                                AnimatableProperties.Position,
                                                                ref positionTransitionComponents);

                    SetupAnimationForCustomTransitions(transitionsForCurrentCondition, layoutPositionData.Item.Owner);
                }
            }

            SetupAnimationForPosition(layoutPositionData, positionTransitionComponents);

            SetupAnimationForText(layoutPositionData);
        }