forked from Tasssadar/multirom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listview.h
73 lines (59 loc) · 1.73 KB
/
listview.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
#ifndef LISTVIEW_H
#define LISTVIEW_H
#include "input.h"
#include "framebuffer.h"
enum
{
IT_VISIBLE = 0x01,
IT_HOVER = 0x02,
IT_SELECTED = 0x04,
};
typedef struct
{
int id;
void *data;
int flags;
} listview_item;
typedef struct
{
int id;
int start_y;
int last_y;
int64_t us_diff;
listview_item *hover;
} listview_touch_data;
typedef struct
{
int x, y;
int w, h;
int pos; // scroll pos
int fullH; // height of all items
listview_item **items;
listview_item *selected;
void (*item_draw)(int, int, int, listview_item *); // x, y, w, item
void (*item_hide)(void*); // data
int (*item_height)(void*); // data
void (*item_destroy)(listview_item *);
void (*item_selected)(listview_item *, listview_item *); // prev, now
fb_item_header **ui_items;
fb_rect *scroll_mark;
listview_touch_data touch;
} listview;
int listview_touch_handler(touch_event *ev, void *data);
void listview_init_ui(listview *view);
void listview_destroy(listview *view);
listview_item *listview_add_item(listview *view, int id, void *data);
void listview_clear(listview *view);
void listview_update_ui(listview *view);
void listview_enable_scroll(listview *view, int enable);
void listview_update_scroll_mark(listview *view);
void listview_scroll_by(listview *view, int y);
void listview_scroll_to(listview *view, int pct);
listview_item *listview_item_at(listview *view, int y_pos);
inline void listview_select_item(listview *view, listview_item *it);
void *rom_item_create(const char *text, const char *partition);
void rom_item_draw(int x, int y, int w, listview_item *it);
void rom_item_hide(void *data);
int rom_item_height(void *data);
void rom_item_destroy(listview_item *it);
#endif