diff --git a/src/res/qml/video_page/brightness/BrightnessGroupBox.qml b/src/res/qml/video_page/brightness/BrightnessGroupBox.qml index e793764..ecc2e0f 100644 --- a/src/res/qml/video_page/brightness/BrightnessGroupBox.qml +++ b/src/res/qml/video_page/brightness/BrightnessGroupBox.qml @@ -40,27 +40,28 @@ GroupBox { } Item { - Layout.preferredWidth: 150 + Layout.preferredWidth: 150 } MyText { - text: "Value :" + text: "Brightness:" horizontalAlignment: Text.AlignRight Layout.rightMargin: 10 } MySlider { id: brightnessSlider - from: 0.05 + from: 0.01 to: 1.0 stepSize: 0.01 value: 1.0 Layout.fillWidth: true onPositionChanged: { - var val = (this.position * 100)/2 + var val = (this.position * 100) brightnessValueText.text = Math.round(val) + "%" } onValueChanged: { + VideoTabController.setBrightnessValue(value.toFixed(2), false) } } @@ -68,6 +69,7 @@ GroupBox { MyTextField { id: brightnessValueText text: "100%" + keyBoardUID: 301 Layout.preferredWidth: 100 Layout.leftMargin: 10 horizontalAlignment: Text.AlignHCenter @@ -80,7 +82,7 @@ GroupBox { val = 100.0 } var v = (val/100).toFixed(2) - brightnessSlider.value = v + brightnessSlider.value = v } text = Math.round(VideoTabController.boundsVisibility * 100) + "%" } diff --git a/src/tabcontrollers/VideoTabController.cpp b/src/tabcontrollers/VideoTabController.cpp index 5dec152..1102a23 100644 --- a/src/tabcontrollers/VideoTabController.cpp +++ b/src/tabcontrollers/VideoTabController.cpp @@ -34,11 +34,11 @@ namespace advsettings notifIconPath->c_str()); vr::VROverlay()->SetOverlayWidthInMeters( m_brightnessNotificationOverlayHandle, 1.0f); - //Places the "overlay just past eye sight 1mx1m should more or less cover all headsets + //Places the "overlay just past eye sight 1mx1m vr::HmdMatrix34_t notificationTransform = { { { 1.0f, 0.0f, 0.0f, 0.00f }, { 0.0f, 1.0f, 0.0f, 0.00f }, - { 0.0f, 0.0f, 1.0f, -0.01f } } }; + { 0.0f, 0.0f, 1.0f, -0.15f } } }; vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative( m_brightnessNotificationOverlayHandle, vr::k_unTrackedDeviceIndex_Hmd, @@ -92,7 +92,7 @@ namespace advsettings float VideoTabController::brightnessValue() const { - return m_brightnessValue; + return (1.0f - m_opacityValue); } bool VideoTabController::brightnessEnabled() const @@ -112,6 +112,7 @@ namespace advsettings if(getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid) { vr::VROverlay()->ShowOverlay(getBrightnessOverlayHandle()); + LOG(INFO) << "overlay is on"; } } else { @@ -127,16 +128,17 @@ namespace advsettings } } - void VideoTabController::setBrightnessValue(float value, bool notify) + void VideoTabController::setBrightnessValue(float percvalue, bool notify) { //TODO mutex? //std::lock_guard lock(eventLoopMutex); - if (value != m_brightnessValue) + float realvalue = (1.0f - percvalue); + + if (realvalue != m_opacityValue) { - m_brightnessValue = value; - if (value <= 1.0f && value >= 0.0f) { - vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, value); - + m_opacityValue = realvalue; + if (realvalue <= 1.0f && realvalue >= 0.0f) { + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, realvalue); if (overlayError != vr::VROverlayError_None) { LOG(ERROR) << "Could not set alpha: " << vr::VROverlay()->GetOverlayErrorNameFromEnum( @@ -145,13 +147,13 @@ namespace advsettings } else { LOG(WARNING) << "alpha value is invalid setting to 1.0"; - m_brightnessValue = 1.0f; + m_opacityValue = 0.0f; } if (notify) { - emit brightnessValueChanged(value); + emit brightnessValueChanged(percvalue); } } } diff --git a/src/tabcontrollers/VideoTabController.h b/src/tabcontrollers/VideoTabController.h index d7f630f..ec80be6 100644 --- a/src/tabcontrollers/VideoTabController.h +++ b/src/tabcontrollers/VideoTabController.h @@ -30,7 +30,7 @@ namespace advsettings { vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle = vr::k_ulOverlayHandleInvalid; - float m_brightnessValue = 1.0f; + float m_opacityValue = 0.0f; bool m_brightnessEnabled = false; //void reloadVideoConfig(); @@ -58,7 +58,7 @@ namespace advsettings { public slots: void setBrightnessEnabled(bool value, bool notify = true); - void setBrightnessValue(float value, bool notify = true); + void setBrightnessValue(float percvalue, bool notify = true); signals: