~earboxer/suggpicker

suggpicker/keyboard.h -rw-r--r-- 1.4 KiB
fd0edc9aZach DeCook release: minor version bump 4 months ago
                                                                                
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
#ifndef __KEYBOARD_H
#define __KEYBOARD_H

#include "drw.h"

#define MAX_LAYERS 25

struct clr_scheme;
struct key;
struct kbd;

enum key_draw_type {
	Unpress = 0,
	Press,
	Swipe,
};

struct clr_scheme {
	Color fg;
	Color bg;
	Color high;
	Color swipe;
	Color text;
};

struct key {
	char *label;
	// actual coordinates on the surface (pixels), will be computed automatically
	// for all keys
	uint32_t x, y, w, h;
};

struct kbd {
	bool debug;

	struct clr_scheme scheme;

	uint32_t w, h, s;
	bool landscape;
	uint8_t mods;
	uint8_t compose;
	struct key *last_press;

	struct key suggs[64];

	struct drwsurf *surf;
};

void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
                uint32_t height, uint32_t border, Color color);
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
                     uint32_t height, uint32_t border, Color color);

void kbd_init(struct kbd *kb);
void kbd_init_suggs(struct key *suggs, uint32_t width, uint32_t height);
struct key *kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y);
void kbd_unpress_key(struct kbd *kb);
void kbd_release_key(struct kbd *kb);
void kbd_motion_key(struct kbd *kb, uint32_t x, uint32_t y);
void kbd_press_key(struct kbd *kb, struct key *k);
void kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type);
void kbd_draw_layout(struct kbd *kb);
void kbd_resize(struct kbd *kb);
double kbd_get_row_length(struct key *k);

#endif