-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathscreen.cpp
73 lines (57 loc) · 1.38 KB
/
screen.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "platform.h"
// this is screen manager
// handling multiple layers (creation, destruction, order, focus, position and blending effects)
// it also receives input stream and dispatches it to given layer input handler
// in xterm mode it is responsible for displaying mouse cursor on top of screen
#include "render.h"
#if 0
struct ScreenCB
{
void(*touch)();
void(*mouse)();
void(*keyb)(); // (focused screen only)
void(*pad)(); // (focused screen only)
};
struct Layer;
struct Screen
{
Layer* parent; // if null it is screen!
void* cookie;
// children
Layer* head;
Layer* tail;
// buf should be cleared or prerendered with some scene or left dirty if children overlaps it fully
void Merge(AnsiCell* buf, int width, int height);
};
struct Layer : Screen
{
bool visible;
// siblings
Layer* prev;
Layer* next;
};
void Screen::Merge(AnsiCell* buf, int width, int height)
{
ClipRect cr = { 0,0, width,height };
Layer* lay = head;
while (lay)
{
cr.x1 = max(0, lay->x, )
lay->Merge(buf, &cr, lay->x, lay->y);
lay = lay->next;
}
}
void Layer::Merge(AnsiCell* buf, int width, int height, int src_x, int src_y, int dst_x, int dst_y, int )
{
cr->x1 += x;
cr->y1 += x;
cr->x2 += x;
cr->y2 += x;
}
// for mouse & touch
Screen* HitTest(Screen* root, int x, int y)
{
// 1. locate topmost screen for root
// 2. traverse down until non transparent bg or fg is found
}
#endif