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);
60void UnderlineOption::SetAnimationFunction(
63 leader_function = std::move(f_leader);
64 follower_function = std::move(f_follower);
70MenuOption MenuOption::Horizontal() {
72 option.direction = Direction::Right;
73 option.entries_option.transform = [](
const EntryState& state) {
81 if (!state.focused && !state.active) {
86 option.elements_infix = [] {
return text(
" "); };
94MenuOption MenuOption::HorizontalAnimated() {
95 auto option = Horizontal();
96 option.underline.enabled =
true;
103MenuOption MenuOption::Vertical() {
105 option.entries_option.transform = [](
const EntryState& state) {
106 Element e = text((state.active ?
"> " :
" ") + state.label);
113 if (!state.focused && !state.active) {
124MenuOption MenuOption::VerticalAnimated() {
125 auto option = MenuOption::Vertical();
126 option.entries_option.transform = [](
const EntryState& state) {
134 if (!state.focused && !state.active) {
139 option.underline.enabled =
true;
146MenuOption MenuOption::Toggle() {
147 auto option = MenuOption::Horizontal();
148 option.elements_infix = [] {
return text(
"│") | automerge; };
154ButtonOption ButtonOption::Ascii() {
156 option.transform = [](
const EntryState& s) {
157 const std::string t = s.focused ?
"[" + s.label +
"]"
158 :
" " + s.label +
" ";
166ButtonOption ButtonOption::Simple() {
168 option.transform = [](
const EntryState& s) {
169 auto element = text(s.label) | borderLight;
180ButtonOption ButtonOption::Border() {
182 option.transform = [](
const EntryState& s) {
183 auto element = text(s.label) | border;
197ButtonOption ButtonOption::Animated() {
198 return Animated(Color::Black, Color::GrayLight,
199 Color::GrayDark, Color::White);
204ButtonOption ButtonOption::Animated(Color color) {
205 return ButtonOption::Animated(
206 Color::Interpolate(0.85F, color, Color::Black),
207 Color::Interpolate(0.10F, color, Color::White),
208 Color::Interpolate(0.10F, color, Color::Black),
209 Color::Interpolate(0.85F, color, Color::White));
214ButtonOption ButtonOption::Animated(Color background, Color foreground) {
216 return ButtonOption::Animated(
226ButtonOption ButtonOption::Animated(Color background,
228 Color background_active,
229 Color foreground_active) {
231 option.transform = [](
const EntryState& s) {
232 auto element = text(s.label) | borderEmpty;
238 option.animated_colors.foreground.Set(foreground, foreground_active);
239 option.animated_colors.background.Set(background, background_active);
245CheckboxOption CheckboxOption::Simple() {
246 auto option = CheckboxOption();
247 option.transform = [](
const EntryState& s) {
248 auto prefix = (Terminal::GetQuirks().ComponentAscii())
249 ? text(s.state ?
"[X] " :
"[ ] ")
250 : text(s.state ?
"▣ " :
"☐ ");
251 auto t = text(s.label);
258 return hbox({prefix, t});
265RadioboxOption RadioboxOption::Simple() {
266 auto option = RadioboxOption();
267 option.transform = [](
const EntryState& s) {
268 auto prefix = (Terminal::GetQuirks().ComponentAscii())
269 ? text(s.state ?
"(*) " :
"( ) ")
270 : text(s.state ?
"◉ " :
"○ ");
271 auto t = text(s.label);
278 return hbox({prefix, t});
285InputOption InputOption::Default() {
287 option.transform = [](InputState state) {
288 if (state.is_placeholder) {
289 state.element |= dim;
293 state.element |= inverted;
294 }
else if (state.hovered) {
295 state.element |= underlined;
298 return state.element;
305InputOption InputOption::Spacious() {
307 option.transform = [](InputState state) {
308 state.element |= borderEmpty;
310 if (state.is_placeholder) {
311 state.element |= dim;
315 state.element |= inverted;
316 }
else if (state.hovered) {
317 state.element |= bold;
320 return state.element;
std::function< float(float)> Function
std::chrono::duration< float > Duration
El espacio de nombres ftxui:: de FTXUI.
std::shared_ptr< Node > Element