mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-22 12:48:09 +08:00
Update every component examples.
Use the functional style instead of classes.
This commit is contained in:
@@ -10,27 +10,19 @@
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
class MyComponent : public ComponentBase {
|
||||
private:
|
||||
std::vector<std::wstring> entries_;
|
||||
int selected_ = 0;
|
||||
|
||||
public:
|
||||
MyComponent() {
|
||||
for (int i = 0; i < 30; ++i)
|
||||
entries_.push_back(L"RadioBox " + to_wstring(i));
|
||||
Add(Radiobox(&entries_, &selected_));
|
||||
}
|
||||
|
||||
Element Render() override {
|
||||
return ComponentBase::Render() | frame | size(HEIGHT, LESS_THAN, 10) |
|
||||
border;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
std::vector<std::wstring> entries;
|
||||
int selected = 0;
|
||||
|
||||
for (int i = 0; i < 30; ++i)
|
||||
entries.push_back(L"RadioBox " + to_wstring(i));
|
||||
auto radiobox = Radiobox(&entries, &selected);
|
||||
auto renderer = Renderer(radiobox, [&] {
|
||||
return radiobox->Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
||||
});
|
||||
|
||||
auto screen = ScreenInteractive::FitComponent();
|
||||
screen.Loop(Make<MyComponent>());
|
||||
screen.Loop(renderer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user