2019-01-13 01:24:46 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_CONTAINER_HPP
|
|
|
|
#define FTXUI_COMPONENT_CONTAINER_HPP
|
|
|
|
|
|
|
|
#include "ftxui/component/component.hpp"
|
|
|
|
|
|
|
|
namespace ftxui {
|
|
|
|
|
|
|
|
// A component where focus and events are automatically handled for you.
|
|
|
|
// List of container:
|
|
|
|
//
|
|
|
|
// Please use HorizontalContainer or VerticalContainer.
|
|
|
|
class Container : public Component {
|
|
|
|
public:
|
|
|
|
static Container Vertical();
|
|
|
|
static Container Horizontal();
|
2019-01-20 05:06:05 +08:00
|
|
|
static Container Tab(int* selector);
|
2019-01-13 01:24:46 +08:00
|
|
|
|
|
|
|
~Container() override = default;
|
|
|
|
|
|
|
|
// Component override.
|
|
|
|
bool OnEvent(Event event) override;
|
2019-01-13 05:25:49 +08:00
|
|
|
Element Render() override;
|
2019-01-13 01:24:46 +08:00
|
|
|
Component* ActiveChild() override;
|
2019-01-13 05:25:49 +08:00
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
protected:
|
|
|
|
// Handlers
|
2019-01-13 05:25:49 +08:00
|
|
|
using EventHandler = bool (Container::*)(Event);
|
|
|
|
bool VerticalEvent(Event event);
|
|
|
|
bool HorizontalEvent(Event event);
|
2019-07-01 05:59:27 +08:00
|
|
|
bool TabEvent(Event) { return false; }
|
2019-01-13 05:25:49 +08:00
|
|
|
EventHandler event_handler_;
|
|
|
|
|
|
|
|
using RenderHandler = Element (Container::*)();
|
|
|
|
Element VerticalRender();
|
|
|
|
Element HorizontalRender();
|
|
|
|
Element TabRender();
|
|
|
|
RenderHandler render_handler_;
|
2019-01-13 01:24:46 +08:00
|
|
|
|
2019-01-20 05:06:05 +08:00
|
|
|
int selected_ = 0;
|
|
|
|
int* selector_ = &selected_;
|
2019-01-13 01:24:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ftxui
|
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_CONTAINER_HPP */
|