foxygit / Torlinkc Log in
commits tags

/include/torlinkc/ui/spinner.hpp · 755 B

raw
#pragma once

#include <functional>

#include <ftxui/component/component.hpp>

namespace torlinkc::ui {

// A small braille spinner driven by FTXUI's native animation system
// (animation::RequestAnimationFrame / ComponentBase::OnAnimation) rather
// than a manual interval timer -- see the plan's "UI animation ticks"
// section. It only keeps requesting frames while `isActive()` is true, so it
// costs nothing once a search finishes. The caller must still call
// ScreenInteractive::RequestAnimationFrame() once to kick off the first
// frame when isActive() flips true; after that this component re-requests
// its own next frame for as long as it's active.
ftxui::Component MakeSpinner(std::function<bool()> isActive);

}  // namespace torlinkc::ui