mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
45
include/ftxui/component/container.hpp
Normal file
45
include/ftxui/component/container.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#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();
|
||||
static Container Tab(int* selector);
|
||||
|
||||
~Container() override = default;
|
||||
|
||||
// Component override.
|
||||
bool OnEvent(Event event) override;
|
||||
Element Render() override;
|
||||
Component* ActiveChild() override;
|
||||
|
||||
protected:
|
||||
// Handlers
|
||||
using EventHandler = bool (Container::*)(Event);
|
||||
bool VerticalEvent(Event event);
|
||||
bool HorizontalEvent(Event event);
|
||||
bool TabEvent(Event event) { return false; }
|
||||
EventHandler event_handler_;
|
||||
|
||||
using RenderHandler = Element (Container::*)();
|
||||
Element VerticalRender();
|
||||
Element HorizontalRender();
|
||||
Element TabRender();
|
||||
RenderHandler render_handler_;
|
||||
|
||||
int selected_ = 0;
|
||||
int* selector_ = &selected_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_COMPONENT_CONTAINER_HPP */
|
Reference in New Issue
Block a user