all repos — mgba @ 209eed35edf2ecb54c7a093c1857b27931f77f68

mGBA Game Boy Advance Emulator

include/mgba-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 <mgba-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_STATUS_FAST_FORWARD,
57	GUI_ICON_STATUS_MUTE,
58	GUI_ICON_MAX,
59};
60
61struct GUIFontGlyphMetric {
62	int width;
63	int height;
64	struct {
65		int top;
66		int right;
67		int bottom;
68		int left;
69	} padding;
70};
71
72struct GUIIconMetric {
73	int x;
74	int y;
75	int width;
76	int height;
77};
78
79unsigned GUIFontHeight(const struct GUIFont*);
80unsigned GUIFontGlyphWidth(const struct GUIFont*, uint32_t glyph);
81unsigned GUIFontSpanWidth(const struct GUIFont*, const char* text);
82void GUIFontIconMetrics(const struct GUIFont*, enum GUIIcon icon, unsigned* w, unsigned* h);
83
84ATTRIBUTE_FORMAT(printf, 6, 7)
85void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text, ...);
86void GUIFontPrint(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text);
87void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint32_t glyph);
88void GUIFontDrawIcon(const struct GUIFont*, int x, int y, enum GUIAlignment, enum GUIOrientation, uint32_t color, enum GUIIcon);
89void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon);
90
91CXX_GUARD_END
92
93#endif