22class ResizableSplitBase :
public ComponentBase {
24 explicit ResizableSplitBase(ResizableSplitOption
options)
32 bool OnEvent(Event
event)
final {
33 if (
event.is_mouse()) {
34 return OnMouseEvent(std::move(
event));
39 bool OnMouseEvent(Event
event) {
41 captured_mouse_.reset();
47 separator_box_.Contain(
event.mouse().x,
event.mouse().y) &&
49 captured_mouse_ = CaptureMouse(
event);
53 if (!captured_mouse_) {
57 switch (options_->direction()) {
59 options_->main_size() =
event.mouse().x - box_.x_min;
62 options_->main_size() = box_.x_max -
event.mouse().x;
65 options_->main_size() =
event.mouse().y - box_.y_min;
68 options_->main_size() = box_.y_max -
event.mouse().y;
77 switch (options_->direction()) {
88 return text(
"unreacheable");
93 options_->main->Render() |
95 options_->separator_func() |
reflect(separator_box_),
96 options_->back->Render() |
xflex,
103 options_->back->Render() |
xflex,
104 options_->separator_func() |
reflect(separator_box_),
105 options_->main->Render() |
113 options_->main->Render() |
115 options_->separator_func() |
reflect(separator_box_),
116 options_->back->Render() |
yflex,
123 options_->back->Render() |
yflex,
124 options_->separator_func() |
reflect(separator_box_),
125 options_->main->Render() |
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< Node > Element
std::shared_ptr< ComponentBase > Component
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.
Component Slider(SliderOption< T > options)
A slider in any direction.
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.
Element vbox(Elements)
A container displaying elements vertically one by one.