Skip to content

Commit

Permalink
Merge pull request #79 from friction2d/hidpi
Browse files Browse the repository at this point in the history
HiDPI fixes etc
  • Loading branch information
rodlie authored Sep 10, 2023
2 parents 9eb1559 + b466b66 commit 3d22995
Show file tree
Hide file tree
Showing 9 changed files with 2,324 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/app/GUI/GradientWidgets/gradientslistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ void GradientsListWidget::resizeEvent(QResizeEvent *e) {
const QSize size = e->size();
mDisplayedGradients->setMinimumHeight(size.height());
mDisplayedGradients->updateHeight();
const int scrollBarWidth = verticalScrollBar()->width();
/*const int scrollBarWidth = verticalScrollBar()->width();
const int availableWidth = size.width() - scrollBarWidth;
mDisplayedGradients->setFixedWidth(availableWidth);
mDisplayedGradients->setFixedWidth(availableWidth);*/
}

void GradientsListWidget::showEvent(QShowEvent *e) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/GUI/alignwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <QHBoxLayout>
#include <QPushButton>

#include "GUI/global.h"

AlignWidget::AlignWidget(QWidget* const parent)
: QWidget(parent)
, mAlignPivot(nullptr)
Expand All @@ -47,13 +49,15 @@ AlignWidget::AlignWidget(QWidget* const parent)

combosLay->addWidget(new QLabel(tr("Align")));
mAlignPivot = new QComboBox(this);
mAlignPivot->setSizePolicy(QSizePolicy::Preferred, 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->setFocusPolicy(Qt::NoFocus);
mRelativeTo->addItem(tr("Scene"));
mRelativeTo->addItem(tr("Last Selected"));
Expand All @@ -63,7 +67,7 @@ AlignWidget::AlignWidget(QWidget* const parent)
mainLayout->addLayout(buttonsLay);
mainLayout->addStretch();

int buttonSize = 20;
int buttonSize = eSizesUI::button;

const auto leftButton = new QPushButton(this);
leftButton->setFocusPolicy(Qt::NoFocus);
Expand Down
1 change: 1 addition & 0 deletions src/app/GUI/canvaswindowevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void CanvasWindow::fitCanvasToSize()
translateView({(widWidth - canvasSize.width() * minScale) * 0.5,
(widHeight - canvasSize.height() * minScale) * 0.5});
mViewTransform.scale(minScale, minScale);
update();
}

void CanvasWindow::zoomInView()
Expand Down
6 changes: 0 additions & 6 deletions src/app/GUI/timelinedockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ TimelineDockWidget::TimelineDockWidget(Document& document,
mMainLayout->setSpacing(0);
mMainLayout->setMargin(0);

const QSize iconSize(AppSupport::getSettings("ui",
"timelineToolbarIconSize",
QSize(24, 24)).toSize());

mFrameRewindAct = new QAction(QIcon::fromTheme("rewind"),
tr("Rewind"),
this);
Expand Down Expand Up @@ -203,8 +199,6 @@ TimelineDockWidget::TimelineDockWidget(Document& document,
mToolBar = new QToolBar(this);
mToolBar->setMovable(false);

mToolBar->setIconSize(iconSize);

mRenderProgress = new QProgressBar(this);
mRenderProgress->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred);
Expand Down
25 changes: 14 additions & 11 deletions src/app/GUI/welcomedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <QPushButton>
#include <QPainter>
#include <QLabel>
#include <QToolButton>

#include "appsupport.h"

Expand Down Expand Up @@ -64,30 +63,34 @@ WelcomeDialog::WelcomeDialog(QMenu *recentMenu,
AppSupport::getAppName()));

const auto buttonWid = new QWidget(this);
buttonWid->setContentsMargins(0, 0, 0, 0);
const auto buttonLay = new QHBoxLayout(buttonWid);
buttonLay->setMargin(0);

const auto newButton = new QPushButton(/*QIcon::fromTheme("file_blank"),*/
tr("New"),
this);
newButton->setObjectName("WelcomeNewButton");
const auto newButton = new QPushButton(tr("New"), this);
newButton->setObjectName("WelcomeButton");
newButton->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Expanding);
connect(newButton, &QPushButton::released, newFunc);

const auto openButton = new QToolButton(this);
openButton->setObjectName("WelcomeOpenButton");
const auto openButton = new QPushButton(this);
openButton->setObjectName("WelcomeButton");
openButton->setText(tr("Open"));
//openButton->setIcon(QIcon::fromTheme("file_folder"));
openButton->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Expanding);
//openButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
openButton->setPopupMode(QToolButton::MenuButtonPopup);
openButton->setMenu(recentMenu);
connect(openButton, &QPushButton::released, openFunc);

const auto recentButton = new QPushButton(tr("Open Recent"), this);
recentButton->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred);
recentButton->setContentsMargins(0, 0, 0, 0);
recentButton->setObjectName("WelcomeRecentButton");
recentButton->setMenu(recentMenu);

thisLay->addWidget(mainWid, 0, Qt::AlignHCenter | Qt::AlignVCenter);
sceneLay->addWidget(logoLabel);
sceneLay->addWidget(buttonWid);
sceneLay->addWidget(recentButton);
buttonLay->addWidget(newButton);
buttonLay->addWidget(openButton);
mainLay->addWidget(sceneWid);
Expand Down
34 changes: 21 additions & 13 deletions src/app/friction.qss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ QToolBar#ViewerDrawBar,

QComboBox#blendModeCombo,
QWidget#menuBarWidget QPushButton,
QLineEdit#SearchLine {
QLineEdit#SearchLine,
AlignWidget QComboBox {
background-color: rgb(23, 23, 28);
}

Expand Down Expand Up @@ -80,29 +81,36 @@ QSpinBox#SpinBoxNoButtons::down-button {
width: 0;
}

QPushButton#WelcomeNewButton,
QToolButton#WelcomeOpenButton {
QPushButton#WelcomeButton {
padding: 0.25em;
border: 2px solid #666;
border-radius: 10%;
color: #ebebeb;
font-weight: bold;
}

QPushButton#WelcomeNewButton:hover,
QToolButton#WelcomeOpenButton:hover {
QPushButton#WelcomeButton:hover {
border-color: #ebebeb;
}

QToolButton#WelcomeOpenButton::menu-button {
padding-right: 0.5em;
border-top-right: 2px solid #ebebeb;
border-bottom-right: 2px solid #ebebeb;
border-top-right-radius: 10%;
border-bottom-right-radius: 10%;
QPushButton#WelcomeRecentButton {
padding: 0.25em;
border: none;
border-radius: 10%;
color: #ebebeb;
font-weight: bold;
}

QPushButton#WelcomeRecentButton:hover {
border: 2px solid #ebebeb;
}

QToolButton#WelcomeOpenButton[popupMode="1"] {
padding-right: 0.5em;
AlignWidget QPushButton {
background-color: none;
border: 0;
border-radius: 10%;
}

QCheckBox::indicator:unchecked:hover {
background-color: rgb(112, 8, 10);
}
11 changes: 7 additions & 4 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QApplication>
#include <QSurfaceFormat>
#include <QProcess>
#include <QDesktopWidget>

#include "hardwareinfo.h"
#include "Private/esettings.h"
Expand Down Expand Up @@ -149,15 +150,17 @@ int main(int argc, char *argv[])
HardwareInfo::sGpuVendor());

OS_FONT = QApplication::font();
eSizesUI::font.setEvaluator([/*&settings*/]() {
eSizesUI::font.setEvaluator([]() {
double dpi = (qApp->desktop()->logicalDpiX() / 96.0);
qDebug() << "DPI" << dpi;
const auto fm = QFontMetrics(OS_FONT);
const qreal scaling = qBound(0.5, /*settings.fInterfaceScaling*/1.0, 1.5);
const qreal scaling = qBound(0.5, dpi, 1.5);
return qRound(fm.height()*scaling);
});
eSizesUI::widget.setEvaluator([]() {
return eSizesUI::font.size()*4/3;
});
/*QObject::connect(&eSizesUI::font, &SizeSetter::sizeChanged,
QObject::connect(&eSizesUI::font, &SizeSetter::sizeChanged,
&eSizesUI::widget, &SizeSetter::updateSize);
eSizesUI::font.add(&app, [&app](const int size) {
const auto fm = QFontMetrics(OS_FONT);
Expand All @@ -169,7 +172,7 @@ int main(int argc, char *argv[])
font.setPixelSize(qRound(mult*OS_FONT.pixelSize()));
}
app.setFont(font);
});*/
});

eSizesUI::widget.add(&eSizesUI::button, [](const int size) {
eSizesUI::button.set(qRound(size*1.1));
Expand Down
2 changes: 1 addition & 1 deletion src/patches/qt/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Qt 5.12.12 patches

Patches used in releases of Friction.
Patches used in Windows releases of Friction.

Loading

0 comments on commit 3d22995

Please sign in to comment.