Merge pull request #48 from OpenVR-Advanced-Settings/rotate-resetbutton-fix

Apply fix for reset button rotation from alpha-kung branch
This commit is contained in:
Kung-vr
2019-01-16 01:51:46 +09:00
committed by GitHub
3 changed files with 41 additions and 14 deletions
+15 -11
View File
@@ -233,11 +233,11 @@ MyStackViewPage {
Layout.preferredWidth: 40 Layout.preferredWidth: 40
text: "-" text: "-"
onClicked: { onClicked: {
var val = MoveCenterTabController.rotation - 45 var val = MoveCenterTabController.tempRotation - 45
if (val < -180) { if (val < -180) {
val = val + 360; val = val + 360;
} }
MoveCenterTabController.rotation = val MoveCenterTabController.tempRotation = val
} }
} }
@@ -250,11 +250,11 @@ MyStackViewPage {
Layout.fillWidth: true Layout.fillWidth: true
onPositionChanged: { onPositionChanged: {
var val = this.from + ( this.position * (this.to - this.from)) var val = this.from + ( this.position * (this.to - this.from))
playspaceRotationText.text = Math.round(val) + "°" MoveCenterTabController.tempRotation = Math.round(val)
} }
onValueChanged: { onValueChanged: {
MoveCenterTabController.rotation = playspaceRotationSlider.value MoveCenterTabController.tempRotation = Math.round(playspaceRotationSlider.value)
playspaceRotationText.text = Math.round(playspaceRotationSlider.value) + "°" //playspaceRotationText.text = Math.round(playspaceRotationSlider.value) + "°"
} }
} }
@@ -263,11 +263,11 @@ MyStackViewPage {
Layout.preferredWidth: 40 Layout.preferredWidth: 40
text: "+" text: "+"
onClicked: { onClicked: {
var val = MoveCenterTabController.rotation + 45 var val = MoveCenterTabController.tempRotation + 45
if (val > 180) { if (val > 180) {
val = val -360; val = val -360;
} }
MoveCenterTabController.rotation = val MoveCenterTabController.tempRotation = val
} }
} }
@@ -282,10 +282,10 @@ MyStackViewPage {
var val = parseInt(input) var val = parseInt(input)
if (!isNaN(val)) { if (!isNaN(val)) {
val = val % 180 val = val % 180
MoveCenterTabController.rotation = val MoveCenterTabController.tempRotation = val
text = MoveCenterTabController.rotation + "°" text = MoveCenterTabController.tempRotation + "°"
} else { } else {
text = MoveCenterTabController.rotation + "°" text = MoveCenterTabController.tempRotation + "°"
} }
} }
} }
@@ -294,7 +294,7 @@ MyStackViewPage {
Layout.preferredWidth: 145 Layout.preferredWidth: 145
text:"Apply" text:"Apply"
onClicked: { onClicked: {
MoveCenterTabController.applyRotation() MoveCenterTabController.rotation = MoveCenterTabController.tempRotation
} }
} }
@@ -409,6 +409,10 @@ MyStackViewPage {
onRotationChanged: { onRotationChanged: {
playspaceRotationSlider.value = MoveCenterTabController.rotation playspaceRotationSlider.value = MoveCenterTabController.rotation
} }
onTempRotationChanged: {
playspaceRotationSlider.value = MoveCenterTabController.tempRotation
playspaceRotationText.text = MoveCenterTabController.tempRotation + "°"
}
onAdjustChaperoneChanged: { onAdjustChaperoneChanged: {
playspaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone playspaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone
} }
+19 -3
View File
@@ -136,13 +136,20 @@ int MoveCenterTabController::rotation() const
return m_rotation; return m_rotation;
} }
int MoveCenterTabController::tempRotation() const
{
return m_tempRotation;
}
void MoveCenterTabController::setRotation( int value, bool notify ) void MoveCenterTabController::setRotation( int value, bool notify )
{ {
if ( m_rotation != value ) if ( m_rotation != value )
{ {
// float angle = (value - m_rotation) * 2 * M_PI / 360.0; float angle = ( value - m_rotation ) * 2 * M_PI / 360.0;
// parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, parent->RotateUniverseCenter(
// angle, m_adjustChaperone); ( vr::TrackingUniverseOrigin ) m_trackingUniverse,
angle,
m_adjustChaperone );
m_rotation = value; m_rotation = value;
if ( notify ) if ( notify )
{ {
@@ -151,6 +158,15 @@ void MoveCenterTabController::setRotation( int value, bool notify )
} }
} }
void MoveCenterTabController::setTempRotation( int value, bool notify )
{
m_tempRotation = value;
if ( notify )
{
emit tempRotationChanged( m_tempRotation );
}
}
void MoveCenterTabController::applyRotation() void MoveCenterTabController::applyRotation()
{ {
if ( m_rotation != m_rotationOld ) if ( m_rotation != m_rotationOld )
@@ -25,6 +25,8 @@ class MoveCenterTabController : public QObject
float offsetZ READ offsetZ WRITE setOffsetZ NOTIFY offsetZChanged ) float offsetZ READ offsetZ WRITE setOffsetZ NOTIFY offsetZChanged )
Q_PROPERTY( Q_PROPERTY(
int rotation READ rotation WRITE setRotation NOTIFY rotationChanged ) int rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
Q_PROPERTY( int tempRotation READ tempRotation WRITE setTempRotation NOTIFY
tempRotationChanged )
Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE
setAdjustChaperone NOTIFY adjustChaperoneChanged ) setAdjustChaperone NOTIFY adjustChaperoneChanged )
Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE
@@ -49,6 +51,7 @@ private:
float m_offsetY = 0.0f; float m_offsetY = 0.0f;
float m_offsetZ = 0.0f; float m_offsetZ = 0.0f;
int m_rotation = 0; int m_rotation = 0;
int m_tempRotation = 0;
int m_rotationOld = 0; int m_rotationOld = 0;
bool m_adjustChaperone = true; bool m_adjustChaperone = true;
bool m_moveShortcutRightPressed = false; bool m_moveShortcutRightPressed = false;
@@ -78,6 +81,7 @@ public:
float offsetY() const; float offsetY() const;
float offsetZ() const; float offsetZ() const;
int rotation() const; int rotation() const;
int tempRotation() const;
bool adjustChaperone() const; bool adjustChaperone() const;
bool moveShortcutRight() const; bool moveShortcutRight() const;
bool moveShortcutLeft() const; bool moveShortcutLeft() const;
@@ -96,6 +100,8 @@ public slots:
void setRotation( int value, bool notify = true ); void setRotation( int value, bool notify = true );
void setTempRotation( int value, bool notify = true );
void setAdjustChaperone( bool value, bool notify = true ); void setAdjustChaperone( bool value, bool notify = true );
void setMoveShortcutRight( bool value, bool notify = true ); void setMoveShortcutRight( bool value, bool notify = true );
@@ -119,6 +125,7 @@ signals:
void offsetYChanged( float value ); void offsetYChanged( float value );
void offsetZChanged( float value ); void offsetZChanged( float value );
void rotationChanged( int value ); void rotationChanged( int value );
void tempRotationChanged( int value );
void adjustChaperoneChanged( bool value ); void adjustChaperoneChanged( bool value );
void moveShortcutRightChanged( bool value ); void moveShortcutRightChanged( bool value );
void moveShortcutLeftChanged( bool value ); void moveShortcutLeftChanged( bool value );