19class DBox :
public Node {
23 void ComputeRequirement()
override {
24 requirement_.min_x = 0;
25 requirement_.min_y = 0;
26 requirement_.flex_grow_x = 0;
27 requirement_.flex_grow_y = 0;
28 requirement_.flex_shrink_x = 0;
29 requirement_.flex_shrink_y = 0;
31 for (
auto&
child : children_) {
32 child->ComputeRequirement();
34 std::max(requirement_.min_x,
child->requirement().min_x);
36 std::max(requirement_.min_y,
child->requirement().min_y);
38 if (requirement_.selection <
child->requirement().selection) {
39 requirement_.selection =
child->requirement().selection;
40 requirement_.selected_box =
child->requirement().selected_box;
45 void SetBox(Box
box)
override {
48 for (
auto&
child : children_) {
54 if (children_.size() <= 1) {
59 const int width = box_.x_max - box_.x_min + 1;
60 const int height = box_.y_max - box_.y_min + 1;
61 std::vector<Pixel>
pixels(std::size_t(width * height));
63 for (
auto&
child : children_) {
68 for (
int x = 0; x < width; ++x) {
69 for (
int y = 0; y < height; ++y) {
70 auto&
pixel =
screen.PixelAt(x + box_.x_min, y + box_.y_min);
71 acc->background_color =
74 if (
pixel.character.empty()) {
75 acc->foreground_color =
83 acc->underlined_double =
pixel.underlined_double;
84 acc->strikethrough =
pixel.strikethrough;
87 acc->foreground_color =
pixel.foreground_color;
98 for (
int x = 0; x < width; ++x) {
99 for (
int y = 0; y < height; ++y) {
100 screen.PixelAt(x + box_.x_min, y + box_.y_min) = *
acc++;
112 return std::make_shared<DBox>(std::move(children_));
static Color Blend(const Color &lhs, const Color &rhs)
Blend two colors together using the alpha channel.
virtual void SetBox(Box box)
Assign a position and a dimension to an element for drawing.
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
std::shared_ptr< Node > Element
std::shared_ptr< T > Make(Args &&... args)
std::vector< Element > Elements
Element dbox(Elements)
Stack several element on top of each other.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.