From 0ef016256a01d6b591e93385f42936ac2dc6de60 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 06:39:55 -0400 Subject: [PATCH] INodeEditor: Make use of in-class initializers where applicable --- src/Editor/INodeEditor.cpp | 19 +++++----------- src/Editor/INodeEditor.h | 46 ++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/Editor/INodeEditor.cpp b/src/Editor/INodeEditor.cpp index fd76830d..3cbaa0e5 100644 --- a/src/Editor/INodeEditor.cpp +++ b/src/Editor/INodeEditor.cpp @@ -5,15 +5,7 @@ INodeEditor::INodeEditor(QWidget *pParent) : IEditor(pParent) - , mPickMode(false) , mpSelection(new CNodeSelection) - , mSelectionLocked(false) - , mShowGizmo(false) - , mGizmoHovering(false) - , mGizmoTransforming(false) - , mTranslateSpace(ETransformSpace::World) - , mRotateSpace(ETransformSpace::World) - , mCloneState(eNotCloning) { // Create gizmo actions mGizmoActions.append(new QAction(QIcon(":/icons/SelectMode.svg"), "Select Objects", this)); @@ -73,7 +65,8 @@ bool INodeEditor::IsGizmoVisible() void INodeEditor::BeginGizmoTransform() { mGizmoTransforming = true; - if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0) mCloneState = eReadyToClone; + if ((qApp->keyboardModifiers() & Qt::ShiftModifier) != 0) + mCloneState = ECloneState::ReadyToClone; foreach (QAction *pAction, mGizmoActions) pAction->setEnabled(false); @@ -96,10 +89,10 @@ void INodeEditor::EndGizmoTransform() mUndoStack.push(CScaleNodeCommand::End()); } - if (mCloneState == eCloning) + if (mCloneState == ECloneState::Cloning) mUndoStack.endMacro(); - mCloneState = eNotCloning; + mCloneState = ECloneState::NotCloning; } ETransformSpace INodeEditor::CurrentTransformSpace() @@ -298,11 +291,11 @@ void INodeEditor::OnSelectionModified() void INodeEditor::OnGizmoMoved() { - if (mCloneState == eReadyToClone) + if (mCloneState == ECloneState::ReadyToClone) { mUndoStack.beginMacro("Clone"); mUndoStack.push(new CCloneSelectionCommand(this)); - mCloneState = eCloning; + mCloneState = ECloneState::Cloning; } switch (mGizmo.Mode()) diff --git a/src/Editor/INodeEditor.h b/src/Editor/INodeEditor.h index d6f08319..69ad83e1 100644 --- a/src/Editor/INodeEditor.h +++ b/src/Editor/INodeEditor.h @@ -18,38 +18,46 @@ class INodeEditor : public IEditor Q_OBJECT protected: + enum class ECloneState + { + NotCloning, + ReadyToClone, + Cloning + }; + // Node management CScene mScene; CNodeSelection *mpSelection; - bool mSelectionLocked; + bool mSelectionLocked = false; // Gizmo CGizmo mGizmo; - bool mShowGizmo; - bool mGizmoHovering; - bool mGizmoTransforming; - ETransformSpace mTranslateSpace; - ETransformSpace mRotateSpace; - enum { eNotCloning, eReadyToClone, eCloning } mCloneState; + bool mShowGizmo = false; + bool mGizmoHovering = false; + bool mGizmoTransforming = false; + ETransformSpace mTranslateSpace{ETransformSpace::World}; + ETransformSpace mRotateSpace{ETransformSpace::World}; + ECloneState mCloneState{ECloneState::NotCloning}; // Gizmo widgets - QActionGroup *mpGizmoGroup; + QActionGroup *mpGizmoGroup = nullptr; QList mGizmoActions; - QComboBox *mpTransformCombo; + QComboBox *mpTransformCombo = nullptr; // Pick mode - bool mPickMode; - bool mExitOnInvalidPick; - bool mEmitOnInvalidPick; - bool mEmitOnButtonPress; - FNodeFlags mAllowedPickNodes; - CSceneNode *mpPickHoverNode; - Qt::MouseButtons mPickButtons; - Qt::KeyboardModifiers mPickModifiers; + bool mPickMode = false; + bool mExitOnInvalidPick = false; + bool mEmitOnInvalidPick = false; + bool mEmitOnButtonPress = false; + FNodeFlags mAllowedPickNodes{}; + CSceneNode *mpPickHoverNode = nullptr; + Qt::MouseButtons mPickButtons{}; + Qt::KeyboardModifiers mPickModifiers{}; public: - explicit INodeEditor(QWidget *pParent = 0); - virtual ~INodeEditor(); + explicit INodeEditor(QWidget *pParent = nullptr); + ~INodeEditor() override; + CScene* Scene(); CGizmo* Gizmo(); bool IsGizmoVisible();