浏览代码

Handle delete via window and presenter rather than `MaterialGraphView`

/main
Peter Bay Bastian 7 年前
当前提交
78c22505
共有 3 个文件被更改,包括 14 次插入17 次删除
  1. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  2. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  3. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


e.commandName == "Copy" && presenter.canCopy
|| e.commandName == "Paste" && presenter.canPaste
|| e.commandName == "Duplicate" && presenter.canDuplicate
|| e.commandName == "Cut" && presenter.canCut))
|| e.commandName == "Cut" && presenter.canCut
|| (e.commandName == "Delete" || e.commandName == "SoftDelete") && presenter.canDelete))
{
e.Use();
}

presenter.Duplicate();
if (e.commandName == "Cut")
presenter.Cut();
if (e.commandName == "Delete" || e.commandName == "SoftDelete")
presenter.Delete();
}
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


InsertCopyPasteGraph(graph);
}
public bool canDelete
{
get { return canCopy; }
}
public void Delete()
{
RemoveElements(elements.OfType<MaterialNodePresenter>().Where(e => e.selected), elements.OfType<GraphEdgePresenter>().Where(e => e.selected));
}
public override void AddElement(EdgePresenter edge)
{
Connect(edge.output as GraphAnchorPresenter, edge.input as GraphAnchorPresenter);

16
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


{Event.KeyboardEvent("a"), FrameAll},
{Event.KeyboardEvent("f"), FrameSelection},
{Event.KeyboardEvent("o"), FrameOrigin},
{Event.KeyboardEvent("delete"), DeleteSelection},
{Event.KeyboardEvent("#tab"), FramePrev},
{Event.KeyboardEvent("tab"), FrameNext}
});

var graphDataSource = GetPresenter<MaterialGraphPresenter>();
graphDataSource.AddNode(node);
}
// TODO JOCE Remove the "new" here. Use the base class' impl
new EventPropagation DeleteSelection()
{
var presenter = GetPresenter<MaterialGraphPresenter>();
if (presenter == null)
return EventPropagation.Stop;
presenter.RemoveElements(
selection.OfType<MaterialNodeView>().Select(x => x.GetPresenter<MaterialNodePresenter>()),
selection.OfType<Edge>().Select(x => x.GetPresenter<GraphEdgePresenter>())
);
return EventPropagation.Stop;
}
public override void OnDataChanged()

正在加载...
取消
保存