1 #ifndef CPPURSES_PAINTER_GLYPH_HPP
2 #define CPPURSES_PAINTER_GLYPH_HPP
3 #include <utility>
4 
5 #include <cppurses/painter/brush.hpp>
6 
7 namespace cppurses {
8 
9 /// Holds a description of a paintable tile on the screen.
10 struct Glyph {
11     /// Construct an invisible Glyph, defaults to space and no attrs/colors.
12     Glyph() = default;
13 
14     /// Construct a Glyph with the provided wchar_t and Brush.
Glyphcppurses::Glyph15     Glyph(wchar_t sym, const Brush& b) : symbol{sym}, brush{b} {}
16 
17     /// Construct with the provided wchar_t and list of Attributes and Colors.
18     template <typename... Attributes>
Glyphcppurses::Glyph19     Glyph(wchar_t sym, Attributes&&... attrs)
20         : symbol{sym}, brush{std::forward<Attributes>(attrs)...} {}
21 
22     /// The Glyph's symbol is the wide character that will be displayed.
23     wchar_t symbol{L' '};
24 
25     /// The Brush that will determine the Attributes and Colors of the symbol.
26     Brush brush;
27 };
28 
29 /// Compares if each symbol and brush are equal.
operator ==(const Glyph & lhs,const Glyph & rhs)30 inline bool operator==(const Glyph& lhs, const Glyph& rhs) {
31     return (lhs.symbol == rhs.symbol) && (lhs.brush == rhs.brush);
32 }
33 
34 /// Compares if each symbol and brush are not equal.
operator !=(const Glyph & lhs,const Glyph & rhs)35 inline bool operator!=(const Glyph& lhs, const Glyph& rhs) {
36     return !(lhs == rhs);
37 }
38 
39 }  // namespace cppurses
40 #endif  // CPPURSES_PAINTER_GLYPH_HPP
41