Skip to content

Commit

Permalink
Allow user to specify window element border. (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexmarsh authored Apr 28, 2024
1 parent 7e3e1d4 commit d38b14f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/ftxui/dom/elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Decorator borderStyled(BorderStyle);
Decorator borderStyled(BorderStyle, Color);
Decorator borderStyled(Color);
Decorator borderWith(const Pixel&);
Element window(Element title, Element content);
Element window(Element title,
Element content,
BorderStyle border = ROUNDED);
Element spinner(int charset_index, size_t image_index);
Element paragraph(const std::string& text);
Element paragraphAlignLeft(const std::string& text);
Expand Down
11 changes: 9 additions & 2 deletions src/ftxui/dom/border.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ Element borderEmpty(Element child) {
/// @brief Draw window with a title and a border around the element.
/// @param title The title of the window.
/// @param content The element to be wrapped.
/// @param border The style of the border. Default is ROUNDED.
/// @ingroup dom
/// @see border
///
Expand All @@ -488,6 +489,12 @@ Element borderEmpty(Element child) {
/// Element document = window(text("Title"),
/// text("content")
/// );
///
/// // With specifying border
/// Element document = window(text("Title"),
/// text("content"),
/// ROUNDED
/// );
/// ```
///
/// ### Output
Expand All @@ -497,8 +504,8 @@ Element borderEmpty(Element child) {
/// │content│
/// └───────┘
/// ```
Element window(Element title, Element content) {
Element window(Element title, Element content, BorderStyle border) {
return std::make_shared<Border>(unpack(std::move(content), std::move(title)),
ROUNDED);
border);
}
} // namespace ftxui

0 comments on commit d38b14f

Please sign in to comment.