mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-16 08:04:21 +08:00
Add size(direction, constraint, value).
For example: ============ element | size(WIDTH, EQUAL 10); element | size(HEIGHT, GREATER_THAN, 10); element | size(WIDTH, EQUAL, 10) | size(HEIGHT, EQUAL, 10)
This commit is contained in:
@@ -25,7 +25,10 @@ class MyComponent : public Component {
|
||||
for(auto& it : checkbox) {
|
||||
content.push_back(it.Render());
|
||||
}
|
||||
return vbox(std::move(content)) | frame | size(20, 10) | border;
|
||||
return vbox(std::move(content))
|
||||
| frame
|
||||
| size(HEIGHT, LESS_THAN, 10)
|
||||
| border;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -54,7 +54,12 @@ class MyComponent : public Component {
|
||||
}
|
||||
|
||||
Element Render(std::wstring name, Component& component) {
|
||||
return hbox(text(name) | size(8,1), separator(), component.Render());
|
||||
return
|
||||
hbox(
|
||||
text(name) | size(WIDTH, EQUAL, 8),
|
||||
separator(),
|
||||
component.Render()
|
||||
);
|
||||
}
|
||||
|
||||
Element Render() override {
|
||||
@@ -69,7 +74,7 @@ class MyComponent : public Component {
|
||||
Render(L"radiobox", radiobox),
|
||||
separator(),
|
||||
Render(L"input", input)
|
||||
) | border | frame | size(10,10) | border;
|
||||
) | border;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -21,7 +21,7 @@ class MyComponent : public Component {
|
||||
}
|
||||
|
||||
Element Render() override {
|
||||
return radiobox.Render() | frame | size(20,10) | border;
|
||||
return radiobox.Render() | frame | size(HEIGHT, LESS_THAN, 10) | border;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "ftxui/component/container.hpp"
|
||||
#include "ftxui/component/menu.hpp"
|
||||
|
@@ -43,7 +43,7 @@ int main(int argc, const char *argv[])
|
||||
int nb_done = 0;
|
||||
|
||||
auto to_text = [](int number) {
|
||||
return text(to_wstring(number)) | size(3,1);
|
||||
return text(to_wstring(number)) | size(WIDTH, EQUAL, 3);
|
||||
};
|
||||
|
||||
auto renderTask = [&](const Task& task) {
|
||||
|
@@ -19,7 +19,8 @@ int main(int argc, const char *argv[])
|
||||
entries.push_back(separator());
|
||||
entries.push_back(
|
||||
hbox(
|
||||
text(to_wstring(i)) | size(5,1),
|
||||
text(to_wstring(i)) | size(WIDTH, EQUAL, 2),
|
||||
separator(),
|
||||
spinner(i, index) | bold
|
||||
)
|
||||
);
|
||||
|
Reference in New Issue
Block a user