21class ResizableSplitBase :
public ComponentBase,
public ResizableSplitOption {
23 explicit ResizableSplitBase(ResizableSplitOption options)
24 : ResizableSplitOption(std::move(options)) {
25 switch (direction()) {
41 bool OnEvent(Event event)
final {
42 if (event.is_mouse()) {
43 return OnMouseEvent(std::move(event));
48 bool OnMouseEvent(Event event) {
50 captured_mouse_.reset();
56 separator_box_.Contain(event.mouse().x, event.mouse().y) &&
58 captured_mouse_ = CaptureMouse(event);
62 if (!captured_mouse_) {
66 switch (direction()) {
68 main_size() = std::max(0, event.mouse().x - box_.x_min);
71 main_size() = std::max(0, box_.x_max - event.mouse().x);
74 main_size() = std::max(0, event.mouse().y - box_.y_min);
77 main_size() = std::max(0, box_.y_max - event.mouse().y);
81 main_size() = std::clamp(main_size(), min(), max());
86 switch (direction()) {
94 return RenderBottom();
97 return text(
"unreacheable");
103 separator_func() |
reflect(separator_box_),
104 back->Render() |
xflex,
111 back->Render() |
xflex,
112 separator_func() |
reflect(separator_box_),
121 separator_func() |
reflect(separator_box_),
122 back->Render() |
yflex,
129 back->Render() |
yflex,
130 separator_func() |
reflect(separator_box_),
virtual bool OnEvent(Event)
响应事件时调用。
Component Horizontal(Components children)
一个组件列表,水平逐个绘制,并使用左/右箭头键或“h”/“l”键水平导航。
Component ResizableSplitTop(Component main, Component back, int *main_size)
两个组件之间的垂直分割,可通过鼠标配置。
Component Vertical(Components children)
一个组件列表,垂直逐个绘制,并使用上/下箭头键或“j”/“k”键垂直导航。
Component ResizableSplitRight(Component main, Component back, int *main_size)
两个组件之间的水平分割,可通过鼠标配置。
Component ResizableSplitBottom(Component main, Component back, int *main_size)
两个组件之间的垂直分割,可通过鼠标配置。
Component ResizableSplitLeft(Component main, Component back, int *main_size)
两个组件之间的水平分割,可通过鼠标配置。
Element xflex(Element)
在 X 轴上尽可能地扩展/收缩。
Decorator size(WidthOrHeight, Constraint, int value)
对元素大小应用约束。
Element yflex(Element)
在 Y 轴上尽可能地扩展/收缩。
Element text(std::wstring text)
显示一段Unicode文本。
Element vbox(Elements)
垂直一个接一个显示元素的容器。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
Element hbox(Elements)
一个按水平顺序逐一显示元素的容器。
Component ResizableSplit(ResizableSplitOption options)
两个组件之间的分割。
Decorator reflect(Box &box)
std::shared_ptr< ComponentBase > Component