feat: Dropdown select menu. (#214)

Dom
 - `vscroll_indicator`. Show a scrollback indicator on the right.

Component
 - `Maybe`: Display an component conditionnally based on a boolean.
 - `Dropdown`: A dropdown select list.

This address:
https://github.com/ArthurSonzogni/FTXUI/issues/204
This commit is contained in:
Arthur Sonzogni
2021-09-26 15:19:17 +02:00
parent 0d1a7ffe6d
commit c5ef0c7fb5
12 changed files with 282 additions and 6 deletions

View File

@@ -39,6 +39,7 @@ Component Menu(ConstStringListRef entries,
int* selected_,
Ref<MenuOption> = {});
Component MenuEntry(ConstStringRef label, Ref<MenuEntryOption> = {});
Component Dropdown(ConstStringListRef entries, int* selected);
Component Radiobox(ConstStringListRef entries,
int* selected_,
Ref<RadioboxOption> option = {});
@@ -55,6 +56,7 @@ Component Renderer(Component child, std::function<Element()>);
Component Renderer(std::function<Element()>);
Component Renderer(std::function<Element(bool /* focused */)>);
Component CatchEvent(Component child, std::function<bool(Event)>);
Component Maybe(Component, bool* show);
namespace Container {
Component Vertical(Components children);

View File

@@ -74,6 +74,7 @@ struct Event {
bool operator!=(const Event& other) const { return !operator==(other); }
//--- State section ----------------------------------------------------------
ScreenInteractive* screen_ = nullptr;
private:
friend ComponentBase;
friend ScreenInteractive;
@@ -95,8 +96,6 @@ struct Event {
struct Cursor cursor_;
};
std::string input_;
ScreenInteractive* screen_ = nullptr;
};
} // namespace ftxui

View File

@@ -104,6 +104,8 @@ Element yframe(Element);
Element focus(Element);
Element select(Element);
Element vscroll_indicator(Element);
// --- Util --------------------------------------------------------------------
Element hcenter(Element);
Element vcenter(Element);