FTXUI/src/ftxui/dom/composite_decorator.cpp
ArthurSonzogni 08ee49f3e6 Add flex_grow and flex_shrink.
Two new elements:
- flex_grow  : Expand the element to occupy free space.
- flex_shrink: Minimize the element leave away missing space.

flex = flex_grow | flex_shrink.

Other changes:
- hbox and vbox are now non flexible by default.
- the vtext element has been added to help writting tests.
- Many new tests.
2020-06-07 02:30:45 +02:00

27 lines
652 B
C++

// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {
Element hcenter(Element child) {
return hbox(filler(), std::move(child), filler()) | flex_grow;
}
Element vcenter(Element child) {
return vbox(filler(), std::move(child), filler()) | flex_grow;
}
Element center(Element child) {
return hcenter(vcenter(std::move(child))) | flex_grow;
}
Element align_right(Element child) {
return hbox(filler(), std::move(child)) | flex_grow;
}
} // namespace ftxui