mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Update example/component/gallery.cpp
This commit is contained in:
parent
621adf1a44
commit
da5b4b5014
@ -1,6 +1,8 @@
|
||||
#include "ftxui/component/container.hpp"
|
||||
#include "ftxui/component/input.hpp"
|
||||
#include "ftxui/component/menu.hpp"
|
||||
#include "ftxui/component/radiobox.hpp"
|
||||
#include "ftxui/component/checkbox.hpp"
|
||||
#include "ftxui/component/screen_interactive.hpp"
|
||||
#include "ftxui/component/toggle.hpp"
|
||||
|
||||
@ -9,8 +11,12 @@ using namespace ftxui;
|
||||
class MyComponent : public Component {
|
||||
Container container = Container::Vertical();
|
||||
Menu menu;
|
||||
Input input;
|
||||
Toggle toggle;
|
||||
Container checkbox_container = Container::Vertical();
|
||||
CheckBox checkbox1;
|
||||
CheckBox checkbox2;
|
||||
RadioBox radiobox;
|
||||
Input input;
|
||||
|
||||
public:
|
||||
MyComponent() {
|
||||
@ -31,18 +37,40 @@ class MyComponent : public Component {
|
||||
};
|
||||
container.Add(&toggle);
|
||||
|
||||
container.Add(&checkbox_container);
|
||||
checkbox1.label = L"checkbox1";
|
||||
checkbox_container.Add(&checkbox1);
|
||||
checkbox2.label = L"checkbox2";
|
||||
checkbox_container.Add(&checkbox2);
|
||||
|
||||
radiobox.entries = {
|
||||
L"Browse the web",
|
||||
L"Meditate",
|
||||
L"Sleep",
|
||||
L"Eat",
|
||||
};
|
||||
container.Add(&radiobox);
|
||||
|
||||
input.placeholder = L"Input placeholder";
|
||||
container.Add(&input);
|
||||
}
|
||||
|
||||
Element Render(std::wstring name, Component& component) {
|
||||
return hbox(text(name) | size(10,1), separator(), component.Render());
|
||||
}
|
||||
|
||||
Element Render() override {
|
||||
return
|
||||
vbox(
|
||||
hbox(text(L"menu") | size(10,1), separator(), menu.Render()),
|
||||
Render(L"menu", menu),
|
||||
separator(),
|
||||
hbox(text(L"toggle") | size(10,1), separator(), toggle.Render()),
|
||||
Render(L"toggle", toggle),
|
||||
separator(),
|
||||
hbox(text(L"input") | size(10,1), separator(), input.Render())
|
||||
Render(L"checkbox", checkbox_container),
|
||||
separator(),
|
||||
Render(L"radiobox", radiobox),
|
||||
separator(),
|
||||
Render(L"input", input)
|
||||
) | frame;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user