-
-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathmvContext.h
More file actions
134 lines (112 loc) · 3.65 KB
/
mvContext.h
File metadata and controls
134 lines (112 loc) · 3.65 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma once
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <queue>
#include <thread>
#include <future>
#include <atomic>
#include <memory>
#include "mvCore.h"
#include "mvPyUtils.h"
#include "mvTypes.h"
#include "mvGraphics.h"
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
struct mvViewport;
struct mvCallbackRegistry;
struct mvItemRegistry;
struct mvIO;
struct mvContext;
struct mvInput;
//-----------------------------------------------------------------------------
// public API
//-----------------------------------------------------------------------------
extern mvContext* GContext;
mvUUID GenerateUUID();
void SetDefaultTheme();
void Render();
std::map<std::string, mvPythonParser>& GetParsers();
struct mvInput
{
struct AtomicVec2
{
std::atomic_int x;
std::atomic_int y;
};
struct AtomicFloatVec2
{
std::atomic<float> x;
std::atomic<float> y;
};
struct AtomicDoubleVec2
{
std::atomic<double> x;
std::atomic<double> y;
};
AtomicVec2 mousePos = { 0, 0 };
AtomicVec2 mouseGlobalPos = { 0, 0 };
AtomicDoubleVec2 mousePlotPos = { 0, 0 };
AtomicVec2 mouseDrawingPos = { 0, 0 };
std::atomic_int mouseDragThreshold = 20;
AtomicVec2 mouseDragDelta = { 0, 0 };
// mouse
std::atomic_int mousewheel;
std::atomic_bool mousedown[5];
std::atomic_bool mouseDragging[5];
std::atomic_int mousedownduration[5]; // 1/100 seconds
std::atomic_bool mouseclick[5];
std::atomic_bool mousedoubleclick[5];
std::atomic_bool mousereleased[5];
};
struct mvIO
{
bool docking = false;
bool dockingViewport = false;
bool dockingShiftOnly = false;
bool kbdNavigation = false;
std::string iniFile;
bool loadIniFile = false;
bool autoSaveIniFile = false;
bool waitForInput = false;
// GPU selection
bool info_auto_device = false;
int info_device = -1;
std::string info_device_name;
// item registry
bool allowAliasOverwrites = false;
bool manualAliasManagement = false;
bool skipRequiredArgs = false;
bool skipPositionalArgs = false;
bool skipKeywordArgs = false;
// callback registry
bool manualCallbacks = false;
ImWchar decimalPoint = '.';
};
struct mvContext
{
std::atomic_bool waitOneFrame = false;
std::atomic_bool started = false;
std::recursive_mutex mutex;
std::future<bool> future;
float deltaTime = 0.0f; // time since last frame
double time = 0.0; // total time since starting
int frame = 0; // frame count
int framerate = 0; // frame rate
mvUUID id = MV_START_UUID; // current ID
mvViewport* viewport = nullptr;
mvGraphics graphics;
bool resetTheme = false;
mvIO IO;
mvItemRegistry* itemRegistry = nullptr;
mvCallbackRegistry* callbackRegistry = nullptr;
mvInput input;
mvUUID activeWindow = 0;
mvUUID focusedItem = 0;
};
//-----------------------------------------------------------------------------
// Python Parsing
//-----------------------------------------------------------------------------
void InsertConstants_mvContext(std::vector<std::pair<std::string, long>>& constants);