/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* text_descriptor.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 00:13:34 by maldavid #+# #+# */ /* Updated: 2024/01/11 04:28:58 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef __MLX_TEXT_DESCRIPTOR__ #define __MLX_TEXT_DESCRIPTOR__ #include #include #include #include #include #include #include namespace mlx { class TextDrawDescriptor : public DrawableResource { friend class std::hash; public: TextID id; uint32_t color; int x; int y; public: TextDrawDescriptor(std::string text, uint32_t _color, int _x, int _y); void init(Font* const font) noexcept; bool operator==(const TextDrawDescriptor& rhs) const { return _text == rhs._text && x == rhs.x && y == rhs.y && color == rhs.color; } void render(std::array& sets, Renderer& renderer) override; void resetUpdate() override; TextDrawDescriptor() = default; private: std::string _text; }; } namespace std { template <> struct hash { std::size_t operator()(const mlx::TextDrawDescriptor& d) const noexcept { std::size_t hash = 0; mlx::hashCombine(hash, d.x, d.y, d.color, d._text); return hash; } }; } #endif