timeline_frames_view.h 5.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *  Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
 *
 *  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 2 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, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

19 20
#ifndef __TIMELINE_FRAMES_VIEW_H
#define __TIMELINE_FRAMES_VIEW_H
21 22 23

#include <QScopedPointer>
#include <QTableView>
24
#include "kis_action_manager.h"
25 26
#include "kritaanimationdocker_export.h"

27
class KisAction;
28
class TimelineWidget;
29

30
class KRITAANIMATIONDOCKER_EXPORT TimelineFramesView : public QTableView
31 32 33
{
    Q_OBJECT
public:
34
    TimelineFramesView(QWidget *parent);
35
    ~TimelineFramesView() override;
36

37
    void setModel(QAbstractItemModel *model) override;
38

39
    void updateGeometries() override;
40

41 42
    void setShowInTimeline(KisAction *action);

43 44
    void setActionManager( KisActionManager * actionManager);

45
public Q_SLOTS:
46
    void slotSelectionChanged();
47
    void slotUpdateIcons();
48 49 50

private Q_SLOTS:
    void slotUpdateLayersMenu();
51
    void slotUpdateFrameActions();
52

53 54 55 56
    void slotSetStartTimeToCurrentPosition();
    void slotSetEndTimeToCurrentPosition();
    void slotUpdatePlackbackRange();

57
    // Layer
58 59 60 61 62 63
    void slotAddNewLayer();
    void slotAddExistingLayer(QAction *action);
    void slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
    void slotRemoveLayer();
    void slotLayerContextMenuRequested(const QPoint &globalPos);

64
    // New, Copy, Insert and Remove Frames
65 66
    void slotNewFrame();
    void slotCopyFrame();
67

68 69
    void slotInsertKeyframesLeft(int count = 1, int timing = 1, bool forceEntireColumn = false);
    void slotInsertKeyframesRight(int count = 1, int timing = 1, bool forceEntireColumn = false);
70 71 72 73 74 75 76

    void slotInsertKeyframesLeftCustom();
    void slotInsertKeyframesRightCustom();

    void slotRemoveFrame(bool forceEntireColumn = false, bool needsOffset = false);
    void slotRemoveFramesAndShift(bool forceEntireColumn = false);

77
    void slotInsertColumnsLeft(int count = 1, int timing = 1);
78 79
    void slotInsertColumnsLeftCustom();

80
    void slotInsertColumnsRight(int count = 1, int timing = 1);
81 82 83 84
    void slotInsertColumnsRightCustom();

    void slotRemoveColumns();
    void slotRemoveColumnsAndShift();
85

86 87
    void slotInsertHoldFrames(int count = 1, bool forceEntireColumn = false);
    void slotRemoveHoldFrames(int count = 1, bool forceEntireColumn = false);
88

89
    void slotInsertHoldFramesCustom();
90 91
    void slotRemoveHoldFramesCustom();

92 93 94 95 96 97
    void slotInsertHoldColumns(int count = 1);
    void slotRemoveHoldColumns(int count = 1);

    void slotInsertHoldColumnsCustom();
    void slotRemoveHoldColumnsCustom();

98 99 100
    void slotMirrorFrames(bool forceEntireColumn = false);
    void slotMirrorColumns();

101
    // Copy-paste
102 103 104 105 106 107 108 109
    void slotCopyFrames(bool forceEntireColumn = false);
    void slotCutFrames(bool forceEntireColumn = false);
    void slotPasteFrames(bool forceEntireColumn = false);

    void slotCopyColumns();
    void slotCutColumns();
    void slotPasteColumns();

110 111 112 113
    void slotReselectCurrentIndex();

    void slotUpdateInfiniteFramesCount();

114 115
    void slotHeaderDataChanged(Qt::Orientation orientation, int first, int last);

116 117
    void slotZoomButtonPressed(qreal staticPoint);
    void slotZoomButtonChanged(qreal value);
118

119
    void slotColorLabelChanged(int);
120 121
    void slotEnsureRowVisible(int row);

122
    // Audio
123 124 125 126
    void slotSelectAudioChannelFile();
    void slotAudioChannelMute(bool value);
    void slotAudioChannelRemove();
    void slotUpdateAudioActions();
127
    void slotAudioVolumeChanged(int value);
128

129 130
private:
    void setFramesPerSecond(int fps);
131
    void calculateSelectionMetrics(int &minColumn, int &maxColumn, QSet<int> &rows) const;
132

133
    void insertFramesImpl(int insertAtColumn, int count, int timing, QSet<int> rows, bool forceEntireColumn);
134

135 136
    void createFrameEditingMenuActions(QMenu *menu, bool addFrameCreationActions);

137 138
    QModelIndexList calculateSelectionSpan(bool forceEntireColumn, bool editableOnly = true) const;
    void cutCopyImpl(bool forceEntireColumn, bool copy);
139

140 141 142 143 144 145 146 147 148 149 150 151
    int defaultNumberOfFramesToAdd() const;
    void setDefaultNumberOfFramesToAdd(int value) const;

    int defaultNumberOfColumnsToAdd() const;
    void setDefaultNumberOfColumnsToAdd(int value) const;

    int defaultNumberOfFramesToRemove() const;
    void setDefaultNumberOfFramesToRemove(int value) const;

    int defaultNumberOfColumnsToRemove() const;
    void setDefaultNumberOfColumnsToRemove(int value) const;

152
protected:
153
    QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
154 155 156 157 158 159 160 161 162 163 164 165 166 167
                                                         const QEvent *event) const override;

    void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
    void startDrag(Qt::DropActions supportedActions) override;
    void dragEnterEvent(QDragEnterEvent *event) override;
    void dragMoveEvent(QDragMoveEvent *event) override;
    void dropEvent(QDropEvent *event) override;
    void dragLeaveEvent(QDragLeaveEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *e) override;
    void mouseReleaseEvent(QMouseEvent *e) override;
    void wheelEvent(QWheelEvent *e) override;
    void rowsInserted(const QModelIndex& parent, int start, int end) override;
    bool viewportEvent(QEvent *event) override;
168 169 170 171 172 173

private:
    struct Private;
    const QScopedPointer<Private> m_d;
};

174
#endif /* __TIMELINE_FRAMES_VIEW_H */