File indexing completed on 2024-05-26 04:32:21

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Jouni Pentikäinen <joupent@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef _KIS_ANIMATION_CURVE_DOCKER_H_
0008 #define _KIS_ANIMATION_CURVE_DOCKER_H_
0009 
0010 #include <QDockWidget>
0011 #include <kis_mainwindow_observer.h>
0012 #include <QScopedPointer>
0013 #include <kis_types.h>
0014 #include <KisKineticScroller.h>
0015 #include <kis_utility_title_bar.h>
0016 
0017 class QToolButton;
0018 class KisCanvas2;
0019 class KisAction;
0020 class KisTransportControls;
0021 class KisIntParseSpinBox;
0022 class KisDoubleParseSpinBox;
0023 class KisSliderSpinBox;
0024 class KisZoomButton;
0025 class KisCollapsibleButtonGroup;
0026 class KisPlaybackEngine;
0027 
0028 /** @brief A customized titlebar for the Animation Curves Docker that's
0029  * packed with useful widgets and menus.
0030  *
0031  * To avoid cluttering the UI, elements that are important to the
0032  * animator's workflow should be available at a glace, while
0033  * set-and-forget types of things should be hidden inside of menus.
0034  */
0035 class KisAnimCurvesDockerTitlebar : public KisUtilityTitleBar
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040     KisAnimCurvesDockerTitlebar(QWidget *parent = nullptr);
0041 
0042     KisTransportControls* transport;
0043 
0044     KisIntParseSpinBox *sbFrameRegister;
0045 
0046     QToolButton *btnAddKey;
0047     QToolButton *btnRemoveKey;
0048 
0049     KisCollapsibleButtonGroup *btnGroupInterpolation;
0050     KisCollapsibleButtonGroup *btnGroupTangents;
0051     KisCollapsibleButtonGroup *btnGroupZoomFit;
0052 
0053     KisDoubleParseSpinBox *sbValueRegister;
0054 
0055     QToolButton *btnOnionSkinsMenu;
0056     QToolButton *btnAudioMenu;
0057     QToolButton *btnSettingsMenu;
0058 
0059     KisIntParseSpinBox *sbStartFrame;
0060     KisIntParseSpinBox *sbEndFrame;
0061     KisIntParseSpinBox *sbFrameRate;
0062     KisSliderSpinBox *sbSpeed;
0063 
0064     QToolButton *btnDropFrames;
0065 
0066     KisZoomButton *btnZoomHori;
0067     KisZoomButton *btnZoomVert;
0068 
0069 
0070 private:
0071     const int MAX_FRAMES = 9999;
0072 };
0073 
0074 /** @brief Krita's Animation Curves Docker.
0075  * This is the GUI heart of Krita's scalar animation workflow.
0076  */
0077 class KisAnimCurvesDocker : public QDockWidget, public KisMainwindowObserver
0078 {
0079     Q_OBJECT
0080 public:
0081     KisAnimCurvesDocker();
0082     ~KisAnimCurvesDocker() override;
0083 
0084     QString observerName() override { return "AnimationCurveDocker"; }
0085     void setCanvas(KoCanvasBase *canvas) override;
0086     void unsetCanvas() override;
0087     void setViewManager(KisViewManager *kisview) override;
0088     void setPlaybackEngine(KisPlaybackEngine *playbackEngine);
0089 
0090 public Q_SLOTS:
0091     void slotScrollerStateChanged(QScroller::State state);
0092     void slotNodeActivated(KisNodeSP node);
0093     void updateFrameRegister();
0094 
0095     void handleFrameRateChange();
0096 
0097 private Q_SLOTS:
0098     void slotUpdateIcons();
0099 
0100     void slotAddAllEnabledKeys();
0101     void slotAddOpacityKey();
0102     void slotRemoveSelectedKeys();
0103     void slotRemoveOpacityKey();
0104 
0105     void slotListRowsInserted(const QModelIndex &parentIndex, int first, int last);
0106 
0107     void slotValueRegisterChanged(double value);
0108 
0109     void slotActiveNodeUpdate(const QModelIndex index);
0110 
0111     void requestChannelMenuAt(const QPoint& point);
0112     void resetChannelTreeSelection();
0113 private:
0114     // Used for adding multiple keyframes as a batch under one undo command.
0115     void addKeyframeCommandToParent(const QString &channelIdentity, KUndo2Command* parentCMD);
0116 
0117     // Used to quickly add one type of specific key automatically, e.g. Opacity.
0118     void addKeyframeQuick(const QString &channelIdentity);
0119 
0120     void removeKeyframe(const QString &channel);
0121 
0122     struct Private;
0123     const QScopedPointer<Private> m_d;
0124 };
0125 
0126 
0127 #endif