-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathscreen.h
59 lines (41 loc) · 1.39 KB
/
screen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "terminal.h"
#include "yaft.h"
#include <UI.h>
class ScreenRenderObject;
class Screen : public rmlib::Widget<ScreenRenderObject> {
public:
Screen(struct terminal_t* term, bool isLandscape, int autoRefresh)
: term(term), isLandscape(isLandscape) {}
std::unique_ptr<rmlib::RenderObject> createRenderObject() const;
private:
friend class ScreenRenderObject;
struct terminal_t* term;
bool isLandscape = false;
int autoRefresh = 0;
};
class ScreenRenderObject : public rmlib::LeafRenderObject<Screen> {
public:
ScreenRenderObject(const Screen& screen)
: rmlib::LeafRenderObject<Screen>(screen) {
markNeedsRebuild();
}
void update(const Screen& newWidget);
protected:
rmlib::Size doLayout(const rmlib::Constraints& constraints) final;
rmlib::UpdateRegion doDraw(rmlib::Rect rect, rmlib::Canvas& canvas) final;
void doRebuild(rmlib::AppContext& ctx, const rmlib::BuildContext& /*buildContext*/) final;
void handleInput(const rmlib::input::Event& ev) final;
private:
rmlib::Rect drawLine(rmlib::Canvas& canvas,
rmlib::Rect rect,
terminal_t& term,
int line) const;
template<typename Ev>
void handleTouchEvent(const Ev& ev);
bool shouldRefresh() const;
int numUpdates = 0;
int mouseSlot = -1;
rmlib::Point lastMousePos;
const rmlib::fb::FrameBuffer* fb = nullptr;
};