-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNodeResizeDragTracker.cs
82 lines (73 loc) · 1.82 KB
/
NodeResizeDragTracker.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
using UnityEngine;
using System.Collections;
public class NodeResizeDragTracker : DiagramDragTracker
{
private NodeHandle nodeHandle;
public NodeResizeDragTracker (NodeHandle nodeHandle)
{
this.nodeHandle = nodeHandle;
}
public void Resize (ref Rect rect,float x, float y, float width, float height)
{
rect.width += width;
rect.height += height;
if(rect.width<10){
rect.width = 10;
}else{
rect.x += x;
}
if(rect.height<10){
rect.height
= 10;
}else{
rect.y += y;
}
}
override public void OnDrag (DiagramContext context, Vector2 position)
{
int pos = nodeHandle.GetPosition ();
Vector2 delta = context.GetDragDelta ();
foreach (DiagramElement element in context.GetSelection().GetElements()) {
if (element is DiagramNode) {
DiagramNode node = (DiagramNode)element;
Debug.Log( " resize delta !!! " + delta);
Debug.Log( " resize !!! " + node.rect);
switch (pos) {
case NodeHandle.POS_TOP_LEFT:
{
Resize (ref node.rect,delta.x, delta.y, -delta.x, -delta.y);
break;
}
case NodeHandle.POS_TOP:{
Resize (ref node.rect,0, delta.y, 0, -delta.y);
break;
}
case NodeHandle.POS_TOP_RIGHT:{
Resize (ref node.rect, 0, delta.y , delta.x, -delta.y);
break;
}
case NodeHandle.POS_LEFT:{
Resize (ref node.rect,delta.x, 0, -delta.x, 0);
break;
}
case NodeHandle.POS_RIGHT:{
Resize (ref node.rect,0, 0, delta.x, 0);
break;
}
case NodeHandle.POS_BOTTOM_LEFT:{
Resize (ref node.rect,delta.x, 0, -delta.x, delta.y);
break;
}
case NodeHandle.POS_BOTTOM:{
Resize (ref node.rect,0, 0, 0, delta.y);
break;
}
case NodeHandle.POS_BOTTOM_RIGHT:{
Resize (ref node.rect,0, 0, delta.x, delta.y);
break;
}
}
}
}
}
}