21class ResizableSplitBase :
public ComponentBase {
23 explicit ResizableSplitBase(ResizableSplitOption options)
24 : options_(std::move(options)) {
25 switch (options_->direction()) {
27 Add(Container::Horizontal({
33 Add(Container::Horizontal({
39 Add(Container::Vertical({
45 Add(Container::Vertical({
53 bool OnEvent(Event event)
final {
54 if (event.is_mouse()) {
55 return OnMouseEvent(std::move(event));
60 bool OnMouseEvent(Event event) {
62 captured_mouse_.reset();
68 separator_box_.Contain(event.mouse().x, event.mouse().y) &&
70 captured_mouse_ = CaptureMouse(event);
74 if (!captured_mouse_) {
78 switch (options_->direction()) {
80 options_->main_size() = std::max(0, event.mouse().x - box_.x_min);
83 options_->main_size() = std::max(0, box_.x_max - event.mouse().x);
86 options_->main_size() = std::max(0, event.mouse().y - box_.y_min);
89 options_->main_size() = std::max(0, box_.y_max - event.mouse().y);
98 switch (options_->direction()) {
102 return RenderRight();
106 return RenderBottom();
109 return text(
"unreacheable");
114 options_->main->Render() |
116 options_->separator_func() |
reflect(separator_box_),
117 options_->back->Render() | xflex,
124 options_->back->Render() | xflex,
125 options_->separator_func() |
reflect(separator_box_),
126 options_->main->Render() |
134 options_->main->Render() |
136 options_->separator_func() |
reflect(separator_box_),
137 options_->back->Render() | yflex,
144 options_->back->Render() | yflex,
145 options_->separator_func() |
reflect(separator_box_),
146 options_->main->Render() |
153 Ref<ResizableSplitOption> options_;
187 return Make<ResizableSplitBase>(std::move(options));
virtual bool OnEvent(Event)
Called in response to an event.
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Component ResizableSplitBottom(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Element text(std::wstring text)
Display a piece of unicode text.
Element vbox(Elements)
A container displaying elements vertically one by one.
The FTXUI ftxui:: namespace.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component
Element hbox(Elements)
A container displaying elements horizontally one by one.
Component ResizableSplit(ResizableSplitOption options)
A split in between two components.
Decorator reflect(Box &box)