#include <functional>
#include <string>
#include <utility>
if (state.is_placeholder) {
state.element |= dim;
}
if (state.focused) {
state.element |=
bgcolor(Color::White);
state.element |=
color(Color::Black);
} else if (state.hovered) {
state.element |=
color(Color::White);
} else {
state.element |=
color(Color::White);
}
return state.element;
};
state.element = hbox({
text(
"Theorem") | center | borderEmpty |
bgcolor(Color::Red),
separatorEmpty(),
separator() |
color(Color::White),
separatorEmpty(),
std::move(state.element),
});
if (state.is_placeholder) {
state.element |= dim;
}
if (state.focused) {
state.element |=
bgcolor(Color::Black);
} else {
state.element |=
bgcolor(Color::Blue);
}
if (state.hovered) {
state.element |=
bgcolor(Color::GrayDark);
}
return vbox({state.element, separatorEmpty()});
};
auto first_name = new std::string();
auto middle_name = new std::string();
auto last_name = new std::string();
return Container::Vertical({
Input(first_name, "first name", style),
Input(middle_name, "middle name", style),
Input(last_name, "last name", style),
}) |
borderEmpty;
};
auto ui = Container::Horizontal({
generateUiFromStyle(style_1),
generateUiFromStyle(style_2),
generateUiFromStyle(style_3),
generateUiFromStyle(style_4),
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(ui);
}
std::function< Element(InputState)> transform
Element color(const LinearGradient &gradient, Element child)
使用线性渐变效果设置元素的前景色。
Element borderDouble(Element child)
在元素周围绘制双线边框。
Element borderRounded(Element child)
在元素周围绘制圆角边框。
Element bgcolor(const LinearGradient &gradient, Element child)
使用线性渐变效果设置元素的背景色。
Element border(Element child)
在元素周围绘制边框。
Element borderEmpty(Element child)
在元素周围绘制一个空边框。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase