@ -50,7 +50,7 @@ struct Element {
virtual ~ Element ( ) = default ;
virtual ElementType elementType ( ) const = 0 ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const = 0 ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick ) = 0 ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) = 0 ;
protected :
Element ( ) = default ;
@ -93,7 +93,7 @@ struct ImageElement : public Element {
virtual ~ ImageElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick ) override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < ImageElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
@ -106,14 +106,14 @@ private:
} ;
struct AnimationElement : public Element {
AnimationElement ( std : : uint16_t x , std : : uint16_t y , std : : uint16_t width , std : : uint16_t height , std : : uint16_t numberOfFrames , std : : uint8 _t updateInterval ) ;
AnimationElement ( std : : uint16_t x , std : : uint16_t y , std : : uint16_t width , std : : uint16_t height , std : : uint16_t numberOfFrames , std : : uint16 _t updateInterval ) ;
std : : uint16_t x ( ) const noexcept ;
std : : uint16_t y ( ) const noexcept ;
std : : uint16_t width ( ) const noexcept ;
std : : uint16_t height ( ) const noexcept ;
std : : uint16_t numberOfFrames ( ) const noexcept ;
std : : uint8 _t updateInterval ( ) const noexcept ;
std : : uint16 _t updateInterval ( ) const noexcept ;
std : : span < std : : byte > buffers ( ) noexcept ;
std : : span < std : : byte const > buffers ( ) const noexcept ;
std : : span < std : : byte > buffer ( std : : uint16_t frameIndex ) noexcept ;
@ -124,7 +124,7 @@ struct AnimationElement : public Element {
virtual ~ AnimationElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick ) override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < AnimationElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
@ -134,7 +134,7 @@ private:
std : : uint16_t m_width { } ;
std : : uint16_t m_height { } ;
std : : uint16_t m_numberOfFrames { } ;
std : : uint8 _t m_updateInterval { } ;
std : : uint16 _t m_updateInterval { } ;
std : : vector < std : : byte > m_buffer ;
} ;
@ -156,7 +156,7 @@ struct HScrollImageElement : public Element {
virtual ~ HScrollImageElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick ) override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < HScrollImageElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
@ -189,7 +189,7 @@ struct VScrollImageElement : public Element {
virtual ~ VScrollImageElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick ) override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < VScrollImageElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
@ -221,7 +221,7 @@ struct LineElement : public Element {
virtual ~ LineElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick ) override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < LineElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
@ -234,7 +234,89 @@ private:
std : : uint8_t m_flags { } ;
} ;
// FIXME: text elements
struct ClippedTextElement : public Element {
ClippedTextElement ( std : : uint16_t x , std : : uint16_t y , std : : uint16_t width , std : : uint16_t height , std : : uint16_t fontIndex , std : : string text ) ;
std : : uint16_t x ( ) const noexcept ;
std : : uint16_t y ( ) const noexcept ;
std : : uint16_t width ( ) const noexcept ;
std : : uint16_t height ( ) const noexcept ;
std : : uint16_t fontIndex ( ) const noexcept ;
std : : string text ( ) const ;
virtual ~ ClippedTextElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < ClippedTextElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
private :
std : : uint16_t m_x { } ;
std : : uint16_t m_y { } ;
std : : uint16_t m_width { } ;
std : : uint16_t m_height { } ;
std : : uint16_t m_fontIndex { } ;
std : : string m_text ;
} ;
struct HScrollTextElement : public Element {
HScrollTextElement ( std : : uint16_t x , std : : uint16_t y , std : : uint16_t width , std : : uint16_t height , std : : uint8_t flags , std : : uint8_t scrollSpeed , std : : uint16_t fontIndex , std : : string text ) ;
std : : uint16_t x ( ) const noexcept ;
std : : uint16_t y ( ) const noexcept ;
std : : uint16_t width ( ) const noexcept ;
std : : uint16_t height ( ) const noexcept ;
std : : uint8_t flags ( ) const noexcept ;
std : : uint8_t scrollSpeed ( ) const noexcept ;
std : : uint16_t fontIndex ( ) const noexcept ;
std : : string text ( ) const ;
virtual ~ HScrollTextElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < HScrollTextElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
private :
std : : uint16_t m_x { } ;
std : : uint16_t m_y { } ;
std : : uint16_t m_width { } ;
std : : uint16_t m_height { } ;
std : : uint8_t m_flags { } ;
std : : uint8_t m_scrollSpeed { } ;
std : : uint16_t m_fontIndex { } ;
std : : string m_text ;
} ;
struct CurrentTimeElement : public Element {
CurrentTimeElement ( std : : uint16_t x , std : : uint16_t y , std : : uint16_t width , std : : uint16_t height , std : : uint16_t fontIndex , std : : uint16_t utcOffset , std : : uint16_t flags ) ;
std : : uint16_t x ( ) const noexcept ;
std : : uint16_t y ( ) const noexcept ;
std : : uint16_t width ( ) const noexcept ;
std : : uint16_t height ( ) const noexcept ;
std : : uint16_t fontIndex ( ) const noexcept ;
std : : uint16_t utcOffset ( ) const noexcept ;
std : : uint16_t flags ( ) const noexcept ;
virtual ~ CurrentTimeElement ( ) override ;
virtual ElementType elementType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
virtual void drawTo ( OneBitBufferInterface * imageBuffer , std : : size_t animationTick , std : : int64_t currentTimestamp ) override ;
static std : : expected < std : : unique_ptr < CurrentTimeElement > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
private :
std : : uint16_t m_x { } ;
std : : uint16_t m_y { } ;
std : : uint16_t m_width { } ;
std : : uint16_t m_height { } ;
std : : uint16_t m_fontIndex { } ;
std : : uint16_t m_utcOffset { } ;
std : : uint16_t m_flags { } ;
} ;
struct AlwaysDrawnSection : public Section {
AlwaysDrawnSection ( ) = default ;
@ -259,6 +341,8 @@ struct AlwaysDrawnSection : public Section {
virtual SectionType sectionType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
static std : : expected < std : : unique_ptr < AlwaysDrawnSection > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
private :
std : : vector < std : : unique_ptr < Element > > m_elements ;
bool m_drawOnFront { true } ;
@ -294,6 +378,8 @@ struct TimeBasedDrawnSection : public Section {
virtual SectionType sectionType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
static std : : expected < std : : unique_ptr < TimeBasedDrawnSection > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
private :
std : : vector < std : : unique_ptr < Element > > m_elements ;
std : : uint64_t m_startTimestamp { } ;
@ -303,7 +389,18 @@ private:
bool m_clearBeforeDrawing { true } ;
} ;
// FIXME: custom font sections
struct CustomFontSection : public Section {
CustomFontSection ( ) = default ;
virtual ~ CustomFontSection ( ) override ;
virtual SectionType sectionType ( ) const override ;
virtual std : : size_t serializeTo ( std : : span < std : : byte > target ) const override ;
static std : : expected < std : : unique_ptr < CustomFontSection > , ParseError > parse ( std : : span < std : : byte const > & buffer ) ;
private :
std : : vector < std : : byte > m_fontData ;
} ;
struct File {
std : : vector < std : : unique_ptr < Section > > sections ;