mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Fixed renaming on group node jittering due to different header heights.
Added new virtual callback 'OnRenameActive()'. Called when rename is first activated.
This commit is contained in:
parent
6e579667b2
commit
47396c06f4
@ -210,6 +210,9 @@ namespace XNodeEditor
|
|||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Called when entering into rename mode for this node. </summary>
|
||||||
|
public virtual void OnRenameActive() {}
|
||||||
|
|
||||||
/// <summary> Called after this node's name has changed. </summary>
|
/// <summary> Called after this node's name has changed. </summary>
|
||||||
public virtual void OnRename() {}
|
public virtual void OnRename() {}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,12 @@ namespace XNodeEditor.NodeGroups
|
|||||||
private NodeGroup _group;
|
private NodeGroup _group;
|
||||||
private bool _isDragging;
|
private bool _isDragging;
|
||||||
private Vector2 _size;
|
private Vector2 _size;
|
||||||
|
private float _currentHeight;
|
||||||
|
|
||||||
|
public override void OnCreate()
|
||||||
|
{
|
||||||
|
_currentHeight = group.height;
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnHeaderGUI()
|
public override void OnHeaderGUI()
|
||||||
{
|
{
|
||||||
@ -29,6 +35,7 @@ namespace XNodeEditor.NodeGroups
|
|||||||
{
|
{
|
||||||
group.width = Mathf.Max(200, (int)e.mousePosition.x + 16);
|
group.width = Mathf.Max(200, (int)e.mousePosition.x + 16);
|
||||||
group.height = Mathf.Max(100, (int)e.mousePosition.y - 34);
|
group.height = Mathf.Max(100, (int)e.mousePosition.y - 34);
|
||||||
|
_currentHeight = group.height;
|
||||||
NodeEditorWindow.current.Repaint();
|
NodeEditorWindow.current.Repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,8 +139,20 @@ namespace XNodeEditor.NodeGroups
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control height of node
|
GUILayout.Space(_currentHeight);
|
||||||
GUILayout.Space(group.height);
|
}
|
||||||
|
|
||||||
|
public override void OnRenameActive()
|
||||||
|
{
|
||||||
|
_currentHeight += 30 - NodeEditorResources.styles.nodeHeaderRename.fixedHeight -
|
||||||
|
NodeEditorResources.styles.nodeHeaderRename.margin.top +
|
||||||
|
NodeEditorResources.styles.nodeHeaderRename.margin.bottom / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void OnRename()
|
||||||
|
{
|
||||||
|
_currentHeight = group.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetWidth()
|
public override int GetWidth()
|
||||||
|
|||||||
@ -38,12 +38,15 @@ namespace XNodeEditor
|
|||||||
input = GUILayout.TextField(input, NodeEditorResources.styles.nodeHeaderRename);
|
input = GUILayout.TextField(input, NodeEditorResources.styles.nodeHeaderRename);
|
||||||
EditorGUI.FocusTextInControl(inputControlName);
|
EditorGUI.FocusTextInControl(inputControlName);
|
||||||
|
|
||||||
// Fixes textfield not being fully selected on multiple consecutive rename activates.
|
|
||||||
if (firstFrame)
|
if (firstFrame)
|
||||||
{
|
{
|
||||||
|
// Fixes textfield not being fully selected on multiple consecutive rename activates.
|
||||||
TextEditor textEditor =
|
TextEditor textEditor =
|
||||||
(TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
|
(TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
|
||||||
textEditor.SelectAll();
|
textEditor.SelectAll();
|
||||||
|
|
||||||
|
NodeEditor.GetEditor((Node)target, NodeEditorWindow.current).OnRenameActive();
|
||||||
|
|
||||||
firstFrame = false;
|
firstFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user