Add collection item duplication.
This commit is contained in:
@@ -70,7 +70,9 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
menu.ItemsContainer.RemoveChildren();
|
menu.ItemsContainer.RemoveChildren();
|
||||||
|
|
||||||
menu.AddButton("Copy", linkedEditor.Copy);
|
menu.AddButton("Copy", linkedEditor.Copy);
|
||||||
var b = menu.AddButton("Paste", linkedEditor.Paste);
|
var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
|
||||||
|
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||||
|
b = menu.AddButton("Paste", linkedEditor.Paste);
|
||||||
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||||
|
|
||||||
menu.AddSeparator();
|
menu.AddSeparator();
|
||||||
@@ -404,8 +406,10 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
|
|
||||||
menu.AddButton("Copy", linkedEditor.Copy);
|
menu.AddButton("Copy", linkedEditor.Copy);
|
||||||
|
var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
|
||||||
|
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||||
var paste = menu.AddButton("Paste", linkedEditor.Paste);
|
var paste = menu.AddButton("Paste", linkedEditor.Paste);
|
||||||
paste.Enabled = linkedEditor.CanPaste;
|
paste.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||||
|
|
||||||
if (_canReorder)
|
if (_canReorder)
|
||||||
{
|
{
|
||||||
@@ -741,6 +745,25 @@ namespace FlaxEditor.CustomEditors.Editors
|
|||||||
cloned[srcIndex] = tmp;
|
cloned[srcIndex] = tmp;
|
||||||
SetValue(cloned);
|
SetValue(cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Duplicates the list item.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The index to duplicate.</param>
|
||||||
|
public void Duplicate(int index)
|
||||||
|
{
|
||||||
|
if (IsSetBlocked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var count = Count;
|
||||||
|
Resize(count + 1);
|
||||||
|
RefreshInternal(); // Force update values.
|
||||||
|
Shift(count, index + 1);
|
||||||
|
RefreshInternal(); // Force update values.
|
||||||
|
var cloned = CloneValues();
|
||||||
|
cloned[index + 1] = Utilities.Utils.CloneValue(cloned[index]);
|
||||||
|
SetValue(cloned);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shifts the specified item at the given index and moves it through the list to the other item. It supports undo.
|
/// Shifts the specified item at the given index and moves it through the list to the other item. It supports undo.
|
||||||
|
|||||||
Reference in New Issue
Block a user