FTXUI/src/ftxui/dom/composite_decorator.cpp

43 lines
1.1 KiB
C++
Raw Normal View History

2021-05-02 02:40:35 +08:00
#include "ftxui/dom/elements.hpp"
2018-09-20 03:52:25 +08:00
namespace ftxui {
2018-09-20 03:52:25 +08:00
2020-05-25 07:34:13 +08:00
/// @brief Center an element horizontally.
/// @param The input element.
/// @return The centered element.
/// @ingroup dom
Element hcenter(Element child) {
2020-07-17 06:27:39 +08:00
return hbox(filler(), std::move(child), filler()) | xflex_grow;
2018-09-20 03:52:25 +08:00
}
2020-05-25 07:34:13 +08:00
/// @brief Center an element vertically.
/// @param The input element.
/// @return The centered element.
/// @ingroup dom
Element vcenter(Element child) {
2020-07-17 06:27:39 +08:00
return vbox(filler(), std::move(child), filler()) | yflex_grow;
2018-09-20 03:52:25 +08:00
}
2020-05-25 07:34:13 +08:00
/// @brief Center an element horizontally and vertically.
/// @param The input element.
/// @return The centered element.
/// @ingroup dom
Element center(Element child) {
return hcenter(vcenter(std::move(child))) | flex_grow;
2018-09-20 03:52:25 +08:00
}
2020-05-25 07:34:13 +08:00
/// @brief Align an element on the right side.
/// @param The input element.
/// @return The right aligned element.
/// @ingroup dom
Element align_right(Element child) {
return hbox(filler(), std::move(child)) | flex_grow;
}
2020-03-23 05:32:44 +08:00
} // namespace ftxui
// 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.