IsAncestor() public method

public IsAncestor ( TreeGroup ancestor, TreeGroup g ) : bool
ancestor TreeGroup
g TreeGroup
return bool
Example #1
0
 private void HandleDragHierachyNodes(TreeData treeData, List<HierachyNode> nodes)
 {
     if (this.dragNode == null)
     {
         this.isDragging = false;
         this.dropNode = null;
     }
     int controlID = GUIUtility.GetControlID(FocusType.Passive);
     EventType typeForControl = Event.current.GetTypeForControl(controlID);
     if ((typeForControl == EventType.MouseDown) && (Event.current.button == 0))
     {
         for (int i = 0; i < nodes.Count; i++)
         {
             if ((nodes[i].rect.Contains(Event.current.mousePosition) && !this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition)) && !(nodes[i].group is TreeGroupRoot))
             {
                 this.dragClickPos = Event.current.mousePosition;
                 this.dragNode = nodes[i];
                 GUIUtility.hotControl = controlID;
                 Event.current.Use();
                 break;
             }
         }
     }
     if (this.dragNode != null)
     {
         this.dropNode = null;
         for (int j = 0; j < nodes.Count; j++)
         {
             if (nodes[j].rect.Contains(Event.current.mousePosition))
             {
                 TreeGroup ancestor = this.dragNode.group;
                 TreeGroup group = nodes[j].group;
                 if (((group != ancestor) && group.CanHaveSubGroups()) && ((treeData.GetGroup(ancestor.parentGroupID) != group) && !treeData.IsAncestor(ancestor, group)))
                 {
                     this.dropNode = nodes[j];
                     break;
                 }
             }
         }
         switch (typeForControl)
         {
             case EventType.MouseMove:
             case EventType.MouseDrag:
             {
                 Vector2 vector = this.dragClickPos - Event.current.mousePosition;
                 if (vector.magnitude > 10f)
                 {
                     this.isDragging = true;
                 }
                 Event.current.Use();
                 break;
             }
             default:
                 if ((typeForControl == EventType.MouseUp) && (GUIUtility.hotControl == controlID))
                 {
                     if (this.dropNode != null)
                     {
                         this.UndoStoreSelected(EditMode.Everything);
                         TreeGroup g = this.dragNode.group;
                         TreeGroup parent = this.dropNode.group;
                         treeData.SetGroupParent(g, parent);
                         this.m_WantCompleteUpdate = true;
                     }
                     else
                     {
                         base.Repaint();
                     }
                     this.dragNode = null;
                     this.dropNode = null;
                     GUIUtility.hotControl = 0;
                     Event.current.Use();
                 }
                 break;
         }
     }
 }
Example #2
0
		private void VerifySelection(TreeData treeData)
		{
			TreeGroup treeGroup = TreeEditor.s_SelectedGroup;
			TreeNode treeNode = TreeEditor.s_SelectedNode;
			if (treeGroup != null)
			{
				treeGroup = treeData.GetGroup(treeGroup.uniqueID);
			}
			if (treeNode != null)
			{
				treeNode = treeData.GetNode(treeNode.uniqueID);
			}
			if (treeGroup != treeData.root && treeGroup != null && !treeData.IsAncestor(treeData.root, treeGroup))
			{
				treeGroup = null;
				treeNode = null;
			}
			if (treeNode != null && treeData.GetGroup(treeNode.groupID) != treeGroup)
			{
				treeNode = null;
			}
			if (treeGroup == null)
			{
				treeGroup = treeData.root;
			}
			if (TreeEditor.s_SelectedGroup != null && treeGroup == TreeEditor.s_SelectedGroup)
			{
				return;
			}
			this.SelectGroup(treeGroup);
			if (treeNode != null)
			{
				this.SelectNode(treeNode, treeData);
			}
		}
Example #3
0
 private void VerifySelection(TreeData treeData)
 {
     TreeGroup g = s_SelectedGroup;
     TreeNode node = s_SelectedNode;
     if (g != null)
     {
         g = treeData.GetGroup(g.uniqueID);
     }
     if (node != null)
     {
         node = treeData.GetNode(node.uniqueID);
     }
     if (((g != treeData.root) && (g != null)) && !treeData.IsAncestor(treeData.root, g))
     {
         g = null;
         node = null;
     }
     if ((node != null) && (treeData.GetGroup(node.groupID) != g))
     {
         node = null;
     }
     if (g == null)
     {
         g = treeData.root;
     }
     if ((s_SelectedGroup == null) || (g != s_SelectedGroup))
     {
         this.SelectGroup(g);
         if (node != null)
         {
             this.SelectNode(node, treeData);
         }
     }
 }
Example #4
0
		private void HandleDragHierachyNodes(TreeData treeData, List<TreeEditor.HierachyNode> nodes)
		{
			if (this.dragNode == null)
			{
				this.isDragging = false;
				this.dropNode = null;
			}
			int controlID = GUIUtility.GetControlID(FocusType.Passive);
			EventType typeForControl = Event.current.GetTypeForControl(controlID);
			if (typeForControl == EventType.MouseDown && Event.current.button == 0)
			{
				for (int i = 0; i < nodes.Count; i++)
				{
					if (nodes[i].rect.Contains(Event.current.mousePosition))
					{
						if (!this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition))
						{
							if (!(nodes[i].group is TreeGroupRoot))
							{
								this.dragClickPos = Event.current.mousePosition;
								this.dragNode = nodes[i];
								GUIUtility.hotControl = controlID;
								Event.current.Use();
								break;
							}
						}
					}
				}
			}
			if (this.dragNode != null)
			{
				this.dropNode = null;
				for (int j = 0; j < nodes.Count; j++)
				{
					if (nodes[j].rect.Contains(Event.current.mousePosition))
					{
						TreeGroup group = this.dragNode.group;
						TreeGroup group2 = nodes[j].group;
						if (group2 != group)
						{
							if (group2.CanHaveSubGroups())
							{
								if (treeData.GetGroup(group.parentGroupID) != group2)
								{
									if (!treeData.IsAncestor(group, group2))
									{
										this.dropNode = nodes[j];
										break;
									}
								}
							}
						}
					}
				}
				if (typeForControl == EventType.MouseMove || typeForControl == EventType.MouseDrag)
				{
					if ((this.dragClickPos - Event.current.mousePosition).magnitude > 10f)
					{
						this.isDragging = true;
					}
					Event.current.Use();
				}
				else
				{
					if (typeForControl == EventType.MouseUp && GUIUtility.hotControl == controlID)
					{
						if (this.dropNode != null)
						{
							this.UndoStoreSelected(TreeEditor.EditMode.Everything);
							TreeGroup group3 = this.dragNode.group;
							TreeGroup group4 = this.dropNode.group;
							treeData.SetGroupParent(group3, group4);
							this.m_WantCompleteUpdate = true;
						}
						else
						{
							base.Repaint();
						}
						this.dragNode = null;
						this.dropNode = null;
						GUIUtility.hotControl = 0;
						Event.current.Use();
					}
				}
			}
		}