Skip to content

Commit

Permalink
Merge pull request #99 from friction2d/scaling
Browse files Browse the repository at this point in the history
Interface scaling fixes
  • Loading branch information
rodlie authored Nov 19, 2023
2 parents df04f90 + e190cd3 commit 8d2665e
Show file tree
Hide file tree
Showing 25 changed files with 242 additions and 44 deletions.
7 changes: 6 additions & 1 deletion src/app/GUI/ColorWidgets/colorsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent) : QWidget(parent) {
// mWheelLayout->setAlignment(wheel_triangle_widget, Qt::AlignHCenter);


int spinWidth = 50;
int spinWidth = eSizesUI::widget * 3;
rSpin->setFixedWidth(spinWidth);
gSpin->setFixedWidth(spinWidth);
bSpin->setFixedWidth(spinWidth);
Expand Down Expand Up @@ -351,6 +351,11 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent) : QWidget(parent) {
mPickingButton->setToolTip(tr("Pick Color"));
connect(mPickingButton, &QPushButton::released,
this, &ColorSettingsWidget::startColorPicking);
eSizesUI::widget.add(mPickingButton, [this](const int size) {
mPickingButton->setFixedHeight(size);
mPickingButton->setIconSize(QSize(size, size));
});

mColorLabelLayout->addWidget(mColorLabel);
mColorLabelLayout->addWidget(mPickingButton);
mWidgetsLayout->addLayout(mColorLabelLayout);
Expand Down
6 changes: 6 additions & 0 deletions src/app/GUI/Dialogs/scenesettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "GUI/coloranimatorbutton.h"
#include "appsupport.h"

#include "GUI/global.h"

SceneSettingsDialog::SceneSettingsDialog(Canvas * const canvas,
QWidget * const parent)
: SceneSettingsDialog(canvas->prp_getName(),
Expand Down Expand Up @@ -103,6 +105,8 @@ SceneSettingsDialog::SceneSettingsDialog(const QString &name,
mResToolButton->setIcon(QIcon::fromTheme("dots"));
mResToolButton->setVisible(mEnableResolutionPresets);
mResToolButton->setEnabled(mEnableResolutionPresets);
mResToolButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
mResToolButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget));

mSizeLayout = new QHBoxLayout();
mSizeLayout->addWidget(mWidthLabel);
Expand Down Expand Up @@ -140,6 +144,8 @@ SceneSettingsDialog::SceneSettingsDialog(const QString &name,
mFpsToolButton->setIcon(QIcon::fromTheme("dots"));
mFpsToolButton->setVisible(mEnableFpsPresets);
mFpsToolButton->setEnabled(mEnableFpsPresets);
mFpsToolButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
mFpsToolButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget));

mFPSLabel = new QLabel(tr("Fps"), this);
mFPSSpinBox = new QDoubleSpinBox(this);
Expand Down
5 changes: 4 additions & 1 deletion src/app/GUI/RenderWidgets/closablecontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ void ClosableContainer::setCheckable(const bool check) {
if(check) {
mCheckBox = new QCheckBox(this);
mCheckBox->setFocusPolicy(Qt::NoFocus);
mCheckBox->setFixedSize(eSizesUI::widget, eSizesUI::widget);
eSizesUI::widget.add(mCheckBox, [this](const int size) {
mCheckBox->setFixedSize(QSize(size, size));
mCheckBox->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
});
mMainLayout->insertWidget(0, mCheckBox, 0, Qt::AlignTop);
mCheckBox->setChecked(true);
} else {
Expand Down
30 changes: 21 additions & 9 deletions src/app/GUI/RenderWidgets/renderinstancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ void RenderInstanceWidget::iniGUI() {
this);
mOutputDestinationButton->setFocusPolicy(Qt::NoFocus);
mOutputDestinationButton->setToolTip(tr("Select output file"));
mOutputDestinationButton->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred);
//mOutputDestinationButton->setSizePolicy(QSizePolicy::Preferred,
// QSizePolicy::Preferred);
connect(mOutputDestinationButton, &QPushButton::pressed,
this, &RenderInstanceWidget::openOutputDestinationDialog);

const auto playButton = new QPushButton(QIcon::fromTheme("play"),
mPlayButton = new QPushButton(QIcon::fromTheme("play"),
QString(),
this);
playButton->setFocusPolicy(Qt::NoFocus);
playButton->setToolTip(tr("Open in default application"));
playButton->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred);
connect(playButton, &QPushButton::pressed,
mPlayButton->setFocusPolicy(Qt::NoFocus);
mPlayButton->setToolTip(tr("Open in default application"));
//mPlayButton->setSizePolicy(QSizePolicy::Preferred,
// QSizePolicy::Preferred);
connect(mPlayButton, &QPushButton::pressed,
this, [this]() {
QString dst = mOutputDestinationLineEdit->text();
if (QFile::exists(dst)) {
Expand All @@ -175,13 +175,25 @@ void RenderInstanceWidget::iniGUI() {
mOutputDestinationLineEdit->setPlaceholderText(tr("Destination ..."));
mOutputDestinationLineEdit->setObjectName(QString::fromUtf8("OutputDestinationLineEdit"));

eSizesUI::widget.add(mOutputSettingsProfilesButton, [this](const int size) {
mRenderSettingsButton->setFixedHeight(size);
mOutputSettingsButton->setFixedHeight(size);
mOutputSettingsProfilesButton->setIconSize(QSize(size, size));
mOutputSettingsProfilesButton->setFixedSize(QSize(size, size));
mOutputDestinationButton->setIconSize(QSize(size, size));
mOutputDestinationButton->setFixedSize(QSize(size, size));
mPlayButton->setIconSize(QSize(size, size));
mPlayButton->setFixedSize(QSize(size, size));
mOutputDestinationLineEdit->setFixedHeight(size);
});

QWidget *outputDestinationWidget = new QWidget(this);
outputDestinationWidget->setContentsMargins(0, 0, 0, 0);
const auto outputDesinationLayout = new QHBoxLayout(outputDestinationWidget);
outputDesinationLayout->setMargin(0);

outputDesinationLayout->addWidget(mOutputDestinationButton);
outputDesinationLayout->addWidget(playButton);
outputDesinationLayout->addWidget(mPlayButton);
outputDesinationLayout->addWidget(mOutputDestinationLineEdit);

outputSettingsLayout->addWidget(outputDestinationWidget);
Expand Down
2 changes: 2 additions & 0 deletions src/app/GUI/RenderWidgets/renderinstancewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class RenderInstanceWidget : public ClosableContainer {
QLineEdit *mNameLabel;
QVBoxLayout *mContentLayout = new QVBoxLayout();
RenderInstanceSettings mSettings;
QPushButton *mPlayButton;

signals:
void duplicate(RenderInstanceSettings&);
protected:
Expand Down
14 changes: 13 additions & 1 deletion src/app/GUI/RenderWidgets/renderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RenderWidget::RenderWidget(QWidget *parent)
const auto darkPal= AppSupport::getDarkPalette();
bottomWidget->setAutoFillBackground(true);
bottomWidget->setPalette(darkPal);
bottomWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

mRenderProgressBar = new QProgressBar(this);
//mRenderProgressBar->setObjectName(QString::fromUtf8("RenderProgressBar"));
Expand All @@ -68,7 +69,7 @@ RenderWidget::RenderWidget(QWidget *parent)
mRenderProgressBar->setFormat("%p%");
mRenderProgressBar->setValue(0);

mStartRenderButton = new QPushButton(QIcon::fromTheme("play"),
mStartRenderButton = new QPushButton(QIcon::fromTheme("render_animation"),
tr("Render"),
this);
mStartRenderButton->setFocusPolicy(Qt::NoFocus);
Expand Down Expand Up @@ -109,6 +110,17 @@ RenderWidget::RenderWidget(QWidget *parent)
connect(mClearQueueButton, &QPushButton::pressed,
this, &RenderWidget::clearRenderQueue);

eSizesUI::widget.add(mStartRenderButton, [this](const int size) {
mStartRenderButton->setIconSize(QSize(size, size));
mStartRenderButton->setFixedHeight(size);
mStopRenderButton->setIconSize(QSize(size, size));
mStopRenderButton->setFixedSize(QSize(size, size));
mAddRenderButton->setIconSize(QSize(size, size));
mAddRenderButton->setFixedSize(QSize(size, size));
mClearQueueButton->setIconSize(QSize(size, size));
mClearQueueButton->setFixedSize(QSize(size, size));
});

mContWidget = new QWidget(this);
mContWidget->setContentsMargins(0, 0, 0, 0);
mContLayout = new QVBoxLayout(mContWidget);
Expand Down
57 changes: 57 additions & 0 deletions src/app/GUI/Settings/generalsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
#include <QLabel>
#include <QGroupBox>

#include "Private/esettings.h"
#include "GUI/global.h"
#include "labeledslider.h"

#include "../mainwindow.h"

GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent)
: SettingsWidget(parent)
, mAutoBackup(nullptr)
, mAutoSave(nullptr)
, mAutoSaveTimer(nullptr)
, mDefaultInterfaceScaling(nullptr)
, mInterfaceScaling(nullptr)
{
const auto mGeneralWidget = new QWidget(this);
mGeneralWidget->setContentsMargins(0, 0, 0, 0);
Expand Down Expand Up @@ -83,8 +89,51 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent)

mGeneralLayout->addWidget(mAutoSaveWidget);

const auto mScaleWidget = new QGroupBox(this);
mScaleWidget->setTitle(tr("Interface Scaling"));
mScaleWidget->setContentsMargins(0, 0, 0, 0);
const auto mScaleLayout = new QVBoxLayout(mScaleWidget);

const auto mScaleContainer = new QWidget(this);
mScaleContainer->setContentsMargins(0, 0, 0, 0);
const auto mScaleContainerLayout = new QHBoxLayout(mScaleContainer);
mScaleLayout->addWidget(mScaleContainer);

mInterfaceScaling = new QSlider(Qt::Horizontal, this);
mInterfaceScaling->setRange(50, 150);
mScaleContainerLayout->addWidget(mInterfaceScaling);

const auto mScaleLabel = new QLabel(this);
connect(mInterfaceScaling, &QSlider::valueChanged,
mScaleLabel, [mScaleLabel](const int value) {
mScaleLabel->setText(QString("%1 %").arg(value));
});
emit mInterfaceScaling->valueChanged(100);
mScaleContainerLayout->addWidget(mScaleLabel);

mDefaultInterfaceScaling = new QCheckBox(this);
mDefaultInterfaceScaling->setText(tr("Auto"));
mDefaultInterfaceScaling->setToolTip(tr("Use scaling reported by the system.\n\nMay not always work as expected."));

mScaleContainerLayout->addWidget(mDefaultInterfaceScaling);

const auto infoLabel = new QLabel(this);
infoLabel->setText(tr("Changes here will require a restart of Friction."));
mScaleLayout->addWidget(infoLabel);

mGeneralLayout->addWidget(mScaleWidget);

mGeneralLayout->addStretch();
addWidget(mGeneralWidget);

eSizesUI::widget.add(mAutoBackup, [this](const int size) {
mAutoBackup->setFixedSize(QSize(size, size));
mAutoBackup->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mAutoSave->setFixedSize(QSize(size, size));
mAutoSave->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mDefaultInterfaceScaling->setFixedHeight(size);
mDefaultInterfaceScaling->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
});
}

void GeneralSettingsWidget::applySettings()
Expand All @@ -99,6 +148,11 @@ void GeneralSettingsWidget::applySettings()
"AutoSaveTimeout",
(mAutoSaveTimer->value() * 60) * 1000);
MainWindow::sGetInstance()->updateAutoSaveBackupState();

mSett.fDefaultInterfaceScaling = mDefaultInterfaceScaling->isChecked();
mSett.fInterfaceScaling = mInterfaceScaling->value() * 0.01;
eSizesUI::font.updateSize();
eSizesUI::widget.updateSize();
}

void GeneralSettingsWidget::updateSettings(bool restore)
Expand All @@ -114,4 +168,7 @@ void GeneralSettingsWidget::updateSettings(bool restore)
300000).toInt();
if (ms < 60000) { ms = 60000; }
mAutoSaveTimer->setValue((ms / 1000) / 60);

mDefaultInterfaceScaling->setChecked(mSett.fDefaultInterfaceScaling);
mInterfaceScaling->setValue(mDefaultInterfaceScaling->isChecked() ? 100 : 100 * mSett.fInterfaceScaling);
}
3 changes: 3 additions & 0 deletions src/app/GUI/Settings/generalsettingswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <QCheckBox>
#include <QSpinBox>
#include <QSlider>

class GeneralSettingsWidget : public SettingsWidget
{
Expand All @@ -40,6 +41,8 @@ class GeneralSettingsWidget : public SettingsWidget
QCheckBox *mAutoBackup;
QCheckBox *mAutoSave;
QSpinBox *mAutoSaveTimer;
QCheckBox *mDefaultInterfaceScaling;
QSlider *mInterfaceScaling;
};

#endif // GENERALSETTINGSWIDGET_H
9 changes: 9 additions & 0 deletions src/app/GUI/Settings/performancesettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ PerformanceSettingsWidget::PerformanceSettingsWidget(QWidget *parent)

setupRasterEffectWidgets();

eSizesUI::widget.add(mCpuThreadsCapCheck, [this](const int size) {
mCpuThreadsCapCheck->setFixedHeight(size);
mCpuThreadsCapCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mRamMBCapCheck->setFixedHeight(size);
mRamMBCapCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mPathGpuAccCheck->setFixedHeight(size);
mPathGpuAccCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
});

QTimer::singleShot(250, this,
&PerformanceSettingsWidget::updateAudioDevices);
connect(AudioHandler::sInstance, &AudioHandler::deviceChanged,
Expand Down
4 changes: 4 additions & 0 deletions src/app/GUI/Settings/pluginssettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <QTreeWidgetItem>
#include <QHeaderView>

#include "GUI/global.h"

PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent)
: SettingsWidget(parent)
, mShaderPath(nullptr)
Expand All @@ -57,6 +59,8 @@ PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent)
QString(),
this);
mShaderPathButton->setFocusPolicy(Qt::NoFocus);
mShaderPathButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
mShaderPathButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget));

mShaderLayout->addWidget(mShaderLabel);
mShaderLayout->addWidget(mShaderPath);
Expand Down
13 changes: 13 additions & 0 deletions src/app/GUI/Settings/presetsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <QPair>
#include <QPushButton>

#include "GUI/global.h"

PresetSettingsWidget::PresetSettingsWidget(QWidget *parent)
: SettingsWidget(parent)
, mTreeResolutions(nullptr)
Expand All @@ -42,6 +44,17 @@ PresetSettingsWidget::PresetSettingsWidget(QWidget *parent)
{
setupResolutionPresetWidget();
setupFpsPresetWidget();

eSizesUI::widget.add(this, [this](const int size) {
mCheckResolutions->setFixedHeight(size);
mCheckResolutions->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mCheckResolutionsAuto->setFixedHeight(size);
mCheckResolutionsAuto->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mCheckFps->setFixedHeight(size);
mCheckFps->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mCheckFpsAuto->setFixedHeight(size);
mCheckFpsAuto->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
});
}

void PresetSettingsWidget::applySettings()
Expand Down
7 changes: 7 additions & 0 deletions src/app/GUI/Settings/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ SettingsDialog::SettingsDialog(QWidget * const parent)
buttonsLayout->addWidget(applyButton);
buttonsLayout->addWidget(cancelButton);

restoreButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
restoreButton->setFixedHeight(eSizesUI::widget);
cancelButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
cancelButton->setFixedHeight(eSizesUI::widget);
applyButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
applyButton->setFixedHeight(eSizesUI::widget);

mainLayout->addLayout(buttonsLayout);
const auto statusBar = new QStatusBar(this);
statusBar->setSizeGripEnabled(false);
Expand Down
9 changes: 9 additions & 0 deletions src/app/GUI/Settings/timelinesettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <QLabel>

#include "GUI/global.h"

TimelineSettingsWidget::TimelineSettingsWidget(QWidget *parent) :
SettingsWidget(parent) {
mAlternateRowCheck = new QCheckBox("Alternate row color", this);
Expand Down Expand Up @@ -77,6 +79,13 @@ TimelineSettingsWidget::TimelineSettingsWidget(QWidget *parent) :
mSelectedVisibilityRangeColor);
add2HWidgets(new QLabel("Animation range color"),
mAnimationRangeColor);

eSizesUI::widget.add(mAlternateRowCheck, [this](const int size) {
mAlternateRowCheck->setFixedHeight(size);
mAlternateRowCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
mHighlightRowCheck->setFixedHeight(size);
mHighlightRowCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5));
});
}

void TimelineSettingsWidget::applySettings() {
Expand Down
6 changes: 3 additions & 3 deletions src/app/GUI/alignwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ AlignWidget::AlignWidget(QWidget* const parent)

combosLay->addWidget(new QLabel(tr("Align")));
mAlignPivot = new QComboBox(this);
mAlignPivot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
mAlignPivot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mAlignPivot->setFocusPolicy(Qt::NoFocus);
mAlignPivot->addItem(tr("Geometry"));
mAlignPivot->addItem(tr("Pivot"));
combosLay->addWidget(mAlignPivot);

combosLay->addWidget(new QLabel(tr("Relative to")));
mRelativeTo = new QComboBox(this);
mRelativeTo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
mRelativeTo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mRelativeTo->setFocusPolicy(Qt::NoFocus);
mRelativeTo->addItem(tr("Scene"));
mRelativeTo->addItem(tr("Last Selected"));
Expand All @@ -67,7 +67,7 @@ AlignWidget::AlignWidget(QWidget* const parent)
mainLayout->addLayout(buttonsLay);
mainLayout->addStretch();

int buttonSize = eSizesUI::button;
int buttonSize = eSizesUI::widget;

const auto leftButton = new QPushButton(this);
leftButton->setFocusPolicy(Qt::NoFocus);
Expand Down
Loading

0 comments on commit 8d2665e

Please sign in to comment.