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 
11 CXX_GUARD_START
12 
13 struct GUIFont;
14 struct GUIFont* GUIFontCreate(void);
15 void GUIFontDestroy(struct GUIFont*);
16 
17 enum 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 
27 enum 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 
40 enum 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 
59 struct 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 
70 struct GUIIconMetric {
71 	int x;
72 	int y;
73 	int width;
74 	int height;
75 };
76 
77 unsigned GUIFontHeight(const struct GUIFont*);
78 unsigned GUIFontGlyphWidth(const struct GUIFont*, uint32_t glyph);
79 unsigned GUIFontSpanWidth(const struct GUIFont*, const char* text);
80 void GUIFontIconMetrics(const struct GUIFont*, enum GUIIcon icon, unsigned* w, unsigned* h);
81 
82 ATTRIBUTE_FORMAT(printf, 6, 7)
83 void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text, ...);
84 void GUIFontPrint(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text);
85 void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint32_t glyph);
86 void GUIFontDrawIcon(const struct GUIFont*, int x, int y, enum GUIAlignment, enum GUIOrientation, uint32_t color, enum GUIIcon);
87 void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon);
88 
89 CXX_GUARD_END
90 
91 #endif
92