25#include "pencilerror.h"
30typedef std::function<void()> ProgressCallback;
34 Q_DECLARE_TR_FUNCTIONS(
Layer)
46 explicit Layer(
int id, LAYER_TYPE eType);
49 int id()
const {
return mId; }
50 void setId(
int layerId) { mId = layerId; }
51 LAYER_TYPE type()
const {
return meType; }
53 void setName(
QString name) { mName = name; }
54 QString name()
const {
return mName; }
56 void switchVisibility() { mVisible = !mVisible; }
58 bool visible()
const {
return mVisible; }
59 void setVisible(
bool b) { mVisible = b; }
68 virtual void loadDomElement(
const QDomElement& element,
QString dataDirPath, ProgressCallback progressForward) = 0;
74 int getMaxKeyFramePosition()
const;
75 int firstKeyFramePosition()
const;
77 bool keyExists(
int position)
const;
78 int getPreviousKeyFramePosition(
int position)
const;
79 int getNextKeyFramePosition(
int position)
const;
80 int getPreviousFrameNumber(
int position,
bool isAbsolute)
const;
81 int getNextFrameNumber(
int position,
bool isAbsolute)
const;
83 int keyFrameCount()
const {
return static_cast<int>(mKeyFrames.size()); }
84 int selectedKeyFrameCount()
const {
return mSelectedFrames_byPosition.
count(); }
85 bool hasAnySelectedFrames()
const {
return !mSelectedFrames_byLast.
empty() && !mSelectedFrames_byPosition.
empty(); }
98 void addOrReplaceKeyFrame(
int position,
KeyFrame* pKeyFrame);
106 virtual bool removeKeyFrame(
int position);
107 virtual void replaceKeyFrame(
const KeyFrame* pKeyFrame) = 0;
109 bool swapKeyFrames(
int position1,
int position2);
110 bool moveKeyFrame(
int position,
int offset);
111 KeyFrame* getKeyFrameAt(
int position)
const;
112 KeyFrame* getLastKeyFrameAtPosition(
int position)
const;
113 bool keyExistsWhichCovers(
int frameNumber);
114 KeyFrame *getKeyFrameWhichCovers(
int frameNumber)
const;
116 void foreachKeyFrame(std::function<
void(
KeyFrame*)>)
const;
118 void setModified(
int position,
bool isModified)
const;
121 bool isFrameSelected(
int position)
const;
122 void setFrameSelected(
int position,
bool isSelected);
123 void toggleFrameSelected(
int position,
bool allowMultiple =
false);
124 void extendSelectionTo(
int position);
125 void selectAllFramesAfter(
int position);
150 bool moveSelectedFrames(
int offset);
151 QList<int> getSelectedFramesByPos()
const {
return mSelectedFrames_byPosition; }
161 virtual Status presave(
const QString& sDataFolder) { Q_UNUSED(sDataFolder);
return Status::SAFE; }
163 bool isPaintable()
const;
176 virtual KeyFrame* createKeyFrame(
int position) = 0;
180 void removeFromSelectionList(
int position);
182 LAYER_TYPE meType = UNDEFINED;
184 bool mVisible =
true;
187 std::map<int, KeyFrame*, std::greater<int>> mKeyFrames;
void markFrameAsDirty(const int frameNumber)
Mark the frame position as dirty.
bool newSelectionOfConnectedFrames(int position)
Make a selection from specified position until a blank spot appears The search is only looking forwar...
QList< int > dirtyFrames() const
Returns a list of dirty frame positions.
bool addNewKeyFrameAt(int position)
Creates a new keyframe at the given position, unless one already exists.
QList< int > selectedKeyFramesPositions() const
Get selected keyframe positions sorted by position.
bool reverseOrderOfSelection()
Reverse order of selected frames.
virtual bool addKeyFrame(int position, KeyFrame *pKeyFrame)
Adds a keyframe at the given position, unless one already exists.
QList< int > selectedKeyFramesByLast() const
Get selected keyframe positions based on the order they were selected.
void setExposureForSelectedFrames(int offset)
Add or subtract exposure from selected frames.
void clearDirtyFrames()
Clear the list of dirty keyframes.
bool canMoveSelectedFramesToOffset(int offset) const
Predetermines whether the frames can be moved to a new position depending on the offset.
bool insertExposureAt(int position)
Will insert an empty frame (exposure) after the given position.
int count(const T &value) const const