src/util/gui.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_H
7#define GUI_H
8
9#include "util/common.h"
10
11#include "util/vector.h"
12
13struct GUIFont;
14
15enum GUIInput {
16 GUI_INPUT_NONE = -1,
17 GUI_INPUT_SELECT = 0,
18 GUI_INPUT_BACK,
19 GUI_INPUT_CANCEL,
20
21 GUI_INPUT_UP,
22 GUI_INPUT_DOWN,
23 GUI_INPUT_LEFT,
24 GUI_INPUT_RIGHT,
25
26 GUI_INPUT_USER_START = 0x10,
27
28 GUI_INPUT_MAX = 0x20
29};
30
31struct GUIBackground {
32 void (*draw)(struct GUIBackground*, void* context);
33};
34
35struct GUIParams {
36 unsigned width;
37 unsigned height;
38 const struct GUIFont* font;
39 const char* basePath;
40
41 void (*drawStart)(void);
42 void (*drawEnd)(void);
43 uint32_t (*pollInput)(void);
44 void (*guiPrepare)(void);
45 void (*guiFinish)(void);
46
47 // State
48 int inputHistory[GUI_INPUT_MAX];
49
50 // Directories
51 char currentPath[PATH_MAX];
52 size_t fileIndex;
53};
54
55#define GUI_PARAMS_TRAIL {}, "", 0
56
57void GUIInit(struct GUIParams* params);
58void GUIPollInput(struct GUIParams* params, uint32_t* newInput, uint32_t* heldInput);
59void GUIInvalidateKeys(struct GUIParams* params);
60
61#endif