16class BgColor :
public NodeDecorator {
18 BgColor(
Element child, Color color)
19 : NodeDecorator(std::move(child)),
color_(color) {}
21 void Render(Screen& screen)
override {
23 for (
int y = box_.y_min;
y <= box_.y_max; ++
y) {
24 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
25 screen.CellAt(x,
y).background_color =
color_;
29 for (
int y = box_.y_min;
y <= box_.y_max; ++
y) {
30 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
31 Color& color = screen.CellAt(x,
y).background_color;
32 color = Color::Blend(color, color_);
36 NodeDecorator::Render(screen);
42class FgColor :
public NodeDecorator {
44 FgColor(
Element child, Color color)
45 : NodeDecorator(std::move(child)),
color_(color) {}
47 void Render(Screen& screen)
override {
49 for (
int y = box_.y_min;
y <= box_.y_max; ++
y) {
50 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
51 screen.CellAt(x,
y).foreground_color =
color_;
55 for (
int y = box_.y_min;
y <= box_.y_max; ++
y) {
56 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
57 Color& color = screen.CellAt(x,
y).foreground_color;
58 color = Color::Blend(color, color_);
62 NodeDecorator::Render(screen);
82 return std::make_shared<FgColor>(std::move(child), color);
97 return std::make_shared<BgColor>(std::move(child), color);
111 return [c](
Element child) {
return color(c, std::move(child)); };
Element bgcolor(Color color, Element child)
Set the background color of an element.
Element color(Color color, Element child)
Set the foreground color of an element.
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element
std::function< Element(Element)> Decorator
void Render(Screen &screen, Node *node, Selection &selection)