diff --git a/UI/CWorldEditor.ui b/UI/CWorldEditor.ui
index 0c504301..6c499258 100644
--- a/UI/CWorldEditor.ui
+++ b/UI/CWorldEditor.ui
@@ -14,7 +14,10 @@
Prime World Editor
-
+
+
+ 0
+
0
@@ -28,7 +31,290 @@
0
-
-
+
+
+
+ 0
+ 1
+
+
+ YLabel
+ YSpinBox
+ XSpinBox
+ XLabel
+ ZSpinBox
+ ZLabel
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Plain
+
+
+
+ 3
+
+
+ 3
+
+
+ 3
+
+
+ 3
+
+
-
+
+
+
+ 200
+ 0
+
+
+
+
+ 200
+ 16777215
+
+
+
+ QFrame::Panel
+
+
+ QFrame::Sunken
+
+
+ 1
+
+
+ 0
+
+
+
+ 3
+
+
+ 3
+
+
+ 3
+
+
+ 3
+
+
-
+
+
+ QFrame::Plain
+
+
+ 1
+
+
+ 0
+
+
+
+
+
+
+
+
+
+ -
+
+
+ X:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 70
+ 0
+
+
+
+
+ 70
+ 16777215
+
+
+
+ 4
+
+
+ -1000000.000000000000000
+
+
+ 1000000.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ Y:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 60
+ 0
+
+
+
+
+ 70
+ 16777215
+
+
+
+ 4
+
+
+ -1000000.000000000000000
+
+
+ 1000000.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ Z:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 60
+ 0
+
+
+
+
+ 70
+ 16777215
+
+
+
+ 4
+
+
+ -1000000.000000000000000
+
+
+ 1000000.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ -
+
+
-
+
+
+ Speed:
+
+
+
+ -
+
+
+
+ 50
+ 16777215
+
+
+
+ true
+
+
+ QAbstractSpinBox::CorrectToNearestValue
+
+
+ 0.010000000000000
+
+
+ 10.000000000000000
+
+
+ 0.100000000000000
+
+
+ 1.000000000000000
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
@@ -143,52 +429,6 @@
- -
-
-
- QFrame::Panel
-
-
- QFrame::Sunken
-
-
- 1
-
-
- 0
-
-
-
- 3
-
-
- 3
-
-
- 3
-
-
- 3
-
-
-
-
-
- QFrame::Plain
-
-
- 1
-
-
- 0
-
-
-
-
-
-
-
-
-
-
@@ -609,6 +849,11 @@
WorldEditor/WInstancesTab.h
1
+
+ WDraggableSpinBox
+ QDoubleSpinBox
+
+
diff --git a/UI/WDraggableSpinBox.cpp b/UI/WDraggableSpinBox.cpp
index d2060d93..61b0b91d 100644
--- a/UI/WDraggableSpinBox.cpp
+++ b/UI/WDraggableSpinBox.cpp
@@ -1,6 +1,7 @@
#include "WDraggableSpinBox.h"
-#include
+#include
#include
+#include
WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
{
@@ -8,19 +9,17 @@ WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
mDefaultValue = value();
setMinimum(-1000000.0);
setMaximum(1000000.0);
- setDecimals(4);
}
WDraggableSpinBox::~WDraggableSpinBox()
{
}
-void WDraggableSpinBox::mousePressEvent(QMouseEvent *Event)
+void WDraggableSpinBox::mousePressEvent(QMouseEvent*)
{
mBeingDragged = true;
mBeenDragged = false;
- mInitialY = Event->y();
- mInitialValue = value();
+ mLastY = QCursor::pos().y();
}
void WDraggableSpinBox::mouseReleaseEvent(QMouseEvent *Event)
@@ -36,6 +35,11 @@ void WDraggableSpinBox::mouseReleaseEvent(QMouseEvent *Event)
else
stepDown();
}
+
+ else
+ {
+ setCursor(Qt::ArrowCursor);
+ }
}
else if (Event->button() == Qt::RightButton)
@@ -44,12 +48,32 @@ void WDraggableSpinBox::mouseReleaseEvent(QMouseEvent *Event)
}
}
-void WDraggableSpinBox::mouseMoveEvent(QMouseEvent *Event)
+void WDraggableSpinBox::mouseMoveEvent(QMouseEvent*)
{
if (mBeingDragged)
{
- double DragAmount = (singleStep() / 10.0) * (mInitialY - Event->y());
- setValue(mInitialValue + DragAmount);
- if (DragAmount != 0) mBeenDragged = true;
+ QPoint cursorPos = QCursor::pos();
+
+ // Update value
+ double DragAmount = (singleStep() / 10.0) * (mLastY - cursorPos.y());
+ setValue(value() + DragAmount);
+
+ // Wrap cursor
+ int screenHeight = QApplication::desktop()->screenGeometry().height();
+
+ if (cursorPos.y() == screenHeight - 1)
+ QCursor::setPos(cursorPos.x(), 1);
+ if (cursorPos.y() == 0)
+ QCursor::setPos(cursorPos.x(), screenHeight - 2);
+
+ // Set cursor shape
+ if (DragAmount != 0)
+ {
+ mBeenDragged = true;
+ setCursor(Qt::SizeVerCursor);
+ }
+
+ // Update last Y
+ mLastY = QCursor::pos().y();
}
}
diff --git a/UI/WDraggableSpinBox.h b/UI/WDraggableSpinBox.h
index e3618f47..2374d7d3 100644
--- a/UI/WDraggableSpinBox.h
+++ b/UI/WDraggableSpinBox.h
@@ -8,9 +8,8 @@ class WDraggableSpinBox : public QDoubleSpinBox
Q_OBJECT
bool mBeingDragged;
bool mBeenDragged;
- double mInitialValue;
double mDefaultValue;
- int mInitialY;
+ int mLastY;
public:
explicit WDraggableSpinBox(QWidget *parent = 0);
diff --git a/UI/WPropertyEditor.cpp b/UI/WPropertyEditor.cpp
index 95cab53c..fae719ee 100644
--- a/UI/WPropertyEditor.cpp
+++ b/UI/WPropertyEditor.cpp
@@ -130,6 +130,7 @@ void WPropertyEditor::CreateEditor()
CFloatProperty *pFloatCast = static_cast(mpProperty);
WDraggableSpinBox *pDraggableSpinBox = new WDraggableSpinBox(this);
+ pDraggableSpinBox->setDecimals(4);
pDraggableSpinBox->setValue(pFloatCast->Get());
mUI.EditorWidget = pDraggableSpinBox;