18class FocusNode :
public Node {
20 explicit FocusNode(
Elements children) : Node(std::move(children)) {}
22 void ComputeRequirement()
override {
23 Node::ComputeRequirement();
24 requirement_ = children_[0]->requirement();
25 requirement_.focused.enabled =
true;
26 requirement_.focused.node =
this;
27 requirement_.focused.box.x_min = 0;
28 requirement_.focused.box.y_min = 0;
29 requirement_.focused.box.x_max = requirement_.min_x - 1;
30 requirement_.focused.box.y_max = requirement_.min_y - 1;
33 void SetBox(Box box)
override {
35 children_[0]->SetBox(box);
39class Frame :
public Node {
41 Frame(
Elements children,
bool x_frame,
bool y_frame)
42 : Node(std::move(children)), x_frame_(x_frame), y_frame_(y_frame) {}
44 void SetBox(Box box)
override {
46 auto& focused_box = requirement_.focused.box;
47 Box children_box = box;
50 const int external_dimx = box.x_max - box.x_min;
51 const int internal_dimx = std::max(requirement_.min_x, external_dimx);
52 const int focused_dimx = focused_box.x_max - focused_box.x_min;
53 int dx = focused_box.x_min - external_dimx / 2 + focused_dimx / 2;
54 dx = std::max(0, std::min(internal_dimx - external_dimx - 1, dx));
55 children_box.x_min = box.x_min - dx;
56 children_box.x_max = box.x_min + internal_dimx - dx;
60 const int external_dimy = box.y_max - box.y_min;
61 const int internal_dimy = std::max(requirement_.min_y, external_dimy);
62 const int focused_dimy = focused_box.y_max - focused_box.y_min;
63 int dy = focused_box.y_min - external_dimy / 2 + focused_dimy / 2;
64 dy = std::max(0, std::min(internal_dimy - external_dimy - 1, dy));
65 children_box.y_min = box.y_min - dy;
66 children_box.y_max = box.y_min + internal_dimy - dy;
69 children_[0]->SetBox(children_box);
72 void Render(Screen& screen)
override {
73 const AutoReset<Box> stencil(&screen.stencil,
74 Box::Intersection(box_, screen.stencil));
75 children_[0]->Render(screen);
83class FocusCursorNode :
public FocusNode {
85 FocusCursorNode(
Elements children, Screen::Cursor::Shape shape)
86 : FocusNode(std::move(children)), shape_(shape) {}
89 void ComputeRequirement()
override {
90 FocusNode::ComputeRequirement();
91 requirement_.focused.cursor_shape = shape_;
93 Screen::Cursor::Shape shape_;
102 return std::make_shared<FocusNode>(unpack(std::move(child)));
109 return focus(std::move(e));
118 return std::make_shared<Frame>(unpack(std::move(child)),
true,
true);
126 return std::make_shared<Frame>(unpack(std::move(child)),
true,
false);
134 return std::make_shared<Frame>(unpack(std::move(child)),
false,
true);
147 return std::make_shared<FocusCursorNode>(unpack(std::move(child)),
148 Screen::Cursor::Block);
161 return std::make_shared<FocusCursorNode>(unpack(std::move(child)),
162 Screen::Cursor::BlockBlinking);
175 return std::make_shared<FocusCursorNode>(unpack(std::move(child)),
176 Screen::Cursor::Bar);
189 return std::make_shared<FocusCursorNode>(unpack(std::move(child)),
190 Screen::Cursor::BarBlinking);
203 return std::make_shared<FocusCursorNode>(unpack(std::move(child)),
204 Screen::Cursor::Underline);
217 return std::make_shared<FocusCursorNode>(unpack(std::move(child)),
218 Screen::Cursor::UnderlineBlinking);
Element focusCursorBarBlinking(Element child)
focus と同じですが、カーソル形状を点滅バーに設定します。
Element focusCursorUnderlineBlinking(Element child)
focus と同じですが、カーソル形状を点滅下線に設定します。
Element focusCursorBar(Element child)
focus と同じですが、カーソル形状を静止ブロックに設定します。
Element focusCursorBlock(Element child)
focus と同じですが、カーソル形状を静止ブロックに設定します。
Element focusCursorUnderline(Element child)
focus と同じですが、カーソル形状を静止下線に設定します。
Element focus(Element child)
子要素を兄弟要素の中でフォーカスされたものとして設定します。
Element focusCursorBlockBlinking(Element child)
focus と同じですが、カーソル形状を点滅ブロックに設定します。
std::shared_ptr< Node > Element
Element xframe(Element child)
frame と同じですが、x軸のみに適用されます。
std::vector< Element > Elements
Element yframe(Element child)
frame と同じですが、y軸のみに適用されます。
void Render(Screen &screen, Node *node, Selection &selection)
Element frame(Element child)
要素を「仮想」領域内に表示できるようにします。そのサイズはコンテナよりも大きくすることができます。 この場合、より小さい部分のみが表示されます。フォーカスされた要素を表示するためにビューはスクロール可能...
Element select(Element e)
childをその兄弟の中でフォーカスされた要素に設定する。