From 1661a5e83d20dc51d57bf1faccc0e19133e29655 Mon Sep 17 00:00:00 2001
From: Arthur Sonzogni <sonzogniarthur@gmail.com>
Date: Tue, 30 Aug 2022 19:03:14 +0200
Subject: [PATCH] Implement ButtonOption::Border() (#472)

It was missing. See:
https://github.com/ArthurSonzogni/FTXUI/issues/471
---
 CHANGELOG.md                              |  1 +
 src/ftxui/component/component_options.cpp | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7666852..6241e888 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ current (development)
     - various values (value, min, max, increment).
 - Improvement: The `Menu` keeps the focus when an entry is selected with the
   mouse.
+- Bug: Add implementation of `ButtonOption::Border()`. It was missing.
 
 ### Screen
 - Feature: add `Box::Union(a,b) -> Box`
diff --git a/src/ftxui/component/component_options.cpp b/src/ftxui/component/component_options.cpp
index 57a2c149..e8a1cf17 100644
--- a/src/ftxui/component/component_options.cpp
+++ b/src/ftxui/component/component_options.cpp
@@ -144,6 +144,23 @@ ButtonOption ButtonOption::Simple() {
   return option;
 }
 
+/// @brief Create a ButtonOption. The button is shown using a border, inverted
+/// when focused. This is the current default.
+ButtonOption ButtonOption::Border() {
+  ButtonOption option;
+  option.transform = [](const EntryState& s) {
+    auto element = text(s.label) | border;
+    if (s.active) {
+      element |= bold;
+    }
+    if (s.focused) {
+      element |= inverted;
+    }
+    return element;
+  };
+  return option;
+}
+
 /// @brief Create a ButtonOption, using animated colors.
 // static
 ButtonOption ButtonOption::Animated() {
-- 
GitLab