22class ResizableSplitBase :
public ComponentBase,
public ResizableSplitOption {
24 explicit ResizableSplitBase(ResizableSplitOption options)
25 : ResizableSplitOption(std::move(options)) {
26 switch (direction()) {
42 bool OnEvent(Event event)
final {
43 if (event.is_mouse()) {
44 return OnMouseEvent(std::move(event));
49 bool OnMouseEvent(Event event) {
51 captured_mouse_.reset();
57 separator_box_.Contain(event.mouse().x, event.mouse().y) &&
59 captured_mouse_ = CaptureMouse(event);
63 if (!captured_mouse_) {
67 switch (direction()) {
69 main_size() = std::max(0, event.mouse().x - box_.x_min);
72 main_size() = std::max(0, box_.x_max - event.mouse().x);
75 main_size() = std::max(0, event.mouse().y - box_.y_min);
78 main_size() = std::max(0, box_.y_max - event.mouse().y);
82 main_size() = std::clamp(main_size(), min(), max());
87 switch (direction()) {
95 return RenderBottom();
98 return text(
"unreacheable");
104 separator_func() |
reflect(separator_box_),
105 back->Render() |
xflex,
112 back->Render() |
xflex,
113 separator_func() |
reflect(separator_box_),
122 separator_func() |
reflect(separator_box_),
123 back->Render() |
yflex,
130 back->Render() |
yflex,
131 separator_func() |
reflect(separator_box_),
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 ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
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.
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.
The FTXUI ftxui:: namespace.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
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)
std::shared_ptr< ComponentBase > Component