Add {Const,}StringRef to simplify components.

This commit is contained in:
ArthurSonzogni
2021-05-14 21:43:35 +02:00
parent 9fdf235836
commit 048efb6912
29 changed files with 201 additions and 164 deletions

View File

@@ -2,12 +2,13 @@
#define FTXUI_COMPONENT_CHECKBOX_HPP
#include <functional> // for function
#include <string> // for wstring, allocator
#include <string> // for allocator, wstring
#include "ftxui/component/component.hpp" // for Component
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/dom/elements.hpp" // for Element, Decorator, inverted, nothing
#include "ftxui/screen/box.hpp" // for Box
#include "ftxui/dom/elements.hpp" // for Element, Decorator, inverted, nothing
#include "ftxui/screen/box.hpp" // for Box
#include "ftxui/screen/string.hpp" // for ConstStringRef
namespace ftxui {
struct Event;
@@ -21,7 +22,7 @@ class CheckboxBase : public ComponentBase {
static CheckboxBase* From(Component component);
// Constructor.
CheckboxBase(const std::wstring* label, bool* state);
CheckboxBase(ConstStringRef label, bool* state);
~CheckboxBase() override = default;
#if defined(_WIN32)
@@ -45,7 +46,7 @@ class CheckboxBase : public ComponentBase {
private:
bool OnMouseEvent(Event event);
const std::wstring* const label_;
ConstStringRef label_;
bool* const state_;
int cursor_position = 0;
Box box_;