-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgui.h
More file actions
79 lines (59 loc) · 1.95 KB
/
gui.h
File metadata and controls
79 lines (59 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 26495) // uninitialized variable
#endif
#include <boost/function.hpp>
#ifdef WIN32
#pragma warning( pop )
#endif
#define GLFW_INCLUDE_GL3
#define GLFW_NO_GLU
#include <GLFW/glfw3.h>
#include "result.h"
namespace gui
{
struct Handle;
typedef boost::function<void (Handle*, uint32_t, uint32_t)> WindowSizeChangeCb;
typedef boost::function<void (Handle*, const std::string&)> FileDropCb;
typedef boost::function<void (Handle*, double)> SeekCb;
typedef boost::function<void (Handle*)> PauseCb;
typedef boost::function<void (Handle*)> SubtitleCb;
struct Handle
{
GLFWwindow* window = nullptr;
WindowSizeChangeCb sizeChangeCb;
FileDropCb fileDropCb;
SeekCb seekCb;
PauseCb pauseCb;
SubtitleCb subtitleCb;
int32_t posx = 0;
int32_t posy = 0;
int32_t width = 0;
int32_t height = 0;
int32_t backupWidth = 0;
int32_t backupHeight = 0;
bool mouseButtonPress = false;
bool mouseButtonShift = false;
uint64_t mouseReleaseTimeUs = 0;
};
Result Init();
Result Create(Handle*& handle);
Result OpenWindow(Handle* handle, uint32_t width, uint32_t height);
void SetTitle(Handle* handle, const char* title);
// ui callbacks
void SetWindowSizeChangeCallback(Handle*, WindowSizeChangeCb);
void SetFileDropCallback(Handle*, FileDropCb);
void SetSeekCallback(Handle*, SeekCb);
void SetPauseCallback(Handle*, PauseCb);
void SetSubtitleCallback(Handle*, SubtitleCb);
// windows state
bool IsFullScreen(Handle* handle);
void SetWindowSize(Handle*, uint32_t width, uint32_t height);
void SwapBuffers(Handle* handle);
void ShowWindow(Handle* handle);
void HideWindow(Handle* handle);
bool ShouldClose(Handle* handle);
void PollEvents();
void Destroy();
}