Added support for adding and removing elements from a list
This commit is contained in:
parent
4c01d68f95
commit
d6764b4551
|
@ -181,7 +181,12 @@ namespace SHADE
|
|||
SHEditorUI::Text(Convert::ToNative(field->Name));
|
||||
SHEditorUI::SameLine();
|
||||
|
||||
SHEditorUI::Button("+");
|
||||
if (SHEditorUI::Button("+"))
|
||||
{
|
||||
System::Object^ obj = System::Activator::CreateInstance(listType);
|
||||
iList->Add(obj);
|
||||
registerUndoListAddAction(listType, iList, iList->Count - 1, obj);
|
||||
}
|
||||
|
||||
SHEditorUI::Indent();
|
||||
for (int i = 0; i < iList->Count; ++i)
|
||||
|
@ -195,7 +200,14 @@ namespace SHADE
|
|||
registerUndoListChangeAction(listType, iList, i, obj, oldObj);
|
||||
}
|
||||
SHEditorUI::SameLine();
|
||||
SHEditorUI::Button("-");
|
||||
if (SHEditorUI::Button("-"))
|
||||
{
|
||||
System::Object^ obj = iList[i];
|
||||
iList->RemoveAt(i);
|
||||
registerUndoListRemoveAction(listType, iList, i, obj);
|
||||
SHEditorUI::PopID();
|
||||
break;
|
||||
}
|
||||
SHEditorUI::PopID();
|
||||
}
|
||||
SHEditorUI::Unindent();
|
||||
|
@ -367,6 +379,9 @@ namespace SHADE
|
|||
return;
|
||||
|
||||
actionStack.Add(gcnew ListElementAddCommand(list, index, data));
|
||||
|
||||
// Inform the C++ Undo-Redo stack
|
||||
SHCommandManager::RegisterCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCLICommand>()));
|
||||
}
|
||||
|
||||
void Editor::registerUndoListRemoveAction(System::Type^ type, System::Collections::IList^ list, int index, System::Object^ data)
|
||||
|
@ -375,6 +390,9 @@ namespace SHADE
|
|||
return;
|
||||
|
||||
actionStack.Add(gcnew ListElementRemoveCommand(list, index, data));
|
||||
|
||||
// Inform the C++ Undo-Redo stack
|
||||
SHCommandManager::RegisterCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCLICommand>()));
|
||||
}
|
||||
|
||||
generic<typename Attribute>
|
||||
|
|
Loading…
Reference in New Issue