mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-21 19:48:16 +08:00
Add CheckBox.
This commit is contained in:
56
examples/component/gallery.cpp
Normal file
56
examples/component/gallery.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "ftxui/component/container.hpp"
|
||||
#include "ftxui/component/input.hpp"
|
||||
#include "ftxui/component/menu.hpp"
|
||||
#include "ftxui/component/screen_interactive.hpp"
|
||||
#include "ftxui/component/toggle.hpp"
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class MyComponent : public Component {
|
||||
Container container = Container::Vertical();
|
||||
Menu menu;
|
||||
Input input;
|
||||
Toggle toggle;
|
||||
|
||||
public:
|
||||
MyComponent() {
|
||||
Add(&container);
|
||||
menu.entries = {
|
||||
L"Browse the web",
|
||||
L"Meditate",
|
||||
L"Sleep",
|
||||
L"Eat",
|
||||
};
|
||||
container.Add(&menu);
|
||||
|
||||
toggle.entries = {
|
||||
L"Browse the web",
|
||||
L"Meditate",
|
||||
L"Sleep",
|
||||
L"Eat",
|
||||
};
|
||||
container.Add(&toggle);
|
||||
|
||||
input.placeholder = L"Input placeholder";
|
||||
container.Add(&input);
|
||||
}
|
||||
|
||||
Element Render() override {
|
||||
return
|
||||
vbox(
|
||||
hbox(text(L"menu") | size(10,1), separator(), menu.Render()),
|
||||
separator(),
|
||||
hbox(text(L"toggle") | size(10,1), separator(), toggle.Render()),
|
||||
separator(),
|
||||
hbox(text(L"input") | size(10,1), separator(), input.Render())
|
||||
) | frame;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
auto screen = ScreenInteractive::TerminalOutput();
|
||||
MyComponent component;
|
||||
screen.Loop(&component);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user