2019-01-05 09:03:49 +08:00
|
|
|
#include <iostream>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include "ftxui/component/component_vertical.hpp"
|
|
|
|
#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-05 09:03:49 +08:00
|
|
|
#include "ftxui/util/string.hpp"
|
|
|
|
|
|
|
|
using namespace ftxui::component;
|
|
|
|
using namespace ftxui::dom;
|
|
|
|
|
|
|
|
class MyComponent : ComponentVertical {
|
|
|
|
public:
|
2019-01-07 00:10:35 +08:00
|
|
|
MyComponent(Delegate* delegate)
|
2019-01-05 09:03:49 +08:00
|
|
|
: ComponentVertical(delegate),
|
|
|
|
toggle(delegate->NewChild()),
|
|
|
|
menu(delegate->NewChild()) {
|
|
|
|
|
|
|
|
toggle.options = {L" left ", L" middle ", L" end "};
|
|
|
|
menu.entries = {L" top ", L" middle ", L" bottom "};
|
|
|
|
Focus(&toggle);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::function<void()> on_enter = [](){};
|
|
|
|
private:
|
|
|
|
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-05 09:03:49 +08:00
|
|
|
MyComponent component(screen.delegate());
|
|
|
|
component.on_enter = screen.ExitLoopClosure();
|
|
|
|
screen.Loop();
|
|
|
|
}
|