FTXUI
6.1.9
C++ functional terminal UI.
Toggle main menu visibility
Loading...
Searching...
No Matches
examples/component/button_in_frame.cpp
// Copyright 2022 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <memory>
// for allocator, __shared_ptr_access, shared_ptr
#include <string>
// for to_string, operator+
#include "
ftxui/component/captured_mouse.hpp
"
// for ftxui
#include "
ftxui/component/component.hpp
"
// for Button, Renderer, Vertical
#include "
ftxui/component/component_base.hpp
"
// for ComponentBase
#include "
ftxui/component/component_options.hpp
"
// for ButtonOption
#include "
ftxui/component/screen_interactive.hpp
"
// for ScreenInteractive
#include "
ftxui/dom/elements.hpp
"
// for operator|, text, Element, hbox, separator, size, vbox, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
#include "
ftxui/screen/color.hpp
"
// for Color, Color::Default, Color::GrayDark, Color::White
using namespace
ftxui
;
int
main() {
int
counter = 0;
auto
on_click = [&] { counter++; };
auto
style =
ButtonOption::Animated
(
Color::Default
,
Color::GrayDark
,
Color::Default
,
Color::White
);
auto
container =
Container::Vertical
({});
for
(
int
i = 0; i < 30; ++i) {
auto
button =
Button
(
"Button "
+ std::to_string(i), on_click, style);
container->Add(button);
}
auto
renderer =
Renderer
(container, [&] {
return
vbox
({
hbox
({
text
(
"Counter:"
),
text
(std::to_string(counter)),
}),
separator
(),
container->Render() |
vscroll_indicator
|
frame
|
size
(
HEIGHT
,
LESS_THAN
, 20),
}) |
border
;
});
auto
screen =
ScreenInteractive::FitComponent
();
screen.Loop(renderer);
return
0;
}
captured_mouse.hpp
ftxui::Color::Default
@ Default
Definition
color.hpp:48
ftxui::Color::White
@ White
Definition
color.hpp:67
ftxui::Color::GrayDark
@ GrayDark
Definition
color.hpp:60
ftxui::ScreenInteractive::FitComponent
static ScreenInteractive FitComponent()
Definition
screen_interactive.cpp:416
color.hpp
component.hpp
component_base.hpp
component_options.hpp
elements.hpp
ftxui::Container::Vertical
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Definition
container.cpp:317
ftxui
Definition
animation.hpp:10
ftxui::HEIGHT
@ HEIGHT
Definition
elements.hpp:153
ftxui::vscroll_indicator
Element vscroll_indicator(Element)
Display a vertical scrollbar to the right. colors.
Definition
scroll_indicator.cpp:21
ftxui::size
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Definition
size.cpp:89
ftxui::Button
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
Definition
button.cpp:176
ftxui::Renderer
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition
renderer.cpp:61
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition
hbox.cpp:94
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition
text.cpp:160
ftxui::separator
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Definition
separator.cpp:134
ftxui::frame
Element frame(Element)
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container....
Definition
frame.cpp:118
ftxui::LESS_THAN
@ LESS_THAN
Definition
elements.hpp:154
ftxui::border
Element border(Element)
Draw a border around the element.
Definition
border.cpp:227
ftxui::vbox
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition
vbox.cpp:96
screen_interactive.hpp
ftxui::ButtonOption::Animated
static ButtonOption Animated()
Create a ButtonOption, using animated colors.
Definition
component_options.cpp:210