libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
painter.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <promeki/core/rect.h>
12#include <promeki/core/color.h>
13#include <promeki/core/string.h>
14#include <promeki/tui/screen.h>
15
17
27 public:
34
36 void drawChar(int x, int y, char32_t ch);
37
39 void drawText(int x, int y, const String &text);
40
46 void drawRect(const Rect2Di32 &rect, char32_t ch = 0);
47
49 void fillRect(const Rect2Di32 &rect, char32_t ch = U' ');
50
52 void drawHLine(int x, int y, int len, char32_t ch = U'\u2500');
53
55 void drawVLine(int x, int y, int len, char32_t ch = U'\u2502');
56
58 void setForeground(const Color &color) { _style.setForeground(color); }
59
61 void setBackground(const Color &color) { _style.setBackground(color); }
62
64 void setAttrs(uint8_t attrs) { _style.setAttrs(attrs); }
65
67 void setStyle(const TuiStyle &style) { _style = style; }
68
70 Color foreground() const { return _style.foreground(); }
71
73 Color background() const { return _style.background(); }
74
76 uint8_t attrs() const { return _style.attrs(); }
77
79 const TuiStyle &style() const { return _style; }
80
82 void setClipRect(const Rect2Di32 &rect) { _clipRect = rect; }
83
85 const Rect2Di32 &clipRect() const { return _clipRect; }
86
87 private:
88 TuiScreen &_screen;
89 Rect2Di32 _clipRect;
90 TuiStyle _style = TuiStyle(Color::White, Color::Black);
91
92 void putCell(int x, int y, char32_t ch);
93};
94
General-purpose RGBA color.
Definition color.h:24
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Painting context for TUI widgets.
Definition painter.h:26
Color background() const
Returns the current background color.
Definition painter.h:73
const Rect2Di32 & clipRect() const
Returns the current clipping rectangle.
Definition painter.h:85
uint8_t attrs() const
Returns the current attribute flags.
Definition painter.h:76
void drawRect(const Rect2Di32 &rect, char32_t ch=0)
Draws a rectangle outline using the given character.
void setStyle(const TuiStyle &style)
Sets all visual properties from a TuiStyle.
Definition painter.h:67
void drawText(int x, int y, const String &text)
Draws horizontal text at the given position.
void setClipRect(const Rect2Di32 &rect)
Sets the clipping rectangle.
Definition painter.h:82
TuiPainter(TuiScreen &screen, const Rect2Di32 &clipRect)
Constructs a TuiPainter.
void drawHLine(int x, int y, int len, char32_t ch=U'\u2500')
Draws a horizontal line.
void drawChar(int x, int y, char32_t ch)
Draws a single character at the given position.
void drawVLine(int x, int y, int len, char32_t ch=U'\u2502')
Draws a vertical line.
void setAttrs(uint8_t attrs)
Sets the current attribute flags.
Definition painter.h:64
void fillRect(const Rect2Di32 &rect, char32_t ch=U' ')
Fills a rectangle with the given character.
void setForeground(const Color &color)
Sets the current foreground color.
Definition painter.h:58
const TuiStyle & style() const
Returns the current style.
Definition painter.h:79
Color foreground() const
Returns the current foreground color.
Definition painter.h:70
void setBackground(const Color &color)
Sets the current background color.
Definition painter.h:61
Double-buffered character cell grid for TUI rendering.
Definition screen.h:60
Visual properties of a TUI cell (everything except the character).
Definition style.h:29
void setForeground(const Color &color)
Sets the foreground color.
Definition style.h:65
Color foreground() const
Returns the foreground color.
Definition style.h:53
void setBackground(const Color &color)
Sets the background color.
Definition style.h:68
uint8_t attrs() const
Returns the attribute flags.
Definition style.h:59
Color background() const
Returns the background color.
Definition style.h:56
void setAttrs(uint8_t attrs)
Sets all attribute flags (marks all bits as defined).
Definition style.h:71
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19