Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ftxui/component/app.hpp>
- #include <ftxui/component/component.hpp>
- //#include <string_view>
- #include <string>
- #include <ranges>
- using namespace ftxui;
- using namespace std::literals::string_literals;
- //using namespace std::literals::string_view_literals;
- int main() {
- float scroll_x = 0.1f;
- float scroll_y = 0.1f;
- auto scrollable_content = [&]{
- auto bigtext = std::ranges::to<std::string>(
- std::ranges::views::indices(1000000)
- | std::ranges::views::transform([](const auto i) { return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "s + std::to_string(i); })
- | std::ranges::views::join_with("\n"s)
- );
- return Renderer([&, content = text(bigtext)] {
- return content | focusPositionRelative(scroll_x, scroll_y) |
- frame | flex;
- });
- }();
- SliderOption<float> option_x;
- option_x.value = &scroll_x;
- option_x.min = 0.f;
- option_x.max = 1.f;
- option_x.increment = 0.1f;
- option_x.direction = Direction::Right;
- option_x.color_active = Color::Blue;
- option_x.color_inactive = Color::BlueLight;
- auto scrollbar_x = Slider(option_x);
- SliderOption<float> option_y;
- option_y.value = &scroll_y;
- option_y.min = 0.f;
- option_y.max = 1.f;
- option_y.increment = 0.1f;
- option_y.direction = Direction::Down;
- option_y.color_active = Color::Yellow;
- option_y.color_inactive = Color::YellowLight;
- auto scrollbar_y = Slider(option_y);
- auto root = Container::Vertical({
- Container::Horizontal({
- scrollable_content,
- scrollbar_y,
- }) | flex,
- Container::Horizontal({
- scrollbar_x,
- Renderer([] { return text(L"x"); }),
- }),
- });
- auto screen = App::Fullscreen();
- screen.Loop(root);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment