INodeEditor: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 06:39:55 -04:00
parent e839c0c70c
commit 0ef016256a
2 changed files with 33 additions and 32 deletions

View File

@ -5,15 +5,7 @@
INodeEditor::INodeEditor(QWidget *pParent) INodeEditor::INodeEditor(QWidget *pParent)
: IEditor(pParent) : IEditor(pParent)
, mPickMode(false)
, mpSelection(new CNodeSelection) , mpSelection(new CNodeSelection)
, mSelectionLocked(false)
, mShowGizmo(false)
, mGizmoHovering(false)
, mGizmoTransforming(false)
, mTranslateSpace(ETransformSpace::World)
, mRotateSpace(ETransformSpace::World)
, mCloneState(eNotCloning)
{ {
// Create gizmo actions // Create gizmo actions
mGizmoActions.append(new QAction(QIcon(":/icons/SelectMode.svg"), "Select Objects", this)); mGizmoActions.append(new QAction(QIcon(":/icons/SelectMode.svg"), "Select Objects", this));
@ -73,7 +65,8 @@ bool INodeEditor::IsGizmoVisible()
void INodeEditor::BeginGizmoTransform() void INodeEditor::BeginGizmoTransform()
{ {
mGizmoTransforming = true; mGizmoTransforming = true;
if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0) mCloneState = eReadyToClone; if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0)
mCloneState = ECloneState::ReadyToClone;
foreach (QAction *pAction, mGizmoActions) foreach (QAction *pAction, mGizmoActions)
pAction->setEnabled(false); pAction->setEnabled(false);
@ -96,10 +89,10 @@ void INodeEditor::EndGizmoTransform()
mUndoStack.push(CScaleNodeCommand::End()); mUndoStack.push(CScaleNodeCommand::End());
} }
if (mCloneState == eCloning) if (mCloneState == ECloneState::Cloning)
mUndoStack.endMacro(); mUndoStack.endMacro();
mCloneState = eNotCloning; mCloneState = ECloneState::NotCloning;
} }
ETransformSpace INodeEditor::CurrentTransformSpace() ETransformSpace INodeEditor::CurrentTransformSpace()
@ -298,11 +291,11 @@ void INodeEditor::OnSelectionModified()
void INodeEditor::OnGizmoMoved() void INodeEditor::OnGizmoMoved()
{ {
if (mCloneState == eReadyToClone) if (mCloneState == ECloneState::ReadyToClone)
{ {
mUndoStack.beginMacro("Clone"); mUndoStack.beginMacro("Clone");
mUndoStack.push(new CCloneSelectionCommand(this)); mUndoStack.push(new CCloneSelectionCommand(this));
mCloneState = eCloning; mCloneState = ECloneState::Cloning;
} }
switch (mGizmo.Mode()) switch (mGizmo.Mode())

View File

@ -18,38 +18,46 @@ class INodeEditor : public IEditor
Q_OBJECT Q_OBJECT
protected: protected:
enum class ECloneState
{
NotCloning,
ReadyToClone,
Cloning
};
// Node management // Node management
CScene mScene; CScene mScene;
CNodeSelection *mpSelection; CNodeSelection *mpSelection;
bool mSelectionLocked; bool mSelectionLocked = false;
// Gizmo // Gizmo
CGizmo mGizmo; CGizmo mGizmo;
bool mShowGizmo; bool mShowGizmo = false;
bool mGizmoHovering; bool mGizmoHovering = false;
bool mGizmoTransforming; bool mGizmoTransforming = false;
ETransformSpace mTranslateSpace; ETransformSpace mTranslateSpace{ETransformSpace::World};
ETransformSpace mRotateSpace; ETransformSpace mRotateSpace{ETransformSpace::World};
enum { eNotCloning, eReadyToClone, eCloning } mCloneState; ECloneState mCloneState{ECloneState::NotCloning};
// Gizmo widgets // Gizmo widgets
QActionGroup *mpGizmoGroup; QActionGroup *mpGizmoGroup = nullptr;
QList<QAction*> mGizmoActions; QList<QAction*> mGizmoActions;
QComboBox *mpTransformCombo; QComboBox *mpTransformCombo = nullptr;
// Pick mode // Pick mode
bool mPickMode; bool mPickMode = false;
bool mExitOnInvalidPick; bool mExitOnInvalidPick = false;
bool mEmitOnInvalidPick; bool mEmitOnInvalidPick = false;
bool mEmitOnButtonPress; bool mEmitOnButtonPress = false;
FNodeFlags mAllowedPickNodes; FNodeFlags mAllowedPickNodes{};
CSceneNode *mpPickHoverNode; CSceneNode *mpPickHoverNode = nullptr;
Qt::MouseButtons mPickButtons; Qt::MouseButtons mPickButtons{};
Qt::KeyboardModifiers mPickModifiers; Qt::KeyboardModifiers mPickModifiers{};
public: public:
explicit INodeEditor(QWidget *pParent = 0); explicit INodeEditor(QWidget *pParent = nullptr);
virtual ~INodeEditor(); ~INodeEditor() override;
CScene* Scene(); CScene* Scene();
CGizmo* Gizmo(); CGizmo* Gizmo();
bool IsGizmoVisible(); bool IsGizmoVisible();