mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 15:46:17 +00:00
Disable gizmo mode actions when the selected nodes don't allow them
This commit is contained in:
@@ -255,7 +255,8 @@ void CBasicViewport::ProcessInput()
|
||||
}
|
||||
|
||||
if (IsKeyboardInputActive())
|
||||
mCamera.ProcessKeyInput((EKeyInputs) mKeysPressed, DeltaTime);
|
||||
if ((mKeysPressed & eCtrlKey) == 0)
|
||||
mCamera.ProcessKeyInput((EKeyInputs) mKeysPressed, DeltaTime);
|
||||
|
||||
// Update view info
|
||||
const CMatrix4f& View = mCamera.ViewMatrix();
|
||||
|
||||
@@ -149,6 +149,26 @@ CGameArea* CWorldEditor::ActiveArea()
|
||||
}
|
||||
|
||||
// ************ UPDATE UI ************
|
||||
void CWorldEditor::UpdateStatusBar()
|
||||
{
|
||||
// Would be cool to do more frequent status bar updates with more info. Unfortunately, this causes lag.
|
||||
QString StatusText = "";
|
||||
|
||||
if (!mGizmoHovering)
|
||||
{
|
||||
if (ui->MainViewport->underMouse())
|
||||
{
|
||||
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
||||
|
||||
if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
|
||||
StatusText = TO_QSTRING(pHoverNode->Name());
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->statusbar->currentMessage() != StatusText)
|
||||
ui->statusbar->showMessage(StatusText);
|
||||
}
|
||||
|
||||
void CWorldEditor::UpdateGizmoUI()
|
||||
{
|
||||
// Update transform XYZ spin boxes
|
||||
@@ -224,26 +244,6 @@ void CWorldEditor::UpdateSelectionUI()
|
||||
UpdateGizmoUI();
|
||||
}
|
||||
|
||||
void CWorldEditor::UpdateStatusBar()
|
||||
{
|
||||
// Would be cool to do more frequent status bar updates with more info. Unfortunately, this causes lag.
|
||||
QString StatusText = "";
|
||||
|
||||
if (!mGizmoHovering)
|
||||
{
|
||||
if (ui->MainViewport->underMouse())
|
||||
{
|
||||
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
||||
|
||||
if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
|
||||
StatusText = TO_QSTRING(pHoverNode->Name());
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->statusbar->currentMessage() != StatusText)
|
||||
ui->statusbar->showMessage(StatusText);
|
||||
}
|
||||
|
||||
// ************ PROTECTED ************
|
||||
void CWorldEditor::GizmoModeChanged(CGizmo::EGizmoMode mode)
|
||||
{
|
||||
|
||||
@@ -44,9 +44,11 @@ public:
|
||||
CGameArea* ActiveArea();
|
||||
|
||||
// Update UI
|
||||
void UpdateStatusBar();
|
||||
|
||||
public slots:
|
||||
void UpdateGizmoUI();
|
||||
void UpdateSelectionUI();
|
||||
void UpdateStatusBar();
|
||||
|
||||
protected:
|
||||
void GizmoModeChanged(CGizmo::EGizmoMode mode);
|
||||
|
||||
@@ -49,6 +49,7 @@ INodeEditor::INodeEditor(QWidget *pParent)
|
||||
connect(mGizmoActions[2], SIGNAL(triggered()), this, SLOT(OnRotateTriggered()));
|
||||
connect(mGizmoActions[3], SIGNAL(triggered()), this, SLOT(OnScaleTriggered()));
|
||||
connect(mpTransformCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(OnTransformSpaceChanged(int)));
|
||||
connect(this, SIGNAL(SelectionModified()), this, SLOT(OnSelectionModified()));
|
||||
}
|
||||
|
||||
INodeEditor::~INodeEditor()
|
||||
@@ -134,24 +135,18 @@ void INodeEditor::SelectNode(CSceneNode *pNode)
|
||||
{
|
||||
if (!pNode->IsSelected())
|
||||
mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection));
|
||||
|
||||
emit SelectionModified();
|
||||
}
|
||||
|
||||
void INodeEditor::DeselectNode(CSceneNode *pNode)
|
||||
{
|
||||
if (pNode->IsSelected())
|
||||
mUndoStack.push(new CDeselectNodeCommand(this, pNode, mSelection));
|
||||
|
||||
emit SelectionModified();
|
||||
}
|
||||
|
||||
void INodeEditor::ClearSelection()
|
||||
{
|
||||
if (!mSelection.empty())
|
||||
mUndoStack.push(new CClearSelectionCommand(this, mSelection));
|
||||
|
||||
emit SelectionModified();
|
||||
}
|
||||
|
||||
void INodeEditor::ClearAndSelectNode(CSceneNode *pNode)
|
||||
@@ -169,8 +164,6 @@ void INodeEditor::ClearAndSelectNode(CSceneNode *pNode)
|
||||
mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection));
|
||||
mUndoStack.endMacro();
|
||||
}
|
||||
|
||||
emit SelectionModified();
|
||||
}
|
||||
|
||||
// ************ PUBLIC SLOTS ************
|
||||
@@ -204,6 +197,31 @@ void INodeEditor::OnGizmoMoved()
|
||||
UpdateGizmoUI();
|
||||
}
|
||||
|
||||
// ************ PRIVATE ************
|
||||
void INodeEditor::UpdateTransformActionsEnabled()
|
||||
{
|
||||
bool AllowTranslate = true, AllowRotate = true, AllowScale = true;
|
||||
bool SelectedModeWasEnabled = mpGizmoGroup->checkedAction()->isEnabled();
|
||||
|
||||
for (auto it = mSelection.begin(); it != mSelection.end(); it++)
|
||||
{
|
||||
if (!(*it)->AllowsTranslate()) AllowTranslate = false;
|
||||
if (!(*it)->AllowsRotate()) AllowRotate = false;
|
||||
if (!(*it)->AllowsScale()) AllowScale = false;
|
||||
}
|
||||
|
||||
mGizmoActions[1]->setEnabled(AllowTranslate);
|
||||
mGizmoActions[2]->setEnabled(AllowRotate);
|
||||
mGizmoActions[3]->setEnabled(AllowScale);
|
||||
|
||||
bool SelectedModeIsEnabled = mpGizmoGroup->checkedAction()->isEnabled();
|
||||
|
||||
if (SelectedModeWasEnabled && !SelectedModeIsEnabled)
|
||||
OnSelectObjectsTriggered();
|
||||
else if (SelectedModeIsEnabled && !SelectedModeWasEnabled)
|
||||
mpGizmoGroup->checkedAction()->trigger();
|
||||
}
|
||||
|
||||
// ************ PRIVATE SLOTS ************
|
||||
void INodeEditor::OnSelectObjectsTriggered()
|
||||
{
|
||||
@@ -278,3 +296,9 @@ void INodeEditor::OnTransformSpaceChanged(int spaceIndex)
|
||||
|
||||
mGizmo.SetTransformSpace(space);
|
||||
}
|
||||
|
||||
void INodeEditor::OnSelectionModified()
|
||||
{
|
||||
UpdateTransformActionsEnabled();
|
||||
UpdateSelectionUI();
|
||||
}
|
||||
|
||||
@@ -57,25 +57,28 @@ public:
|
||||
void ClearSelection();
|
||||
void ClearAndSelectNode(CSceneNode *pNode);
|
||||
|
||||
virtual void UpdateGizmoUI() = 0;
|
||||
virtual void UpdateSelectionUI() = 0;
|
||||
|
||||
signals:
|
||||
void SelectionModified();
|
||||
void SelectionTransformed();
|
||||
|
||||
public slots:
|
||||
void OnGizmoMoved();
|
||||
virtual void UpdateGizmoUI() = 0;
|
||||
virtual void UpdateSelectionUI() = 0;
|
||||
|
||||
protected:
|
||||
virtual void GizmoModeChanged(CGizmo::EGizmoMode /*mode*/) {}
|
||||
|
||||
private:
|
||||
void UpdateTransformActionsEnabled();
|
||||
|
||||
private slots:
|
||||
void OnSelectObjectsTriggered();
|
||||
void OnTranslateTriggered();
|
||||
void OnRotateTriggered();
|
||||
void OnScaleTriggered();
|
||||
void OnTransformSpaceChanged(int spaceIndex);
|
||||
void OnSelectionModified();
|
||||
};
|
||||
|
||||
#endif // INODEEDITOR_H
|
||||
|
||||
@@ -27,7 +27,7 @@ void CClearSelectionCommand::undo()
|
||||
}
|
||||
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
mpEditor->SelectionModified();
|
||||
}
|
||||
|
||||
void CClearSelectionCommand::redo()
|
||||
@@ -38,5 +38,5 @@ void CClearSelectionCommand::redo()
|
||||
|
||||
mpSelection->clear();
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
mpEditor->SelectionModified();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void CDeselectNodeCommand::undo()
|
||||
}
|
||||
|
||||
mpEditor->ExpandSelectionBounds(mpNode);
|
||||
mpEditor->UpdateSelectionUI();
|
||||
mpEditor->SelectionModified();
|
||||
}
|
||||
|
||||
void CDeselectNodeCommand::redo()
|
||||
@@ -38,5 +38,5 @@ void CDeselectNodeCommand::redo()
|
||||
}
|
||||
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
mpEditor->SelectionModified();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void CSelectNodeCommand::undo()
|
||||
}
|
||||
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
mpEditor->SelectionModified();
|
||||
}
|
||||
|
||||
void CSelectNodeCommand::redo()
|
||||
@@ -38,5 +38,5 @@ void CSelectNodeCommand::redo()
|
||||
}
|
||||
|
||||
mpEditor->ExpandSelectionBounds(mpNode);
|
||||
mpEditor->UpdateSelectionUI();
|
||||
mpEditor->SelectionModified();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user