mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Improve documentation (#1058)
* Remove @ingroup from class member definitions * Add the documentation for every public classes.
This commit is contained in:
@@ -8,11 +8,21 @@
|
||||
#include <functional> // for function
|
||||
|
||||
namespace ftxui::animation {
|
||||
// Components who haven't completed their animation can call this function to
|
||||
// request a new frame to be drawn later.
|
||||
//
|
||||
// When there is no new events and no animations to complete, no new frame is
|
||||
// drawn.
|
||||
/// @brief RequestAnimationFrame is a function that requests a new frame to be
|
||||
/// drawn in the next animation cycle.
|
||||
///
|
||||
/// @note This function is typically called by components that need to
|
||||
/// update their state or appearance over time, such as animations or
|
||||
/// transitions. This is useful when the change doesn't depend depend on the
|
||||
/// events seen by the terminal, but rather on the passage of time.
|
||||
///
|
||||
/// Components who haven't completed their animation can call this function to
|
||||
/// request a new frame to be drawn later.
|
||||
///
|
||||
/// When there is no new events and no animations to complete, no new frame is
|
||||
/// drawn.
|
||||
///
|
||||
/// @ingroup component
|
||||
void RequestAnimationFrame();
|
||||
|
||||
using Clock = std::chrono::steady_clock;
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
class CapturedMouseInterface {
|
||||
public:
|
||||
CapturedMouseInterface() = default;
|
||||
|
@@ -27,6 +27,8 @@ struct EntryState {
|
||||
int index; ///< Index of the entry when applicable or -1.
|
||||
};
|
||||
|
||||
/// @brief Option for the underline effect.
|
||||
/// @ingroup component
|
||||
struct UnderlineOption {
|
||||
bool enabled = false;
|
||||
|
||||
@@ -230,7 +232,8 @@ struct SliderOption {
|
||||
std::function<void()> on_change; ///> Called when `value` is updated.
|
||||
};
|
||||
|
||||
// Parameter pack used by `WindowOptions::render`.
|
||||
/// @brief State passed to the `Window` component's render function.
|
||||
/// @ingroup component
|
||||
struct WindowRenderState {
|
||||
Element inner; ///< The element wrapped inside this window.
|
||||
const std::string& title; ///< The title of the window.
|
||||
|
@@ -24,6 +24,8 @@ class ComponentBase;
|
||||
///
|
||||
/// Useful documentation about xterm specification:
|
||||
/// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||
///
|
||||
/// @ingroup component
|
||||
struct Event {
|
||||
// --- Constructor section ---------------------------------------------------
|
||||
static Event Character(std::string);
|
||||
|
@@ -14,6 +14,45 @@ class ComponentBase;
|
||||
using Component = std::shared_ptr<ComponentBase>;
|
||||
class ScreenInteractive;
|
||||
|
||||
/// @brief Loop is a class that manages the event loop for a component.
|
||||
///
|
||||
/// It is responsible for running the component, handling events, and
|
||||
/// updating the screen.
|
||||
///
|
||||
/// The Loop class is designed to be used with a ScreenInteractive object,
|
||||
/// which represents the terminal screen.
|
||||
///
|
||||
/// **Example**
|
||||
/// ```cpp
|
||||
/// #include <ftxui/component/component.hpp>
|
||||
/// #include <ftxui/component/screen_interactive.hpp>
|
||||
/// #include <ftxui/component/loop.hpp>
|
||||
///
|
||||
/// int main() {
|
||||
/// auto screen = ftxui::ScreenInteractive::TerminalOutput();
|
||||
/// auto component = ftxui::Button("Click me", [] { ... });
|
||||
///
|
||||
/// ftxui::Loop loop(screen.get(), component);
|
||||
///
|
||||
/// // Either
|
||||
/// loop.Run(); // Blocking until the component quits.
|
||||
///
|
||||
/// // Or
|
||||
/// loop.RunOnce(); // Non-blocking, returns immediately.
|
||||
///
|
||||
/// // Or
|
||||
/// loop.RunOnceBlocking(); // Blocking until handling one event.
|
||||
///
|
||||
/// // Or in a loop:
|
||||
/// while (!loop.HasQuitted()) {
|
||||
/// loop.RunOnce();
|
||||
///
|
||||
/// // Do something else like running a different library loop function.
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// @ingroup component
|
||||
class Loop {
|
||||
public:
|
||||
Loop(ScreenInteractive* screen, Component component);
|
||||
|
@@ -27,6 +27,10 @@ struct Event;
|
||||
using Component = std::shared_ptr<ComponentBase>;
|
||||
class ScreenInteractivePrivate;
|
||||
|
||||
/// @brief ScreenInteractive is a `Screen` that can handle events, run a main
|
||||
/// loop, and manage components.
|
||||
///
|
||||
/// @ingroup component
|
||||
class ScreenInteractive : public Screen {
|
||||
public:
|
||||
// Constructors:
|
||||
|
Reference in New Issue
Block a user