Ejemplo n.º 1
0
        /// <summary>
        /// Called directly from DALi C++ type registry to create a control (view) using no marshalling.
        /// </summary>
        /// <returns>Pointer to the control (views) handle.</returns>
        /// <param name="cPtrControlName">C pointer to the control (view) name.</param>
        private static IntPtr CreateControl(IntPtr cPtrControlName)
        {
            string controlName = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(cPtrControlName);

            NUILog.Debug("Create controlled called from C++ create a " + controlName);

            Func <CustomView> controlConstructor;

            // find the control constructor
            if (Instance._constructorMap.TryGetValue(controlName, out controlConstructor))
            {
                // Create the control
                CustomView newControl = controlConstructor();
                if (newControl != null)
                {
                    return(newControl.GetPtrfromView());  // return pointer to handle
                }
                else
                {
                    return(IntPtr.Zero);
                }
            }
            else
            {
                throw new global::System.InvalidOperationException("C# View not registererd with ViewRegistry" + controlName);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set up the animation from each LayoutItems position data.
        /// Iterates the transition stack, adding an Animator to the core animation.
        /// </summary>
        private bool SetupCoreAnimation()
        {
            // Initialize animation for this layout run.
            bool animationPending = false;

            NUILog.Debug("LayoutController SetupCoreAnimation for:" + layoutTransitionDataQueue.Count);

            if (layoutTransitionDataQueue.Count > 0) // Something to animate
            {
                if (!coreAnimation)
                {
                    coreAnimation = new Animation();
                }
                coreAnimation.EndAction = Animation.EndActions.StopFinal;
                coreAnimation.Finished += AnimationFinished;

                // Iterate all items that have been queued for repositioning.
                foreach (LayoutData layoutPositionData in layoutTransitionDataQueue)
                {
                    AddAnimatorsToAnimation(layoutPositionData);
                }

                animationPending = true;

                // transitions have now been applied, clear stack, ready for new transitions on
                // next layout traversal.
                layoutTransitionDataQueue.Clear();
            }
            return(animationPending);
        }
Ejemplo n.º 3
0
        private void SetupAnimationForSize(LayoutData layoutPositionData, TransitionComponents sizeTransitionComponents)
        {
            // Text size cant be animated so is set to it's final size.
            // It is due to the internals of the Text not being able to recalculate fast enough.
            if (layoutPositionData.Item.Owner is TextLabel || layoutPositionData.Item.Owner is TextField)
            {
                float itemWidth  = layoutPositionData.Right - layoutPositionData.Left;
                float itemHeight = layoutPositionData.Bottom - layoutPositionData.Top;
                // Set size directly.
                layoutPositionData.Item.Owner.Size2D = new Size2D((int)itemWidth, (int)itemHeight);
            }
            else
            {
                coreAnimation.AnimateTo(layoutPositionData.Item.Owner, "Size",
                                        new Vector3(layoutPositionData.Right - layoutPositionData.Left,
                                                    layoutPositionData.Bottom - layoutPositionData.Top,
                                                    layoutPositionData.Item.Owner.Position.Z),
                                        sizeTransitionComponents.Delay,
                                        sizeTransitionComponents.Duration,
                                        sizeTransitionComponents.AlphaFunction);

                NUILog.Debug("LayoutController SetupAnimationForSize View:" + layoutPositionData.Item.Owner.Name +
                             " width:" + (layoutPositionData.Right - layoutPositionData.Left) +
                             " height:" + (layoutPositionData.Bottom - layoutPositionData.Top) +
                             " delay:" + sizeTransitionComponents.Delay +
                             " duration:" + sizeTransitionComponents.Duration);
            }
        }
Ejemplo n.º 4
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();
 }