Create property in module for inverse zoom direction

This commit is contained in:
Ylva Selling
2022-04-27 17:00:31 -04:00
parent 6605bfcd07
commit 673b7f2325
3 changed files with 14 additions and 1 deletions

View File

@@ -87,6 +87,13 @@ namespace {
"panel is minimized."
};
constexpr const openspace::properties::Property::PropertyInfo InverseZoomInfo = {
"InverseZoomDirection",
"Inverse Zoom Direction",
"If checked, the zoom direction of the scroll over the AAS WWT browser will be "
"inversed."
};
struct [[codegen::Dictionary(SkyBrowserModule)]] Parameters {
// [[codegen::verbatim(EnabledInfo.description)]]
std::optional<bool> enabled;
@@ -105,6 +112,9 @@ namespace {
// [[codegen::verbatim(HideWithGuiInfo.description)]]
std::optional<bool> hideTargetsBrowsersGui;
// [[codegen::verbatim(InverseZoomInfo.description)]]
std::optional<bool> inverseZoomDirection;
};
#include "skybrowsermodule_codegen.cpp"
@@ -121,6 +131,7 @@ SkyBrowserModule::SkyBrowserModule()
, _targetAnimationSpeed(TargetSpeedInfo, 0.2, 0.0, 1.0)
, _browserAnimationSpeed(BrowserSpeedInfo, 5.0, 0.0, 10.0)
, _hideTargetsBrowsersWithGui(HideWithGuiInfo, false)
, _inverseZoomDirection(InverseZoomInfo, false)
{
addProperty(_enabled);
addProperty(_showTitleInGuiBrowser);
@@ -129,6 +140,7 @@ SkyBrowserModule::SkyBrowserModule()
addProperty(_targetAnimationSpeed);
addProperty(_browserAnimationSpeed);
addProperty(_hideTargetsBrowsersWithGui);
addProperty(_inverseZoomDirection);
// Set callback functions
global::callback::mouseButton->emplace(global::callback::mouseButton->begin(),

View File

@@ -106,6 +106,7 @@ private:
properties::BoolProperty _showTitleInGuiBrowser;
properties::BoolProperty _allowCameraRotation;
properties::BoolProperty _hideTargetsBrowsersWithGui;
properties::BoolProperty _inverseZoomDirection;
properties::DoubleProperty _cameraRotationSpeed;
properties::DoubleProperty _targetAnimationSpeed;
properties::DoubleProperty _browserAnimationSpeed;

View File

@@ -302,7 +302,7 @@ void ScreenSpaceSkyBrowser::setVerticalFovWithScroll(float scroll) {
// Make scroll more sensitive the smaller the FOV
double x = _verticalFov;
double zoomFactor = atan(x / 50.0) + exp(x / 40.0) - 0.99999999999999999999999999999;
double zoom = scroll > 0.0 ? -zoomFactor : zoomFactor;
double zoom = scroll > 0.0 ? zoomFactor : -zoomFactor;
_verticalFov = std::clamp(_verticalFov + zoom, 0.0, 70.0);
}