Skip to content

Commit

Permalink
Easing UX Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Aug 20, 2024
1 parent 77c5eee commit 1cc81da
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 47 deletions.
5 changes: 3 additions & 2 deletions src/app/GUI/Expressions/expressiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,13 @@ bool ExpressionDialog::populateEasingPresets()
mEasingPresetsBox->addItem(tr("Select preset ..."));
}
for (int i = 0; i < presets.size(); ++i) {
QFileInfo file(presets.at(i));
QFileInfo file(presets.at(i).second);
if (mEasingPresetsBox->findText(file.baseName(), Qt::MatchExactly) > -1) {
qWarning() << "expression preset already exists, skip:" << file.absoluteFilePath();
continue;
}
mEasingPresetsBox->addItem(file.baseName(),
mEasingPresetsBox->addItem(QIcon::fromTheme("easing"),
presets.at(i).first,
file.absoluteFilePath());
}
return true;
Expand Down
49 changes: 40 additions & 9 deletions src/app/GUI/animationdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ AnimationDockWidget::AnimationDockWidget(QWidget *parent,

const auto easingButton = new QPushButton(QIcon::fromTheme("easing"),
QString(), this);
easingButton->setToolTip(tr("Ease between two keyframes"));
easingButton->setToolTip(tr("Ease between keyframes"));
easingButton->setFocusPolicy(Qt::NoFocus);
easingButton->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
generateEasingActions(easingButton, keysView);

mLineButton = new QAction(QIcon::fromTheme("segmentLine"),
Expand Down Expand Up @@ -113,6 +115,10 @@ AnimationDockWidget::AnimationDockWidget(QWidget *parent,
addAction(mFitToHeightButton);
//addWidget(valueLines);
addAction(mOnlySelectedAct);

eSizesUI::widget.add(this, [this](const int size) {
setIconSize(QSize(size, size));
});
}

void AnimationDockWidget::showGraph(const bool show)
Expand All @@ -129,19 +135,44 @@ void AnimationDockWidget::showGraph(const bool show)
void AnimationDockWidget::generateEasingActions(QPushButton *button,
KeysView *keysView)
{
const auto presets = AppSupport::getEasingPresets();
const QIcon easeIcon(QIcon::fromTheme("easing"));
const QString easeInText = tr("Ease In ");
const QString easeOutText = tr("Ease Out ");
const QString easeInOutText = tr("Ease In/Out ");

const auto menu = new QMenu(this);
const auto menuIn = new QMenu(easeInText, menu);
const auto menuOut = new QMenu(easeOutText, menu);
const auto menuInOut = new QMenu(easeInOutText, menu);

menuIn->setIcon(easeIcon);
menuOut->setIcon(easeIcon);
menuInOut->setIcon(easeIcon);

const auto presets = AppSupport::getEasingPresets();
for (const auto &preset : presets) {
QString title = preset;
const auto presetAct = new QAction(QIcon::fromTheme("easing"),
title.split("/").takeLast().remove(".js"),
this);
presetAct->setData(preset);
menu->addAction(presetAct);
const auto presetAct = new QAction(easeIcon, QString(), this);
presetAct->setData(preset.second);
QString title = preset.first;
if (title.startsWith(easeInText)) {
title.replace(easeInText, "");
menuIn->addAction(presetAct);
} else if (title.startsWith(easeOutText)) {
title.replace(easeOutText, "");
menuOut->addAction(presetAct);
} else if (title.startsWith(easeInOutText)) {
title.replace(easeInOutText, "");
menuInOut->addAction(presetAct);
}
presetAct->setText(title.simplified());

connect(presetAct, &QAction::triggered,
this, [presetAct, keysView]() {
keysView->graphEasingAction(presetAct->data().toString());
});
}
if (!menu->isEmpty()) { button->setMenu(menu); }
menu->addMenu(menuIn);
menu->addMenu(menuOut);
menu->addMenu(menuInOut);
button->setMenu(menu);
}
9 changes: 7 additions & 2 deletions src/app/friction.qss
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,19 @@ QScrollBar::sub-line:horizontal {
}

QToolBar#animationDockWidget {
margin-bottom: 1em;
margin-right: 1em;
background: transparent;
}

QToolBar#animationDockWidget QToolButton,
QToolBar#animationDockWidget QPushButton {
background-color: %3;
border-radius: 2%;
border-color: %2;
}

QToolBar#animationDockWidget QToolButton::hover,
QToolBar#animationDockWidget QPushButton::hover {
border-color: %4;
}

QTabWidget#TabWidgetWide QTabBar {
Expand Down
70 changes: 37 additions & 33 deletions src/core/appsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,38 +937,42 @@ const AppSupport::ExPreset AppSupport::readEasingPreset(const QString &filename)
return preset;
}

const QStringList AppSupport::getEasingPresets()
{
QStringList presets;
presets << ":/easing/presets/easeInBack.js"
<< ":/easing/presets/easeInBounce.js"
<< ":/easing/presets/easeInCirc.js"
<< ":/easing/presets/easeInCubic.js"
<< ":/easing/presets/easeInElastic.js"
<< ":/easing/presets/easeInExpo.js"
<< ":/easing/presets/easeInOutBack.js"
<< ":/easing/presets/easeInOutBounce.js"
<< ":/easing/presets/easeInOutCirc.js"
<< ":/easing/presets/easeInOutCubic.js"
<< ":/easing/presets/easeInOutElastic.js"
<< ":/easing/presets/easeInOutExpo.js"
<< ":/easing/presets/easeInOutQuad.js"
<< ":/easing/presets/easeInOutQuart.js"
<< ":/easing/presets/easeInOutQuint.js"
<< ":/easing/presets/easeInOutSine.js"
<< ":/easing/presets/easeInQuad.js"
<< ":/easing/presets/easeInQuart.js"
<< ":/easing/presets/easeInQuint.js"
<< ":/easing/presets/easeInSine.js"
<< ":/easing/presets/easeOutBack.js"
<< ":/easing/presets/easeOutBounce.js"
<< ":/easing/presets/easeOutCirc.js"
<< ":/easing/presets/easeOutCubic.js"
<< ":/easing/presets/easeOutElastic.js"
<< ":/easing/presets/easeOutExpo.js"
<< ":/easing/presets/easeOutQuad.js"
<< ":/easing/presets/easeOutQuart.js"
<< ":/easing/presets/easeOutQuint.js"
<< ":/easing/presets/easeOutSine.js";
const QList<QPair<QString, QString> > AppSupport::getEasingPresets()
{
QList<QPair<QString, QString> > presets;

presets.push_back({tr("Ease In Back"), ":/easing/presets/easeInBack.js"});
presets.push_back({tr("Ease In Bounce"), ":/easing/presets/easeInBounce.js"});
presets.push_back({tr("Ease In Circ"), ":/easing/presets/easeInCirc.js"});
presets.push_back({tr("Ease In Cubic"), ":/easing/presets/easeInCubic.js"});
presets.push_back({tr("Ease In Elastic"), ":/easing/presets/easeInElastic.js"});
presets.push_back({tr("Ease In Expo"), ":/easing/presets/easeInExpo.js"});
presets.push_back({tr("Ease In Quad"), ":/easing/presets/easeInQuad.js"});
presets.push_back({tr("Ease In Quart"), ":/easing/presets/easeInQuart.js"});
presets.push_back({tr("Ease In Quint"), ":/easing/presets/easeInQuint.js"});
presets.push_back({tr("Ease In Sine"), ":/easing/presets/easeInSine.js"});

presets.push_back({tr("Ease Out Back"), ":/easing/presets/easeOutBack.js"});
presets.push_back({tr("Ease Out Bounce"), ":/easing/presets/easeOutBounce.js"});
presets.push_back({tr("Ease Out Circ"), ":/easing/presets/easeOutCirc.js"});
presets.push_back({tr("Ease Out Cubic"), ":/easing/presets/easeOutCubic.js"});
presets.push_back({tr("Ease Out Elastic"), ":/easing/presets/easeOutElastic.js"});
presets.push_back({tr("Ease Out Expo"), ":/easing/presets/easeOutExpo.js"});
presets.push_back({tr("Ease Out Quad"), ":/easing/presets/easeOutQuad.js"});
presets.push_back({tr("Ease Out Quart"), ":/easing/presets/easeOutQuart.js"});
presets.push_back({tr("Ease Out Quint"), ":/easing/presets/easeOutQuint.js"});
presets.push_back({tr("Ease Out Sine"), ":/easing/presets/easeOutSine.js"});

presets.push_back({tr("Ease In/Out Back"), ":/easing/presets/easeInOutBack.js"});
presets.push_back({tr("Ease In/Out Bounce"), ":/easing/presets/easeInOutBounce.js"});
presets.push_back({tr("Ease In/Out Circ"), ":/easing/presets/easeInOutCirc.js"});
presets.push_back({tr("Ease In/Out Cubis"), ":/easing/presets/easeInOutCubic.js"});
presets.push_back({tr("Ease In/Out Elastic"), ":/easing/presets/easeInOutElastic.js"});
presets.push_back({tr("Ease In/Out Expo"), ":/easing/presets/easeInOutExpo.js"});
presets.push_back({tr("Ease In/Out Quad"), ":/easing/presets/easeInOutQuad.js"});
presets.push_back({tr("Ease In/Out Quart"), ":/easing/presets/easeInOutQuart.js"});
presets.push_back({tr("Ease In/Out Quint"), ":/easing/presets/easeInOutQuint.js"});
presets.push_back({tr("Ease In/Out Sine"), ":/easing/presets/easeInOutSine.js"});

return presets;
}
2 changes: 1 addition & 1 deletion src/core/appsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class CORE_EXPORT AppSupport : public QObject
static bool setupXDGDesktopIntegration();
static bool removeXDGDesktopIntegration();
static const ExPreset readEasingPreset(const QString &filename);
static const QStringList getEasingPresets();
static const QList<QPair<QString,QString>> getEasingPresets();
};

#endif // APPSUPPORT_H

0 comments on commit 1cc81da

Please sign in to comment.