20 MenuEntryOption option;
21 option.animated_colors.foreground.enabled =
true;
22 option.animated_colors.background.enabled =
true;
23 option.animated_colors.background.active = c;
24 option.animated_colors.background.inactive = Color::Black;
25 option.animated_colors.foreground.active = Color::White;
26 option.animated_colors.foreground.inactive = c;
31 auto screen = App::TerminalOutput();
34 auto menu = Container::Vertical(
55 hbox(
text(
"selected = "),
text(std::to_string(selected))),
57 menu->Render() |
frame,
62 screen.Loop(renderer);
64 std::cout <<
"Selected element = " << selected << std::endl;
Component Renderer(Component child, std::function< Element()>)
回傳一個新的 Component,類似 |child|,但使用 |render| 作為 Component::Render() 事件。
Component MenuEntry(ConstStringRef label, MenuEntryOption options={})
一個特定的選單項目。可以將它們放入 Container::Vertical 以 組成一個選單。
Element text(std::string_view text)
顯示一段 UTF8 編碼的 Unicode 文字。
Element bgcolor(Color color, Element child)
設定元素的背景顏色。
Element separator()
在兩個元素之間繪製垂直或水平分隔線。
Element vbox(Elements children)
一個垂直一個接一個顯示元素的容器。
Element hbox(Elements children)
一個逐一水平顯示元素的容器。
Element frame(Element child)
允許元素顯示在「虛擬」區域內。其大小可以大於其容器。在這種情況下,只會顯示較小的一部分。視圖可滾動以使聚焦元素可見。