2019-01-07 00:10:35 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
|
|
|
#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-27 09:33:06 +08:00
|
|
|
#include <condition_variable>
|
2018-10-10 01:06:03 +08:00
|
|
|
#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"
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2019-01-13 01:24:46 +08:00
|
|
|
class Component;
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
class ScreenInteractive : public Screen {
|
2018-10-10 01:06:03 +08:00
|
|
|
public:
|
2019-01-27 04:52:55 +08:00
|
|
|
static ScreenInteractive FixedSize(int dimx, int dimy);
|
2019-01-05 09:03:49 +08:00
|
|
|
static ScreenInteractive Fullscreen();
|
2019-01-19 07:20:29 +08:00
|
|
|
static ScreenInteractive FitComponent();
|
2019-01-05 09:03:49 +08:00
|
|
|
static ScreenInteractive TerminalOutput();
|
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
~ScreenInteractive();
|
2019-01-13 01:24:46 +08:00
|
|
|
void Loop(Component*);
|
2019-01-07 00:10:35 +08:00
|
|
|
std::function<void()> ExitLoopClosure();
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-27 09:33:06 +08:00
|
|
|
void PostEvent(Event event);
|
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
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);
|
2019-01-05 09:03:49 +08:00
|
|
|
|
|
|
|
enum class Dimension {
|
2019-01-19 07:20:29 +08:00
|
|
|
FitComponent,
|
2019-01-05 09:03:49 +08:00
|
|
|
Fixed,
|
|
|
|
Fullscreen,
|
2019-01-19 07:20:29 +08:00
|
|
|
TerminalOutput,
|
2019-01-05 09:03:49 +08:00
|
|
|
};
|
|
|
|
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
|
|
|
|
2019-02-02 23:28:44 +08:00
|
|
|
std::condition_variable events_queue_cv;
|
2019-01-27 09:33:06 +08:00
|
|
|
std::mutex events_queue_mutex;
|
|
|
|
std::queue<Event> events_queue;
|
|
|
|
std::atomic<bool> quit_ = false;
|
2018-10-10 01:06:03 +08:00
|
|
|
};
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
} // namespace ftxui
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */
|