OpenShaderDesigner 0.0.1
Loading...
Searching...
No Matches
EditorSystem.h
1// =====================================================================================================================
2// Copyright 2024 Medusa Slockbower
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// =====================================================================================================================
15
16#ifndef EDITORSYSTEM_H
17#define EDITORSYSTEM_H
18
19#include <SDL_events.h>
20#include <open-cpp-utils/unique_id.h>
21#include <unordered_map>
22
23#include <Editor/EditorWindow.h>
24
25#define MAX_EDITORS 256
26
27namespace OpenShaderDesigner
28{
30 {
31 public:
32 using WindowID = uint64_t;
33
34 template<typename T>
35 static WindowID ID() { return open_cpp_utils::unique_id<WindowID, T>(); }
36
37 template<typename T>
38 static T* Open() { T* window; (window = Get<T>())->Open(); return window; }
39
40 template<typename T>
41 static T* Close() { T* window; (window = Get<T>())->Close(); return window; }
42
43 template<typename T>
44 static T* Get()
45 {
46 T* window = reinterpret_cast<T*>(Windows[ID<T>()]);
47 if(window == nullptr) Windows[ID<T>()] = window = new T();
48 return window;
49 }
50
51 static void Initialize();
52 static void Draw();
53 static void Shutdown();
54 static void HandleEvents(SDL_Event* event);
55
56 private:
57 inline static EditorWindow* Windows[MAX_EDITORS] { nullptr };
58 };
59}
60
61
62
63#endif //EDITORSYSTEM_H
Definition EditorSystem.h:30
EditorWindow class for wrapping ImGui window functionality.
Definition EditorWindow.h:28