summaryrefslogtreecommitdiff
path: root/src/entry.h
blob: 05c459b0758c17c943d7b63d9184e55e1d7ffdfc (plain)
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
#ifndef ENTRY_H
#define ENTRY_H

#include <pango/pangocairo.h>
#include "color.h"
#include "image.h"
#include "surface.h"

#define MAX_PASSWORD_LENGTH 64

struct entry {
	struct surface surface;
	struct wl_subsurface *wl_subsurface;
	struct image image;
	struct {
		PangoContext *context;
		PangoLayout *layout;
		cairo_surface_t *surface;
		cairo_t *cr;
	} pangocairo;
	PangoRectangle text_bounds;

	wchar_t password[MAX_PASSWORD_LENGTH];
	/* Assume maximum of 4 bytes per wchar_t (for UTF-8) */
	char password_mb[4*MAX_PASSWORD_LENGTH];
	char password_mb_print[4*MAX_PASSWORD_LENGTH];
	uint32_t password_length;
	bool password_visible;

	/* Options */
	uint32_t font_size;
	const char *font_name;
	uint32_t padding;
	bool tight_layout;
	wchar_t password_character;
	uint32_t num_characters;
	struct color foreground_color;
	struct color background_color;
	struct {
		struct color color;
		struct color outline_color;
		int32_t width;
		int32_t outline_width;
	} border;
};

void entry_init(struct entry *entry, uint32_t scale);
void entry_destroy(struct entry *entry);
void entry_update(struct entry *entry);
void entry_set_scale(struct entry *entry, uint32_t scale);

#endif /* ENTRY_H */