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)
: 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())

View File

@ -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<QAction*> 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();