FuncDoodle
Loading...
Searching...
No Matches
FuncDoodle::ProjectFile Class Reference

Class that is responsible for storing, reading & saving users' project files. More...

#include <Project.h>

Public Member Functions

 ProjectFile (char name[256], int width, int height, char author[100], int fps, char desc[512], Platform::Window *win, Col bgCol)
 Creates a new in-memory project file.
 ~ProjectFile ()
const char * AnimName () const
 Returns the animation name.
void SetAnimName (char name[256])
 Sets the animation name.
int AnimWidth () const
 Returns the animation width in pixels.
void SetAnimWidth (int width, bool clear=false)
 Sets the animation width.
int AnimHeight () const
 Returns the animation height in pixels.
void SetAnimHeight (int height, bool clear=false)
 Sets the animation height.
const char * AnimAuthor () const
 Returns the animation author.
void SetAnimAuthor (char *author)
 Sets the animation author.
int AnimFPS () const
 Returns the animation frame rate.
void SetAnimFPS (int FPS)
 Sets the animation frame rate.
const char * AnimDesc () const
 Returns the animation description.
void SetAnimDesc (char *desc)
 Sets the animation description.
unsigned long AnimFrameCount () const
 Returns the number of frames in the animation.
void SetAnimFrameCount (unsigned long count)
 Resizes the animation frame count.
void SetBgCol (const float *bgCol)
 Sets the project background color and rebuilds backing frame storage.
Col BgCol () const
 Returns the current background color.
const char * LastSavePath () const
 Returns the last saved file path.
SharedPtr< LongIndexArrayAnimFrames ()
 Returns the animation frame storage.
void Write (const char *fileName)
 Serializes the project to disk.
void ReadAndPopulate (const char *filePath)
 Loads project data from disk into this instance.
void Export (const char *filePath, int format)
 Exports the animation using the chosen format.
constexpr Platform::WindowWindow () const
 Returns the owning application window.
bool Saved () const
 Returns whether the project matches the last saved state.
void DisplayAltFPS (double fps)
 Shows a temporary FPS value in the window title.
void UpdateTitle ()
 Refreshes the window title using current project state.
template<typename T>
void PushUndoable (T &&action)
 Pushes a new undoable action and clears redo history.
void Undo ()
 Undoes the most recent action on the undo stack.
void Redo ()
 Reapplies the most recent action on the redo stack.
void ClearRedoStack ()
 Removes all actions from the redo stack.

Private Attributes

char m_Name [256]
int m_Width = 0
int m_Height = 0
char m_Author [100]
int m_FPS = 0
char m_Desc [512]
SharedPtr< LongIndexArraym_Frames
Platform::Windowm_Window
std::stack< UniquePtr< Action > > m_UndoStack
std::stack< UniquePtr< Action > > m_RedoStack
bool m_Saved = false
const char * m_LastSavePath = ""
Col m_BG

Detailed Description

Class that is responsible for storing, reading & saving users' project files.

Represents a user's project, handling all aspects of its lifecycle - including in-memory storage of project data, deserializing from disk, and serializing back to the .fdp binary format that is documented in ../doc/FDP.md

Invariant
m_Window != nullptr
m_Width > 0
m_Height > 0

Constructor & Destructor Documentation

◆ ProjectFile()

FuncDoodle::ProjectFile::ProjectFile ( char name[256],
int width,
int height,
char author[100],
int fps,
char desc[512],
Platform::Window * win,
Col bgCol )

Creates a new in-memory project file.

Parameters
nameAnimation name buffer.
widthInitial canvas width.
heightInitial canvas height.
authorAnimation author buffer.
fpsInitial playback FPS.
descAnimation description buffer.
winWindow used for title updates.
bgColInitial background color.

◆ ~ProjectFile()

FuncDoodle::ProjectFile::~ProjectFile ( )
default

Member Function Documentation

◆ AnimAuthor()

const char * FuncDoodle::ProjectFile::AnimAuthor ( ) const
nodiscard

Returns the animation author.

Returns
Author string.

◆ AnimDesc()

const char * FuncDoodle::ProjectFile::AnimDesc ( ) const
nodiscard

Returns the animation description.

Returns
Description string.

◆ AnimFPS()

int FuncDoodle::ProjectFile::AnimFPS ( ) const
nodiscard

Returns the animation frame rate.

Returns
Frames per second.

◆ AnimFrameCount()

unsigned long FuncDoodle::ProjectFile::AnimFrameCount ( ) const
nodiscard

Returns the number of frames in the animation.

Returns
Frame count.

◆ AnimFrames()

SharedPtr< LongIndexArray > FuncDoodle::ProjectFile::AnimFrames ( )

Returns the animation frame storage.

Returns
Shared frame array.

◆ AnimHeight()

int FuncDoodle::ProjectFile::AnimHeight ( ) const
nodiscard

Returns the animation height in pixels.

Returns
Canvas height.

◆ AnimName()

const char * FuncDoodle::ProjectFile::AnimName ( ) const
nodiscard

Returns the animation name.

Returns
Animation name string.

◆ AnimWidth()

int FuncDoodle::ProjectFile::AnimWidth ( ) const
nodiscard

Returns the animation width in pixels.

Returns
Canvas width.

◆ BgCol()

Col FuncDoodle::ProjectFile::BgCol ( ) const
inlinenodiscard

Returns the current background color.

Returns
Background color.

◆ ClearRedoStack()

void FuncDoodle::ProjectFile::ClearRedoStack ( )
inline

Removes all actions from the redo stack.

◆ DisplayAltFPS()

void FuncDoodle::ProjectFile::DisplayAltFPS ( double fps)

Shows a temporary FPS value in the window title.

Parameters
fpsFPS value to display.

◆ Export()

void FuncDoodle::ProjectFile::Export ( const char * filePath,
int format )

Exports the animation using the chosen format.

Parameters
filePathOutput path.
formatExport format identifier.

◆ LastSavePath()

const char * FuncDoodle::ProjectFile::LastSavePath ( ) const
inlinenodiscard

Returns the last saved file path.

Returns
Last save path string.

◆ PushUndoable()

template<typename T>
void FuncDoodle::ProjectFile::PushUndoable ( T && action)
inline

Pushes a new undoable action and clears redo history.

Parameters
actionAction instance to store on the undo stack.

◆ ReadAndPopulate()

void FuncDoodle::ProjectFile::ReadAndPopulate ( const char * filePath)

Loads project data from disk into this instance.

Parameters
filePathProject path to read.

◆ Redo()

void FuncDoodle::ProjectFile::Redo ( )

Reapplies the most recent action on the redo stack.

◆ Saved()

bool FuncDoodle::ProjectFile::Saved ( ) const
inline

Returns whether the project matches the last saved state.

Returns
Save-state flag.

◆ SetAnimAuthor()

void FuncDoodle::ProjectFile::SetAnimAuthor ( char * author)

Sets the animation author.

Parameters
authorNew author buffer.

◆ SetAnimDesc()

void FuncDoodle::ProjectFile::SetAnimDesc ( char * desc)

Sets the animation description.

Parameters
descNew description buffer.

◆ SetAnimFPS()

void FuncDoodle::ProjectFile::SetAnimFPS ( int FPS)

Sets the animation frame rate.

Parameters
FPSNew frames-per-second value.

◆ SetAnimFrameCount()

void FuncDoodle::ProjectFile::SetAnimFrameCount ( unsigned long count)

Resizes the animation frame count.

Parameters
countNew frame count.

◆ SetAnimHeight()

void FuncDoodle::ProjectFile::SetAnimHeight ( int height,
bool clear = false )

Sets the animation height.

Parameters
heightNew canvas height.
clearWhether to clear existing frame data.

◆ SetAnimName()

void FuncDoodle::ProjectFile::SetAnimName ( char name[256])

Sets the animation name.

Parameters
nameNew animation name buffer.

◆ SetAnimWidth()

void FuncDoodle::ProjectFile::SetAnimWidth ( int width,
bool clear = false )

Sets the animation width.

Parameters
widthNew canvas width.
clearWhether to clear existing frame data.

◆ SetBgCol()

void FuncDoodle::ProjectFile::SetBgCol ( const float * bgCol)
inline

Sets the project background color and rebuilds backing frame storage.

Parameters
bgColPointer to three normalized RGB float values.

◆ Undo()

void FuncDoodle::ProjectFile::Undo ( )

Undoes the most recent action on the undo stack.

◆ UpdateTitle()

void FuncDoodle::ProjectFile::UpdateTitle ( )

Refreshes the window title using current project state.

◆ Window()

Platform::Window * FuncDoodle::ProjectFile::Window ( ) const
inlinenodiscardconstexpr

Returns the owning application window.

Returns
Window pointer.

◆ Write()

void FuncDoodle::ProjectFile::Write ( const char * fileName)

Serializes the project to disk.

Parameters
filePathOutput project path.

Member Data Documentation

◆ m_Author

char FuncDoodle::ProjectFile::m_Author[100]
private

◆ m_BG

Col FuncDoodle::ProjectFile::m_BG
private

◆ m_Desc

char FuncDoodle::ProjectFile::m_Desc[512]
private

◆ m_FPS

int FuncDoodle::ProjectFile::m_FPS = 0
private

◆ m_Frames

SharedPtr<LongIndexArray> FuncDoodle::ProjectFile::m_Frames
private

◆ m_Height

int FuncDoodle::ProjectFile::m_Height = 0
private

◆ m_LastSavePath

const char* FuncDoodle::ProjectFile::m_LastSavePath = ""
private

◆ m_Name

char FuncDoodle::ProjectFile::m_Name[256]
private

◆ m_RedoStack

std::stack<UniquePtr<Action> > FuncDoodle::ProjectFile::m_RedoStack
private

◆ m_Saved

bool FuncDoodle::ProjectFile::m_Saved = false
private

◆ m_UndoStack

std::stack<UniquePtr<Action> > FuncDoodle::ProjectFile::m_UndoStack
private

◆ m_Width

int FuncDoodle::ProjectFile::m_Width = 0
private

◆ m_Window

Platform::Window* FuncDoodle::ProjectFile::m_Window
private

The documentation for this class was generated from the following files: