-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathviewGridNavigator.h
109 lines (74 loc) · 2.42 KB
/
viewGridNavigator.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef cViewGridNAVIGATOR_H
#define cViewGridNAVIGATOR_H
#include <memory>
#include <vector>
#include <functional>
#include <libskindesignerapi/osdelements.h>
class cGridElement {
private:
bool m_bInit;
double m_posX;
double m_posY;
static unsigned int AbsoluteGridIdCounter;
protected:
unsigned int m_iGridId;
public:
cGridElement();
bool IsNew() { return m_bInit; };
void Dirty() { m_bInit = true; };
void InitFinished() { m_bInit = false; };
unsigned int GridElementId() { return m_iGridId; }
bool IsVisible() { return Position > -1; }
void SetPosition(double x, double y) {
m_posX = x;
m_posY = y;
};
void GetPosition(double &x, double &y) {
x = m_posX;
y = m_posY;
};
virtual void AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> osdElem, bool clear = true,
std::function<void(cGridElement *)> OnCached = NULL) = 0;
int Position;
int AbsolutePosition;
};
class cViewGridNavigator {
protected:
int m_rows;
int m_columns;
bool m_bHidden;
bool m_bEnableRedraw;
std::shared_ptr<skindesignerapi::cOsdView> m_pRootView;
std::shared_ptr<skindesignerapi::cViewGrid> m_pGrid;
std::shared_ptr<skindesignerapi::cViewElement> m_pScrollbar = nullptr;
bool m_newDimensions;
bool m_setIterator;
std::vector<cGridElement *> m_vElements;
std::vector<cGridElement *>::iterator m_activeElementIter;
int m_startIndex;
int m_endIndex;
void FilterElements(int scrollOffset);
void SetGridElementData(cGridElement *obj);
void SetViewGrid(std::shared_ptr<skindesignerapi::cViewGrid> grid);
public:
cViewGridNavigator(std::shared_ptr<skindesignerapi::cOsdView> rootView,
std::shared_ptr<skindesignerapi::cViewElement> pScrollbar);
void SetGridDimensions(int rows, int columns);
virtual void Flush() {
m_pGrid->Display();
m_pRootView->Display();
};
virtual void Clear() = 0;
virtual bool NavigateLeft();
virtual bool NavigateRight();
virtual bool NavigateUp();
virtual bool NavigateDown();
virtual eOSState NavigateSelect() = 0;
virtual eOSState NavigateBack() = 0;
virtual void ReDraw(cGridElement *element);
cGridElement *SelectedObject();
virtual void Deactivate(bool hide);
virtual void Activate();
void DrawScrollbar();
};
#endif // cViewGridNAVIGATOR_H