libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
painter.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/namespace.h>
11#include <promeki/rect.h>
12#include <promeki/color.h>
13#include <promeki/string.h>
14#include <promeki/tui/screen.h>
15
16PROMEKI_NAMESPACE_BEGIN
17
34 public:
40 TuiPainter(TuiScreen &screen, const Rect2Di32 &clipRect);
41
43 void drawChar(int x, int y, char32_t ch);
44
46 void drawText(int x, int y, const String &text);
47
53 void drawRect(const Rect2Di32 &rect, char32_t ch = 0);
54
56 void fillRect(const Rect2Di32 &rect, char32_t ch = U' ');
57
59 void drawHLine(int x, int y, int len, char32_t ch = U'\u2500');
60
62 void drawVLine(int x, int y, int len, char32_t ch = U'\u2502');
63
65 void setForeground(const Color &color) { _style.setForeground(color); }
66
68 void setBackground(const Color &color) { _style.setBackground(color); }
69
71 void setAttrs(uint8_t attrs) { _style.setAttrs(attrs); }
72
74 void setStyle(const TuiStyle &style) { _style = style; }
75
77 Color foreground() const { return _style.foreground(); }
78
80 Color background() const { return _style.background(); }
81
83 uint8_t attrs() const { return _style.attrs(); }
84
86 const TuiStyle &style() const { return _style; }
87
89 void setClipRect(const Rect2Di32 &rect) { _clipRect = rect; }
90
92 const Rect2Di32 &clipRect() const { return _clipRect; }
93
94 private:
95 TuiScreen &_screen;
96 Rect2Di32 _clipRect;
97 TuiStyle _style = TuiStyle(Color::White, Color::Black);
98
99 void putCell(int x, int y, char32_t ch);
100};
101
102PROMEKI_NAMESPACE_END
Painting context for TUI widgets.
Definition painter.h:33
void drawRect(const Rect2Di32 &rect, char32_t ch=0)
Draws a rectangle outline using the given character.
void drawVLine(int x, int y, int len, char32_t ch=U'\u2502')
Draws a vertical line.
void drawHLine(int x, int y, int len, char32_t ch=U'\u2500')
Draws a horizontal line.
TuiPainter(TuiScreen &screen, const Rect2Di32 &clipRect)
Constructs a TuiPainter.
const Rect2Di32 & clipRect() const
Returns the current clipping rectangle.
Definition painter.h:92
uint8_t attrs() const
Returns the current attribute flags.
Definition painter.h:83
Color foreground() const
Returns the current foreground color.
Definition painter.h:77
const TuiStyle & style() const
Returns the current style.
Definition painter.h:86
void setClipRect(const Rect2Di32 &rect)
Sets the clipping rectangle.
Definition painter.h:89
void fillRect(const Rect2Di32 &rect, char32_t ch=U' ')
Fills a rectangle with the given character.
void drawText(int x, int y, const String &text)
Draws horizontal text at the given position.
void setAttrs(uint8_t attrs)
Sets the current attribute flags.
Definition painter.h:71
void setForeground(const Color &color)
Sets the current foreground color.
Definition painter.h:65
void setBackground(const Color &color)
Sets the current background color.
Definition painter.h:68
Color background() const
Returns the current background color.
Definition painter.h:80
void setStyle(const TuiStyle &style)
Sets all visual properties from a TuiStyle.
Definition painter.h:74
void drawChar(int x, int y, char32_t ch)
Draws a single character at the given position.
Double-buffered character cell grid for TUI rendering.
Definition screen.h:68
Visual properties of a TUI cell (everything except the character).
Definition style.h:35