浏览代码

Added titleButtonContainer for buttons.

Removed bring to front on previewfiller
/main
Martin Thorzen 7 年前
当前提交
ed104fa3
共有 4 个文件被更改,包括 45 次插入41 次删除
  1. 1
      com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs
  2. 44
      com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs
  3. 38
      com.unity.shadergraph/Editor/Resources/Styles/MaterialNodeView.uss
  4. 3
      com.unity.shadergraph/Editor/Resources/Styles/NodeSettings.uss

1
com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs


container.Add(settingsElement);
}
//return new MasterSettingsView(this);
return container;
}

44
com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs


VisualElement m_SettingsDivider;
VisualElement m_Settings;
VisualElement m_NodeSettingsView;
VisualElement m_CollapseButton;
public void Initialize(AbstractMaterialNode inNode, PreviewManager previewManager, IEdgeConnectorListener connectorListener)
{

SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0));
/*if (node is PreviewNode)
{
var resizeHandle = new Label { name = "resize", text = "" };
resizeHandle.AddManipulator(new Draggable(OnResize));
Add(resizeHandle);
UpdateSize();
}*/
if (node is SubGraphNode)
{
RegisterCallback<MouseDownEvent>(OnSubGraphDoubleClick);

if (node.hasPreview)
m_PreviewFiller.BringToFront();
var buttonContainer = new VisualElement();
buttonContainer.name = "button-container";
VisualElement collapseButton = this.Q("collapse-button");
VisualElement parent = collapseButton.parent;
parent.Add(buttonContainer);
m_NodeSettingsView = new NodeSettingsView();
m_NodeSettingsView.visible = false;
Add(m_NodeSettingsView);
m_CollapseButton = this.Q("collapse-button");
m_NodeSettingsView = new NodeSettingsView();
m_NodeSettingsView.visible = false;
Add(m_NodeSettingsView);
buttonContainer.Add(m_SettingsButton);
titleButtonContainer.Add(m_SettingsButton);
titleButtonContainer.Add(m_CollapseButton);
RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
buttonContainer.Add(collapseButton);
}
void OnGeometryChanged(GeometryChangedEvent evt)
{
// style.positionTop and style.positionLeft are in relation to the parent,
// so we translate the layout of the settings button to be in the coordinate
// space of the settings view's parent.
var settingsButtonLayout = m_SettingsButton.ChangeCoordinatesTo(m_NodeSettingsView.parent, m_SettingsButton.layout);
m_NodeSettingsView.style.positionTop = settingsButtonLayout.yMax - 18f;
m_NodeSettingsView.style.positionLeft = settingsButtonLayout.xMin - 16f;
}
void OnSubGraphDoubleClick(MouseDownEvent evt)

RefreshExpandedState(); //This should not be needed. GraphView needs to improve the extension api here
UpdatePortInputVisibilities();
if (node.hasPreview)
m_PreviewFiller.BringToFront();
}
}

38
com.unity.shadergraph/Editor/Resources/Styles/MaterialNodeView.uss


background-color : rgb(63, 63, 63);
}
MaterialNodeView > #node-border > #title > #button-container{
/* MaterialNodeView > #node-border > #title > #title-button-container{
} */
#settings-button {
width: 16;
align-self: center;
justify-content: center;
padding-left: 8;
MaterialNodeView > #node-border > #title > #button-container > #settings-button{
align-self : center;
width : 12;
#settings-button > #icon {
width : 12;
height : 12;
align-self: center;
visibility: hidden;
background-image : resource("Icons/SettingsIcons");
MaterialNodeView > #node-border > #title > #button-container > #settings-button:hover{
.node:hover #settings-button > #icon {
visibility: visible;
}
#settings-button:hover > #icon {
align-self: center;
width : 12;
height : 12;
MaterialNodeView > #node-border > #title > #button-container > #settings-button.clicked{
#settings-button.clicked > #icon{
width : 12;
height : 12;
visibility: visible;
MaterialNodeView > #node-border > #title > #button-container > #settings-button > #icon{
align-self : center;
background-image : resource("Icons/SettingsIcons");
width : 12;
height : 12;
}

3
com.unity.shadergraph/Editor/Resources/Styles/NodeSettings.uss


NodeSettingsView {
width: 232;
position-type: absolute;
position-left: 146.5;
position-top: 22;
slice-top: 40;
slice-left: 80;
slice-right: 25;

正在加载...
取消
保存