Add preserving selection of the created new folder in the Content window
This commit is contained in:
@@ -235,8 +235,9 @@ namespace FlaxEditor.Content.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="items">The items to show.</param>
|
/// <param name="items">The items to show.</param>
|
||||||
/// <param name="sortType">The sort method for items.</param>
|
/// <param name="sortType">The sort method for items.</param>
|
||||||
/// <param name="additive">If set to <c>true</c> items will be added to the current selection. Otherwise selection will be cleared before.</param>
|
/// <param name="additive">If set to <c>true</c> items will be added to the current list. Otherwise items list will be cleared before.</param>
|
||||||
public void ShowItems(List<ContentItem> items, SortType sortType, bool additive = false)
|
/// <param name="keepSelection">If set to <c>true</c> selected items list will be preserved. Otherwise selection will be cleared before.</param>
|
||||||
|
public void ShowItems(List<ContentItem> items, SortType sortType, bool additive = false, bool keepSelection = false)
|
||||||
{
|
{
|
||||||
if (items == null)
|
if (items == null)
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
@@ -253,6 +254,7 @@ namespace FlaxEditor.Content.GUI
|
|||||||
// Lock layout
|
// Lock layout
|
||||||
var wasLayoutLocked = IsLayoutLocked;
|
var wasLayoutLocked = IsLayoutLocked;
|
||||||
IsLayoutLocked = true;
|
IsLayoutLocked = true;
|
||||||
|
var selection = !additive && keepSelection ? _selection.ToArray() : null;
|
||||||
|
|
||||||
// Deselect items if need to
|
// Deselect items if need to
|
||||||
if (!additive)
|
if (!additive)
|
||||||
@@ -265,6 +267,11 @@ namespace FlaxEditor.Content.GUI
|
|||||||
items[i].Parent = this;
|
items[i].Parent = this;
|
||||||
items[i].AddReference(this);
|
items[i].AddReference(this);
|
||||||
}
|
}
|
||||||
|
if (selection != null)
|
||||||
|
{
|
||||||
|
_selection.Clear();
|
||||||
|
_selection.AddRange(selection);
|
||||||
|
}
|
||||||
|
|
||||||
// Sort items depending on sortMethod parameter
|
// Sort items depending on sortMethod parameter
|
||||||
_children.Sort(((control, control1) =>
|
_children.Sort(((control, control1) =>
|
||||||
|
|||||||
@@ -739,12 +739,12 @@ namespace FlaxEditor.Windows
|
|||||||
items.Add(node.Folder);
|
items.Add(node.Folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_view.ShowItems(items, _sortType);
|
_view.ShowItems(items, _sortType, false, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Show folder contents
|
// Show folder contents
|
||||||
_view.ShowItems(target.Folder.Children, _sortType);
|
_view.ShowItems(target.Folder.Children, _sortType, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user