Added ability to change camera move speed in World Editor + display position in bottom bar, and WDraggableSpinBox fixes
This commit is contained in:
parent
8280055e21
commit
0ba4b7ddd4
|
@ -7,6 +7,7 @@
|
|||
#include <QOpenGLContext>
|
||||
#include <QFontMetrics>
|
||||
#include <Core/Log.h>
|
||||
#include "WDraggableSpinBox.h"
|
||||
|
||||
#include "WorldEditor/CLayerEditor.h"
|
||||
#include "WorldEditor/WModifyTab.h"
|
||||
|
@ -29,8 +30,6 @@ CWorldEditor::CWorldEditor(QWidget *parent) :
|
|||
mpArea = nullptr;
|
||||
mpWorld = nullptr;
|
||||
mpHoverNode = nullptr;
|
||||
//mpInstanceModel = new CInstanceModel(this);
|
||||
//ui->InstancesTreeView->setModel(mpInstanceModel);
|
||||
mDrawSky = true;
|
||||
|
||||
mFrameCount = 0;
|
||||
|
@ -47,11 +46,16 @@ CWorldEditor::CWorldEditor(QWidget *parent) :
|
|||
|
||||
delete pOldTitleBar;
|
||||
|
||||
ResetHover();
|
||||
|
||||
// Initialize UI stuff
|
||||
ui->ModifyTabContents->SetEditor(this);
|
||||
ui->InstancesTabContents->SetEditor(this, mpSceneManager);
|
||||
ui->MainDock->installEventFilter(this);
|
||||
ui->CamSpeedSpinBox->SetDefaultValue(1.0);
|
||||
ResetHover();
|
||||
|
||||
// Connect signals and slots
|
||||
connect(ui->CamSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnCameraSpeedChange(double)));
|
||||
connect(ui->MainViewport, SIGNAL(PreRender()), this, SLOT(ViewportPreRender()));
|
||||
connect(ui->MainViewport, SIGNAL(Render(CCamera&)), this, SLOT(ViewportRender(CCamera&)));
|
||||
connect(ui->MainViewport, SIGNAL(ViewportResized(int,int)), this, SLOT(SetViewportSize(int,int)));
|
||||
|
@ -362,9 +366,25 @@ void CWorldEditor::UpdateSelectionUI()
|
|||
QFontMetrics Metrics(ui->SelectionInfoLabel->font());
|
||||
SelectionText = Metrics.elidedText(SelectionText, Qt::ElideRight, ui->SelectionInfoFrame->width() - 10);
|
||||
ui->SelectionInfoLabel->setText(SelectionText);
|
||||
|
||||
// Update transform
|
||||
CVector3f pos = (!mSelectedNodes.empty() ? mSelectedNodes.front()->GetAbsolutePosition() : CVector3f::skZero);
|
||||
ui->XSpinBox->setValue(pos.x);
|
||||
ui->YSpinBox->setValue(pos.y);
|
||||
ui->ZSpinBox->setValue(pos.z);
|
||||
}
|
||||
|
||||
// ************ ACTIONS ************
|
||||
void CWorldEditor::OnCameraSpeedChange(double speed)
|
||||
{
|
||||
static const double skDefaultSpeed = 1.0;
|
||||
ui->MainViewport->Camera().SetMoveSpeed(skDefaultSpeed * speed);
|
||||
|
||||
ui->CamSpeedSpinBox->blockSignals(true);
|
||||
ui->CamSpeedSpinBox->setValue(speed);
|
||||
ui->CamSpeedSpinBox->blockSignals(false);
|
||||
}
|
||||
|
||||
// These functions are from "Go to slot" in the designer
|
||||
void CWorldEditor::on_ActionDrawWorld_triggered()
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ private:
|
|||
void UpdateStatusBar();
|
||||
|
||||
private slots:
|
||||
void OnCameraSpeedChange(double speed);
|
||||
void on_ActionDrawWorld_triggered();
|
||||
void on_ActionDrawCollision_triggered();
|
||||
void on_ActionDrawObjects_triggered();
|
||||
|
|
|
@ -38,12 +38,6 @@
|
|||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<zorder>YLabel</zorder>
|
||||
<zorder>YSpinBox</zorder>
|
||||
<zorder>XSpinBox</zorder>
|
||||
<zorder>XLabel</zorder>
|
||||
<zorder>ZSpinBox</zorder>
|
||||
<zorder>ZLabel</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -158,6 +152,9 @@
|
|||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
|
@ -199,6 +196,9 @@
|
|||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
|
@ -240,6 +240,9 @@
|
|||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
|
@ -278,6 +281,9 @@
|
|||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
||||
{
|
||||
mBeingDragged = false;
|
||||
mDefaultValue = value();
|
||||
mDefaultValue = 0;
|
||||
setMinimum(-1000000.0);
|
||||
setMaximum(1000000.0);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ void WDraggableSpinBox::mousePressEvent(QMouseEvent*)
|
|||
void WDraggableSpinBox::mouseReleaseEvent(QMouseEvent *Event)
|
||||
{
|
||||
mBeingDragged = false;
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
if (Event->button() == Qt::LeftButton)
|
||||
{
|
||||
|
@ -35,11 +36,6 @@ void WDraggableSpinBox::mouseReleaseEvent(QMouseEvent *Event)
|
|||
else
|
||||
stepDown();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
|
||||
else if (Event->button() == Qt::RightButton)
|
||||
|
@ -83,3 +79,13 @@ void WDraggableSpinBox::wheelEvent(QWheelEvent *pEvent)
|
|||
if (!hasFocus()) pEvent->ignore();
|
||||
else QDoubleSpinBox::wheelEvent(pEvent);
|
||||
}
|
||||
|
||||
void WDraggableSpinBox::contextMenuEvent(QContextMenuEvent *pEvent)
|
||||
{
|
||||
pEvent->ignore();
|
||||
}
|
||||
|
||||
void WDraggableSpinBox::SetDefaultValue(double value)
|
||||
{
|
||||
mDefaultValue = value;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
void mouseReleaseEvent(QMouseEvent *pEvent);
|
||||
void mouseMoveEvent(QMouseEvent *pEvent);
|
||||
void wheelEvent(QWheelEvent *pEvent);
|
||||
void contextMenuEvent(QContextMenuEvent *pEvent);
|
||||
void SetDefaultValue(double value);
|
||||
};
|
||||
|
||||
#endif // WDRAGGABLESPINBOX_H
|
||||
|
|
|
@ -40,6 +40,9 @@ WVectorEditor::WVectorEditor(const CVector3f& Value, QWidget *pParent) : QWidget
|
|||
mpSpinBoxX = new WDraggableSpinBox(this);
|
||||
mpSpinBoxY = new WDraggableSpinBox(this);
|
||||
mpSpinBoxZ = new WDraggableSpinBox(this);
|
||||
mpSpinBoxX->setDecimals(4);
|
||||
mpSpinBoxX->setDecimals(4);
|
||||
mpSpinBoxX->setDecimals(4);
|
||||
mpSpinBoxX->setValue((double) Value.x);
|
||||
mpSpinBoxY->setValue((double) Value.y);
|
||||
mpSpinBoxZ->setValue((double) Value.z);
|
||||
|
|
Loading…
Reference in New Issue