2019-01-05 09:03:49 +08:00
|
|
|
#include <iostream>
|
|
|
|
#include <thread>
|
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
#include "ftxui/component/container.hpp"
|
2019-01-05 09:03:49 +08:00
|
|
|
#include "ftxui/component/menu.hpp"
|
2019-01-07 00:10:35 +08:00
|
|
|
#include "ftxui/component/screen_interactive.hpp"
|
|
|
|
#include "ftxui/component/toggle.hpp"
|
2019-01-13 01:24:46 +08:00
|
|
|
#include "ftxui/screen/string.hpp"
|
2019-01-05 09:03:49 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
using namespace ftxui;
|
2019-01-05 09:03:49 +08:00
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
class MyComponent : public Component {
|
2019-01-05 09:03:49 +08:00
|
|
|
public:
|
2019-01-13 01:24:46 +08:00
|
|
|
MyComponent() {
|
|
|
|
Add(&container);
|
|
|
|
container.Add(&toggle);
|
|
|
|
container.Add(&menu);
|
2019-01-05 09:03:49 +08:00
|
|
|
|
|
|
|
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();
|
2019-01-05 09:03:49 +08:00
|
|
|
Toggle toggle;
|
|
|
|
Menu menu;
|
|
|
|
|
|
|
|
Element Render() override {
|
|
|
|
return
|
|
|
|
vbox(
|
|
|
|
hbox(frame(toggle.Render()), filler()),
|
|
|
|
frame(menu.Render()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[])
|
|
|
|
{
|
2019-01-07 00:10:35 +08:00
|
|
|
auto screen = ScreenInteractive::TerminalOutput();
|
2019-01-13 01:24:46 +08:00
|
|
|
MyComponent component;
|
2019-01-05 09:03:49 +08:00
|
|
|
component.on_enter = screen.ExitLoopClosure();
|
2019-01-13 01:24:46 +08:00
|
|
|
screen.Loop(&component);
|
2019-01-05 09:03:49 +08:00
|
|
|
}
|