17class Select :
public Node {
21 void ComputeRequirement()
override {
25 selected_box.
x_min = 0;
26 selected_box.y_min = 0;
32 void SetBox(Box box)
override {
39 return std::make_shared<Select>(unpack(std::move(child)));
44class Focus :
public Select {
48 void ComputeRequirement()
override {
49 Select::ComputeRequirement();
53 void Render(Screen& screen)
override {
73#if !defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
80 return std::make_shared<Focus>(unpack(std::move(child)));
85class Frame :
public Node {
87 Frame(
Elements children,
bool x_frame,
bool y_frame)
88 :
Node(std::move(children)), x_frame_(x_frame), y_frame_(y_frame) {}
90 void ComputeRequirement()
override {
95 void SetBox(Box box)
override {
98 Box children_box = box;
101 int external_dimx = box.x_max - box.x_min;
103 int focused_dimx = selected_box.x_max - selected_box.x_min;
104 int dx = selected_box.x_min - external_dimx / 2 + focused_dimx / 2;
105 dx = std::max(0, std::min(internal_dimx - external_dimx - 1, dx));
106 children_box.x_min = box.x_min - dx;
107 children_box.x_max = box.x_min + internal_dimx - dx;
111 int external_dimy = box.y_max - box.y_min;
113 int focused_dimy = selected_box.y_max - selected_box.y_min;
114 int dy = selected_box.y_min - external_dimy / 2 + focused_dimy / 2;
115 dy = std::max(0, std::min(internal_dimy - external_dimy - 1, dy));
116 children_box.y_min = box.y_min - dy;
117 children_box.y_max = box.y_min + internal_dimy - dy;
123 void Render(Screen& screen)
override {
124 AutoReset<Box> stencil(&screen.stencil,
139 return std::make_shared<Frame>(unpack(std::move(child)),
true,
true);
143 return std::make_shared<Frame>(unpack(std::move(child)),
true,
false);
147 return std::make_shared<Frame>(unpack(std::move(child)),
false,
true);
virtual void SetBox(Box box)
Assign a position and a dimension to an element for drawing.
virtual void ComputeRequirement()
Compute how much space an elements needs.
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
std::shared_ptr< Node > Element
std::vector< Element > Elements
Element frame(Element)
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container....
static Box Intersection(Box a, Box b)