FTXUI/include/ftxui/component/screen_interactive.hpp

52 lines
1.2 KiB
C++
Raw Normal View History

#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
2019-01-27 09:33:06 +08:00
#include <condition_variable>
#include <functional>
#include <memory>
2019-01-27 09:33:06 +08:00
#include <mutex>
#include <queue>
#include <atomic>
#include "ftxui/component/event.hpp"
#include "ftxui/screen/screen.hpp"
namespace ftxui {
2019-01-13 01:24:46 +08:00
class Component;
2019-01-13 01:24:46 +08:00
class ScreenInteractive : public Screen {
public:
2019-01-27 04:52:55 +08:00
static ScreenInteractive FixedSize(int dimx, int dimy);
static ScreenInteractive Fullscreen();
2019-01-19 07:20:29 +08:00
static ScreenInteractive FitComponent();
static ScreenInteractive TerminalOutput();
~ScreenInteractive();
2019-01-13 01:24:46 +08:00
void Loop(Component*);
std::function<void()> ExitLoopClosure();
2019-01-27 09:33:06 +08:00
void PostEvent(Event event);
private:
2019-01-13 01:24:46 +08:00
void Draw(Component* component);
2019-01-27 09:33:06 +08:00
void EventLoop(Component* component);
enum class Dimension {
2019-01-19 07:20:29 +08:00
FitComponent,
Fixed,
Fullscreen,
2019-01-19 07:20:29 +08:00
TerminalOutput,
};
Dimension dimension_ = Dimension::Fixed;
2019-01-27 04:52:55 +08:00
ScreenInteractive(int dimx, int dimy, Dimension dimension);
2019-01-27 09:33:06 +08:00
std::condition_variable events_queue_wait;
std::mutex events_queue_mutex;
std::queue<Event> events_queue;
std::atomic<bool> quit_ = false;
};
} // namespace ftxui
#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */