Browse Source

PopupSelectors now show tooltips from Event and Command HelpText

master
desktop-maesty/steve 6 years ago
parent
commit
6734ade8bb
  1. 37
      Assets/Fungus/Scripts/Editor/BasePopupWindowContent.cs
  2. 2
      Assets/Fungus/Scripts/Editor/CommandSelectorPopupWindowContent.cs
  3. 4
      Assets/Fungus/Scripts/Editor/EventSelectorPopupWindowContent.cs

37
Assets/Fungus/Scripts/Editor/BasePopupWindowContent.cs

@ -20,27 +20,34 @@ namespace Fungus.EditorUtils
abstract protected void SelectByOrigIndex(int index);
/// <summary>
/// Called during Base Ctor, so that all
/// Called during Base Ctor, must fill allItems list so the ctor can continue to fill
/// the visible items and current selected index.
/// </summary>
abstract protected void PrepareAllItems();
/// <summary>
/// Internal representation of 1 row of our popup list
/// </summary>
public class FilteredListItem
{
public FilteredListItem(int index, string str)
public FilteredListItem(int index, string str, string tip = "")
{
origIndex = index;
name = str;
lowerName = str.ToLowerInvariant();
content = new GUIContent(str, tip);
}
public int origIndex;
public string name, lowerName;
public GUIContent content;
}
protected Block block;
protected int hoverIndex;
protected readonly string SEARCH_CONTROL_NAME = "PopupSearchControlName";
protected readonly float ROW_HEIGHT = EditorGUIUtility.singleLineHeight;
protected List<FilteredListItem> allItems = new List<FilteredListItem>(), visibleItems = new List<FilteredListItem>();
protected List<FilteredListItem> allItems = new List<FilteredListItem>(),
visibleItems = new List<FilteredListItem>();
protected string currentFilter = string.Empty;
protected Vector2 scroll;
protected int scrollToIndex;
@ -57,9 +64,10 @@ namespace Fungus.EditorUtils
PrepareAllItems();
allItems.Sort((lhs, rhs) => lhs.name.CompareTo(rhs.name));
allItems.Sort((lhs, rhs) => lhs.lowerName.CompareTo(rhs.lowerName));
UpdateFilter();
currentIndex = Mathf.Max(0, visibleItems.FindIndex(x=>x.name.Contains(currentHandlerName)));
hoverIndex = currentIndex;
}
public override void OnGUI(Rect rect)
@ -153,7 +161,16 @@ namespace Fungus.EditorUtils
{
if (Event.current.type == EventType.MouseMove ||
Event.current.type == EventType.ScrollWheel)
{
//if new item force update so it's snappier
if (hoverIndex != 1)
{
this.editorWindow.Repaint();
}
hoverIndex = i;
}
if (Event.current.type == EventType.MouseDown)
{
//onSelectionMade(list.Entries[i].Index);
@ -188,7 +205,7 @@ namespace Fungus.EditorUtils
Rect labelRect = new Rect(rowRect);
//labelRect.xMin += ROW_INDENT;
GUI.Label(labelRect, visibleItems[i].name);
GUI.Label(labelRect, visibleItems[i].content);
}
/// <summary>
@ -231,11 +248,11 @@ namespace Fungus.EditorUtils
}
protected void SelectByName(string name)
{
var loc = allItems.FindIndex(x => x.name == name);
SelectByOrigIndex(loc);
}
//protected void SelectByName(string name)
//{
// var loc = allItems.FindIndex(x => x.name == name);
// SelectByOrigIndex(loc);
//}
}
}

2
Assets/Fungus/Scripts/Editor/CommandSelectorPopupWindowContent.cs

@ -58,7 +58,7 @@ namespace Fungus.EditorUtils
int i = 0;
foreach (var item in filteredAttributes)
{
allItems.Add(new FilteredListItem(i, (item.Value.Category.Length > 0 ? item.Value.Category + "/" : "") + item.Value.CommandName));
allItems.Add(new FilteredListItem(i, (item.Value.Category.Length > 0 ? item.Value.Category + "/" : "") + item.Value.CommandName, item.Value.HelpText));
i++;
}

4
Assets/Fungus/Scripts/Editor/EventSelectorPopupWindowContent.cs

@ -51,11 +51,11 @@ namespace Fungus.EditorUtils
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
if (info != null)
{
allItems.Add(new FilteredListItem(i, (info.Category.Length > 0 ? info.Category + "/" : "") + info.EventHandlerName));
allItems.Add(new FilteredListItem(i, (info.Category.Length > 0 ? info.Category + "/" : "") + info.EventHandlerName, info.HelpText));
}
else
{
allItems.Add(new FilteredListItem(i, type.Name));
allItems.Add(new FilteredListItem(i, type.Name, info.HelpText));
}
i++;

Loading…
Cancel
Save