22 using NodeDecorator::NodeDecorator;
24 void ComputeRequirement()
override {
25 NodeDecorator::ComputeRequirement();
26 requirement_ = children_[0]->requirement();
30 void SetBox(
Box box)
override {
33 children_[0]->SetBox(box);
36 void Render(
Screen& screen)
final {
37 NodeDecorator::Render(screen);
41 const int size_inner = box_.y_max - box_.y_min;
42 if (size_inner <= 0) {
45 const int size_outter = stencil.
y_max - stencil.
y_min + 1;
46 if (size_outter >= size_inner) {
50 int size = 2 * size_outter * size_outter / size_inner;
51 size = std::max(size, 1);
55 2 * (stencil.
y_min - box_.y_min) * size_outter / size_inner;
57 const int x = stencil.
x_max;
58 for (
int y = stencil.
y_min; y <= stencil.
y_max; ++y) {
59 const int y_up = 2 * y + 0;
60 const int y_down = 2 * y + 1;
61 const bool up = (start_y <= y_up) && (y_up <= start_y + size);
62 const bool down = (start_y <= y_down) && (y_down <= start_y + size);
64 const char* c = up ? (
down ?
"┃" :
"╹") : (
down ?
"╻" :
" ");
69 return std::make_shared<Impl>(std::move(child));
77 using NodeDecorator::NodeDecorator;
79 void ComputeRequirement()
override {
80 NodeDecorator::ComputeRequirement();
81 requirement_ = children_[0]->requirement();
85 void SetBox(
Box box)
override {
88 children_[0]->SetBox(box);
91 void Render(
Screen& screen)
final {
92 NodeDecorator::Render(screen);
96 const int size_inner = box_.x_max - box_.x_min;
97 if (size_inner <= 0) {
100 const int size_outter = stencil.
x_max - stencil.
x_min + 1;
101 if (size_outter >= size_inner) {
105 int size = 2 * size_outter * size_outter / size_inner;
106 size = std::max(size, 1);
110 2 * (stencil.
x_min - box_.x_min) * size_outter / size_inner;
112 const int y = stencil.
y_max;
113 for (
int x = stencil.
x_min; x <= stencil.
x_max; ++x) {
114 const int x_left = 2 * x + 0;
115 const int x_right = 2 * x + 1;
116 const bool left = (start_x <= x_left) && (x_left <= start_x + size);
117 const bool right = (start_x <= x_right) && (x_right <= start_x + size);
125 return std::make_shared<Impl>(std::move(child));