mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 11:18:22 -05:00
Added lock for window aspect ratio
This commit is contained in:
@@ -38,8 +38,8 @@ class Orientation : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Constructor for Orientation class, which manages the overall control layout including
|
||||
* monitorBox, multiple WindowControl columns, and additional controls
|
||||
* Constructor for Orientation class, which manages the overall control layout
|
||||
* including monitorBox, multiple WindowControl columns, and additional controls
|
||||
*
|
||||
* \param monitorRenderBox pointer to the MonitorBox object
|
||||
* \param monitorSizeList A vector containing QRect objects containing pixel dims
|
||||
|
||||
@@ -183,6 +183,7 @@ private slots:
|
||||
void onFullscreenClicked();
|
||||
void onSpoutSelection(int selectionState);
|
||||
void onWebGuiSelection(int selectionState);
|
||||
void onAspectRatioLockClicked();
|
||||
|
||||
private:
|
||||
void createWidgets(QWidget* parent);
|
||||
@@ -201,6 +202,7 @@ private:
|
||||
32768, 65536 };
|
||||
int _lineEditWidthFixedWinSize = 50;
|
||||
int _lineEditWidthFixedFov = 80;
|
||||
float _aspectRatioSize = 16.f / 9.f;
|
||||
float _marginFractionOfWidgetSize = 0.025f;
|
||||
float _defaultFovH = 80.f;
|
||||
float _defaultFovV = 50.534f;
|
||||
@@ -209,6 +211,7 @@ private:
|
||||
unsigned int _monIndex = 0;
|
||||
unsigned int _monIndexDefault = 0;
|
||||
unsigned int _index = 0;
|
||||
bool _aspectRatioLocked = false;
|
||||
std::vector<QRect>& _monitorResolutions;
|
||||
int _maxWindowSizePixels = 10000;
|
||||
const QColor& _colorForWindow;
|
||||
@@ -218,6 +221,7 @@ private:
|
||||
QLineEdit* _sizeY = nullptr;
|
||||
QLineEdit* _offsetX = nullptr;
|
||||
QLineEdit* _offsetY = nullptr;
|
||||
QPushButton* _buttonLockAspectRatio = nullptr;
|
||||
QRectF _windowDims;
|
||||
QPushButton* _fullscreenButton = nullptr;
|
||||
QCheckBox* _checkBoxWindowDecor = nullptr;
|
||||
@@ -234,6 +238,8 @@ private:
|
||||
QLabel* _labelHeightOffset = nullptr;
|
||||
QLineEdit* _lineHeightOffset = nullptr;
|
||||
QLineEdit* _windowName = nullptr;
|
||||
QIcon _lockIcon;
|
||||
QIcon _unlockIcon;
|
||||
};
|
||||
|
||||
#endif // __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 278 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -3,5 +3,7 @@
|
||||
<file>qss/launcher.qss</file>
|
||||
<file>images/openspace-horiz-logo-small.png</file>
|
||||
<file>images/launcher-background.png</file>
|
||||
<file>images/outline_locked.png</file>
|
||||
<file>images/outline_unlocked.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -46,8 +46,18 @@ DisplayWindowUnion::DisplayWindowUnion(std::shared_ptr<MonitorBox> monitorRender
|
||||
for (unsigned int i = 0; i < _nMaxWindows; ++i) {
|
||||
initializeWindowControl();
|
||||
}
|
||||
connect(_addWindowButton, &QPushButton::clicked, this, &DisplayWindowUnion::addWindow);
|
||||
connect(_removeWindowButton, &QPushButton::clicked, this, &DisplayWindowUnion::removeWindow);
|
||||
connect(
|
||||
_addWindowButton,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&DisplayWindowUnion::addWindow
|
||||
);
|
||||
connect(
|
||||
_removeWindowButton,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&DisplayWindowUnion::removeWindow
|
||||
);
|
||||
initializeLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ WindowControl::WindowControl(unsigned int monitorIndex, unsigned int windowIndex
|
||||
, _monitorResolutions(monitorDims)
|
||||
, _colorForWindow(winColor)
|
||||
{
|
||||
Q_INIT_RESOURCE(resources);
|
||||
_nMonitors = static_cast<unsigned int>(_monitorResolutions.size());
|
||||
createWidgets(parent);
|
||||
resetToDefaults();
|
||||
@@ -121,6 +122,10 @@ void WindowControl::createWidgets(QWidget* parent) {
|
||||
_labelFovH = new QLabel;
|
||||
_labelFovV = new QLabel;
|
||||
_labelHeightOffset = new QLabel;
|
||||
_buttonLockAspectRatio = new QPushButton(parent);
|
||||
_lockIcon.addPixmap(QPixmap(":/images/outline_locked.png"));
|
||||
_unlockIcon.addPixmap(QPixmap(":/images/outline_unlocked.png"));
|
||||
_buttonLockAspectRatio->setIcon(_unlockIcon);
|
||||
{
|
||||
QIntValidator* validatorSizeX = new QIntValidator(10, _maxWindowSizePixels);
|
||||
QIntValidator* validatorSizeY = new QIntValidator(10, _maxWindowSizePixels);
|
||||
@@ -200,6 +205,12 @@ void WindowControl::createWidgets(QWidget* parent) {
|
||||
this,
|
||||
&WindowControl::onFullscreenClicked
|
||||
);
|
||||
connect(
|
||||
_buttonLockAspectRatio,
|
||||
&QPushButton::released,
|
||||
this,
|
||||
&WindowControl::onAspectRatioLockClicked
|
||||
);
|
||||
}
|
||||
|
||||
QVBoxLayout* WindowControl::initializeLayout() {
|
||||
@@ -256,6 +267,7 @@ QVBoxLayout* WindowControl::initializeLayout() {
|
||||
labelSize->setToolTip("Enter window width & height in pixels");
|
||||
_sizeX->setToolTip("Enter window width (pixels)");
|
||||
_sizeY->setToolTip("Enter window height (pixels)");
|
||||
_buttonLockAspectRatio->setToolTip("Locks/Unlocks size aspect ratio");
|
||||
layoutSize->addWidget(labelSize);
|
||||
labelSize->setText("Size:");
|
||||
labelSize->setFixedWidth(55);
|
||||
@@ -263,6 +275,7 @@ QVBoxLayout* WindowControl::initializeLayout() {
|
||||
layoutSize->addWidget(labelDelim);
|
||||
layoutSize->addWidget(_sizeY);
|
||||
layoutSize->addWidget(labelUnit);
|
||||
layoutSize->addWidget(_buttonLockAspectRatio);
|
||||
layoutSize->addStretch(1);
|
||||
labelDelim->setText("x");
|
||||
labelDelim->setFixedWidth(9);
|
||||
@@ -409,6 +422,13 @@ void WindowControl::showWindowLabel(bool show) {
|
||||
|
||||
void WindowControl::onSizeXChanged(const QString& newText) {
|
||||
_windowDims.setWidth(newText.toInt());
|
||||
if (_aspectRatioLocked) {
|
||||
int updatedHeight = _windowDims.width() / _aspectRatioSize;
|
||||
_sizeY->blockSignals(true);
|
||||
_sizeY->setText(QString::number(updatedHeight));
|
||||
_sizeY->blockSignals(false);
|
||||
_windowDims.setHeight(updatedHeight);
|
||||
}
|
||||
if (_windowChangeCallback) {
|
||||
_windowChangeCallback(_monIndex, _index, _windowDims);
|
||||
}
|
||||
@@ -416,6 +436,13 @@ void WindowControl::onSizeXChanged(const QString& newText) {
|
||||
|
||||
void WindowControl::onSizeYChanged(const QString& newText) {
|
||||
_windowDims.setHeight(newText.toInt());
|
||||
if (_aspectRatioLocked) {
|
||||
int updatedWidth = _windowDims.height() * _aspectRatioSize;
|
||||
_sizeX->blockSignals(true);
|
||||
_sizeX->setText(QString::number(updatedWidth));
|
||||
_sizeX->blockSignals(false);
|
||||
_windowDims.setWidth(updatedWidth);
|
||||
}
|
||||
if (_windowChangeCallback) {
|
||||
_windowChangeCallback(_monIndex, _index, _windowDims);
|
||||
}
|
||||
@@ -504,6 +531,14 @@ void WindowControl::onProjectionChanged(int newSelection) {
|
||||
|| selected == ProjectionIndeces::Equirectangular);
|
||||
}
|
||||
|
||||
void WindowControl::onAspectRatioLockClicked() {
|
||||
_aspectRatioLocked = !_aspectRatioLocked;
|
||||
_buttonLockAspectRatio->setIcon(_aspectRatioLocked ? _lockIcon : _unlockIcon);
|
||||
if (_aspectRatioLocked) {
|
||||
_aspectRatioSize = _windowDims.width() / _windowDims.height();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowControl::setWindowChangeCallback(
|
||||
std::function<void(int, int, const QRectF&)> cb)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user