FTXUI/examples/component/tab.cpp

45 lines
1012 B
C++
Raw Normal View History

#include <iostream>
#include <thread>
2019-01-13 01:24:46 +08:00
#include "ftxui/component/container.hpp"
#include "ftxui/component/menu.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/toggle.hpp"
2019-01-13 01:24:46 +08:00
#include "ftxui/screen/string.hpp"
using namespace ftxui;
2019-01-13 01:24:46 +08:00
class MyComponent : public Component {
public:
2019-01-13 01:24:46 +08:00
MyComponent() {
Add(&container);
container.Add(&toggle);
container.Add(&menu);
toggle.options = {L" left ", L" middle ", L" end "};
menu.entries = {L" top ", L" middle ", L" bottom "};
}
std::function<void()> on_enter = [](){};
private:
2019-01-13 01:24:46 +08:00
Container container = Container::Vertical();
Toggle toggle;
Menu menu;
Element Render() override {
return
vbox(
hbox(frame(toggle.Render()), filler()),
frame(menu.Render()));
}
};
int main(int argc, const char *argv[])
{
auto screen = ScreenInteractive::TerminalOutput();
2019-01-13 01:24:46 +08:00
MyComponent component;
component.on_enter = screen.ExitLoopClosure();
2019-01-13 01:24:46 +08:00
screen.Loop(&component);
}