diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index 8f2b1d32a..58d8721c4 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -77,6 +77,7 @@ #include "RasterEffects/rastereffectmenucreator.h" #include "BlendEffects/blendeffectmenucreator.h" +#include "TransformEffects/transformeffectmenucreator.h" MainWindow *MainWindow::sInstance = nullptr; @@ -1322,8 +1323,17 @@ void MainWindow::setupMenuEffects() { // path TODO // adapt PathEffectsMenu::addPathEffectsToBoxActionMenu(menu); } - { // transform TODO - // adapt TransformEffectCollection::prp_setupTreeViewMenu(menu); + { // transform + const auto adder = [this, menu](const QString& name, + const TransformEffectMenuCreator::EffectCreator& creator) { + if (name.isEmpty()) { return; } + const auto act = menu->addAction(name); + cmdAddAction(act); + connect(act, &QAction::triggered, this, [this, creator]() { + addTransformEffect(creator()); + }); + }; + TransformEffectMenuCreator::forEveryEffect(adder); } { // blend const auto adder = [this, menu](const QString& name, @@ -1363,6 +1373,18 @@ void MainWindow::addBlendEffect(const qsptr &effect) mDocument.actionFinished(); } +void MainWindow::addTransformEffect(const qsptr &effect) +{ + const auto scene = *mDocument.fActiveScene; + if (!scene) { return; } + + const auto box = scene->getCurrentBox(); + if (!box) { return; } + + box->addTransformEffect(effect); + mDocument.actionFinished(); +} + void MainWindow::setupExtraMenus() { const auto menu = new QMenu(this); diff --git a/src/app/GUI/mainwindow.h b/src/app/GUI/mainwindow.h index f91fd4861..08fb5e82b 100644 --- a/src/app/GUI/mainwindow.h +++ b/src/app/GUI/mainwindow.h @@ -366,6 +366,7 @@ class MainWindow : public QMainWindow void setupMenuEffects(); void addRasterEffect(const qsptr &effect); void addBlendEffect(const qsptr &effect); + void addTransformEffect(const qsptr &effect); void setupExtraMenus(); QList mLoadedGradientsList; diff --git a/src/core/BlendEffects/blendeffectmenucreator.h b/src/core/BlendEffects/blendeffectmenucreator.h index 55ec75435..66218f480 100644 --- a/src/core/BlendEffects/blendeffectmenucreator.h +++ b/src/core/BlendEffects/blendeffectmenucreator.h @@ -24,6 +24,8 @@ #ifndef BLENDEFFECTMENUCREATOR_H #define BLENDEFFECTMENUCREATOR_H +#include "core_global.h" + #include #include #include "BlendEffects/moveblendeffect.h" diff --git a/src/core/Boxes/boundingbox.cpp b/src/core/Boxes/boundingbox.cpp index 99316bc72..25c398429 100644 --- a/src/core/Boxes/boundingbox.cpp +++ b/src/core/Boxes/boundingbox.cpp @@ -1020,6 +1020,11 @@ void BoundingBox::addBlendEffect(const qsptr &blendEffect) mBlendEffectCollection->addChild(blendEffect); } +void BoundingBox::addTransformEffect(const qsptr &transformEffect) +{ + mTransformEffectCollection->addChild(transformEffect); +} + //int BoundingBox::prp_getParentFrameShift() const { // if(!mParentGroup) { // return 0; diff --git a/src/core/Boxes/boundingbox.h b/src/core/Boxes/boundingbox.h index 731133ecb..99497db56 100644 --- a/src/core/Boxes/boundingbox.h +++ b/src/core/Boxes/boundingbox.h @@ -367,6 +367,7 @@ class CORE_EXPORT BoundingBox : public eBoxOrSound { void removeRasterEffect(const qsptr &effect); void addBlendEffect(const qsptr &blendEffect); + void addTransformEffect(const qsptr &transformEffect); void setBlendModeSk(const SkBlendMode blendMode); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 210492d2a..f746dd688 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -560,6 +560,7 @@ set( TransformEffects/trackeffect.h TransformEffects/transformeffect.h TransformEffects/transformeffectcollection.h + TransformEffects/transformeffectmenucreator.h XML/runtimewriteid.h XML/xevexporter.h XML/xevimporter.h diff --git a/src/core/TransformEffects/transformeffectmenucreator.h b/src/core/TransformEffects/transformeffectmenucreator.h new file mode 100644 index 000000000..ed3f0b1ed --- /dev/null +++ b/src/core/TransformEffects/transformeffectmenucreator.h @@ -0,0 +1,62 @@ +/* +# +# Friction - https://friction.graphics +# +# Copyright (c) Friction contributors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# See 'README.md' for more information. +# +*/ + +#ifndef TRANSFORMEFFECTMENUCREATOR_H +#define TRANSFORMEFFECTMENUCREATOR_H + +#include "core_global.h" + +#include +#include +#include "TransformEffects/followobjecteffect.h" +#include "TransformEffects/followobjectrelativeeffect.h" +#include "TransformEffects/followpatheffect.h" +#include "TransformEffects/parenteffect.h" +#include "TransformEffects/trackeffect.h" +#include "smartPointers/selfref.h" + +class TransformEffect; + +struct CORE_EXPORT TransformEffectMenuCreator +{ + template using Func = std::function; + template using Creator = Func()>; + using EffectCreator = Creator; + using EffectAdder = Func; + static void forEveryEffect(const EffectAdder& add) + { + add(QObject::tr("Add Track Effect"), + []() { return enve::make_shared(); }); + add(QObject::tr("Add Follow Path Effect"), + []() { return enve::make_shared(); }); + add(QObject::tr("Add Follow Object Effect"), + []() { return enve::make_shared(); }); + add(QObject::tr("Add Follow Object Relative Effect"), + []() { return enve::make_shared(); }); + add(QObject::tr("Add Parent Effect"), + []() { return enve::make_shared(); }); + } +}; + +#endif // TRANSFORMEFFECTMENUCREATOR_H