/// <summary> /// Request that this layout is re-laid out.<br /> /// This will make this layout and all it's parent layouts dirty.<br /> /// </summary> /// <since_tizen> 6 </since_tizen> public void RequestLayout() { flags = flags | LayoutFlags.ForceLayout; if (parent == null) { // If RequestLayout() is called while main loop is in idle state, // then Awake() is required to awake main loop again and // Layout can be re-calculated correctly. // For performance, Awake() is called only by the root layout. ProcessorController.Instance.Awake(); } else { LayoutGroup layoutGroup = parent as LayoutGroup; if (layoutGroup != null && !layoutGroup.LayoutRequested) { layoutGroup.RequestLayout(); } } }
/// <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(); }
/// <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); }