mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-23 00:19:31 -04:00
49 lines
1.0 KiB
C++
49 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <Color.hpp>
|
|
#include <functional>
|
|
|
|
namespace gui
|
|
{
|
|
class RawFont;
|
|
|
|
class TextFormat
|
|
{
|
|
private:
|
|
RawFont *font = nullptr;
|
|
Color color = ColorFullBlack;
|
|
|
|
static constexpr auto setter = [](auto &local, auto &next) {
|
|
if (local != next) {
|
|
local = next;
|
|
}
|
|
};
|
|
|
|
public:
|
|
TextFormat(RawFont *font, Color color = {}) : font(font), color(color){};
|
|
TextFormat(const TextFormat &) = default;
|
|
|
|
[[nodiscard]] auto getFont() const
|
|
{
|
|
return font;
|
|
}
|
|
[[nodiscard]] auto getColor() const
|
|
{
|
|
return color;
|
|
}
|
|
|
|
// sets font
|
|
// @note triggers onFormat change
|
|
void setFont(RawFont *font)
|
|
{
|
|
setter(this->font, font);
|
|
}
|
|
// sets color
|
|
// @note triggers onFormat change
|
|
void setColor(Color color)
|
|
{
|
|
setter(this->color, color);
|
|
}
|
|
};
|
|
}; // namespace gui
|