예제 #1
0
        private static List <Type> GetUsedCustomControls(GUIControlCollection controls)
        {
            List <Type> customControls = new List <Type>();

            foreach (GUIControl control in controls)
            {
                // Found a custom GUIControl.  Ensure that the "ControlAttribute" is present
                System.Attribute attribute = System.Attribute.GetCustomAttribute(control.GetType(), typeof(Plugins.ControlAttribute));
                if (attribute != null)
                {
                    Otter.Plugins.ControlAttribute  controlAttribute  = (Otter.Plugins.ControlAttribute)attribute;
                    Otter.Plugins.ControlDescriptor controlDescriptor = controlAttribute.GetDescriptor();

                    customControls.Add(control.GetType());
                }

                List <Type> list = GetUsedCustomControls(control.Controls);

                foreach (Type type in list)
                {
                    if (!customControls.Contains(type))
                    {
                        customControls.Add(type);
                    }
                }
            }

            return(customControls);
        }
예제 #2
0
        /// <summary>
        /// Removes a control
        /// </summary>
        /// <param name="control"></param>
        public void RemoveControl(GUIControl control)
        {
            GUIControlCollection collection = (control.Parent != null ? control.Parent.Controls : Controls);

            if (collection.Contains(control, true))
            {
                // Now cycle through the active sceneView's animations and remove
                // all animations for this control.
                int cnt = Animations.Count;
                for (int i = cnt - 1; i >= 0; i--)
                {
                    GUIAnimation animation = Animations[i];
                    if (animation.GetAnimationChannel(control) != null)
                    {
                        animation.RemoveAnimationChannel(control);
                    }
                }

                control.Parent = null;
                collection.Remove(control, true);
            }

            if (control.GetType() == typeof(GUIMask))
            {
                //remove any reference to this mask from other controls
                foreach (GUIControl thisControl in Controls)
                {
                    if (thisControl.Mask == control.ID)
                    {
                        thisControl.Mask = -1;
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a control as the child of another.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="control"></param>
        /// <param name="atIndex"></param>
        public void AddControl(GUIControl parent, GUIControl control, int atIndex)
        {
            GUIControlCollection collection = (parent != null ? parent.Controls : this.Controls);

            if (!collection.Contains(control, true))
            {
                // We need create a keyframe for this control on the "OnActivate" channel
                GUIAnimation onActivate = Animations["OnActivate"];
                if (onActivate != null)
                {
                    onActivate.CreateKeyFrame(control, 0);
                }

                control.Parent = (parent != null) ? parent : this;

                if (atIndex >= 0)
                {
                    collection.Insert(atIndex, control);
                }
                else
                {
                    collection.Add(control);
                }
            }
        }
예제 #4
0
        private void AddControls(ListBox listBox, GUIControlCollection controls)
        {
            foreach (GUIControl control in controls)
            {
                if (control.GetType() == typeof(GUIMask))
                    listBox.Items.Add(control);

                AddControls(listBox, control.Controls);
            }
        }
예제 #5
0
        /// <summary>
        /// Retrieves the maximum control count in the collection of controls.
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="currentMax"></param>
        private void GetMaxControlID(GUIControlCollection collection, ref int currentMax)
        {
            foreach (GUIControl control in collection)
            {
                if (control == null)
                {
                    continue;
                }

                if (control.ID > currentMax)
                {
                    currentMax = control.ID;
                }

                GetMaxControlID(control.Controls, ref currentMax);
            }
        }
예제 #6
0
 /// <summary>
 /// Adds the GUI Control nodes to the treeview
 /// </summary>
 /// <param name="ancestor"></param>
 /// <param name="sceneView"></param>
 private void AddControlNodes(Node parentNode, GUIControlCollection controls)
 {
     foreach (GUIControl control in controls)
     {
         AddControlNode(parentNode, control);
     }
 }
예제 #7
0
        /// <summary>
        /// Populates the list of channels to display.
        /// </summary>
        private List<TimelineChannel> GetChannelList(GUIControlCollection controls, int indent)
        {
            List<TimelineChannel> list = new List<TimelineChannel>();

            if (controls != null && mAnimation != null)
            {
                foreach (GUIControl control in controls)
                {
                    GUIAnimationChannel animChannel = mAnimation.GetAnimationChannel(control);
                    List<TimelineChannel> childList = GetChannelList(control.Controls, indent + 1);

                    if (animChannel != null || ChannelFilter == Filter.All || childList.Count > 0)
                    {
                        TimelineChannel channel = new TimelineChannel();
                        channel.Control = control;
                        channel.Channel = mAnimation.GetAnimationChannel(control);
                        channel.Indent = indent;
                        list.Add(channel);
                    }

                    list.AddRange(childList);
                }
            }

            return list;
        }
예제 #8
0
        private void DrawSnapTargets(GUIControlCollection controls)
        {
            int col = Otter.Editor.Properties.Settings.Default.ViewBoundsColor.ToArgb();
            foreach (GUIControl control in controls)
            {
                if (SelectedControls.Contains(control))
                    continue;

                DrawSnapTargets(control.Controls);
                DrawHighlightBox(control, false, Otter.Editor.Properties.Settings.Default.ViewBoundsColor, Otter.Editor.Properties.Settings.Default.ViewBoundsColor);                
            }
        }
예제 #9
0
        private bool SnapToControls(GUIControl control, GUIControlCollection controls)
        {
            float radius = Math.Max(control.Size.Width, control.Size.Height);
            radius += (float)Math.Sqrt(Math.Pow(control.Center.X, 2) + Math.Pow(control.Center.Y, 2));
            radius += Otter.Editor.Properties.Settings.Default.ViewGridIncrement;

            Vector4 controlWorldPos = Vector4.Transform(new Vector4(control.Center.X, control.Center.Y, 0.0f, 1.0f), control.FullTransform);

            // Now check against all other controls
            foreach (GUIControl otherControl in controls)
            {
                if (SelectedControls.Contains(otherControl))
                    continue;

                // find the maximum bounding radius for this control
                float sibRadius = Math.Max(otherControl.Size.Width, otherControl.Size.Height);
                sibRadius += (float)Math.Sqrt(Math.Pow(otherControl.Center.X, 2) + Math.Pow(otherControl.Center.Y, 2));

                // See if the circles intersect.  If they do, check snapping
                Vector4 siblingWorldPos = Vector4.Transform(new Vector4(otherControl.Center.X, otherControl.Center.Y, 0.0f, 1.0f), otherControl.FullTransform);

                float dist = (float)(Math.Pow((siblingWorldPos.X - controlWorldPos.X), 2) + Math.Pow((siblingWorldPos.Y - controlWorldPos.Y), 2));
                if (dist <= Math.Pow((radius + sibRadius), 2))
                {
                    // Left Edge
                    Vector4 ls = Vector4.Transform(new Vector4(0.0f, 0.0f, 0.0f, 1.0f), otherControl.FullTransform);
                    Vector4 le = Vector4.Transform(new Vector4(0.0f, otherControl.Size.Height, 0.0f, 1.0f), otherControl.FullTransform);

                    if (SnapControl(control, mPointArea, ref ls, ref le))
                        return true;

                    // Right Edge
                    ls = Vector4.Transform(new Vector4(otherControl.Size.Width, 0.0f, 0.0f, 1.0f), otherControl.FullTransform);
                    le = Vector4.Transform(new Vector4(otherControl.Size.Width, otherControl.Size.Height, 0.0f, 1.0f), otherControl.FullTransform);

                    if (SnapControl(control, mPointArea, ref ls, ref le))
                        return true;

                    // Top Edge
                    ls = Vector4.Transform(new Vector4(0.0f, 0.0f, 0.0f, 1.0f), otherControl.FullTransform);
                    le = Vector4.Transform(new Vector4(otherControl.Size.Width, 0.0f, 0.0f, 1.0f), otherControl.FullTransform);

                    if (SnapControl(control, mPointArea, ref ls, ref le))
                        return true;

                    // Bottom Edge
                    ls = Vector4.Transform(new Vector4(0.0f, otherControl.Size.Height, 0.0f, 1.0f), otherControl.FullTransform);
                    le = Vector4.Transform(new Vector4(otherControl.Size.Width, otherControl.Size.Height, 0.0f, 1.0f), otherControl.FullTransform);

                    if (SnapControl(control, mPointArea, ref ls, ref le))
                        return true;
                }

                if (SnapToControls(control, otherControl.Controls))
                    return true;
            }

            return false;
        }