From 53d07d82263c172033ab13a6be44ebcb2e21ff71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 3 Aug 2024 02:17:04 +0200 Subject: [PATCH] Support 'Add Key(s)' shortcut (Insert) --- src/app/GUI/mainwindow.cpp | 9 +++++++++ src/core/canvas.cpp | 10 ++++++++++ src/core/canvas.h | 1 + 3 files changed, 20 insertions(+) diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index c59abbbea..c7264e7a7 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -676,6 +676,15 @@ void MainWindow::setupMenuBar() mEditMenu->addSeparator(); + const auto addKeyAct = mEditMenu->addAction(tr("Add Key(s)"), [this]() { + const auto scene = *mDocument.fActiveScene; + if (!scene) { return; } + scene->addKeySelectedProperties(); + }, QKeySequence(tr("Insert"))); + cmdAddAction(addKeyAct); + + mEditMenu->addSeparator(); + const auto clearCacheAct = mEditMenu->addAction(tr("Clear Cache", "MenuBar_Edit"), [this]() { const auto m = MemoryHandler::sInstance; m->clearMemory(); diff --git a/src/core/canvas.cpp b/src/core/canvas.cpp index ea032d824..2414b1db8 100644 --- a/src/core/canvas.cpp +++ b/src/core/canvas.cpp @@ -504,6 +504,16 @@ void Canvas::clearMarkers() emit requestUpdate(); } +void Canvas::addKeySelectedProperties() +{ + for (const auto &prop : mSelectedProps.getList()) { + const auto asAnim = enve_cast(prop); + if (!asAnim) { continue; } + asAnim->anim_saveCurrentValueAsKey(); + } + mDocument.actionFinished(); +} + stdsptr Canvas::createRenderData() { return enve::make_shared(this); } diff --git a/src/core/canvas.h b/src/core/canvas.h index f43a9873b..6dd125007 100644 --- a/src/core/canvas.h +++ b/src/core/canvas.h @@ -369,6 +369,7 @@ class CORE_EXPORT Canvas : public CanvasBase const std::vector getMarkers(); void clearMarkers(); + void addKeySelectedProperties(); ColorAnimator *getBgColorAnimator() {