23 class Impl :
public NodeDecorator {
24 using NodeDecorator::NodeDecorator;
26 void ComputeRequirement()
override {
27 NodeDecorator::ComputeRequirement();
28 requirement_ = children_[0]->requirement();
32 void SetBox(Box box)
override {
35 children_[0]->SetBox(box);
38 void Render(Screen& screen)
final {
40 const Box stencil = screen.stencil;
41 std::vector<Cell> saved;
42 for (
int y = stencil.y_min;
y <= stencil.y_max; ++
y) {
43 saved.push_back(screen.CellAt(stencil.x_max,
y));
46 NodeDecorator::Render(screen);
48 const int size_inner = box_.y_max - box_.y_min;
49 if (size_inner <= 0) {
52 const int size_outter = stencil.y_max - stencil.y_min + 1;
53 if (size_outter >= size_inner) {
57 int size = 2 * size_outter * size_outter / size_inner;
58 size = std::max(size, 1);
62 2 * (stencil.y_min - box_.y_min) * size_outter / size_inner;
64 const int x = stencil.x_max;
65 for (
int y = stencil.y_min;
y <= stencil.y_max; ++
y) {
66 const int y_up = 2 *
y + 0;
67 const int y_down = 2 *
y + 1;
68 const bool up = (start_y <= y_up) && (y_up <= start_y + size);
69 const bool down = (start_y <= y_down) && (y_down <= start_y + size);
71 const char* c = up ? (
down ?
"┃" :
"╹") : (
down ?
"╻" :
" ");
72 Cell& cell = screen.CellAt(x,
y);
73 const Color background = cell.background_color;
74 cell = saved[
y - stencil.y_min];
75 cell.background_color = background;
80 return std::make_shared<Impl>(std::move(child));
87 class Impl :
public NodeDecorator {
88 using NodeDecorator::NodeDecorator;
90 void ComputeRequirement()
override {
91 NodeDecorator::ComputeRequirement();
92 requirement_ = children_[0]->requirement();
96 void SetBox(Box box)
override {
99 children_[0]->SetBox(box);
102 void Render(Screen& screen)
final {
104 const Box stencil = screen.stencil;
105 std::vector<Cell> saved;
106 for (
int x = stencil.x_min; x <= stencil.x_max; ++x) {
107 saved.push_back(screen.CellAt(x, stencil.y_max));
110 NodeDecorator::Render(screen);
112 const int size_inner = box_.x_max - box_.x_min;
113 if (size_inner <= 0) {
116 const int size_outter = stencil.x_max - stencil.x_min + 1;
117 if (size_outter >= size_inner) {
121 int size = 2 * size_outter * size_outter / size_inner;
122 size = std::max(size, 1);
126 2 * (stencil.x_min - box_.x_min) * size_outter / size_inner;
128 const int y = stencil.y_max;
129 for (
int x = stencil.x_min; x <= stencil.x_max; ++x) {
130 const int x_left = 2 * x + 0;
131 const int x_right = 2 * x + 1;
132 const bool left = (start_x <= x_left) && (x_left <= start_x + size);
133 const bool right = (start_x <= x_right) && (x_right <= start_x + size);
137 Cell& cell = screen.CellAt(x,
y);
138 const Color background = cell.background_color;
139 cell = saved[x - stencil.x_min];
140 cell.background_color = background;
145 return std::make_shared<Impl>(std::move(child));