X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Finternal%2FLayouting%2FLayoutGroup.cs;h=16f62101b163f893a92ef7b5db7ce8e64a13401d;hb=2e2d0feb1e8896e568230e308fed7fa5e4d1f23d;hp=d74749ac7b359e272a810f5f5eee8c9cf786dc83;hpb=6079fcf274a494640a25c0afec56343d9a6764af;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs b/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs index d74749a..16f6210 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using Tizen.NUI.BaseComponents; using System.Linq; @@ -46,13 +47,17 @@ namespace Tizen.NUI _children = new List(); } - /// + /// /// From ILayoutParent.
///
public virtual void Add(LayoutItem childLayout) { _children.Add(childLayout); childLayout.SetParent(this); + // Child added to use a Add transition. + childLayout.ConditionForAnimation = ConditionForAnimation | TransitionCondition.Add; + // Child's parent sets all other children not being added to a ChangeOnAdd transition. + SetConditionsForAnimationOnLayoutGroup(TransitionCondition.ChangeOnAdd); OnChildAdd(childLayout); RequestLayout(); } @@ -64,6 +69,7 @@ namespace Tizen.NUI { foreach( LayoutItem childLayout in _children ) { + childLayout.ConditionForAnimation = ConditionForAnimation | TransitionCondition.Remove; childLayout.Owner = null; } _children.Clear(); @@ -76,17 +82,31 @@ namespace Tizen.NUI ///
public virtual void Remove(LayoutItem layoutItem) { + bool childRemoved = false; foreach( LayoutItem childLayout in _children.ToList() ) { if( childLayout == layoutItem ) { - childLayout.SetParent(null); + Window.Instance.LayoutController.AddToRemovalStack(childLayout); _children.Remove(childLayout); + childLayout.ConditionForAnimation = childLayout.ConditionForAnimation | TransitionCondition.Remove; + // Add LayoutItem to the transition stack so can animate it out. + Window.Instance.LayoutController.AddTransitionDataEntry(new LayoutData(layoutItem, ConditionForAnimation, 0,0,0,0)); + // Reset condition for animation ready for next transition when required. + // SetFrame usually would do this but this LayoutItem is being removed. + childLayout.ConditionForAnimation = TransitionCondition.Unspecified; + childRemoved = true; } } + if (childRemoved) + { + // If child removed then set all siblings not being added to a ChangeOnRemove transition. + SetConditionsForAnimationOnLayoutGroup(TransitionCondition.ChangeOnRemove); + } RequestLayout(); } + // Attaches to View ChildAdded signal so called when a View is added to a view. private void AddChildToLayoutGroup(View child) { // Only give children a layout if their parent is an explicit container or a pure View. @@ -122,18 +142,64 @@ namespace Tizen.NUI Add(child.Layout); } } + // Parent transitions are not attached to children. } /// /// If the child has a layout then it is removed from the parent layout. /// - /// Child to remove.true - private void RemoveChildFromLayoutGroup(View child) + /// Child View to remove. + internal void RemoveChildFromLayoutGroup(View child) + { + Debug.Assert(child.Layout !=null); + Remove(child.Layout); + } + + /// + /// Set all children in a LayoutGroup to the supplied condition. + /// Children with Add or Remove conditions should not be changed. + /// + private void SetConditionsForAnimationOnLayoutGroup( TransitionCondition conditionToSet) { - if(child.Layout != null) + foreach( LayoutItem childLayout in _children ) { - Remove(child.Layout); + switch( conditionToSet ) + { + case TransitionCondition.ChangeOnAdd : + { + // If other children also being added (TransitionCondition.Add) then do not change their + // conditions, Continue to use their Add transitions. + if (childLayout.ConditionForAnimation.HasFlag(TransitionCondition.Add)) + { + break; // Child being Added so don't update it's condition + } + else + { + // Set siblings for the child being added to use the ChangeOnAdd transition. + childLayout.ConditionForAnimation = TransitionCondition.ChangeOnAdd; + } + break; + } + case TransitionCondition.ChangeOnRemove : + { + if (childLayout.ConditionForAnimation.HasFlag(TransitionCondition.Remove)) + { + break; // Child being Removed so don't update it's condition + } + else + { + childLayout.ConditionForAnimation = TransitionCondition.ChangeOnRemove; + } + break; + } + case TransitionCondition.LayoutChanged : + { + childLayout.ConditionForAnimation = TransitionCondition.LayoutChanged; + break; + } + } } + } /// @@ -345,9 +411,10 @@ namespace Tizen.NUI AddChildToLayoutGroup(view); } - // Layout attached to owner so connect to ChildAdded and ChildRemoved signals. + // Connect to owner ChildAdded signal. Owner.ChildAdded += OnChildAddedToOwner; - Owner.ChildRemoved += OnChildRemovedFromOwner; + + // Removing Child from the owners View will directly call the LayoutGroup removal API. } // Virtual Methods that can be overridden by derived classes. @@ -440,4 +507,4 @@ namespace Tizen.NUI child.Measure( childWidthMeasureSpec, childHeightMeasureSpec ); } } -} +} \ No newline at end of file