18#include "cameracontextmenu.h"
20#include "cameraeasingtype.h"
21#include "layercamera.h"
24CameraContextMenu::CameraContextMenu(
int frameNumber,
const LayerCamera* layer) :
25 mFrameNumber(frameNumber), mCurrentLayer(layer)
28 int nextFrame = layer->getNextKeyFramePosition(frameNumber);
30 QMenu* cameraInterpolationMenu = addMenu(tr(
"Easing: frame %1 to %2").arg(frameNumber).arg(nextFrame));
32 cameraInterpolationMenu->
setEnabled(layer->getMaxKeyFramePosition() != frameNumber);
34 Camera* selectedKey = layer->getCameraAtFrame(frameNumber);
35 if (selectedKey !=
nullptr) {
36 QAction* selectedAction = cameraInterpolationMenu->
addAction(tr(
"Selected: ") + getInterpolationText(selectedKey->getEasingType()));
40 cameraInterpolationMenu->
addAction(tr(
"Linear"), [=] { layer->setCameraEasingAtFrame(CameraEasingType::LINEAR, frameNumber); });
42 QMenu* inMenu = cameraInterpolationMenu->
addMenu(tr(
"In"));
43 QMenu* outMenu = cameraInterpolationMenu->
addMenu(tr(
"Out"));
44 QMenu* inOutMenu = cameraInterpolationMenu->
addMenu(tr(
"In-Out"));
45 QMenu* outInMenu = cameraInterpolationMenu->
addMenu(tr(
"Out-In"));
48 QString moderate = tr(
"Moderate");
52 QString fastest = tr(
"Fastest");
53 QString circleBased = tr(
"Circle-based");
54 QString overshoot = tr(
"Overshoot");
55 QString elastic = tr(
"Elastic");
58 inMenu->
addAction(slow, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INSINE, frameNumber); });
59 outMenu->
addAction(slow, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTSINE, frameNumber); });
60 inOutMenu->
addAction(slow, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTSINE, frameNumber); });
61 outInMenu->
addAction(slow, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINSINE, frameNumber); });
62 inMenu->
addAction(moderate, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INQUAD, frameNumber); });
63 outMenu->
addAction(moderate, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTQUAD, frameNumber); });
64 inOutMenu->
addAction(moderate, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTQUAD, frameNumber); });
65 outInMenu->
addAction(moderate, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINQUAD, frameNumber); });
66 inMenu->
addAction(quick, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INCUBIC, frameNumber); });
67 outMenu->
addAction(quick, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTCUBIC, frameNumber); });
68 inOutMenu->
addAction(quick, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTCUBIC, frameNumber); });
69 outInMenu->
addAction(quick, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINCUBIC, frameNumber); });
70 inMenu->
addAction(fast, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INQUART, frameNumber); });
71 outMenu->
addAction(fast, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTQUART, frameNumber); });
72 inOutMenu->
addAction(fast, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTQUART, frameNumber); });
73 outInMenu->
addAction(fast, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINQUART, frameNumber); });
74 inMenu->
addAction(faster, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INQUINT, frameNumber); });
75 outMenu->
addAction(faster, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTQUINT, frameNumber); });
76 inOutMenu->
addAction(faster, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTQUINT, frameNumber); });
77 outInMenu->
addAction(faster, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINQUINT, frameNumber); });
78 inMenu->
addAction(fastest, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INEXPO, frameNumber); });
79 outMenu->
addAction(fastest, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTEXPO, frameNumber); });
80 inOutMenu->
addAction(fastest, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTEXPO, frameNumber); });
81 outInMenu->
addAction(fastest, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINEXPO, frameNumber); });
82 inMenu->
addAction(circleBased, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INCIRC, frameNumber); });
83 outMenu->
addAction(circleBased, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTCIRC, frameNumber); });
84 inOutMenu->
addAction(circleBased, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTCIRC, frameNumber); });
85 outInMenu->
addAction(circleBased, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINCIRC, frameNumber); });
86 inMenu->
addAction(overshoot, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INBACK, frameNumber); });
87 outMenu->
addAction(overshoot, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTBACK, frameNumber); });
88 inOutMenu->
addAction(overshoot, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTBACK, frameNumber); });
89 outInMenu->
addAction(overshoot, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINBACK, frameNumber); });
90 inMenu->
addAction(elastic, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INELASTIC, frameNumber); });
91 outMenu->
addAction(elastic, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTELASTIC, frameNumber); });
92 inOutMenu->
addAction(elastic, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTELASTIC, frameNumber); });
93 outInMenu->
addAction(elastic, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINELASTIC, frameNumber); });
94 inMenu->
addAction(bounce, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INBOUNCE, frameNumber); });
95 outMenu->
addAction(bounce, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTBOUNCE, frameNumber); });
96 inOutMenu->
addAction(bounce, [=] { layer->setCameraEasingAtFrame(CameraEasingType::INOUTBOUNCE, frameNumber); });
97 outInMenu->
addAction(bounce, [=] { layer->setCameraEasingAtFrame(CameraEasingType::OUTINBOUNCE, frameNumber); });
99 QMenu* cameraFieldMenu = addMenu(tr(
"Transform"));
100 cameraFieldMenu->
addAction(tr(
"Reset all"), [=] { layer->resetCameraAtFrame(CameraFieldOption::RESET_FIELD, frameNumber); });
102 cameraFieldMenu->
addAction(tr(
"Reset position"), [=] { layer->resetCameraAtFrame(CameraFieldOption::RESET_TRANSLATION, frameNumber); });
103 cameraFieldMenu->
addAction(tr(
"Reset scale"), [=] { layer->resetCameraAtFrame(CameraFieldOption::RESET_SCALING, frameNumber); });
104 cameraFieldMenu->
addAction(tr(
"Reset rotation"), [=] { layer->resetCameraAtFrame(CameraFieldOption::RESET_ROTATION, frameNumber); });
106 QAction* alignHAction = cameraFieldMenu->
addAction(tr(
"Align horizontally to frame %1").arg(nextFrame), [=] { layer->resetCameraAtFrame(CameraFieldOption::ALIGN_HORIZONTAL, frameNumber); });
107 QAction* alignVAction = cameraFieldMenu->
addAction(tr(
"Align vertically to frame %1").arg(nextFrame), [=] { layer->resetCameraAtFrame(CameraFieldOption::ALIGN_VERTICAL, frameNumber); });
109 QAction* holdAction = cameraFieldMenu->
addAction(tr(
"Hold to keyframe %1").arg(nextFrame), [=] { layer->resetCameraAtFrame(CameraFieldOption::HOLD_FRAME, frameNumber); });
110 if (frameNumber == layer->getMaxKeyFramePosition()) {