Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Layer Class Referenceabstract
+ Inheritance diagram for Layer:
Inheritance graph
[legend]
+ Collaboration diagram for Layer:
Collaboration graph
[legend]

Public Types

enum  LAYER_TYPE {
  UNDEFINED = 0 , BITMAP = 1 , VECTOR = 2 , MOVIE = 3 ,
  SOUND = 4 , CAMERA = 5
}
 

Public Member Functions

 Layer (int id, LAYER_TYPE eType)
 
int id () const
 
void setId (int layerId)
 
LAYER_TYPE type () const
 
void setName (QString name)
 
QString name () const
 
void switchVisibility ()
 
bool visible () const
 
void setVisible (bool b)
 
QList< int > selectedKeyFramesPositions () const
 Get selected keyframe positions sorted by position.
 
QList< int > selectedKeyFramesByLast () const
 Get selected keyframe positions based on the order they were selected.
 
virtual Status saveKeyFrameFile (KeyFrame *, QString dataPath)=0
 
virtual void loadDomElement (const QDomElement &element, QString dataDirPath, ProgressCallback progressForward)=0
 
virtual QDomElement createDomElement (QDomDocument &doc) const =0
 
QDomElement createBaseDomElement (QDomDocument &doc) const
 
void loadBaseDomElement (const QDomElement &elem)
 
int getMaxKeyFramePosition () const
 
int firstKeyFramePosition () const
 
bool keyExists (int position) const
 
int getPreviousKeyFramePosition (int position) const
 
int getNextKeyFramePosition (int position) const
 
int getPreviousFrameNumber (int position, bool isAbsolute) const
 
int getNextFrameNumber (int position, bool isAbsolute) const
 
int keyFrameCount () const
 
int selectedKeyFrameCount () const
 
bool hasAnySelectedFrames () const
 
bool insertExposureAt (int position)
 Will insert an empty frame (exposure) after the given position.
 
bool addNewKeyFrameAt (int position)
 Creates a new keyframe at the given position, unless one already exists.
 
void addOrReplaceKeyFrame (int position, KeyFrame *pKeyFrame)
 
virtual bool addKeyFrame (int position, KeyFrame *pKeyFrame)
 Adds a keyframe at the given position, unless one already exists.
 
virtual bool removeKeyFrame (int position)
 
virtual void replaceKeyFrame (const KeyFrame *pKeyFrame)=0
 
bool swapKeyFrames (int position1, int position2)
 
bool moveKeyFrame (int position, int offset)
 
KeyFrame * getKeyFrameAt (int position) const
 
KeyFrame * getLastKeyFrameAtPosition (int position) const
 
bool keyExistsWhichCovers (int frameNumber)
 
KeyFrame * getKeyFrameWhichCovers (int frameNumber) const
 
void foreachKeyFrame (std::function< void(KeyFrame *)>) const
 
void setModified (int position, bool isModified) const
 
bool isFrameSelected (int position) const
 
void setFrameSelected (int position, bool isSelected)
 
void toggleFrameSelected (int position, bool allowMultiple=false)
 
void extendSelectionTo (int position)
 
void selectAllFramesAfter (int position)
 
bool newSelectionOfConnectedFrames (int position)
 Make a selection from specified position until a blank spot appears The search is only looking forward, e.g.
 
void setExposureForSelectedFrames (int offset)
 Add or subtract exposure from selected frames.
 
bool reverseOrderOfSelection ()
 Reverse order of selected frames.
 
void deselectAll ()
 
bool moveSelectedFrames (int offset)
 
QList< int > getSelectedFramesByPos () const
 
bool canMoveSelectedFramesToOffset (int offset) const
 Predetermines whether the frames can be moved to a new position depending on the offset.
 
Status save (const QString &sDataFolder, QStringList &attachedFiles, ProgressCallback progressStep)
 
virtual Status presave (const QString &sDataFolder)
 
bool isPaintable () const
 
QList< int > dirtyFrames () const
 Returns a list of dirty frame positions.
 
void markFrameAsDirty (const int frameNumber)
 Mark the frame position as dirty.
 
void clearDirtyFrames ()
 Clear the list of dirty keyframes.
 

Protected Member Functions

virtual KeyFrame * createKeyFrame (int position)=0
 
bool loadKey (KeyFrame *)
 

Private Member Functions

void removeFromSelectionList (int position)
 

Private Attributes

LAYER_TYPE meType = UNDEFINED
 
int mId = 0
 
bool mVisible = true
 
QString mName
 
std::map< int, KeyFrame *, std::greater< int > > mKeyFrames
 
QList< int > mSelectedFrames_byLast
 
QList< int > mSelectedFrames_byPosition
 
QList< int > mDirtyFrames
 

Detailed Description

Definition at line 32 of file layer.h.

Member Enumeration Documentation

◆ LAYER_TYPE

enum Layer::LAYER_TYPE

Definition at line 36 of file layer.h.

Constructor & Destructor Documentation

◆ Layer()

Layer::Layer ( int  id,
LAYER_TYPE  eType 
)
explicit

Definition at line 32 of file layer.cpp.

◆ ~Layer()

Layer::~Layer ( )
virtual

Definition at line 42 of file layer.cpp.

Member Function Documentation

◆ addKeyFrame()

bool Layer::addKeyFrame ( int  position,
KeyFrame *  pKeyFrame 
)
virtual

Adds a keyframe at the given position, unless one already exists.

Parameters
positionThe new position of the keyframe
pKeyFrameThe keyframe to add. Its previous position will be overwritten
Returns
false if a keyframe already exists at the position, true if the keyframe was successfully added

Reimplemented in LayerCamera.

Definition at line 191 of file layer.cpp.

◆ addNewKeyFrameAt()

bool Layer::addNewKeyFrameAt ( int  position)

Creates a new keyframe at the given position, unless one already exists.

Parameters
positionThe position of the new keyframe
Returns
false if a keyframe already exists at the position, true if the new keyframe was successfully added

Definition at line 170 of file layer.cpp.

◆ addOrReplaceKeyFrame()

void Layer::addOrReplaceKeyFrame ( int  position,
KeyFrame *  pKeyFrame 
)

Definition at line 183 of file layer.cpp.

◆ canMoveSelectedFramesToOffset()

bool Layer::canMoveSelectedFramesToOffset ( int  offset) const

Predetermines whether the frames can be moved to a new position depending on the offset.

Parameters
offsetShould be start press position - current position
Returns
true if selected frames can be moved otherwise false

Definition at line 507 of file layer.cpp.

◆ clearDirtyFrames()

void Layer::clearDirtyFrames ( )
inline

Clear the list of dirty keyframes.

Definition at line 173 of file layer.h.

◆ createBaseDomElement()

QDomElement Layer::createBaseDomElement ( QDomDocument &  doc) const

Definition at line 706 of file layer.cpp.

◆ deselectAll()

void Layer::deselectAll ( )

Definition at line 496 of file layer.cpp.

◆ dirtyFrames()

QList< int > Layer::dirtyFrames ( ) const
inline

Returns a list of dirty frame positions.

Definition at line 166 of file layer.h.

◆ extendSelectionTo()

void Layer::extendSelectionTo ( int  position)

Definition at line 430 of file layer.cpp.

◆ firstKeyFramePosition()

int Layer::firstKeyFramePosition ( ) const

Definition at line 152 of file layer.cpp.

◆ foreachKeyFrame()

void Layer::foreachKeyFrame ( std::function< void(KeyFrame *)>  action) const

Definition at line 52 of file layer.cpp.

◆ getKeyFrameAt()

KeyFrame * Layer::getKeyFrameAt ( int  position) const

Definition at line 65 of file layer.cpp.

◆ getKeyFrameWhichCovers()

KeyFrame * Layer::getKeyFrameWhichCovers ( int  frameNumber) const

Definition at line 693 of file layer.cpp.

◆ getLastKeyFrameAtPosition()

KeyFrame * Layer::getLastKeyFrameAtPosition ( int  position) const

Definition at line 75 of file layer.cpp.

◆ getMaxKeyFramePosition()

int Layer::getMaxKeyFramePosition ( ) const

Definition at line 161 of file layer.cpp.

◆ getNextFrameNumber()

int Layer::getNextFrameNumber ( int  position,
bool  isAbsolute 
) const

Definition at line 137 of file layer.cpp.

◆ getNextKeyFramePosition()

int Layer::getNextKeyFramePosition ( int  position) const

Definition at line 99 of file layer.cpp.

◆ getPreviousFrameNumber()

int Layer::getPreviousFrameNumber ( int  position,
bool  isAbsolute 
) const

Definition at line 121 of file layer.cpp.

◆ getPreviousKeyFramePosition()

int Layer::getPreviousKeyFramePosition ( int  position) const

Definition at line 89 of file layer.cpp.

◆ getSelectedFramesByPos()

QList< int > Layer::getSelectedFramesByPos ( ) const
inline

Definition at line 151 of file layer.h.

◆ hasAnySelectedFrames()

bool Layer::hasAnySelectedFrames ( ) const
inline

Definition at line 85 of file layer.h.

◆ id()

int Layer::id ( ) const
inline

Definition at line 49 of file layer.h.

◆ insertExposureAt()

bool Layer::insertExposureAt ( int  position)

Will insert an empty frame (exposure) after the given position.

Parameters
positionThe frame to add exposure to

Definition at line 204 of file layer.cpp.

◆ isFrameSelected()

bool Layer::isFrameSelected ( int  position) const

Definition at line 382 of file layer.cpp.

◆ isPaintable()

bool Layer::isPaintable ( ) const

Definition at line 683 of file layer.cpp.

◆ keyExists()

bool Layer::keyExists ( int  position) const

Definition at line 60 of file layer.cpp.

◆ keyExistsWhichCovers()

bool Layer::keyExistsWhichCovers ( int  frameNumber)

Definition at line 688 of file layer.cpp.

◆ keyFrameCount()

int Layer::keyFrameCount ( ) const
inline

Definition at line 83 of file layer.h.

◆ loadBaseDomElement()

void Layer::loadBaseDomElement ( const QDomElement &  elem)

Definition at line 716 of file layer.cpp.

◆ loadKey()

bool Layer::loadKey ( KeyFrame *  pKey)
protected

Definition at line 328 of file layer.cpp.

◆ markFrameAsDirty()

void Layer::markFrameAsDirty ( const int  frameNumber)
inline

Mark the frame position as dirty.

Any operation causing the frame to be modified, added, updated or removed, should call this.

Definition at line 170 of file layer.h.

◆ moveKeyFrame()

bool Layer::moveKeyFrame ( int  position,
int  offset 
)

Definition at line 241 of file layer.cpp.

◆ moveSelectedFrames()

bool Layer::moveSelectedFrames ( int  offset)

Definition at line 627 of file layer.cpp.

◆ name()

QString Layer::name ( ) const
inline

Definition at line 54 of file layer.h.

◆ newSelectionOfConnectedFrames()

bool Layer::newSelectionOfConnectedFrames ( int  position)

Make a selection from specified position until a blank spot appears The search is only looking forward, e.g.

|123| 4 5
^
pos/search from
Parameters
positionthe current position

Definition at line 458 of file layer.cpp.

◆ presave()

virtual Status Layer::presave ( const QString &  sDataFolder)
inlinevirtual

Definition at line 161 of file layer.h.

◆ removeFromSelectionList()

void Layer::removeFromSelectionList ( int  position)
private

Definition at line 235 of file layer.cpp.

◆ removeKeyFrame()

bool Layer::removeKeyFrame ( int  position)
virtual

Definition at line 218 of file layer.cpp.

◆ reverseOrderOfSelection()

bool Layer::reverseOrderOfSelection ( )

Reverse order of selected frames.

Returns
true if all frames were successfully reversed, otherwise will return false.

Definition at line 612 of file layer.cpp.

◆ save()

Status Layer::save ( const QString &  sDataFolder,
QStringList &  attachedFiles,
ProgressCallback  progressStep 
)

Definition at line 340 of file layer.cpp.

◆ selectAllFramesAfter()

void Layer::selectAllFramesAfter ( int  position)

Definition at line 478 of file layer.cpp.

◆ selectedKeyFrameCount()

int Layer::selectedKeyFrameCount ( ) const
inline

Definition at line 84 of file layer.h.

◆ selectedKeyFramesByLast()

QList< int > Layer::selectedKeyFramesByLast ( ) const
inline

Get selected keyframe positions based on the order they were selected.

Definition at line 65 of file layer.h.

◆ selectedKeyFramesPositions()

QList< int > Layer::selectedKeyFramesPositions ( ) const
inline

Get selected keyframe positions sorted by position.

Definition at line 62 of file layer.h.

◆ setExposureForSelectedFrames()

void Layer::setExposureForSelectedFrames ( int  offset)

Add or subtract exposure from selected frames.

Parameters
offsetAny value above 0 for adding exposure and any value below 0 to subtract exposure

Definition at line 522 of file layer.cpp.

◆ setFrameSelected()

void Layer::setFrameSelected ( int  position,
bool  isSelected 
)

Definition at line 392 of file layer.cpp.

◆ setId()

void Layer::setId ( int  layerId)
inline

Definition at line 50 of file layer.h.

◆ setModified()

void Layer::setModified ( int  position,
bool  isModified 
) const

Definition at line 373 of file layer.cpp.

◆ setName()

void Layer::setName ( QString  name)
inline

Definition at line 53 of file layer.h.

◆ setVisible()

void Layer::setVisible ( bool  b)
inline

Definition at line 59 of file layer.h.

◆ swapKeyFrames()

bool Layer::swapKeyFrames ( int  position1,
int  position2 
)

Definition at line 299 of file layer.cpp.

◆ switchVisibility()

void Layer::switchVisibility ( )
inline

Definition at line 56 of file layer.h.

◆ toggleFrameSelected()

void Layer::toggleFrameSelected ( int  position,
bool  allowMultiple = false 
)

Definition at line 418 of file layer.cpp.

◆ type()

LAYER_TYPE Layer::type ( ) const
inline

Definition at line 51 of file layer.h.

◆ visible()

bool Layer::visible ( ) const
inline

Definition at line 58 of file layer.h.

Member Data Documentation

◆ mDirtyFrames

QList<int> Layer::mDirtyFrames
private

Definition at line 197 of file layer.h.

◆ meType

LAYER_TYPE Layer::meType = UNDEFINED
private

Definition at line 182 of file layer.h.

◆ mId

int Layer::mId = 0
private

Definition at line 183 of file layer.h.

◆ mKeyFrames

std::map<int, KeyFrame*, std::greater<int> > Layer::mKeyFrames
private

Definition at line 187 of file layer.h.

◆ mName

QString Layer::mName
private

Definition at line 185 of file layer.h.

◆ mSelectedFrames_byLast

QList<int> Layer::mSelectedFrames_byLast
private

Definition at line 193 of file layer.h.

◆ mSelectedFrames_byPosition

QList<int> Layer::mSelectedFrames_byPosition
private

Definition at line 194 of file layer.h.

◆ mVisible

bool Layer::mVisible = true
private

Definition at line 184 of file layer.h.


The documentation for this class was generated from the following files:
  • core_lib/src/structure/layer.h
  • core_lib/src/structure/layer.cpp
Generated on Thu May 8 2025 04:47:54 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39