mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-25 20:27:31 +08:00
Introduce xflex and yflex.
This commit is contained in:
parent
13e4f97c35
commit
e3ca437a48
@ -363,7 +363,7 @@ class Tab : public Component {
|
|||||||
return vbox({
|
return vbox({
|
||||||
text(L"FTXUI Demo") | bold | hcenter,
|
text(L"FTXUI Demo") | bold | hcenter,
|
||||||
tab_selection.Render() | hcenter,
|
tab_selection.Render() | hcenter,
|
||||||
container.Render(),
|
container.Render() | flex,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -61,11 +61,20 @@ Element hflow(Elements);
|
|||||||
// -- Flexibility ---
|
// -- Flexibility ---
|
||||||
// Define how to share the remaining space when not all of it is used inside a
|
// Define how to share the remaining space when not all of it is used inside a
|
||||||
// container.
|
// container.
|
||||||
Element flex(Element); // Expand/Minimize if possible/needed.
|
Element flex(Element); // Expand/Minimize if possible/needed.
|
||||||
Element flex_grow(Element); // Expand element if possible.
|
Element flex_grow(Element); // Expand element if possible.
|
||||||
Element flex_shrink(Element); // Minimize element if needed.
|
Element flex_shrink(Element); // Minimize element if needed.
|
||||||
Element notflex(Element); // Reset the flex attribute.
|
|
||||||
Element filler(); // A blank expandable element.
|
Element xflex(Element); // Expand/Minimize if possible/needed.
|
||||||
|
Element xflex_grow(Element); // Expand element if possible.
|
||||||
|
Element xflex_shrink(Element); // Minimize element if needed.
|
||||||
|
|
||||||
|
Element yflex(Element); // Expand/Minimize if possible/needed.
|
||||||
|
Element yflex_grow(Element); // Expand element if possible.
|
||||||
|
Element yflex_shrink(Element); // Minimize element if needed.
|
||||||
|
|
||||||
|
Element notflex(Element); // Reset the flex attribute.
|
||||||
|
Element filler(); // A blank expandable element.
|
||||||
|
|
||||||
// -- Size override;
|
// -- Size override;
|
||||||
enum Direction { WIDTH, HEIGHT };
|
enum Direction { WIDTH, HEIGHT };
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
Element hcenter(Element child) {
|
Element hcenter(Element child) {
|
||||||
return hbox(filler(), std::move(child), filler()) | flex_grow;
|
return hbox(filler(), std::move(child), filler()) | xflex_grow;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element vcenter(Element child) {
|
Element vcenter(Element child) {
|
||||||
return vbox(filler(), std::move(child), filler()) | flex_grow;
|
return vbox(filler(), std::move(child), filler()) | yflex_grow;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element center(Element child) {
|
Element center(Element child) {
|
||||||
|
@ -14,11 +14,27 @@ void function_flex_grow(Requirement& r) {
|
|||||||
r.flex_grow_y = 1;
|
r.flex_grow_y = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void function_xflex_grow(Requirement& r) {
|
||||||
|
r.flex_grow_x = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void function_yflex_grow(Requirement& r) {
|
||||||
|
r.flex_grow_y = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void function_flex_shrink(Requirement& r) {
|
void function_flex_shrink(Requirement& r) {
|
||||||
r.flex_shrink_x = 1;
|
r.flex_shrink_x = 1;
|
||||||
r.flex_shrink_y = 1;
|
r.flex_shrink_y = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void function_xflex_shrink(Requirement& r) {
|
||||||
|
r.flex_shrink_x = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void function_yflex_shrink(Requirement& r) {
|
||||||
|
r.flex_shrink_y = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void function_flex(Requirement& r) {
|
void function_flex(Requirement& r) {
|
||||||
r.flex_grow_x = 1;
|
r.flex_grow_x = 1;
|
||||||
r.flex_grow_y = 1;
|
r.flex_grow_y = 1;
|
||||||
@ -26,6 +42,16 @@ void function_flex(Requirement& r) {
|
|||||||
r.flex_shrink_y = 1;
|
r.flex_shrink_y = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void function_xflex(Requirement& r) {
|
||||||
|
r.flex_grow_x = 1;
|
||||||
|
r.flex_shrink_x = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void function_yflex(Requirement& r) {
|
||||||
|
r.flex_grow_y = 1;
|
||||||
|
r.flex_shrink_y = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void function_not_flex(Requirement& r) {
|
void function_not_flex(Requirement& r) {
|
||||||
r.flex_grow_x = 0;
|
r.flex_grow_x = 0;
|
||||||
r.flex_grow_y = 0;
|
r.flex_grow_y = 0;
|
||||||
@ -65,14 +91,38 @@ Element flex(Element child) {
|
|||||||
return std::make_shared<Flex>(function_flex, std::move(child));
|
return std::make_shared<Flex>(function_flex, std::move(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element xflex(Element child) {
|
||||||
|
return std::make_shared<Flex>(function_xflex, std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
Element yflex(Element child) {
|
||||||
|
return std::make_shared<Flex>(function_yflex, std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
Element flex_grow(Element child) {
|
Element flex_grow(Element child) {
|
||||||
return std::make_shared<Flex>(function_flex_grow, std::move(child));
|
return std::make_shared<Flex>(function_flex_grow, std::move(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element xflex_grow(Element child) {
|
||||||
|
return std::make_shared<Flex>(function_xflex_grow, std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
Element yflex_grow(Element child) {
|
||||||
|
return std::make_shared<Flex>(function_yflex_grow, std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
Element flex_shrink(Element child) {
|
Element flex_shrink(Element child) {
|
||||||
return std::make_shared<Flex>(function_flex_shrink, std::move(child));
|
return std::make_shared<Flex>(function_flex_shrink, std::move(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element xflex_shrink(Element child) {
|
||||||
|
return std::make_shared<Flex>(function_xflex_shrink, std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
Element yflex_shrink(Element child) {
|
||||||
|
return std::make_shared<Flex>(function_yflex_shrink, std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
Element notflex(Element child) {
|
Element notflex(Element child) {
|
||||||
return std::make_shared<Flex>(function_not_flex, std::move(child));
|
return std::make_shared<Flex>(function_not_flex, std::move(child));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user