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_MAX
27};
28
29struct GUIParams {
30 unsigned width;
31 unsigned height;
32 const struct GUIFont* font;
33 const char* basePath;
34
35 void (*drawStart)(void);
36 void (*drawEnd)(void);
37 int (*pollInput)(void);
38 void (*guiPrepare)(void);
39 void (*guiFinish)(void);
40
41 // State
42 int inputHistory[GUI_INPUT_MAX];
43
44 // Directories
45 char currentPath[PATH_MAX];
46 size_t fileIndex;
47};
48
49#define GUI_PARAMS_TRAIL {}, "", 0
50
51void GUIInit(struct GUIParams* params);
52void GUIPollInput(struct GUIParams* params, int* newInput, int* heldInput);
53void GUIInvalidateKeys(struct GUIParams* params);
54
55#endif