19class ResizableSplitBase :
public ComponentBase {
21 ResizableSplitBase(ResizableSplitOption options)
22 : options_(std::move(options)) {
29 bool OnEvent(Event event)
final {
30 if (event.is_mouse()) {
31 return OnMouseEvent(std::move(event));
36 bool OnMouseEvent(Event event) {
38 captured_mouse_.reset();
44 separator_box_.Contain(event.mouse().x, event.mouse().y) &&
46 captured_mouse_ = CaptureMouse(event);
50 if (!captured_mouse_) {
54 switch (options_->direction()) {
56 options_->main_size() =
event.mouse().x - box_.x_min;
59 options_->main_size() = box_.x_max -
event.mouse().x;
62 options_->main_size() =
event.mouse().y - box_.y_min;
65 options_->main_size() = box_.y_max -
event.mouse().y;
74 switch (options_->direction()) {
82 return RenderBottom();
85 return text(
"unreacheable");
90 options_->main->Render() |
92 options_->separator_func() |
reflect(separator_box_),
93 options_->back->Render() |
xflex,
100 options_->back->Render() |
xflex,
101 options_->separator_func() |
reflect(separator_box_),
102 options_->main->Render() |
110 options_->main->Render() |
112 options_->separator_func() |
reflect(separator_box_),
113 options_->back->Render() |
yflex,
120 options_->back->Render() |
yflex,
121 options_->separator_func() |
reflect(separator_box_),
122 options_->main->Render() |
129 Ref<ResizableSplitOption> options_;
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...
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.
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
Element yflex(Element)
Expand/Minimize if possible/needed on the Y axis.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Component ResizableSplit(ResizableSplitOption options)
A split in between two components.
Element text(std::wstring text)
Display a piece of unicode text.
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Decorator reflect(Box &box)
Component ResizableSplitBottom(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
std::shared_ptr< ComponentBase > Component
Element vbox(Elements)
A container displaying elements vertically one by one.