mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 11:17:06 +08:00
5887114793
The goal is to increase the separation in between: * ftxui::screen * ftxui::dom * ftxui::component
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#include <iostream>
|
|
#include <thread>
|
|
|
|
#include "ftxui/component/component_vertical.hpp"
|
|
#include "ftxui/component/menu.hpp"
|
|
#include "ftxui/component/screen_interactive.hpp"
|
|
#include "ftxui/component/toggle.hpp"
|
|
#include "ftxui/util/string.hpp"
|
|
|
|
using namespace ftxui::component;
|
|
using namespace ftxui::dom;
|
|
|
|
class MyComponent : ComponentVertical {
|
|
public:
|
|
MyComponent(Delegate* delegate)
|
|
: 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[])
|
|
{
|
|
auto screen = ScreenInteractive::TerminalOutput();
|
|
MyComponent component(screen.delegate());
|
|
component.on_enter = screen.ExitLoopClosure();
|
|
screen.Loop();
|
|
}
|