mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Improve the documentation.
This commit is contained in:
@@ -27,10 +27,43 @@ class RendererBase : public ComponentBase {
|
||||
std::function<Element()> render_;
|
||||
};
|
||||
|
||||
/// @brief Return a component, using |render| to render its interface.
|
||||
/// @param render The function drawing the interface.
|
||||
/// @ingroup component
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```cpp
|
||||
/// auto screen = ScreenInteractive::TerminalOutput();
|
||||
/// auto renderer = Renderer([] {
|
||||
/// return text(L"My interface");
|
||||
/// });
|
||||
/// screen.Loop(renderer);
|
||||
/// ```
|
||||
Component Renderer(std::function<Element()> render) {
|
||||
return Make<RendererBase>(std::move(render));
|
||||
}
|
||||
|
||||
/// @brief Return a new Component, similar to |child|, but using |render| as the
|
||||
/// Component::Render() event.
|
||||
/// @param child The component to forward events to.
|
||||
/// @param render The function drawing the interface.
|
||||
/// @ingroup component
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```cpp
|
||||
/// auto screen = ScreenInteractive::TerminalOutput();
|
||||
/// std::wstring label = "Click to quit";
|
||||
/// auto button = Button(&label, screen.ExitLoopClosure());
|
||||
/// auto renderer = Renderer(button, [&] {
|
||||
/// return hbox({
|
||||
/// text("A button:"),
|
||||
/// button->Render(),
|
||||
/// });
|
||||
/// });
|
||||
/// screen.Loop(renderer);
|
||||
/// ```
|
||||
Component Renderer(Component child, std::function<Element()> render) {
|
||||
Component renderer = Renderer(std::move(render));
|
||||
renderer->Add(std::move(child));
|
||||
|
Reference in New Issue
Block a user