Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ScreenInteractive methods public #945

Open
techsupport-noah opened this issue Oct 29, 2024 · 3 comments
Open

Make ScreenInteractive methods public #945

techsupport-noah opened this issue Oct 29, 2024 · 3 comments

Comments

@techsupport-noah
Copy link

I would like to include ftxui into a realtime scheduling framework where there are tasks from which you derive so that you get the rt functionality without much work.
For that it would be pretty nice to be able to skip the usage of the screens loop functionality and just call the RunOnce, ... methods directly by the scheduling defined in the framework.

I think my request could be done by just making these methods inside the class public:

public:
  void ExitNow();

  void Install();
  void Uninstall();

  void PreMain();
  void PostMain();

  bool HasQuitted();
  void RunOnce(Component component);
  void RunOnceBlocking(Component component);

  void HandleTask(Component component, Task& task);
  void Draw(Component component);
  void ResetCursorPosition();

  void Signal(int signal);

I think this change would actually be great for other scenarios as well, not only when you need tight control over resources but also when you just want to have a little more control over the ui rendering in general.
I don't think this change would affect the current usage of ftxui too much.

@ArthurSonzogni
Copy link
Owner

Hello!

Would the ftxui::Loop work for you?

while (!loop.HasQuitted()) {
custom_loop_count++;
loop.RunOnce();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}

See doc:
https://arthursonzogni.github.io/FTXUI/classftxui_1_1Loop.html

You directly have access to:

Loop::RunOnce();
Loop::RunOnceBlocking();

This way, you can control when "processing" FTXUI happen, and when to wait.

@techsupport-noah
Copy link
Author

Hey Arthur, thanks for you quick reply!

First of all yes, i could make it work with your loop class, but currently i am doing a multi page application which uses a collection of layout containers each making a single page. If I would use your loop class i would need one loop per page, which doesn't make much sense in my opinion as all the loop does is making sure you call preMain and postMain. The class doesn't add more functionality and i would love to remove the need for extra loop objects so i thought it may be easier to open these methods up fo r public access. In the end you could still use the loop class with that change!

Maybe i am missing something here, but i still think that this would be better.

@ArthurSonzogni
Copy link
Owner

Do you mean you are using nested screen? One screen loop looping into another screen loop?
Example: https://github.com/ArthurSonzogni/FTXUI/blob/main/examples/component/nested_screen.cpp

Maybe you can use a single loop and switch pages with dynamically or with Container::Tab?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants