all repos — mgba @ 2f1cb61d0197893cf0c3861e9130ff1aeaefb0b0

mGBA Game Boy Advance Emulator

src/util/gui/font.h (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef GUI_FONT_H
 7#define GUI_FONT_H
 8
 9#include "util/common.h"
10
11CXX_GUARD_START
12
13struct GUIFont;
14struct GUIFont* GUIFontCreate(void);
15void GUIFontDestroy(struct GUIFont*);
16
17enum GUIAlignment {
18	GUI_ALIGN_LEFT = 1,
19	GUI_ALIGN_HCENTER = 3,
20	GUI_ALIGN_RIGHT = 2,
21
22	GUI_ALIGN_TOP = 4,
23	GUI_ALIGN_VCENTER = 12,
24	GUI_ALIGN_BOTTOM = 8,
25};
26
27enum GUIOrientation {
28	GUI_ORIENT_0,
29	GUI_ORIENT_90_CCW,
30	GUI_ORIENT_180,
31	GUI_ORIENT_270_CCW,
32
33	GUI_ORIENT_VMIRROR,
34	GUI_ORIENT_HMIRROR,
35
36	GUI_ORIENT_90_CW = GUI_ORIENT_270_CCW,
37	GUI_ORIENT_270_CW = GUI_ORIENT_90_CCW
38};
39
40enum GUIIcon {
41	GUI_ICON_BATTERY_FULL,
42	GUI_ICON_BATTERY_HIGH,
43	GUI_ICON_BATTERY_HALF,
44	GUI_ICON_BATTERY_LOW,
45	GUI_ICON_BATTERY_EMPTY,
46	GUI_ICON_SCROLLBAR_THUMB,
47	GUI_ICON_SCROLLBAR_TRACK,
48	GUI_ICON_SCROLLBAR_BUTTON,
49	GUI_ICON_CURSOR,
50	GUI_ICON_POINTER,
51	GUI_ICON_BUTTON_CIRCLE,
52	GUI_ICON_BUTTON_CROSS,
53	GUI_ICON_BUTTON_TRIANGLE,
54	GUI_ICON_BUTTON_SQUARE,
55	GUI_ICON_BUTTON_HOME,
56	GUI_ICON_MAX,
57};
58
59struct GUIFontGlyphMetric {
60	int width;
61	int height;
62	struct {
63		int top;
64		int right;
65		int bottom;
66		int left;
67	} padding;
68};
69
70struct GUIIconMetric {
71	int x;
72	int y;
73	int width;
74	int height;
75};
76
77unsigned GUIFontHeight(const struct GUIFont*);
78unsigned GUIFontGlyphWidth(const struct GUIFont*, uint32_t glyph);
79unsigned GUIFontSpanWidth(const struct GUIFont*, const char* text);
80void GUIFontIconMetrics(const struct GUIFont*, enum GUIIcon icon, unsigned* w, unsigned* h);
81
82ATTRIBUTE_FORMAT(printf, 6, 7)
83void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text, ...);
84void GUIFontPrint(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text);
85void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint32_t glyph);
86void GUIFontDrawIcon(const struct GUIFont*, int x, int y, enum GUIAlignment, enum GUIOrientation, uint32_t color, enum GUIIcon);
87void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon);
88
89CXX_GUARD_END
90
91#endif