- Implemented filtering by group by using a dot as a seperator
- Added type sort priority to context sensitive search - Now updating filters when populating groups for the first time in order to make sort priority actually work when opening context menu for the first time - Fixed some cases where context sensitivity was applied even when context sensitive search was disabled
This commit is contained in:
@@ -307,7 +307,10 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
if (!IsLayoutLocked)
|
if (!IsLayoutLocked)
|
||||||
{
|
{
|
||||||
group.UnlockChildrenRecursive();
|
group.UnlockChildrenRecursive();
|
||||||
SortGroups();
|
if(_contextSensitiveSearchEnabled && _selectedBox != null)
|
||||||
|
UpdateFilters();
|
||||||
|
else
|
||||||
|
SortGroups();
|
||||||
if (ShowExpanded)
|
if (ShowExpanded)
|
||||||
group.Open(false);
|
group.Open(false);
|
||||||
group.PerformLayout();
|
group.PerformLayout();
|
||||||
@@ -367,7 +370,10 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
|
|
||||||
if (!isLayoutLocked)
|
if (!isLayoutLocked)
|
||||||
{
|
{
|
||||||
SortGroups();
|
if(_contextSensitiveSearchEnabled && _selectedBox != null)
|
||||||
|
UpdateFilters();
|
||||||
|
else
|
||||||
|
SortGroups();
|
||||||
Profiler.BeginEvent("Perform Layout");
|
Profiler.BeginEvent("Perform Layout");
|
||||||
UnlockChildrenRecursive();
|
UnlockChildrenRecursive();
|
||||||
foreach (var group in groups)
|
foreach (var group in groups)
|
||||||
@@ -482,10 +488,11 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
|
|
||||||
// Update groups
|
// Update groups
|
||||||
LockChildrenRecursive();
|
LockChildrenRecursive();
|
||||||
|
var contextSensitiveSelectedBox = _contextSensitiveSearchEnabled ? _selectedBox : null;
|
||||||
for (int i = 0; i < _groups.Count; i++)
|
for (int i = 0; i < _groups.Count; i++)
|
||||||
{
|
{
|
||||||
_groups[i].UpdateFilter(_searchBox.Text, _contextSensitiveSearchEnabled ? _selectedBox : null);
|
_groups[i].UpdateFilter(_searchBox.Text, contextSensitiveSelectedBox);
|
||||||
_groups[i].UpdateItemSort(_selectedBox);
|
_groups[i].UpdateItemSort(contextSensitiveSelectedBox);
|
||||||
}
|
}
|
||||||
SortGroups();
|
SortGroups();
|
||||||
UnlockChildrenRecursive();
|
UnlockChildrenRecursive();
|
||||||
@@ -560,7 +567,10 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
}
|
}
|
||||||
UnlockChildrenRecursive();
|
UnlockChildrenRecursive();
|
||||||
|
|
||||||
SortGroups();
|
if(_contextSensitiveSearchEnabled && _selectedBox != null)
|
||||||
|
UpdateFilters();
|
||||||
|
else
|
||||||
|
SortGroups();
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
|
|
||||||
Profiler.EndEvent();
|
Profiler.EndEvent();
|
||||||
|
|||||||
@@ -88,6 +88,25 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
public void UpdateFilter(string filterText, Box selectedBox)
|
public void UpdateFilter(string filterText, Box selectedBox)
|
||||||
{
|
{
|
||||||
Profiler.BeginEvent("VisjectCMGroup.UpdateFilter");
|
Profiler.BeginEvent("VisjectCMGroup.UpdateFilter");
|
||||||
|
|
||||||
|
// Check if a dot is inside the filter text and split the string accordingly.
|
||||||
|
// Everything in front of the dot is for specifying a class/group name. And everything afterward is the actual item filter text
|
||||||
|
if (!string.IsNullOrEmpty(filterText))
|
||||||
|
{
|
||||||
|
int dotIndex = filterText.IndexOf('.');
|
||||||
|
if (dotIndex != -1)
|
||||||
|
{
|
||||||
|
// Early out and make the group invisible if it doesn't start with the specified string
|
||||||
|
string filterGroupName = filterText.Substring(0, dotIndex);
|
||||||
|
if (!Name.StartsWith(filterGroupName, StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Visible = false;
|
||||||
|
Profiler.EndEvent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
filterText = filterText.Substring(dotIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update items
|
// Update items
|
||||||
bool isAnyVisible = false;
|
bool isAnyVisible = false;
|
||||||
@@ -177,6 +196,13 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
SortScore = item.SortScore;
|
SortScore = item.SortScore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedBox != null)
|
||||||
|
{
|
||||||
|
if (string.Equals(Name, selectedBox.CurrentType.Name, StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
SortScore += 10;
|
||||||
|
}
|
||||||
|
|
||||||
SortChildren();
|
SortChildren();
|
||||||
|
|
||||||
Profiler.EndEvent();
|
Profiler.EndEvent();
|
||||||
|
|||||||
Reference in New Issue
Block a user