You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.4 KiB
78 lines
2.4 KiB
using System; |
|
using UnityEngine; |
|
using UnityEngine.Assertions; |
|
using UnityEngine.UIElements; |
|
|
|
namespace UnityEditor.ShaderGraph.Drawing |
|
{ |
|
class SGBlackboardRow : VisualElement |
|
{ |
|
static readonly string k_UxmlTemplatePath = "UXML/Blackboard/SGBlackboardRow"; |
|
static readonly string k_StyleSheetPath = "Styles/SGBlackboard"; |
|
|
|
VisualElement m_Root; |
|
Button m_ExpandButton; |
|
VisualElement m_ItemContainer; |
|
VisualElement m_PropertyViewContainer; |
|
bool m_Expanded = true; |
|
|
|
public bool expanded |
|
{ |
|
get { return m_Expanded; } |
|
set |
|
{ |
|
if (m_Expanded == value) |
|
{ |
|
return; |
|
} |
|
|
|
m_Expanded = value; |
|
|
|
if (m_Expanded) |
|
{ |
|
m_Root.Add(m_PropertyViewContainer); |
|
AddToClassList("expanded"); |
|
} |
|
else |
|
{ |
|
m_Root.Remove(m_PropertyViewContainer); |
|
RemoveFromClassList("expanded"); |
|
} |
|
} |
|
} |
|
|
|
public SGBlackboardRow(VisualElement item, VisualElement propertyView) |
|
{ |
|
var stylesheet = Resources.Load(k_StyleSheetPath) as StyleSheet; |
|
Assert.IsNotNull(stylesheet); |
|
styleSheets.Add(stylesheet); |
|
|
|
var uxmlTemplate = Resources.Load(k_UxmlTemplatePath) as VisualTreeAsset; |
|
Assert.IsNotNull(uxmlTemplate); |
|
|
|
VisualElement mainContainer = null; |
|
mainContainer = uxmlTemplate.Instantiate(); |
|
Assert.IsNotNull(mainContainer); |
|
mainContainer.AddToClassList("mainContainer"); |
|
|
|
m_Root = mainContainer.Q("root"); |
|
m_ItemContainer = mainContainer.Q("itemContainer"); |
|
m_PropertyViewContainer = mainContainer.Q("propertyViewContainer"); |
|
|
|
m_ExpandButton = mainContainer.Q<Button>("expandButton"); |
|
m_ExpandButton.clickable.clicked += () => expanded = !expanded; |
|
m_ExpandButton.RemoveFromHierarchy(); |
|
|
|
Add(mainContainer); |
|
|
|
ClearClassList(); |
|
AddToClassList("blackboardRow"); |
|
|
|
name = "SGBlackboardRow"; |
|
m_ItemContainer.Add(item); |
|
m_PropertyViewContainer.Add(propertyView); |
|
|
|
expanded = false; |
|
} |
|
} |
|
}
|
|
|