C++: refactor flags into their own structs (for better code readability)

backup
Christian Seiler 2 weeks ago
parent 6602bec421
commit c77efa8461
  1. 28
      cpp/src/monoformat_bithelpers.hpp
  2. 43
      cpp/src/monoformat_parseonly.cpp
  3. 6
      cpp/src/monoformat_schema.cpp
  4. 67
      cpp/src/monoformat_schema.hpp
  5. 109
      cpp/src/monoformat_structured.cpp
  6. 30
      cpp/src/monoformat_structured.hpp

@ -63,6 +63,34 @@ constexpr inline void unsetBit(std::byte& value, OtherInt bit) {
value = static_cast<std::byte>(static_cast<std::uint8_t>(value) & ~mask);
}
template<std::integral Int, std::integral OtherInt>
constexpr inline void maybeSetBit(Int& value, OtherInt bit, bool set) {
if (bit < 0 || bit >= (sizeof(Int) * CHAR_BIT)) [[unlikely]] {
return;
}
Int mask = Int{1} << static_cast<Int>(bit);
if (set) {
value |= mask;
} else {
value &= ~mask;
}
}
template<std::integral OtherInt>
constexpr inline void maybeSetBit(std::byte& value, OtherInt bit, bool set) {
if (bit < 0 || bit >= CHAR_BIT) [[unlikely]] {
return;
}
std::uint8_t mask = std::uint8_t{1} << static_cast<std::uint8_t>(bit);
if (set) {
value = static_cast<std::byte>(static_cast<std::uint8_t>(value) | mask);
} else {
value = static_cast<std::byte>(static_cast<std::uint8_t>(value) & ~mask);
}
}
} // namespace monoformat
#endif // MONOFORMAT_BITHELPERS_HPP

@ -464,10 +464,12 @@ std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& b
return {};
}
bool restarting = !isBitSet(*flags, 0);
bool invert = isBitSet(*flags, 1);
bool padBefore = isBitSet(*flags, 2);
bool padAfter = isBitSet(*flags, 3);
ScrollFlags scrollFlags{*flags};
bool restarting = !scrollFlags.endless;
bool invert = scrollFlags.invertDirection;
bool padBefore = scrollFlags.padBefore;
bool padAfter = scrollFlags.padAfter;
if (!padBefore && !padAfter && *contentWidth < *width) {
std::int16_t offset = invert ? (*width - *contentWidth) : 0;
@ -627,10 +629,12 @@ std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& b
return {};
}
bool restarting = !isBitSet(*flags, 0);
bool invert = isBitSet(*flags, 1);
bool padBefore = isBitSet(*flags, 2);
bool padAfter = isBitSet(*flags, 3);
ScrollFlags scrollFlags{*flags};
bool restarting = !scrollFlags.endless;
bool invert = scrollFlags.invertDirection;
bool padBefore = scrollFlags.padBefore;
bool padAfter = scrollFlags.padAfter;
if (!padBefore && !padAfter && *contentHeight < *height) {
std::int16_t offset = invert ? (*height - *contentHeight) : 0;
@ -768,6 +772,9 @@ std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, O
<< std::endl;
#endif
LineFlags lineFlags{*flags};
std::ignore = lineFlags;
std::int32_t dx = static_cast<std::int32_t>(*targetX) - static_cast<std::int32_t>(*originX);
std::int32_t dy = static_cast<std::int32_t>(*targetY) - static_cast<std::int32_t>(*originY);
bool value = true;
@ -944,10 +951,12 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu
return {};
}
bool restarting = !isBitSet(*flags, 0);
bool invert = isBitSet(*flags, 1);
bool padBefore = isBitSet(*flags, 2);
bool padAfter = isBitSet(*flags, 3);
ScrollFlags scrollFlags{*flags};
bool restarting = !scrollFlags.endless;
bool invert = scrollFlags.invertDirection;
bool padBefore = scrollFlags.padBefore;
bool padAfter = scrollFlags.padAfter;
if (!padBefore && !padAfter && contentWidth < *width) {
std::uint16_t offset = invert ? (*width - contentWidth) : 0;
@ -1081,10 +1090,12 @@ std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& bu
}
ClippedImage target{screen, *x, *y, *width, *height};
bool use12h = isBitSet(*flags, 0);
bool showHours = isBitSet(*flags, 1);
bool showMinutes = isBitSet(*flags, 2);
bool showSeconds = isBitSet(*flags, 3);
TimeDisplayFlags timeDisplayFlags{*flags};
bool use12h = timeDisplayFlags.use12h;
bool showHours = timeDisplayFlags.showHours;
bool showMinutes = timeDisplayFlags.showMinutes;
bool showSeconds = timeDisplayFlags.showSeconds;
if (showHours && showSeconds) {
showMinutes = true;
}

@ -37,11 +37,7 @@ void MemoryOneBitBuffer::setPixel(std::uint16_t x, std::uint16_t y, bool value)
std::size_t pxIndex = static_cast<std::size_t>(y) * m_width + x;
std::size_t byteIndex = pxIndex / 8;
std::size_t bitIndex = pxIndex % 8;
if (value) {
setBit(m_buffer[byteIndex], bitIndex);
} else {
unsetBit(m_buffer[byteIndex], bitIndex);
}
maybeSetBit(m_buffer[byteIndex], bitIndex, value);
}
ConstMemoryOneBitBuffer::ConstMemoryOneBitBuffer(std::span<std::byte const> buffer, std::uint16_t width, std::uint16_t height)

@ -1,6 +1,8 @@
#ifndef MONOFORMAT_SCHEMA_HPP
#define MONOFORMAT_SCHEMA_HPP
#include "monoformat_bithelpers.hpp"
#include <cstddef>
#include <cstdint>
#include <span>
@ -29,6 +31,71 @@ enum class LineStyle : std::uint8_t {
Solid = 0,
};
struct ScrollFlags {
bool endless{};
bool invertDirection{};
bool padBefore{};
bool padAfter{};
ScrollFlags() = default;
explicit ScrollFlags(std::uint8_t flags) noexcept
: endless{isBitSet(flags, 0)}
, invertDirection{isBitSet(flags, 1)}
, padBefore{isBitSet(flags, 2)}
, padAfter{isBitSet(flags, 3)}
{
}
explicit operator std::uint8_t() const noexcept {
std::uint8_t result{};
maybeSetBit(result, 0, endless);
maybeSetBit(result, 1, invertDirection);
maybeSetBit(result, 2, padBefore);
maybeSetBit(result, 3, padAfter);
return result;
}
};
struct LineFlags {
LineFlags() = default;
explicit LineFlags(std::uint8_t flags) noexcept
{
}
explicit operator std::uint8_t() const noexcept {
std::uint8_t result{};
return result;
}
};
struct TimeDisplayFlags {
bool use12h{};
bool showHours{};
bool showMinutes{};
bool showSeconds{};
TimeDisplayFlags() = default;
explicit TimeDisplayFlags(std::uint16_t flags) noexcept
: use12h{isBitSet(flags, 0)}
, showHours{isBitSet(flags, 1)}
, showMinutes{isBitSet(flags, 2)}
, showSeconds{isBitSet(flags, 3)}
{
}
explicit operator std::uint16_t() const noexcept {
std::uint16_t result{};
maybeSetBit(result, 0, use12h);
maybeSetBit(result, 1, showHours);
maybeSetBit(result, 2, showMinutes);
maybeSetBit(result, 3, showSeconds);
return result;
}
};
struct OneBitBufferInterface {
using Color = bool;

@ -1,5 +1,6 @@
#include "monoformat_structured.hpp"
#include "monoformat_fontreader.hpp"
#include "monoformat_bithelpers.hpp"
#include <iostream>
@ -292,7 +293,7 @@ std::expected<std::unique_ptr<AnimationElement>, ParseError> AnimationElement::p
return result;
}
HScrollImageElement::HScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentWidth, std::uint8_t flags, std::uint8_t scrollSpeed)
HScrollImageElement::HScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentWidth, ScrollFlags flags, std::uint8_t scrollSpeed)
: m_x{x}
, m_y{y}
, m_width{width}
@ -325,7 +326,7 @@ std::uint16_t HScrollImageElement::contentWidth() const noexcept {
return m_contentWidth;
}
std::uint8_t HScrollImageElement::flags() const noexcept {
ScrollFlags HScrollImageElement::flags() const noexcept {
return m_flags;
}
@ -370,7 +371,7 @@ std::size_t HScrollImageElement::serializeTo(std::span<std::byte> target) const
pos = writeU16LE(target, pos, m_width);
pos = writeU16LE(target, pos, m_height);
pos = writeU16LE(target, pos, m_contentWidth);
pos = writeU8LE(target, pos, m_flags);
pos = writeU8LE(target, pos, static_cast<std::uint8_t>(m_flags));
pos = writeU8LE(target, pos, m_scrollSpeed);
pos = writeU16LE(target, pos, 0);
pos = writeBuffer(target, pos, m_buffer);
@ -388,10 +389,10 @@ void HScrollImageElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
return;
}
bool restarting = (m_flags & 0x01) == 0x00;
bool invert = (m_flags & 0x02) == 0x02;
bool padBefore = (m_flags & 0x04) == 0x04;
bool padAfter = (m_flags & 0x08) == 0x08;
bool restarting = !m_flags.endless;
bool invert = m_flags.invertDirection;
bool padBefore = m_flags.padBefore;
bool padAfter = m_flags.padAfter;
if (!padBefore && !padAfter && m_contentWidth < m_width) {
std::int16_t offset = invert ? (m_width - m_contentWidth) : 0;
@ -531,12 +532,12 @@ std::expected<std::unique_ptr<HScrollImageElement>, ParseError> HScrollImageElem
buffer = buffer.subspan(rounded - imageSize);
}
auto result = std::make_unique<HScrollImageElement>(*x, *y, *width, *height, *contentWidth, *flags, *scrollSpeed);
auto result = std::make_unique<HScrollImageElement>(*x, *y, *width, *height, *contentWidth, ScrollFlags{*flags}, *scrollSpeed);
result->updateBuffer(*imageData);
return result;
}
VScrollImageElement::VScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentHeight, std::uint8_t flags, std::uint8_t scrollSpeed)
VScrollImageElement::VScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentHeight, ScrollFlags flags, std::uint8_t scrollSpeed)
: m_x{x}
, m_y{y}
, m_width{width}
@ -569,7 +570,7 @@ std::uint16_t VScrollImageElement::contentHeight() const noexcept {
return m_contentHeight;
}
std::uint8_t VScrollImageElement::flags() const noexcept {
ScrollFlags VScrollImageElement::flags() const noexcept {
return m_flags;
}
@ -614,7 +615,7 @@ std::size_t VScrollImageElement::serializeTo(std::span<std::byte> target) const
pos = writeU16LE(target, pos, m_width);
pos = writeU16LE(target, pos, m_height);
pos = writeU16LE(target, pos, m_contentHeight);
pos = writeU8LE(target, pos, m_flags);
pos = writeU8LE(target, pos, static_cast<std::uint8_t>(m_flags));
pos = writeU8LE(target, pos, m_scrollSpeed);
pos = writeU16LE(target, pos, 0);
pos = writeBuffer(target, pos, m_buffer);
@ -632,10 +633,10 @@ void VScrollImageElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
return;
}
bool restarting = (m_flags & 0x01) == 0x00;
bool invert = (m_flags & 0x02) == 0x02;
bool padBefore = (m_flags & 0x04) == 0x04;
bool padAfter = (m_flags & 0x08) == 0x08;
bool restarting = !m_flags.endless;
bool invert = m_flags.invertDirection;
bool padBefore = m_flags.padBefore;
bool padAfter = m_flags.padAfter;
if (!padBefore && !padAfter && m_contentHeight < m_height) {
std::int16_t offset = invert ? (m_height - m_contentHeight) : 0;
@ -775,13 +776,13 @@ std::expected<std::unique_ptr<VScrollImageElement>, ParseError> VScrollImageElem
buffer = buffer.subspan(rounded - imageSize);
}
auto result = std::make_unique<VScrollImageElement>(*x, *y, *width, *height, *contentHeight, *flags, *scrollSpeed);
auto result = std::make_unique<VScrollImageElement>(*x, *y, *width, *height, *contentHeight, ScrollFlags{*flags}, *scrollSpeed);
result->updateBuffer(*imageData);
return result;
}
LineElement::LineElement(std::uint16_t originX, std::uint16_t originY, std::uint16_t targetX, std::uint16_t targetY, LineStyle lineStyle, std::uint8_t flags)
LineElement::LineElement(std::uint16_t originX, std::uint16_t originY, std::uint16_t targetX, std::uint16_t targetY, LineStyle lineStyle, LineFlags flags)
: m_originX{originX}
, m_originY{originY}
, m_targetX{targetX}
@ -811,7 +812,7 @@ LineStyle LineElement::lineStyle() const noexcept {
return m_lineStyle;
}
std::uint8_t LineElement::flags() const noexcept {
LineFlags LineElement::flags() const noexcept {
return m_flags;
}
@ -830,7 +831,7 @@ std::size_t LineElement::serializeTo(std::span<std::byte> target) const {
pos = writeU16LE(target, pos, m_targetX);
pos = writeU16LE(target, pos, m_targetY);
pos = writeU8LE(target, pos, static_cast<std::uint8_t>(m_lineStyle));
pos = writeU8LE(target, pos, m_flags);
pos = writeU8LE(target, pos, static_cast<std::uint8_t>(m_flags));
return alignNextWrite(target, pos, 4);
}
@ -895,7 +896,7 @@ std::expected<std::unique_ptr<LineElement>, ParseError> LineElement::parse(std::
if (!flags) {
return std::unexpected(flags.error());
}
auto result = std::make_unique<LineElement>(*originX, *originY, *targetX, *targetY, static_cast<LineStyle>(*lineStyle), *flags);
auto result = std::make_unique<LineElement>(*originX, *originY, *targetX, *targetY, static_cast<LineStyle>(*lineStyle), LineFlags{*flags});
return result;
}
@ -1019,7 +1020,7 @@ std::expected<std::unique_ptr<ClippedTextElement>, ParseError> ClippedTextElemen
return result;
}
HScrollTextElement::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)
HScrollTextElement::HScrollTextElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, ScrollFlags flags, std::uint8_t scrollSpeed, std::uint16_t fontIndex, std::string text)
: m_x{x}
, m_y{y}
, m_width{width}
@ -1047,7 +1048,7 @@ std::uint16_t HScrollTextElement::height() const noexcept {
return m_height;
}
std::uint8_t HScrollTextElement::flags() const noexcept {
ScrollFlags HScrollTextElement::flags() const noexcept {
return m_flags;
}
@ -1077,7 +1078,7 @@ std::size_t HScrollTextElement::serializeTo(std::span<std::byte> target) const {
pos = writeU16LE(target, pos, m_y);
pos = writeU16LE(target, pos, m_width);
pos = writeU16LE(target, pos, m_height);
pos = writeU8LE(target, pos, m_flags);
pos = writeU8LE(target, pos, static_cast<std::uint8_t>(m_flags));
pos = writeU8LE(target, pos, m_scrollSpeed);
pos = writeU16LE(target, pos, m_fontIndex);
pos = writeU16LE(target, pos, m_text.size());
@ -1116,10 +1117,10 @@ void HScrollTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
return;
}
bool restarting = (m_flags & 0x01) == 0x00;
bool invert = (m_flags & 0x02) == 0x02;
bool padBefore = (m_flags & 0x04) == 0x04;
bool padAfter = (m_flags & 0x08) == 0x08;
bool restarting = !m_flags.endless;
bool invert = m_flags.invertDirection;
bool padBefore = m_flags.padBefore;
bool padAfter = m_flags.padAfter;
if (!padBefore && !padAfter && contentWidth < m_width) {
std::uint16_t offset = invert ? (m_width - contentWidth) : 0;
@ -1235,11 +1236,11 @@ std::expected<std::unique_ptr<HScrollTextElement>, ParseError> HScrollTextElemen
return std::unexpected(textData.error());
}
std::string_view text{reinterpret_cast<char const*>(textData->data()), *textLength};
auto result = std::make_unique<HScrollTextElement>(*x, *y, *width, *height, *flags, *scrollSpeed, *fontIndex, std::string{text});
auto result = std::make_unique<HScrollTextElement>(*x, *y, *width, *height, ScrollFlags{*flags}, *scrollSpeed, *fontIndex, std::string{text});
return result;
}
CurrentTimeElement::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)
CurrentTimeElement::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, TimeDisplayFlags flags)
: m_x{x}
, m_y{y}
, m_width{width}
@ -1274,7 +1275,7 @@ std::uint16_t CurrentTimeElement::utcOffset() const noexcept {
return m_utcOffset;
}
std::uint16_t CurrentTimeElement::flags() const noexcept {
TimeDisplayFlags CurrentTimeElement::flags() const noexcept {
return m_flags;
}
@ -1294,7 +1295,7 @@ std::size_t CurrentTimeElement::serializeTo(std::span<std::byte> target) const {
pos = writeU16LE(target, pos, m_height);
pos = writeU16LE(target, pos, m_fontIndex);
pos = writeU16LE(target, pos, m_utcOffset);
pos = writeU16LE(target, pos, m_flags);
pos = writeU16LE(target, pos, static_cast<std::uint16_t>(m_flags));
return alignNextWrite(target, pos, 4);
}
@ -1315,10 +1316,10 @@ void CurrentTimeElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t
return;
}
bool use12h = (m_flags & 0x01u) == 0x01u;
bool showHours = (m_flags & 0x02u) == 0x02u;
bool showMinutes = (m_flags & 0x04u) == 0x04u;
bool showSeconds = (m_flags & 0x08u) == 0x08u;
bool use12h = m_flags.use12h;
bool showHours = m_flags.showHours;
bool showMinutes = m_flags.showMinutes;
bool showSeconds = m_flags.showSeconds;
if (showHours && showSeconds) {
showMinutes = true;
}
@ -1391,7 +1392,7 @@ std::expected<std::unique_ptr<CurrentTimeElement>, ParseError> CurrentTimeElemen
if (!flags) {
return std::unexpected(flags.error());
}
auto result = std::make_unique<CurrentTimeElement>(*x, *y, *width, *height, *fontIndex, *utcOffset, *flags);
auto result = std::make_unique<CurrentTimeElement>(*x, *y, *width, *height, *fontIndex, *utcOffset, TimeDisplayFlags{*flags});
return result;
}
@ -1474,15 +1475,9 @@ std::size_t AlwaysDrawnSection::serializeTo(std::span<std::byte> target) const {
// Will be replaced later
pos = writeU24LE(target, pos, 0);
std::uint16_t flags = 0;
if (m_drawOnFront) {
flags |= std::uint16_t{1};
}
if (m_drawOnBack) {
flags |= std::uint16_t{2};
}
if (m_clearBeforeDrawing) {
flags |= std::uint16_t{4};
}
maybeSetBit(flags, 0, m_drawOnFront);
maybeSetBit(flags, 1, m_drawOnBack);
maybeSetBit(flags, 2, m_clearBeforeDrawing);
pos = writeU16LE(target, pos, flags);
pos = writeU16LE(target, pos, m_elements.size());
for (auto const& element : m_elements) {
@ -1523,9 +1518,9 @@ std::expected<std::unique_ptr<AlwaysDrawnSection>, ParseError> AlwaysDrawnSectio
auto sectionData = buffer.subspan(0, *size - 8);
buffer = buffer.subspan(*size - 8);
auto section = std::make_unique<AlwaysDrawnSection>();
section->setDrawOnFront((((*flags) >> 0u) & 0x01u) == 0x01u);
section->setDrawOnBack((((*flags) >> 1u) & 0x01u) == 0x01u);
section->setClearBeforeDrawing((((*flags) >> 2u) & 0x01u) == 0x01u);
section->setDrawOnFront(isBitSet(*flags, 0));
section->setDrawOnBack(isBitSet(*flags, 1));
section->setClearBeforeDrawing(isBitSet(*flags, 2));
section->m_elements.reserve(*elementCount);
for (std::size_t i = 0; i < *elementCount; ++i) {
auto type = peekU16LE(sectionData);
@ -1648,15 +1643,9 @@ std::size_t TimeBasedDrawnSection::serializeTo(std::span<std::byte> target) cons
// Will be replaced later
pos = writeU24LE(target, pos, 0);
std::uint16_t flags = 0;
if (m_drawOnFront) {
flags |= std::uint16_t{1};
}
if (m_drawOnBack) {
flags |= std::uint16_t{2};
}
if (m_clearBeforeDrawing) {
flags |= std::uint16_t{4};
}
maybeSetBit(flags, 0, m_drawOnFront);
maybeSetBit(flags, 1, m_drawOnBack);
maybeSetBit(flags, 2, m_clearBeforeDrawing);
pos = writeU16LE(target, pos, flags);
pos = writeU16LE(target, pos, m_elements.size());
pos = writeU64LE(target, pos, std::bit_cast<std::uint64_t>(m_startTimestamp));
@ -1707,9 +1696,9 @@ std::expected<std::unique_ptr<TimeBasedDrawnSection>, ParseError> TimeBasedDrawn
auto sectionData = buffer.subspan(0, *size - 24);
buffer = buffer.subspan(*size - 24);
auto section = std::make_unique<TimeBasedDrawnSection>();
section->setDrawOnFront((((*flags) >> 0u) & 0x01u) == 0x01u);
section->setDrawOnBack((((*flags) >> 1u) & 0x01u) == 0x01u);
section->setClearBeforeDrawing((((*flags) >> 2u) & 0x01u) == 0x01u);
section->setDrawOnFront(isBitSet(*flags, 0));
section->setDrawOnBack(isBitSet(*flags, 1));
section->setClearBeforeDrawing(isBitSet(*flags, 2));
section->setStartTimestamp(std::bit_cast<std::int64_t>(*startTimestamp));
section->setEndTimestamp(std::bit_cast<std::int64_t>(*endTimestamp));
section->m_elements.reserve(*elementCount);

@ -96,14 +96,14 @@ private:
};
struct HScrollImageElement : public Element {
HScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentWidth, std::uint8_t flags, std::uint8_t scrollSpeed);
HScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentWidth, ScrollFlags flags, std::uint8_t scrollSpeed);
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 contentWidth() const noexcept;
std::uint8_t flags() const noexcept;
ScrollFlags flags() const noexcept;
std::uint8_t scrollSpeed() const noexcept;
std::span<std::byte> buffer() noexcept;
std::span<std::byte const> buffer() const noexcept;
@ -124,20 +124,20 @@ private:
std::uint16_t m_width{};
std::uint16_t m_height{};
std::uint16_t m_contentWidth{};
std::uint8_t m_flags{};
ScrollFlags m_flags;
std::uint8_t m_scrollSpeed{};
std::vector<std::byte> m_buffer;
};
struct VScrollImageElement : public Element {
VScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentHeight, std::uint8_t flags, std::uint8_t scrollSpeed);
VScrollImageElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, std::uint16_t contentHeight, ScrollFlags flags, std::uint8_t scrollSpeed);
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 contentHeight() const noexcept;
std::uint8_t flags() const noexcept;
ScrollFlags flags() const noexcept;
std::uint8_t scrollSpeed() const noexcept;
std::span<std::byte> buffer() noexcept;
std::span<std::byte const> buffer() const noexcept;
@ -158,20 +158,20 @@ private:
std::uint16_t m_width{};
std::uint16_t m_height{};
std::uint16_t m_contentHeight{};
std::uint8_t m_flags{};
ScrollFlags m_flags;
std::uint8_t m_scrollSpeed{};
std::vector<std::byte> m_buffer;
};
struct LineElement : public Element {
LineElement(std::uint16_t originX, std::uint16_t originY, std::uint16_t targetX, std::uint16_t targetY, LineStyle lineStyle, std::uint8_t flags);
LineElement(std::uint16_t originX, std::uint16_t originY, std::uint16_t targetX, std::uint16_t targetY, LineStyle lineStyle, LineFlags flags);
std::uint16_t originX() const noexcept;
std::uint16_t originY() const noexcept;
std::uint16_t targetX() const noexcept;
std::uint16_t targetY() const noexcept;
LineStyle lineStyle() const noexcept;
std::uint8_t flags() const noexcept;
LineFlags flags() const noexcept;
virtual ~LineElement() override;
virtual ElementType elementType() const override;
@ -186,7 +186,7 @@ private:
std::uint16_t m_targetX{};
std::uint16_t m_targetY{};
LineStyle m_lineStyle{};
std::uint8_t m_flags{};
LineFlags m_flags;
};
struct ClippedTextElement : public Element {
@ -216,13 +216,13 @@ private:
};
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);
HScrollTextElement(std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height, ScrollFlags 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;
ScrollFlags flags() const noexcept;
std::uint8_t scrollSpeed() const noexcept;
std::uint16_t fontIndex() const noexcept;
std::string text() const;
@ -239,14 +239,14 @@ private:
std::uint16_t m_y{};
std::uint16_t m_width{};
std::uint16_t m_height{};
std::uint8_t m_flags{};
ScrollFlags 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);
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, TimeDisplayFlags flags);
std::uint16_t x() const noexcept;
std::uint16_t y() const noexcept;
@ -254,7 +254,7 @@ struct CurrentTimeElement : public Element {
std::uint16_t height() const noexcept;
std::uint16_t fontIndex() const noexcept;
std::uint16_t utcOffset() const noexcept;
std::uint16_t flags() const noexcept;
TimeDisplayFlags flags() const noexcept;
virtual ~CurrentTimeElement() override;
virtual ElementType elementType() const override;
@ -270,7 +270,7 @@ private:
std::uint16_t m_height{};
std::uint16_t m_fontIndex{};
std::uint16_t m_utcOffset{};
std::uint16_t m_flags{};
TimeDisplayFlags m_flags;
};
struct AlwaysDrawnSection : public Section {

Loading…
Cancel
Save