FTXUI  5.0.0
C++ functional terminal UI.
menu.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <algorithm> // for max, fill_n, reverse
5#include <chrono> // for milliseconds
6#include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up
7#include <functional> // for function
8#include <memory> // for allocator_traits<>::value_type, swap
9#include <string> // for operator+, string
10#include <utility> // for move
11#include <vector> // for vector, __alloc_traits<>::value_type
12
13#include "ftxui/component/animation.hpp" // for Animator, Linear
14#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse
15#include "ftxui/component/component.hpp" // for Make, Menu, MenuEntry, Toggle
16#include "ftxui/component/component_base.hpp" // for ComponentBase
17#include "ftxui/component/component_options.hpp" // for MenuOption, MenuEntryOption, UnderlineOption, AnimatedColorOption, AnimatedColorsOption, EntryState
18#include "ftxui/component/event.hpp" // for Event, Event::ArrowDown, Event::ArrowLeft, Event::ArrowRight, Event::ArrowUp, Event::End, Event::Home, Event::PageDown, Event::PageUp, Event::Return, Event::Tab, Event::TabReverse
19#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::Left, Mouse::Released, Mouse::WheelDown, Mouse::WheelUp, Mouse::None
20#include "ftxui/component/screen_interactive.hpp" // for Component
21#include "ftxui/dom/elements.hpp" // for operator|, Element, reflect, Decorator, nothing, Elements, bgcolor, color, hbox, separatorHSelector, separatorVSelector, vbox, xflex, yflex, text, bold, focus, inverted, select
22#include "ftxui/screen/box.hpp" // for Box
23#include "ftxui/screen/color.hpp" // for Color
24#include "ftxui/screen/util.hpp" // for clamp
25#include "ftxui/util/ref.hpp" // for Ref, ConstStringListRef, ConstStringRef
26
27namespace ftxui {
28
29namespace {
30
31Element DefaultOptionTransform(const EntryState& state) {
32 std::string label = (state.active ? "> " : " ") + state.label; // NOLINT
33 Element e = text(std::move(label));
34 if (state.focused) {
35 e = e | inverted;
36 }
37 if (state.active) {
38 e = e | bold;
39 }
40 return e;
41}
42
43bool IsInverted(Direction direction) {
44 switch (direction) {
45 case Direction::Up:
46 case Direction::Left:
47 return true;
48 case Direction::Down:
50 return false;
51 }
52 return false; // NOT_REACHED()
53}
54
55bool IsHorizontal(Direction direction) {
56 switch (direction) {
57 case Direction::Left:
59 return true;
60 case Direction::Down:
61 case Direction::Up:
62 return false;
63 }
64 return false; // NOT_REACHED()
65}
66
67} // namespace
68
69/// @brief A list of items. The user can navigate through them.
70/// @ingroup component
71class MenuBase : public ComponentBase, public MenuOption {
72 public:
73 explicit MenuBase(MenuOption option) : MenuOption(std::move(option)) {}
74
75 bool IsHorizontal() { return ftxui::IsHorizontal(direction); }
76 void OnChange() {
77 if (on_change) {
78 on_change();
79 }
80 }
81
82 void OnEnter() {
83 if (on_enter) {
84 on_enter();
85 }
86 }
87
88 void Clamp() {
89 if (selected() != selected_previous_) {
90 SelectedTakeFocus();
91 }
92 boxes_.resize(size());
93 selected() = util::clamp(selected(), 0, size() - 1);
94 selected_previous_ = util::clamp(selected_previous_, 0, size() - 1);
95 selected_focus_ = util::clamp(selected_focus_, 0, size() - 1);
97 }
98
99 void OnAnimation(animation::Params& params) override {
100 animator_first_.OnAnimation(params);
101 animator_second_.OnAnimation(params);
102 for (auto& animator : animator_background_) {
103 animator.OnAnimation(params);
104 }
105 for (auto& animator : animator_foreground_) {
106 animator.OnAnimation(params);
107 }
108 }
109
110 Element Render() override {
111 Clamp();
112 UpdateAnimationTarget();
113
114 Elements elements;
115 const bool is_menu_focused = Focused();
116 if (elements_prefix) {
117 elements.push_back(elements_prefix());
118 }
119 elements.reserve(size());
120 for (int i = 0; i < size(); ++i) {
121 if (i != 0 && elements_infix) {
122 elements.push_back(elements_infix());
123 }
124 const bool is_focused = (focused_entry() == i) && is_menu_focused;
125 const bool is_selected = (selected() == i);
126
127 const EntryState state = {
128 entries[i],
129 false,
130 is_selected,
131 is_focused,
132 };
133
134 auto focus_management =
135 is_menu_focused && (selected_focus_ == i) ? focus : nothing;
136
137 const Element element =
139 : DefaultOptionTransform) //
140 (state);
141 elements.push_back(element | AnimatedColorStyle(i) | reflect(boxes_[i]) |
142 focus_management);
143 }
144 if (elements_postfix) {
145 elements.push_back(elements_postfix());
146 }
147
148 if (IsInverted(direction)) {
149 std::reverse(elements.begin(), elements.end());
150 }
151
152 const Element bar =
153 IsHorizontal() ? hbox(std::move(elements)) : vbox(std::move(elements));
154
155 if (!underline.enabled) {
156 return bar | reflect(box_);
157 }
158
159 if (IsHorizontal()) {
160 return vbox({
161 bar | xflex,
162 separatorHSelector(first_, second_, //
165 }) |
166 reflect(box_);
167 } else {
168 return hbox({
169 separatorVSelector(first_, second_, //
172 bar | yflex,
173 }) |
174 reflect(box_);
175 }
176 }
177
178 void SelectedTakeFocus() {
179 selected_previous_ = selected();
180 selected_focus_ = selected();
181 }
182
183 void OnUp() {
184 switch (direction) {
185 case Direction::Up:
186 selected()++;
187 break;
188 case Direction::Down:
189 selected()--;
190 break;
191 case Direction::Left:
192 case Direction::Right:
193 break;
194 }
195 }
196
197 void OnDown() {
198 switch (direction) {
199 case Direction::Up:
200 selected()--;
201 break;
202 case Direction::Down:
203 selected()++;
204 break;
205 case Direction::Left:
206 case Direction::Right:
207 break;
208 }
209 }
210
211 void OnLeft() {
212 switch (direction) {
213 case Direction::Left:
214 selected()++;
215 break;
216 case Direction::Right:
217 selected()--;
218 break;
219 case Direction::Down:
220 case Direction::Up:
221 break;
222 }
223 }
224
225 void OnRight() {
226 switch (direction) {
227 case Direction::Left:
228 selected()--;
229 break;
230 case Direction::Right:
231 selected()++;
232 break;
233 case Direction::Down:
234 case Direction::Up:
235 break;
236 }
237 }
238
239 // NOLINTNEXTLINE(readability-function-cognitive-complexity)
240 bool OnEvent(Event event) override {
241 Clamp();
242 if (!CaptureMouse(event)) {
243 return false;
244 }
245
246 if (event.is_mouse()) {
247 return OnMouseEvent(event);
248 }
249
250 if (Focused()) {
251 const int old_selected = selected();
252 if (event == Event::ArrowUp || event == Event::Character('k')) {
253 OnUp();
254 }
255 if (event == Event::ArrowDown || event == Event::Character('j')) {
256 OnDown();
257 }
258 if (event == Event::ArrowLeft || event == Event::Character('h')) {
259 OnLeft();
260 }
261 if (event == Event::ArrowRight || event == Event::Character('l')) {
262 OnRight();
263 }
264 if (event == Event::PageUp) {
265 selected() -= box_.y_max - box_.y_min;
266 }
267 if (event == Event::PageDown) {
268 selected() += box_.y_max - box_.y_min;
269 }
270 if (event == Event::Home) {
271 selected() = 0;
272 }
273 if (event == Event::End) {
274 selected() = size() - 1;
275 }
276 if (event == Event::Tab && size()) {
277 selected() = (selected() + 1) % size();
278 }
279 if (event == Event::TabReverse && size()) {
280 selected() = (selected() + size() - 1) % size();
281 }
282
283 selected() = util::clamp(selected(), 0, size() - 1);
284
285 if (selected() != old_selected) {
287 SelectedTakeFocus();
288 OnChange();
289 return true;
290 }
291 }
292
293 if (event == Event::Return) {
294 OnEnter();
295 return true;
296 }
297
298 return false;
299 }
300
301 bool OnMouseEvent(Event event) {
302 if (event.mouse().button == Mouse::WheelDown ||
303 event.mouse().button == Mouse::WheelUp) {
304 return OnMouseWheel(event);
305 }
306
307 if (event.mouse().button != Mouse::None &&
308 event.mouse().button != Mouse::Left) {
309 return false;
310 }
311 if (!CaptureMouse(event)) {
312 return false;
313 }
314 for (int i = 0; i < size(); ++i) {
315 if (!boxes_[i].Contain(event.mouse().x, event.mouse().y)) {
316 continue;
317 }
318
319 TakeFocus();
320 focused_entry() = i;
321 if (event.mouse().IsPressed()) {
322 if (selected() != i) {
323 selected() = i;
324 selected_previous_ = selected();
325 OnChange();
326 }
327 return true;
328 }
329 }
330 return false;
331 }
332
333 bool OnMouseWheel(Event event) {
334 if (!box_.Contain(event.mouse().x, event.mouse().y)) {
335 return false;
336 }
337 const int old_selected = selected();
338
339 if (event.mouse().button == Mouse::WheelUp) {
340 selected()--;
341 }
342 if (event.mouse().button == Mouse::WheelDown) {
343 selected()++;
344 }
345
346 selected() = util::clamp(selected(), 0, size() - 1);
347
348 if (selected() != old_selected) {
349 SelectedTakeFocus();
350 OnChange();
351 }
352 return true;
353 }
354
355 void UpdateAnimationTarget() {
356 UpdateColorTarget();
357 UpdateUnderlineTarget();
358 }
359
360 void UpdateColorTarget() {
361 if (size() != int(animation_background_.size())) {
362 animation_background_.resize(size());
363 animation_foreground_.resize(size());
364 animator_background_.clear();
365 animator_foreground_.clear();
366
367 const int len = size();
368 animator_background_.reserve(len);
369 animator_foreground_.reserve(len);
370 for (int i = 0; i < len; ++i) {
371 animation_background_[i] = 0.F;
372 animation_foreground_[i] = 0.F;
373 animator_background_.emplace_back(&animation_background_[i], 0.F,
374 std::chrono::milliseconds(0),
376 animator_foreground_.emplace_back(&animation_foreground_[i], 0.F,
377 std::chrono::milliseconds(0),
379 }
380 }
381
382 const bool is_menu_focused = Focused();
383 for (int i = 0; i < size(); ++i) {
384 const bool is_focused = (focused_entry() == i) && is_menu_focused;
385 const bool is_selected = (selected() == i);
386 float target = is_selected ? 1.F : is_focused ? 0.5F : 0.F; // NOLINT
387 if (animator_background_[i].to() != target) {
388 animator_background_[i] = animation::Animator(
389 &animation_background_[i], target,
392 animator_foreground_[i] = animation::Animator(
393 &animation_foreground_[i], target,
396 }
397 }
398 }
399
400 Decorator AnimatedColorStyle(int i) {
401 Decorator style = nothing;
403 style = style | color(Color::Interpolate(
404 animation_foreground_[i],
407 }
408
410 style = style | bgcolor(Color::Interpolate(
411 animation_background_[i],
414 }
415 return style;
416 }
417
418 void UpdateUnderlineTarget() {
419 if (!underline.enabled) {
420 return;
421 }
422
423 if (FirstTarget() == animator_first_.to() &&
424 SecondTarget() == animator_second_.to()) {
425 return;
426 }
427
428 if (FirstTarget() >= animator_first_.to()) {
429 animator_first_ = animation::Animator(
430 &first_, FirstTarget(), underline.follower_duration,
432
433 animator_second_ = animation::Animator(
434 &second_, SecondTarget(), underline.leader_duration,
436 } else {
437 animator_first_ = animation::Animator(
438 &first_, FirstTarget(), underline.leader_duration,
440
441 animator_second_ = animation::Animator(
442 &second_, SecondTarget(), underline.follower_duration,
444 }
445 }
446
447 bool Focusable() const final { return entries.size(); }
448 int size() const { return int(entries.size()); }
449 float FirstTarget() {
450 if (boxes_.empty()) {
451 return 0.F;
452 }
453 const int value = IsHorizontal() ? boxes_[selected()].x_min - box_.x_min
454 : boxes_[selected()].y_min - box_.y_min;
455 return float(value);
456 }
457 float SecondTarget() {
458 if (boxes_.empty()) {
459 return 0.F;
460 }
461 const int value = IsHorizontal() ? boxes_[selected()].x_max - box_.x_min
462 : boxes_[selected()].y_max - box_.y_min;
463 return float(value);
464 }
465
466 protected:
467 int selected_previous_ = selected();
468 int selected_focus_ = selected();
469
470 // Mouse click support:
471 std::vector<Box> boxes_;
472 Box box_;
473
474 // Animation support:
475 float first_ = 0.F;
476 float second_ = 0.F;
477 animation::Animator animator_first_ = animation::Animator(&first_, 0.F);
478 animation::Animator animator_second_ = animation::Animator(&second_, 0.F);
479 std::vector<animation::Animator> animator_background_;
480 std::vector<animation::Animator> animator_foreground_;
481 std::vector<float> animation_background_;
482 std::vector<float> animation_foreground_;
483};
484
485/// @brief A list of text. The focused element is selected.
486/// @param option a structure containing all the paramters.
487/// @ingroup component
488///
489/// ### Example
490///
491/// ```cpp
492/// auto screen = ScreenInteractive::TerminalOutput();
493/// std::vector<std::string> entries = {
494/// "entry 1",
495/// "entry 2",
496/// "entry 3",
497/// };
498/// int selected = 0;
499/// auto menu = Menu({
500/// .entries = &entries,
501/// .selected = &selected,
502/// });
503/// screen.Loop(menu);
504/// ```
505///
506/// ### Output
507///
508/// ```bash
509/// > entry 1
510/// entry 2
511/// entry 3
512/// ```
514 return Make<MenuBase>(std::move(option));
515}
516
517/// @brief A list of text. The focused element is selected.
518/// @param entries The list of entries in the menu.
519/// @param selected The index of the currently selected element.
520/// @param option Additional optional parameters.
521/// @ingroup component
522///
523/// ### Example
524///
525/// ```cpp
526/// auto screen = ScreenInteractive::TerminalOutput();
527/// std::vector<std::string> entries = {
528/// "entry 1",
529/// "entry 2",
530/// "entry 3",
531/// };
532/// int selected = 0;
533/// auto menu = Menu(&entries, &selected);
534/// screen.Loop(menu);
535/// ```
536///
537/// ### Output
538///
539/// ```bash
540/// > entry 1
541/// entry 2
542/// entry 3
543/// ```
544Component Menu(ConstStringListRef entries, int* selected, MenuOption option) {
545 option.entries = entries;
546 option.selected = selected;
547 return Menu(std::move(option));
548}
549
550/// @brief An horizontal list of elements. The user can navigate through them.
551/// @param entries The list of selectable entries to display.
552/// @param selected Reference the selected entry.
553/// See also |Menu|.
554/// @ingroup component
555Component Toggle(ConstStringListRef entries, int* selected) {
556 return Menu(entries, selected, MenuOption::Toggle());
557}
558
559/// @brief A specific menu entry. They can be put into a Container::Vertical to
560/// form a menu.
561/// @param label The text drawn representing this element.
562/// @param option Additional optional parameters.
563/// @ingroup component
564///
565/// ### Example
566///
567/// ```cpp
568/// auto screen = ScreenInteractive::TerminalOutput();
569/// int selected = 0;
570/// auto menu = Container::Vertical({
571/// MenuEntry("entry 1"),
572/// MenuEntry("entry 2"),
573/// MenuEntry("entry 3"),
574/// }, &selected);
575/// screen.Loop(menu);
576/// ```
577///
578/// ### Output
579///
580/// ```bash
581/// > entry 1
582/// entry 2
583/// entry 3
584/// ```
586 option.label = label;
587 return MenuEntry(std::move(option));
588}
589
590/// @brief A specific menu entry. They can be put into a Container::Vertical to
591/// form a menu.
592/// @param option The parameters.
593/// @ingroup component
594///
595/// ### Example
596///
597/// ```cpp
598/// auto screen = ScreenInteractive::TerminalOutput();
599/// int selected = 0;
600/// auto menu = Container::Vertical({
601/// MenuEntry({.label = "entry 1"}),
602/// MenuEntry({.label = "entry 2"}),
603/// MenuEntry({.label = "entry 3"}),
604/// }, &selected);
605/// screen.Loop(menu);
606/// ```
607///
608/// ### Output
609///
610/// ```bash
611/// > entry 1
612/// entry 2
613/// entry 3
614/// ```
616 class Impl : public ComponentBase, public MenuEntryOption {
617 public:
618 explicit Impl(MenuEntryOption option)
619 : MenuEntryOption(std::move(option)) {}
620
621 private:
622 Element Render() override {
623 const bool focused = Focused();
624 UpdateAnimationTarget();
625
626 const EntryState state = {
627 label(),
628 false,
629 hovered_,
630 focused,
631 };
632
633 const Element element =
634 (transform ? transform : DefaultOptionTransform) //
635 (state);
636
637 auto focus_management = focused ? select : nothing;
638 return element | AnimatedColorStyle() | focus_management | reflect(box_);
639 }
640
641 void UpdateAnimationTarget() {
642 const bool focused = Focused();
643 float target = focused ? 1.F : hovered_ ? 0.5F : 0.F; // NOLINT
644 if (target == animator_background_.to()) {
645 return;
646 }
647 animator_background_ = animation::Animator(
648 &animation_background_, target, animated_colors.background.duration,
649 animated_colors.background.function);
650 animator_foreground_ = animation::Animator(
651 &animation_foreground_, target, animated_colors.foreground.duration,
652 animated_colors.foreground.function);
653 }
654
655 Decorator AnimatedColorStyle() {
656 Decorator style = nothing;
657 if (animated_colors.foreground.enabled) {
658 style = style |
659 color(Color::Interpolate(animation_foreground_,
660 animated_colors.foreground.inactive,
661 animated_colors.foreground.active));
662 }
663
664 if (animated_colors.background.enabled) {
665 style = style |
666 bgcolor(Color::Interpolate(animation_background_,
667 animated_colors.background.inactive,
668 animated_colors.background.active));
669 }
670 return style;
671 }
672
673 bool Focusable() const override { return true; }
674 bool OnEvent(Event event) override {
675 if (!event.is_mouse()) {
676 return false;
677 }
678
679 hovered_ = box_.Contain(event.mouse().x, event.mouse().y);
680
681 if (!hovered_) {
682 return false;
683 }
684
685 if (event.mouse().IsPressed()) {
686 TakeFocus();
687 return true;
688 }
689
690 return false;
691 }
692
693 void OnAnimation(animation::Params& params) override {
694 animator_background_.OnAnimation(params);
695 animator_foreground_.OnAnimation(params);
696 }
697
698 MenuEntryOption option_;
699 Box box_;
700 bool hovered_ = false;
701
702 float animation_background_ = 0.F;
703 float animation_foreground_ = 0.F;
704 animation::Animator animator_background_ =
705 animation::Animator(&animation_background_, 0.F);
706 animation::Animator animator_foreground_ =
707 animation::Animator(&animation_foreground_, 0.F);
708 };
709
710 return Make<Impl>(std::move(option));
711}
712
713} // namespace ftxui
static Color Interpolate(float t, const Color &a, const Color &b)
Definition: color.cpp:217
It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ft...
bool Focused() const
Returns if the elements if focused by the user. True when the ComponentBase is focused by the user....
Definition: component.cpp:161
CapturedMouse CaptureMouse(const Event &event)
Take the CapturedMouse if available. There is only one component of them. It represents a component t...
Definition: component.cpp:195
void TakeFocus()
Configure all the ancestors to give focus to this component.
Definition: component.cpp:183
An adapter. Reference a list of strings.
Definition: ref.hpp:98
size_t size() const
Definition: ref.hpp:106
An adapter. Own or reference a constant string. For convenience, this class convert multiple immutabl...
Definition: ref.hpp:86
float Linear(float p)
Modeled after the line y = x.
Definition: animation.cpp:30
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
Definition: util.hpp:12
Decorator bgcolor(Color)
Decorate using a background color.
Definition: color.cpp:124
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Definition: flex.cpp:129
std::function< Element(Element)> Decorator
Definition: elements.hpp:25
Element separatorVSelector(float up, float down, Color unselected_color, Color selected_color)
Draw an vertical bar, with the area in between up/downcolored differently.
Definition: separator.cpp:510
AnimatedColorOption foreground
Element nothing(Element element)
A decoration doing absolutely nothing.
Definition: util.cpp:30
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Definition: size.cpp:90
Direction
Definition: direction.hpp:8
std::shared_ptr< Node > Element
Definition: elements.hpp:23
Component Menu(MenuOption options)
A list of text. The focused element is selected.
Definition: menu.cpp:513
Component MenuEntry(MenuEntryOption options)
A specific menu entry. They can be put into a Container::Vertical to form a menu.
Definition: menu.cpp:615
std::shared_ptr< ComponentBase > Component
Component Toggle(ConstStringListRef entries, int *selected)
An horizontal list of elements. The user can navigate through them.
Definition: menu.cpp:555
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition: bold.cpp:33
Element yflex(Element)
Expand/Minimize if possible/needed on the Y axis.
Definition: flex.cpp:135
Element separatorHSelector(float left, float right, Color unselected_color, Color selected_color)
Draw an horizontal bar, with the area in between left/right colored differently.
Definition: separator.cpp:440
AnimatedColorOption background
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition: hbox.cpp:83
std::function< Element(const EntryState &state)> transform
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Definition: inverted.cpp:34
Element text(std::wstring text)
Display a piece of unicode text.
Definition: text.cpp:120
std::vector< Element > Elements
Definition: elements.hpp:24
Element select(Element)
Set the child to be the one selected among its siblings.
Definition: frame.cpp:150
Element focus(Element)
Set the child to be the one in focus globally.
Definition: frame.cpp:157
Decorator reflect(Box &box)
Definition: reflect.cpp:44
AnimatedColorsOption animated_colors
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition: node.cpp:47
Decorator color(Color)
Decorate using a foreground color.
Definition: color.cpp:110
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition: vbox.cpp:83
arguments for |ButtonOption::transform|, |CheckboxOption::transform|, |Radiobox::transform|,...
Option for the MenuEntry component.
animation::easing::Function function
animation::Duration duration
Represent an event. It can be key press event, a terminal resize, or more ...
Definition: event.hpp:29
static const Event TabReverse
Definition: event.hpp:56
static const Event PageUp
Definition: event.hpp:63
bool is_mouse() const
Definition: event.hpp:78
struct Mouse & mouse()
Definition: event.hpp:79
static Event Character(std::string)
An event corresponding to a given typed character.
Definition: event.cpp:16
static const Event ArrowUp
Definition: event.hpp:42
static const Event Tab
Definition: event.hpp:55
static const Event ArrowDown
Definition: event.hpp:43
static const Event End
Definition: event.hpp:61
static const Event Home
Definition: event.hpp:60
static const Event PageDown
Definition: event.hpp:64
static const Event Return
Definition: event.hpp:53
static const Event ArrowLeft
Definition: event.hpp:40
static const Event ArrowRight
Definition: event.hpp:41
Option for the Menu component.
std::function< Element()> elements_prefix
static MenuOption Toggle()
Standard options for a horitontal menu with some separator. This can be useful to implement a tab bar...
MenuEntryOption entries_option
std::function< void()> on_enter
‍Called when the selected entry changes.
UnderlineOption underline
‍The index of the selected entry.
ConstStringListRef entries
Ref< int > focused_entry
‍Called when the user presses enter.
std::function< Element()> elements_infix
std::function< Element()> elements_postfix
std::function< void()> on_change
Ref< int > selected
‍The list of entries.
bool IsPressed(Button btn=Left) const
Definition: mouse.cpp:18
animation::Duration follower_duration
animation::easing::Function leader_function
animation::Duration follower_delay
animation::Duration leader_duration
animation::easing::Function follower_function
animation::Duration leader_delay