-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCPage.h
More file actions
141 lines (104 loc) · 2.77 KB
/
TCPage.h
File metadata and controls
141 lines (104 loc) · 2.77 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef TCPage_h
#define TCPage_h
#include <list>
#include <sys/time.h>
#ifndef NULL
#define NULL 0
#endif
namespace Touched {
class TCPage {
protected:
struct timeval cur_time;
float force_delta;
void* touch_address;
float touch_position;
float force;
/* 다음 3개의 속성들은 scroller도 써야함*/
//위치
float position;
float GetVisiblePosition() {
if(size > 0.0)
return (-position+width_left_margin) / size;
else
return (-position+width_left_margin) / GetSize();
};
//전체사이즈
float size;
//화면에 보이는 사이즈(비율임)
//(GetSize() - width_left_margin - width_right_margin) / size
float GetVisiblePer() {
if((GetSize() - width_left_margin - width_right_margin) > size)
return 1.0;
else
return (GetSize() - width_left_margin - width_right_margin) / size;
}
float step;
int start_index;
bool is_center;
float width_left_margin;
float width_right_margin;
bool enable;
bool is_movement;
float x_translate;
bool enable_rollback_scroll;
typedef struct Page {
void* address;
float position;
float size;
int number;
bool moved;
} Page;
std::list<Page*> page_list;
Page* GetPage(int _page_number);
void CalculateSize();
virtual void CalculateMovement();
virtual void CalculateStartIndex(float _change_position);
void CalculateAllocPage();
void CalculateFreeOrUpdatePage(float _change_position);
public:
TCPage();
virtual ~TCPage();
void Init();
virtual void Clean();
virtual int GetPageLength()=0;
virtual float GetPageSize(int _page_number)=0;
virtual float GetSize()=0;
virtual void* AllocPage(int _page_number)=0;
virtual void FreePage(void* _address)=0;
virtual void UpdatePage(void* _address, float _position)=0;
void ReloadData();
void Reset();
void UpdateCell(int _page_num);
void SetForce(float _force) {
force = _force;
}
void SetIsMovement(bool _is_movement) {
is_movement = _is_movement;
}
void TranslateX(float _x) {
x_translate += _x;
}
virtual void Update();
virtual void TouchBegin(void* _address, float _position);
virtual void TouchMove(void* _address, float _position);
virtual void TouchEndOrCancel(void* _address, float _position);
void SetEnable(bool _enable) {
enable = _enable;
}
bool GetEnable() {
return enable;
}
void SetWithRightMargin(float _margin) {
width_right_margin = _margin;
}
void SetWithLeftMargin(float _margin) {
width_left_margin = _margin;
}
void SetEnableRollbackScroll(float _enable) {
enable_rollback_scroll = _enable;
}
// virtual void FetchRefresh(bool _dir, float _width) {};
// virtual void UnfetchRefresh(float _l_width, float _r_width) {};
};
}
#endif