22class ResizableSplitBase :
public ComponentBase {
24 explicit ResizableSplitBase(ResizableSplitOption options)
25 : options_(std::move(options)) {
26 switch (options_->direction()) {
28 Add(Container::Horizontal({
54 bool OnEvent(Event event)
final {
55 if (event.is_mouse()) {
56 return OnMouseEvent(std::move(event));
61 bool OnMouseEvent(Event event) {
63 captured_mouse_.reset();
69 separator_box_.
Contain(event.mouse().x, event.mouse().y) &&
71 captured_mouse_ = CaptureMouse(event);
75 if (!captured_mouse_) {
79 switch (options_->direction()) {
81 options_->main_size() = std::max(0, event.mouse().x - box_.
x_min);
84 options_->main_size() = std::max(0, box_.
x_max - event.mouse().x);
87 options_->main_size() = std::max(0, event.mouse().y - box_.
y_min);
90 options_->main_size() = std::max(0, box_.
y_max - event.mouse().y);
99 switch (options_->direction()) {
103 return RenderRight();
107 return RenderBottom();
110 return text(
"unreacheable");
115 options_->main->Render() |
117 options_->separator_func() |
reflect(separator_box_),
118 options_->back->Render() |
xflex,
125 options_->back->Render() |
xflex,
126 options_->separator_func() |
reflect(separator_box_),
127 options_->main->Render() |
135 options_->main->Render() |
137 options_->separator_func() |
reflect(separator_box_),
138 options_->back->Render() |
yflex,
145 options_->back->Render() |
yflex,
146 options_->separator_func() |
reflect(separator_box_),
147 options_->main->Render() |
154 Ref<ResizableSplitOption> options_;
188 return Make<ResizableSplitBase>(std::move(options));
217 return ResizableSplit({
251 return ResizableSplit({
285 return ResizableSplit({
319 return ResizableSplit({
virtual bool OnEvent(Event)
Called in response to an event.
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Element yflex(Element)
Expand/Minimize if possible/needed on the Y axis.
Element text(std::wstring text)
Display a piece of unicode text.
Element vbox(Elements)
A container displaying elements vertically one by one.
bool Contain(int x, int y) const
The FTXUI ftxui:: namespace.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< Node > Element
Element hbox(Elements)
A container displaying elements horizontally one by one.
Decorator reflect(Box &box)
std::shared_ptr< ComponentBase > Component