0.4.0: Added double-click open to Favorites and History
This commit is contained in:
parent
9b73200c73
commit
d35a79faf1
|
|
@ -5,6 +5,7 @@
|
||||||
None,
|
None,
|
||||||
BeginClick,
|
BeginClick,
|
||||||
PerformedClick,
|
PerformedClick,
|
||||||
|
PerformedDoubleClick,
|
||||||
EndClick,
|
EndClick,
|
||||||
BeginContextClick,
|
BeginContextClick,
|
||||||
PerformedContextClick,
|
PerformedContextClick,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ namespace Game.NavigationTool.Editor.Favorite
|
||||||
public static EManipulatingState manipulatingState;
|
public static EManipulatingState manipulatingState;
|
||||||
public static Vector2 manipulatingMouseOffset;
|
public static Vector2 manipulatingMouseOffset;
|
||||||
public static Rect manipulatingRect;
|
public static Rect manipulatingRect;
|
||||||
|
|
||||||
|
private static Favorites.Entry LAST_CLICK_ENTRY;
|
||||||
|
private static double LAST_CLICK_TIME;
|
||||||
|
private static int CLICK_COUNT;
|
||||||
|
|
||||||
public static Favorites.Entry hoverEntry;
|
public static Favorites.Entry hoverEntry;
|
||||||
|
|
||||||
|
|
@ -40,9 +44,22 @@ namespace Game.NavigationTool.Editor.Favorite
|
||||||
if (manipulatingState == EManipulatingState.BeginClick)
|
if (manipulatingState == EManipulatingState.BeginClick)
|
||||||
{
|
{
|
||||||
if (intersects && Event.current.button == 0)
|
if (intersects && Event.current.button == 0)
|
||||||
SetManipulating(rect, entry, EManipulatingState.PerformedClick);
|
{
|
||||||
|
double dt = EditorApplication.timeSinceStartup - LAST_CLICK_TIME;
|
||||||
|
|
||||||
|
if (dt < 0.3 && CLICK_COUNT == 1 && LAST_CLICK_ENTRY == entry)
|
||||||
|
CLICK_COUNT++;
|
||||||
|
else
|
||||||
|
CLICK_COUNT = 1;
|
||||||
|
|
||||||
|
LAST_CLICK_ENTRY = entry;
|
||||||
|
LAST_CLICK_TIME = EditorApplication.timeSinceStartup;
|
||||||
|
SetManipulating(rect, entry, CLICK_COUNT == 1 ? EManipulatingState.PerformedClick : EManipulatingState.PerformedDoubleClick);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SetManipulating(rect, entry, EManipulatingState.EndClick);
|
SetManipulating(rect, entry, EManipulatingState.EndClick);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (manipulatingState == EManipulatingState.BeginContextClick)
|
else if (manipulatingState == EManipulatingState.BeginContextClick)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,12 @@ namespace Game.NavigationTool.Editor.Favorite
|
||||||
favorites.Save();
|
favorites.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FavoritesGUIUtility.ClearManipulating();
|
||||||
|
break;
|
||||||
|
case EManipulatingState.PerformedDoubleClick:
|
||||||
|
if (entry.isAsset)
|
||||||
|
AssetDatabase.OpenAsset(favorites.GetObject(entry));
|
||||||
|
|
||||||
FavoritesGUIUtility.ClearManipulating();
|
FavoritesGUIUtility.ClearManipulating();
|
||||||
break;
|
break;
|
||||||
case EManipulatingState.BeginDrag:
|
case EManipulatingState.BeginDrag:
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,13 @@ namespace Game.NavigationTool.Editor.History
|
||||||
private static readonly int ENTRY_HASH = "DrawHistoryEntry".GetHashCode();
|
private static readonly int ENTRY_HASH = "DrawHistoryEntry".GetHashCode();
|
||||||
|
|
||||||
public static bool isClicked;
|
public static bool isClicked;
|
||||||
|
public static bool isDoubleClick;
|
||||||
public static HistoryList.Entry currentEntry;
|
public static HistoryList.Entry currentEntry;
|
||||||
|
|
||||||
|
private static HistoryList.Entry LAST_CLICK_ENTRY;
|
||||||
|
private static double LAST_CLICK_TIME;
|
||||||
|
private static int CLICK_COUNT;
|
||||||
|
|
||||||
public static void DrawEntry(Rect rect, HistoryList.Entry entry, Styles styles, bool ignoreIndentLevel = false)
|
public static void DrawEntry(Rect rect, HistoryList.Entry entry, Styles styles, bool ignoreIndentLevel = false)
|
||||||
{
|
{
|
||||||
int id = GUIUtility.GetControlID(ENTRY_HASH, FocusType.Passive, rect);
|
int id = GUIUtility.GetControlID(ENTRY_HASH, FocusType.Passive, rect);
|
||||||
|
|
@ -31,6 +36,24 @@ namespace Game.NavigationTool.Editor.History
|
||||||
{
|
{
|
||||||
isClicked = intersects;
|
isClicked = intersects;
|
||||||
|
|
||||||
|
if (isClicked)
|
||||||
|
{
|
||||||
|
double dt = EditorApplication.timeSinceStartup - LAST_CLICK_TIME;
|
||||||
|
|
||||||
|
if (dt < 0.3 && CLICK_COUNT == 1 && LAST_CLICK_ENTRY == entry)
|
||||||
|
CLICK_COUNT++;
|
||||||
|
else
|
||||||
|
CLICK_COUNT = 1;
|
||||||
|
|
||||||
|
LAST_CLICK_ENTRY = entry;
|
||||||
|
LAST_CLICK_TIME = EditorApplication.timeSinceStartup;
|
||||||
|
isDoubleClick = CLICK_COUNT == 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentEntry = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isClicked)
|
if (!isClicked)
|
||||||
currentEntry = null;
|
currentEntry = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,16 @@ namespace Game.NavigationTool.Editor.History
|
||||||
|
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
HistoryListPostProcess.IgnoreNextSelectionChange();
|
if (HistoryGUIUtility.isDoubleClick)
|
||||||
Selection.activeObject = obj;
|
{
|
||||||
EditorGUIUtility.PingObject(obj);
|
AssetDatabase.OpenAsset(obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HistoryListPostProcess.IgnoreNextSelectionChange();
|
||||||
|
Selection.activeObject = obj;
|
||||||
|
EditorGUIUtility.PingObject(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryGUIUtility.Used();
|
HistoryGUIUtility.Used();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.navigationtool",
|
"name": "com.module.navigationtool",
|
||||||
"version": "0.3.0",
|
"version": "0.4.0",
|
||||||
"displayName": "Module.NavigationTool",
|
"displayName": "Module.NavigationTool",
|
||||||
"description": "Support for navigation tools, like favorites and history",
|
"description": "Support for navigation tools, like favorites and history",
|
||||||
"unity": "2019.2",
|
"unity": "2019.2",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue