TermOx
painter.hpp
1 #ifndef TERMOX_PAINTER_PAINTER_HPP
2 #define TERMOX_PAINTER_PAINTER_HPP
3 #include <termox/painter/brush.hpp>
4 #include <termox/widget/area.hpp>
5 #include <termox/widget/point.hpp>
6 
7 namespace ox {
8 class Glyph_string;
9 struct Glyph;
10 class Widget;
11 } // namespace ox
12 
13 namespace ox::detail {
14 class Canvas;
15 } // namespace ox::detail
16 
17 namespace ox {
18 
20 
21 class Painter {
22  public:
24  Painter(Widget& w, detail::Canvas& canvas);
25 
26  Painter(Painter const&) = delete;
27  Painter(Painter&&) = delete;
28  Painter& operator=(Painter const&) = delete;
29  Painter& operator=(Painter&&) = delete;
30 
31  public:
33  auto put(Glyph tile, Point p) -> Painter&;
34 
36  auto put(Glyph_string const& text, Point p) -> Painter&;
37 
39  [[nodiscard]] auto at(Point p) const -> Glyph;
40 
42  [[nodiscard]] auto at(Point p) -> Glyph&;
43 
45 
46  auto fill(Glyph tile, Point point, Area area) -> Painter&;
47 
49  auto hline(Glyph tile, Point a, Point b) -> Painter&;
50 
52  auto vline(Glyph tile, Point a, Point b) -> Painter&;
53 
55  auto wallpaper_fill() -> Painter&;
56 
57  private:
59 
61  void put_global(Glyph tile, Point p);
62 
64 
65  void hline_global(Glyph tile, Point a, Point b);
66  void hline_global_no_brush(Glyph tile, Point a, Point b);
67 
69 
70  void vline_global(Glyph tile, Point a, Point b);
71 
73 
74  void fill_global(Glyph tile, Point point, Area area);
75  void fill_global_no_brush(Glyph tile, Point point, Area area);
76 
77  private:
78  Widget const& widget_;
79  detail::Canvas& canvas_;
80  Brush brush_;
81 };
82 
83 } // namespace ox
84 #endif // TERMOX_PAINTER_PAINTER_HPP
Holds the look of any paintable object with Traits and Colors.
Definition: brush.hpp:13
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
Contains functions to paint Glyphs to a Widget's screen area.
Definition: painter.hpp:21
auto hline(Glyph tile, Point a, Point b) -> Painter &
Draw a horizontal line from a to b, inclusive, in local coords.
Definition: painter.cpp:59
auto at(Point p) const -> Glyph
Return a copy of the Glyph at p, is U'\0' if Glyph is not set yet.
Definition: painter.cpp:36
auto wallpaper_fill() -> Painter &
Fill the entire widget screen with wallpaper.
Definition: painter.cpp:73
auto fill(Glyph tile, Point point, Area area) -> Painter &
Fill the Widget with tile Glyphs starting at the top left point.
Definition: painter.cpp:48
auto vline(Glyph tile, Point a, Point b) -> Painter &
Draw a vertical line from a to b, inclusive, in local coords.
Definition: painter.cpp:66
Painter(Widget &w, detail::Canvas &canvas)
Construct an object ready to paint Glyphs from w to canvas.
Definition: painter.cpp:12
auto put(Glyph tile, Point p) -> Painter &
Put single Glyph to local coordinates.
Definition: painter.cpp:18
Definition: widget.hpp:31
A 2D field of Glyphs, useful as a screen buffer.
Definition: canvas.hpp:18
Holds a description of a paintable tile on the screen.
Definition: glyph.hpp:11