Implemented lock for Planar field of view

This commit is contained in:
GPayne
2022-02-27 20:42:45 -07:00
parent dcca589695
commit 1e01166c4a
2 changed files with 56 additions and 4 deletions

View File

@@ -184,25 +184,28 @@ private slots:
void onSpoutSelection(int selectionState);
void onWebGuiSelection(int selectionState);
void onAspectRatioLockClicked();
void onFovLockClicked();
private:
void createWidgets(QWidget* parent);
void determineIdealWindowSize();
void updatePlanarLockedFov();
void updateScaledWindowDimensions();
std::function<void(int, int, const QRectF&)> _windowChangeCallback;
std::function<void(unsigned int)> _windowGuiCheckCallback;
QRectF defaultWindowSizes[4] = {
{50.f, 50.f, 1280.f, 720.f},
{900.f, 250.f, 1280.f, 720.f},
{1200.f, 340.f, 1280.f, 720.f},
{50.f, 50.f, 1280.f, 720.f}
{150.f, 150.f, 1280.f, 720.f},
{50.f, 50.f, 1280.f, 720.f},
{150.f, 150.f, 1280.f, 720.f}
};
QList<QString> _monitorNames = { "Primary", "Secondary" };
int QualityValues[10] = { 256, 512, 1024, 1536, 2048, 4096, 8192, 16384,
32768, 65536 };
int _lineEditWidthFixedWinSize = 50;
int _lineEditWidthFixedFov = 80;
float _aspectRatioSize = 16.f / 9.f;
const float _idealAspectRatio = 16.f / 9.f;
float _aspectRatioSize = _idealAspectRatio;
float _marginFractionOfWidgetSize = 0.025f;
float _defaultFovH = 80.f;
float _defaultFovV = 50.534f;
@@ -212,6 +215,7 @@ private:
unsigned int _monIndexDefault = 0;
unsigned int _index = 0;
bool _aspectRatioLocked = false;
bool _FovLocked = true;
std::vector<QRect>& _monitorResolutions;
int _maxWindowSizePixels = 10000;
const QColor& _colorForWindow;
@@ -222,6 +226,7 @@ private:
QLineEdit* _offsetX = nullptr;
QLineEdit* _offsetY = nullptr;
QPushButton* _buttonLockAspectRatio = nullptr;
QPushButton* _buttonLockFov = nullptr;
QRectF _windowDims;
QPushButton* _fullscreenButton = nullptr;
QCheckBox* _checkBoxWindowDecor = nullptr;

View File

@@ -123,9 +123,11 @@ void WindowControl::createWidgets(QWidget* parent) {
_labelFovV = new QLabel;
_labelHeightOffset = new QLabel;
_buttonLockAspectRatio = new QPushButton(parent);
_buttonLockFov = new QPushButton(parent);
_lockIcon.addPixmap(QPixmap(":/images/outline_locked.png"));
_unlockIcon.addPixmap(QPixmap(":/images/outline_unlocked.png"));
_buttonLockAspectRatio->setIcon(_unlockIcon);
_buttonLockFov->setIcon(_lockIcon);
{
QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels);
QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels);
@@ -211,6 +213,12 @@ void WindowControl::createWidgets(QWidget* parent) {
this,
&WindowControl::onAspectRatioLockClicked
);
connect(
_buttonLockFov,
&QPushButton::released,
this,
&WindowControl::onFovLockClicked
);
}
QVBoxLayout* WindowControl::initializeLayout() {
@@ -339,6 +347,9 @@ QVBoxLayout* WindowControl::initializeLayout() {
QHBoxLayout* layoutComboProjection = new QHBoxLayout;
_comboProjection->setToolTip("Select from the supported window projection types");
layoutComboProjection->addWidget(_comboProjection);
layoutComboProjection->addWidget(_buttonLockFov);
_buttonLockFov->setToolTip("Locks and scales the Horizontal & Vertical F.O.V. "
"to the ideal settings based on aspect ratio.");
layoutComboProjection->addStretch(1);
layoutProjectionGroup->addLayout(layoutComboProjection);
QFrame* borderProjectionGroup = new QFrame;
@@ -387,6 +398,8 @@ QVBoxLayout* WindowControl::initializeLayout() {
layoutFovV->addWidget(_lineFovV);
_lineFovH->setFixedWidth(_lineEditWidthFixedFov);
_lineFovV->setFixedWidth(_lineEditWidthFixedFov);
_lineFovH->setEnabled(false);
_lineFovV->setEnabled(false);
layoutProjectionGroup->addLayout(layoutFovH);
layoutProjectionGroup->addLayout(layoutFovV);
QHBoxLayout* layoutHeightOffset = new QHBoxLayout;
@@ -432,6 +445,9 @@ void WindowControl::onSizeXChanged(const QString& newText) {
if (_windowChangeCallback) {
_windowChangeCallback(_monIndex, _index, _windowDims);
}
if (_FovLocked) {
updatePlanarLockedFov();
}
}
void WindowControl::onSizeYChanged(const QString& newText) {
@@ -446,6 +462,9 @@ void WindowControl::onSizeYChanged(const QString& newText) {
if (_windowChangeCallback) {
_windowChangeCallback(_monIndex, _index, _windowDims);
}
if (_FovLocked) {
updatePlanarLockedFov();
}
}
void WindowControl::onOffsetXChanged(const QString& newText) {
@@ -525,6 +544,7 @@ void WindowControl::onProjectionChanged(int newSelection) {
_lineFovH->setVisible(selected == ProjectionIndeces::Planar);
_labelFovV->setVisible(selected == ProjectionIndeces::Planar);
_lineFovV->setVisible(selected == ProjectionIndeces::Planar);
_buttonLockFov->setVisible(selected == ProjectionIndeces::Planar);
_labelHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical);
_lineHeightOffset->setVisible(selected == ProjectionIndeces::Cylindrical);
_checkBoxSpoutOutput->setVisible(selected == ProjectionIndeces::Fisheye
@@ -539,6 +559,33 @@ void WindowControl::onAspectRatioLockClicked() {
}
}
void WindowControl::onFovLockClicked() {
_FovLocked = !_FovLocked;
_buttonLockFov->setIcon(_FovLocked ? _lockIcon : _unlockIcon);
if (_FovLocked) {
_lineFovH->setEnabled(false);
_lineFovV->setEnabled(false);
updatePlanarLockedFov();
}
else {
_lineFovH->setEnabled(true);
_lineFovV->setEnabled(true);
}
}
void WindowControl::updatePlanarLockedFov() {
float currentAspectRatio = _windowDims.width() / _windowDims.height();
float relativeRatio = currentAspectRatio / _idealAspectRatio;
if (relativeRatio >= 1.0) {
_lineFovH->setText(QString::number(std::min(_defaultFovH *relativeRatio, 180.f)));
_lineFovV->setText(QString::number(_defaultFovV));
}
else {
_lineFovH->setText(QString::number(_defaultFovH));
_lineFovV->setText(QString::number(std::min(_defaultFovV /relativeRatio, 180.f)));
}
}
void WindowControl::setWindowChangeCallback(
std::function<void(int, int, const QRectF&)> cb)
{