mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-13 23:26:19 +00:00
Split off lots of editor functionality into new abstract INodeEditor class and viewport functionality into CBasicViewport class; added viewport subclasses and undo/redo system in the World Editor
This commit is contained in:
42
UI/undo/CDeselectNodeCommand.cpp
Normal file
42
UI/undo/CDeselectNodeCommand.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "CDeselectNodeCommand.h"
|
||||
#include "../CWorldEditor.h"
|
||||
|
||||
CDeselectNodeCommand::CDeselectNodeCommand(INodeEditor *pEditor, CSceneNode *pNode, QList<CSceneNode*>& selection)
|
||||
: QUndoCommand("Deselect"),
|
||||
mpEditor(pEditor),
|
||||
mpNode(pNode),
|
||||
mpSelection(&selection)
|
||||
{
|
||||
}
|
||||
|
||||
void CDeselectNodeCommand::undo()
|
||||
{
|
||||
if (!mpNode->IsSelected())
|
||||
{
|
||||
mpNode->SetSelected(true);
|
||||
mpSelection->push_back(mpNode);
|
||||
}
|
||||
|
||||
mpEditor->ExpandSelectionBounds(mpNode);
|
||||
mpEditor->UpdateSelectionUI();
|
||||
}
|
||||
|
||||
void CDeselectNodeCommand::redo()
|
||||
{
|
||||
if (mpNode->IsSelected())
|
||||
{
|
||||
mpNode->SetSelected(false);
|
||||
|
||||
for (auto it = mpSelection->begin(); it != mpSelection->end(); it++)
|
||||
{
|
||||
if (*it == mpNode)
|
||||
{
|
||||
mpSelection->erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
}
|
||||
Reference in New Issue
Block a user