浏览代码

Make class for adding resize handles along the border of a visual element

/main
Jens Holm 7 年前
当前提交
55869a0b
共有 5 个文件被更改,包括 57 次插入25 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  2. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeSideHandle.cs
  3. 32
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
  4. 25
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeBorderFrame.cs
  5. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeBorderFrame.cs.meta

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


foreach (var property in m_Graph.properties)
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));
ResizeSideHandle.AddResizeHandleBorderFrame(this);
Add(new ResizeBorderFrame(this) { name = "resizeBorderFrame" });
}
MasterNode masterNode

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeSideHandle.cs


public class ResizeSideHandle : VisualElement
{
public static void AddResizeHandleBorderFrame(VisualElement targetElement)
{
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.TopLeft));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.Top));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.TopRight));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.Right));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.BottomRight));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.Bottom));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.BottomLeft));
targetElement.Add(new ResizeSideHandle(targetElement, ResizeHandleAnchor.Left));
}
VisualElement m_ResizeTarget;
public ResizeSideHandle(VisualElement resizeTarget, ResizeHandleAnchor anchor)

32
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss


padding-bottom: 4;
}
GraphInspectorView > .resize {
#resizeBorderFrame > .resize {
GraphInspectorView > .resize.vertical {
#resizeBorderFrame > .resize.vertical {
cursor: resize-vertical;
height: 10;
position-left: 10;

margin-bottom: 0;
}
GraphInspectorView > .resize.horizontal {
#resizeBorderFrame > .resize.horizontal {
cursor: resize-horizontal;
width: 10;
position-top: 10;

margin-right: 0;
}
GraphInspectorView > .resize.diagonal {
#resizeBorderFrame > .resize.diagonal {
GraphInspectorView > .resize.diagonal.top-left {
#resizeBorderFrame > .resize.diagonal.top-left {
GraphInspectorView > .resize.diagonal.top-right {
#resizeBorderFrame > .resize.diagonal.top-right {
GraphInspectorView > .resize.diagonal.bottom-left {
#resizeBorderFrame > .resize.diagonal.bottom-left {
GraphInspectorView > .resize.diagonal.bottom-right {
#resizeBorderFrame > .resize.diagonal.bottom-right {
GraphInspectorView > .resize.vertical.top {
#resizeBorderFrame > .resize.vertical.top {
GraphInspectorView > .resize.vertical.bottom {
#resizeBorderFrame > .resize.vertical.bottom {
GraphInspectorView > .resize.horzontal.left {
#resizeBorderFrame > .resize.horzontal.left {
GraphInspectorView > .resize.horizontal.right {
#resizeBorderFrame > .resize.horizontal.right {
}
.reszieBorderFrame {
position-type: absolute;
position-top: 0;
position-right: 0;
position-bottom: 0;
position-left: 0;
}
ShaderPropertyView {

25
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeBorderFrame.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEditor.ShaderGraph.Drawing;
public class ResizeBorderFrame : VisualElement
{
public ResizeBorderFrame(VisualElement target)
{
pickingMode = PickingMode.Ignore;
AddToClassList("reszieBorderFrame");
Add(new ResizeSideHandle(target, ResizeHandleAnchor.TopLeft));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.Top));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.TopRight));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.Right));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.BottomRight));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.Bottom));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.BottomLeft));
Add(new ResizeSideHandle(target, ResizeHandleAnchor.Left));
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeBorderFrame.cs.meta


fileFormatVersion: 2
guid: 1128492b211994d46be4acd2ccac15fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存