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)
回應事件時呼叫。
Component Horizontal(Components children)
一個元件列表,水平地一個接一個繪製,並使用左/右箭頭鍵或 'h'/'l' 鍵進行水平導航。
Component ResizableSplitTop(Component main, Component back, int *main_size)
兩個元件之間的垂直分割,可透過滑鼠設定。
Component Vertical(Components children)
一個元件列表,垂直地一個接一個繪製,並使用上/下箭頭鍵或 'j'/'k' 鍵進行垂直導航。
Component ResizableSplitRight(Component main, Component back, int *main_size)
兩個元件之間的水平分割,可透過滑鼠設定。
Component ResizableSplitBottom(Component main, Component back, int *main_size)
兩個元件之間的垂直分割,可透過滑鼠設定。
Component ResizableSplitLeft(Component main, Component back, int *main_size)
兩個元件之間的水平分割,可透過滑鼠設定。
Element xflex(Element)
在 X 軸上盡可能擴展/在需要時最小化。
Decorator size(WidthOrHeight, Constraint, int value)
限制元素的大小。
Element yflex(Element)
在 Y 軸上盡可能擴展/在需要時最小化。
Element text(std::wstring text)
顯示一段 Unicode 文字。
Element vbox(Elements)
一個垂直一個接一個顯示元素的容器。
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< Node > Element
Element hbox(Elements)
一個逐一水平顯示元素的容器。
Component ResizableSplit(ResizableSplitOption options)
兩個元件之間的分隔。
Decorator reflect(Box &box)
std::shared_ptr< ComponentBase > Component