22void AnimatedColorOption::Set(Color _inactive,
30 function = std::move(_function);
38 SetAnimationDuration(d);
39 SetAnimationFunction(std::move(f));
46 follower_duration = d;
53 follower_function = std::move(f);
61void UnderlineOption::SetAnimationFunction(
64 leader_function = std::move(f_leader);
65 follower_function = std::move(f_follower);
71MenuOption MenuOption::Horizontal() {
73 option.direction = Direction::Right;
74 option.entries_option.transform = [](
const EntryState& state) {
82 if (!state.focused && !state.active) {
87 option.elements_infix = [] {
return text(
" "); };
95MenuOption MenuOption::HorizontalAnimated() {
96 auto option = Horizontal();
97 option.underline.enabled =
true;
104MenuOption MenuOption::Vertical() {
106 option.entries_option.transform = [](
const EntryState& state) {
107 Element e = text((state.active ?
"> " :
" ") + state.label);
114 if (!state.focused && !state.active) {
125MenuOption MenuOption::VerticalAnimated() {
126 auto option = MenuOption::Vertical();
127 option.entries_option.transform = [](
const EntryState& state) {
135 if (!state.focused && !state.active) {
140 option.underline.enabled =
true;
147MenuOption MenuOption::Toggle() {
148 auto option = MenuOption::Horizontal();
149 option.elements_infix = [] {
return text(
"│") | automerge; };
155ButtonOption ButtonOption::Ascii() {
157 option.transform = [](
const EntryState& s) {
158 const std::string t = s.focused ?
"[" + s.label +
"]"
159 :
" " + s.label +
" ";
167ButtonOption ButtonOption::Simple() {
169 option.transform = [](
const EntryState& s) {
170 auto element = text(s.label) | borderLight;
181ButtonOption ButtonOption::Border() {
183 option.transform = [](
const EntryState& s) {
184 auto element = text(s.label) | border;
198ButtonOption ButtonOption::Animated() {
199 return Animated(Color::Black, Color::GrayLight,
200 Color::GrayDark, Color::White);
205ButtonOption ButtonOption::Animated(Color color) {
206 return ButtonOption::Animated(
207 Color::Interpolate(0.85F, color, Color::Black),
208 Color::Interpolate(0.10F, color, Color::White),
209 Color::Interpolate(0.10F, color, Color::Black),
210 Color::Interpolate(0.85F, color, Color::White));
215ButtonOption ButtonOption::Animated(Color background, Color foreground) {
217 return ButtonOption::Animated(
227ButtonOption ButtonOption::Animated(Color background,
229 Color background_active,
230 Color foreground_active) {
232 option.transform = [](
const EntryState& s) {
233 auto element = text(s.label) | borderEmpty;
239 option.animated_colors.foreground.Set(foreground, foreground_active);
240 option.animated_colors.background.Set(background, background_active);
246CheckboxOption CheckboxOption::Simple() {
247 auto option = CheckboxOption();
248 option.transform = [](
const EntryState& s) {
249 auto prefix = (Terminal::GetQuirks().ComponentAscii())
250 ? text(s.state ?
"[X] " :
"[ ] ")
251 : text(s.state ?
"▣ " :
"☐ ");
252 auto t = text(s.label);
259 return hbox({prefix, t});
266RadioboxOption RadioboxOption::Simple() {
267 auto option = RadioboxOption();
268 option.transform = [](
const EntryState& s) {
269 auto prefix = (Terminal::GetQuirks().ComponentAscii())
270 ? text(s.state ?
"(*) " :
"( ) ")
271 : text(s.state ?
"◉ " :
"○ ");
272 auto t = text(s.label);
279 return hbox({prefix, t});
286InputOption InputOption::Default() {
288 option.transform = [](InputState state) {
289 if (state.is_placeholder) {
290 state.element |= dim;
294 state.element |= inverted;
295 }
else if (state.hovered) {
296 state.element |= underlined;
299 return state.element;
306InputOption InputOption::Spacious() {
308 option.transform = [](InputState state) {
309 state.element |= borderEmpty;
311 if (state.is_placeholder) {
312 state.element |= dim;
316 state.element |= inverted;
317 }
else if (state.hovered) {
318 state.element |= bold;
321 return state.element;
std::function< float(float)> Function
std::chrono::duration< float > Duration
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element