-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockContainer.cs
110 lines (95 loc) · 2.88 KB
/
DockContainer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
namespace DockGUI
{
public class DockContainer : VisualElement
{
private StyleSheet _styleSheet;
public DockContainer DockContainerParent => (DockContainer) parent;
public bool HasContainerParent
{
get
{
if (parent == null)
{
return false;
}
Type parentType = parent.GetType();
return parentType == typeof(DockContainer) || parentType.IsSubclassOf(typeof(DockContainer));
}
}
public DockContainer() : this(DockGUIStyles.DefaultStyle) { }
public DockContainer(StyleSheet styleSheet)
{
styleSheets.Add(styleSheet);
}
public void SetDockingClass(string styleClass)
{
foreach (var styleName in DockGUIStyles.DockingStyleNames())
{
if (styleName == styleClass)
{
continue;
}
if (ClassListContains(styleName))
{
RemoveFromClassList(styleName);
}
}
if (!ClassListContains(styleClass))
{
AddToClassList(styleClass);
}
}
public void UnsetDockingClass()
{
foreach (var styleName in DockGUIStyles.DockingStyleNames())
{
if (ClassListContains(styleName))
{
RemoveFromClassList(styleName);
}
}
}
public DockLayout GetRootDockLayout()
{
if (parent == null)
{
return null;
}
DockContainer nextParent = DockContainerParent;
DockContainer curParent = null;
while (nextParent != null)
{
curParent = nextParent;
nextParent = nextParent.HasContainerParent ? nextParent.DockContainerParent : null;
}
return (DockLayout)curParent;
}
// public VisualElement GetRootElement()
// {
// if (parent == null)
// {
// return null;
// }
//
// VisualElement nextParent = parent;
// VisualElement curParent = null;
//
// while (nextParent != null)
// {
// curParent = nextParent;
// if (curParent.GetType() != typeof(DockLayout))
// {
// break;
// }
// nextParent = nextParent.parent;
// }
//
// return curParent;
// }
}
}