Files
MuditaOS/module-gui/gui/widgets/TextFormat.hpp
pholat 50a1f97643 [feature] Font handling feature (#527)
* Font renamed to RawFont
* Added gui::Font adapter
2020-07-15 12:15:14 +02:00

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